Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!-- default badges list -->
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/128656024/22.2.2%2B)
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T587301)
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
<!-- default badges end -->
Expand Down
4 changes: 2 additions & 2 deletions VB/ColorMappingExample/ColorMappingExample.Net5.vbproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OptionInfer>On</OptionInfer>
Expand Down Expand Up @@ -41,4 +41,4 @@
<PackageReference Include="DevExpress.Wpf.Scheduling" Version="22.2.*-*" />
<PackageReference Include="DevExpress.Wpf.Themes.All" Version="22.2.*-*" />
</ItemGroup>
</Project>
</Project>
7 changes: 3 additions & 4 deletions VB/ColorMappingExample/ColorMappingExample.vbproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OptionInfer>On</OptionInfer>
Expand Down Expand Up @@ -92,7 +92,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="HtmlColorCodeToColorConverter.vb" />
<Compile Include="PriorityToColorConverter.vb" />
<Compile Include="ViewModels\MainViewModel.vb" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
Expand All @@ -108,7 +108,6 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Model\Category.vb" />
<Compile Include="Model\MyAppointment.vb" />
<Compile Include="Properties\AssemblyInfo.vb">
<SubType>Code</SubType>
Expand Down Expand Up @@ -146,4 +145,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
38 changes: 11 additions & 27 deletions VB/ColorMappingExample/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,24 @@
xmlns:local="clr-namespace:ColorMappingExample"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduling"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:viewmodels="clr-namespace:ColorMappingExample.ViewModels"
Height="600"
Width="800"
mc:Ignorable="d"
DataContext="{dxmvvm:ViewModelSource viewmodels:MainViewModel}"
Title="MainWindow">

<Window.DataContext>
<viewmodels:MainViewModel/>
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="480*" />
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0">
<dxe:PopupColorEdit
Height="Auto"
Width="Auto"
Margin="10,10,10,10"
Color="{Binding ElementName = scheduler, Path= LabelItems[1].Color ,
Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock
Margin="10,10,10,10"
VerticalAlignment="Center"
Text= "{Binding Categories[1].ColorDataInfo}" />
</WrapPanel>
<dxsch:SchedulerControl x:Name="scheduler" Grid.Row="1">
<dxsch:SchedulerControl x:Name="scheduler">
<dxsch:SchedulerControl.DataSource>
<dxsch:DataSource AppointmentLabelsSource="{Binding Categories}" AppointmentsSource="{Binding Appointments}">
<dxsch:DataSource AppointmentLabelsSource="{dxe:EnumItemsSource EnumType={x:Type local:Priority}}"
AppointmentsSource="{Binding Appointments}">
<dxsch:DataSource.AppointmentMappings>
<dxsch:AppointmentMappings
AllDay="AllDay"
End="EndTime"
LabelId="CategoryId"
LabelId="PriorityId"
Location="Location"
RecurrenceInfo="RecurrenceInfo"
Reminder="ReminderInfo"
Expand All @@ -50,11 +35,10 @@
</dxsch:DataSource.AppointmentMappings>
<!--region #AppointmentLabelMappings-->
<dxsch:DataSource.AppointmentLabelMappings>
<dxsch:AppointmentLabelMappings Color="{dxsch:Mapping FieldName=ColorData,
ConversionBehavior=BetweenFieldAndMapping,
Converter= {local:HtmlColorCodeToHexConverter}}"
Caption="Caption"
ColorSavingType="ColorString"
<dxsch:AppointmentLabelMappings
Color="{dxsch:Mapping FieldName=Id, ConversionBehavior=BetweenFieldAndMapping, Converter={local:PriorityToColorConverter}}"
Caption="Name"
ColorSavingType="ColorInstance"
Id="Id" />
</dxsch:DataSource.AppointmentLabelMappings>
<!--endregion #AppointmentLabelMappings-->
Expand Down
6 changes: 6 additions & 0 deletions VB/ColorMappingExample/MainWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ Namespace ColorMappingExample
Me.InitializeComponent()
End Sub
End Class

Public Enum Priority
High
Normal
Low
End Enum
End Namespace
22 changes: 7 additions & 15 deletions VB/ColorMappingExample/Model/MyAppointment.vb
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
Imports DevExpress.Mvvm.POCO

Namespace ColorMappingExample.Model

Public Class MyAppointment

Public Shared Function Create() As MyAppointment
Return ViewModelSource.Create(Function() New MyAppointment())
End Function

