SchedulerControl.GetResourceColorSchemasCopy() Method
Returns copies of color schemas that are currently used to paint visible resources.
Namespace: DevExpress.Xpf.Scheduler
Assembly: DevExpress.Xpf.Scheduler.v14.2.dll
#Declaration
#Returns
Type | Description |
---|---|
Scheduler |
A DevExpress. |
#Remarks
Call the GetResourceColorSchemasCopy method to get the collection of the currently used resource color schema copies. By default, if you change a set of visible resources (for example, by using resource filter controls) the collection of resource color schemas will remain unchanged, i.e. the same color schemas in the same order will be used to paint newly selected resources that are to be displayed in the scheduler.
However, you can assign a specific color schema to each visible resource. To do this, handle the SchedulerControl.QueryResourceColorSchema event.
#Examples
This example demonstrates how to link a specific scheduler color schema to each visible resource.
Call the SchedulerControl.GetResourceColorSchemasCopy method to obtain a collection of color schemas that are currently available for resource coloring, and handle the SchedulerControl.QueryResourceColorSchema event to associate a specific color schema from the obtained collection to each resource displayed in the scheduler control.
using DevExpress.XtraScheduler;
using System.Collections.Generic;
// ...
namespace WpfApplication1 {
public partial class MainWindow : Window {
Dictionary<object, SchedulerColorSchema> resourceColorSchemas =
new Dictionary<object, SchedulerColorSchema>();
public MainWindow() {
InitializeComponent();
// Get copies of color schemas that are currently used to paint resources.
PrepareResourceColorSchemas();
}
// ...
private void PrepareResourceColorSchemas() {
int count = schedulerControl1.Storage.ResourceStorage.Count;
SchedulerColorSchemaCollection currentColorchemas =
schedulerControl1.GetResourceColorSchemasCopy();
int schemaCount = currentColorchemas.Count;
for (int i = 0; i < count; i++) {
Resource resource = schedulerControl1.Storage.ResourceStorage[i];
resourceColorSchemas.Add(resource.Id, currentColorchemas[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];
}
}
}
}