Skip to main content

QueryResourceColorSchemaEventArgs Class

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v22.1.Core.Desktop.dll

Declaration

public class QueryResourceColorSchemaEventArgs :
    EventArgs

Remarks

An instance of the QueryResourceColorSchemaEventArgs class with appropriate settings is automatically created and passed to the corresponding event’s handler.

Example

This example demonstrates how to link a specific SchedulerColorSchema to each visible resource.

Call the SchedulerControl.GetResourceColorSchemasCopy method to obtain a collection of color schemas that are currently available for resource coloring (according to the currently active skin) and handle the SchedulerControl.QueryResourceColorSchema event to associate a specific color schema from the obtained collection to each resource displayed in the scheduler control.

Tip

A complete sample project is available in the DevExpress Code Examples database at https://supportcenter.devexpress.com/ticket/details/e3209/how-to-associate-a-specific-color-schema-with-a-particular-resource.

using DevExpress.XtraScheduler;
using System.Collections.Generic;
// ...

namespace QueryResourceColorSchema {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            AddResources();

            // Get copies of color schemas that are curremnty used to paint resources.
            PrepareResourceColorSchemas();

            schedulerControl1.LookAndFeel.StyleChanged += new EventHandler(LookAndFeel_StyleChanged);
        }

        void LookAndFeel_StyleChanged(object sender, EventArgs e) {
            // Get copies of color schemas to be used to paint resources
            // after the active skin has been changed.
            PrepareResourceColorSchemas();

            schedulerControl1.ActiveView.LayoutChanged();
        }

        // ...

        Dictionary<object, SchedulerColorSchema> resourceColorSchemas = 
            new Dictionary<object, SchedulerColorSchema>();

        private void PrepareResourceColorSchemas() {
            this.resourceColorSchemas.Clear();
            int count = Resources.Count;
            SchedulerColorSchemaCollection currentColorSchemas = 
                schedulerControl1.GetResourceColorSchemasCopy();
            int schemaCount = currentColorSchemas.Count;
            for (int i = 0; i < count; i++) {
                Resource resource = schedulerControl1.Storage.Resources[i];
                this.resourceColorSchemas.Add(resource.Id, currentColorSchemas[i % schemaCount]);
            }
        }

        private void schedulerControl1_QueryResourceColorSchema(object sender, 
                                                                QueryResourceColorSchemaEventArgs e) {
            object key = e.Resource.Id;
            if (this.resourceColorSchemas.ContainsKey(key))
                e.ResourceColorSchema = this.resourceColorSchemas[key];
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the QueryResourceColorSchemaEventArgs class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

Object
EventArgs
QueryResourceColorSchemaEventArgs
See Also