Friend Shared Function Create(ByVal startTime As Date, ByVal endTime As Date, ByVal subject As String, ByVal categoryId As Integer) As MyAppointment
Dim apt As MyAppointment = Create()
apt.StartTime = startTime
apt.EndTime = endTime
apt.Subject = subject
apt.CategoryId = categoryId
Return apt
End Function
Public Sub New(ByVal startTime As Date, ByVal endTime As Date, ByVal subject As String, ByVal priorityId As Priority)
Me.StartTime = startTime
Me.EndTime = endTime
Me.Subject = subject
Me.PriorityId = priorityId
End Sub

Protected Sub New()
End Sub
Expand All @@ -32,7 +24,7 @@ Namespace ColorMappingExample.Model

Public Overridable Property StatusId As Integer

Public Overridable Property CategoryId As Integer
Public Overridable Property PriorityId As Priority

Public Overridable Property Type As Integer

Expand Down
48 changes: 48 additions & 0 deletions VB/ColorMappingExample/PriorityToColorConverter.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Imports System
Imports System.Globalization
Imports System.Windows.Data
Imports System.Windows.Markup
Imports System.Windows.Media

Namespace ColorMappingExample

Friend Class PriorityToColorConverter
Inherits MarkupExtension
Implements IValueConverter

Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
Dim val As Priority = Nothing
If CSharpImpl.__Assign(val, TryCast(value, Priority)) IsNot Nothing Then
Select Case val
Case Priority.High
Return Colors.Red
Case Priority.Normal
Return Colors.Yellow
Case Priority.Low
Return Colors.Green
Case Else
Return Colors.Black
End Select
End If

Return Colors.Transparent
End Function

Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function

Public Overrides Function ProvideValue(ByVal serviceProvider As IServiceProvider) As Object
Return Me
End Function

Private Class CSharpImpl

<Obsolete("Please refactor calling code to use normal Visual Basic assignment")>
Shared Function __Assign(Of T)(ByRef target As T, value As T) As T
target = value
Return value
End Function
End Class
End Class
End Namespace
34 changes: 5 additions & 29 deletions VB/ColorMappingExample/ViewModels/MainViewModel.vb
Original file line number Diff line number Diff line change
@@ -1,45 +1,21 @@
Imports ColorMappingExample.Model
Imports DevExpress.Mvvm.DataAnnotations
Imports DevExpress.Mvvm
Imports System.Collections.ObjectModel
Imports System.Windows.Media

Namespace ColorMappingExample.ViewModels

<POCOViewModel>
Public Class MainViewModel
Inherits ViewModelBase

Public Overridable Property Appointments As ObservableCollection(Of MyAppointment)
Public Property Appointments As ObservableCollection(Of MyAppointment)

Public Overridable Property Categories As ObservableCollection(Of Category)

Public Overridable Property ColorSavingType As DevExpress.Xpf.Scheduling.DXColorSavingType

Protected Sub New()
Public Sub New()
Appointments = CreateAppointments()
Categories = CreateCategories()
End Sub

Private Function CreateAppointments() As ObservableCollection(Of MyAppointment)
Dim result As ObservableCollection(Of MyAppointment) = New ObservableCollection(Of MyAppointment)()
result.Add(MyAppointment.Create(Date.Today.AddHours(10), Date.Today.AddHours(11), "TEST", 1))
Return result
End Function

#Region "#CreateCategories"
Private Function CreateCategories() As ObservableCollection(Of Category)
Dim result As ObservableCollection(Of Category) = New ObservableCollection(Of Category)()
result.Add(Category.Create(0, "Blank category", "0xFFFFFFFF"))
' Set the AppointmentLabelMappings.ColorSavingType to ColorString
' and use the HtmlColorCodeToHexConverter.
' Otherwise color values assigned as follows will be translated incorrectly.
result.Add(Category.Create(1, "Color category", Colors.Orange.ToString()))
result.Add(Category.Create(2, "Red category", "Red"))
''' Set the AppointmentLabelMappings.ColorSavingType to ColorInstance.
''' Otherwise color values assigned as follows will be translated incorrectly.
'result.Add(Category.Create(1, "Color category", Colors.Orange));
'result.Add(Category.Create(3, "Red category", Colors.Red));
Dim result As ObservableCollection(Of MyAppointment) = New ObservableCollection(Of MyAppointment) From {New MyAppointment(Date.Today.AddHours(10), Date.Today.AddHours(11), "TEST", Priority.Normal)}
Return result
End Function
#End Region ' #CreateCategories
End Class
End Namespace