зеркало из https://github.com/telerik/xaml-sdk.git
Update examples
This commit is contained in:
Родитель
37aaf4fa02
Коммит
ce6d28a025
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="BindPropertyDefinitionsViewModel.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:BindPropertyDefinitionsViewModel"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace BindPropertyDefinitionsViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A442B519-D605-42FA-ACED-D956F583156E}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DynamicSettings</RootNamespace>
|
||||
<AssemblyName>DynamicSettings</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>BindPropertyDefinitionsViewModel.App</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Controls">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Controls.Data">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Controls.Input">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.Input.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Data">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="PropertyDefinitionsBehavior.cs" />
|
||||
<Compile Include="Setting.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainWindowViewModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,24 @@
|
|||
<Window x:Class="BindPropertyDefinitionsViewModel.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:BindPropertyDefinitionsViewModel"
|
||||
mc:Ignorable="d"
|
||||
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||
Title="MainWindow" Height="350" Width="525">
|
||||
<Grid>
|
||||
<Grid.DataContext>
|
||||
<local:MainWindowViewModel />
|
||||
</Grid.DataContext>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<telerik:RadPropertyGrid x:Name="radPropertyGrid"
|
||||
Item="{Binding Settings}"
|
||||
local:PropertyDefinitionsBehavior.PropertyDefinitions="{Binding PropertyDefinitions}"
|
||||
AutoGeneratePropertyDefinitions="False" />
|
||||
<telerik:RadButton Grid.Row="1" Command="{Binding AddSettingCommand}" Content="Add Setting" />
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using Telerik.Windows.Controls;
|
||||
using Telerik.Windows.Controls.Data.PropertyGrid;
|
||||
|
||||
namespace BindPropertyDefinitionsViewModel
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using Telerik.Windows.Controls;
|
||||
using Telerik.Windows.Controls.Data.PropertyGrid;
|
||||
|
||||
namespace BindPropertyDefinitionsViewModel
|
||||
{
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public ICommand AddSettingCommand { get; set; }
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
this.AddSettingCommand = new DelegateCommand(AddSetting);
|
||||
}
|
||||
|
||||
ObservableCollection<PropertyDefinition> propertyDefinitions;
|
||||
public ObservableCollection<PropertyDefinition> PropertyDefinitions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (propertyDefinitions == null)
|
||||
{
|
||||
propertyDefinitions = new ObservableCollection<PropertyDefinition>();
|
||||
}
|
||||
|
||||
return propertyDefinitions;
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<Setting> settings;
|
||||
|
||||
public ObservableCollection<Setting> Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.settings == null)
|
||||
{
|
||||
this.settings = new ObservableCollection<Setting>();
|
||||
this.settings.CollectionChanged += Settings_CollectionChanged;
|
||||
settings.Add(new Setting() { Key = "setting1", Value = "value1" });
|
||||
settings.Add(new Setting() { Key = "setting2", Value = "value2" });
|
||||
settings.Add(new Setting() { Key = "setting3", Value = "value3" });
|
||||
settings.Add(new Setting() { Key = "setting4", Value = "value4" });
|
||||
}
|
||||
|
||||
return this.settings;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddSetting(object obj)
|
||||
{
|
||||
this.Settings.Add(new Setting() { Key = "setting" + (this.Settings.Count + 1).ToString(), Value = "value" + (this.Settings.Count + 1).ToString() });
|
||||
}
|
||||
|
||||
private void Settings_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.NewItems != null)
|
||||
{
|
||||
foreach (Setting item in e.NewItems)
|
||||
{
|
||||
this.PropertyDefinitions.Add(new PropertyDefinition() { DisplayName = item.Key, Binding = new Binding("Value") { Source = item } });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PropertyGridKeyValue")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PropertyGridKeyValue")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
PropertyGrid/BindPropertyDefinitionsViewModel/Properties/Resources.Designer.cs
сгенерированный
Normal file
63
PropertyGrid/BindPropertyDefinitionsViewModel/Properties/Resources.Designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,63 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace BindPropertyDefinitionsViewModel.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DynamicSettings.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
26
PropertyGrid/BindPropertyDefinitionsViewModel/Properties/Settings.Designer.cs
сгенерированный
Normal file
26
PropertyGrid/BindPropertyDefinitionsViewModel/Properties/Settings.Designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace BindPropertyDefinitionsViewModel.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -0,0 +1,108 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Windows;
|
||||
using System.Windows.Interactivity;
|
||||
using Telerik.Windows.Controls;
|
||||
|
||||
namespace BindPropertyDefinitionsViewModel
|
||||
{
|
||||
public class PropertyDefinitionsBehavior : ViewModelBase
|
||||
{
|
||||
private readonly RadPropertyGrid propertyGrid = null;
|
||||
private readonly INotifyCollectionChanged PropertyDefinitions = null;
|
||||
|
||||
public static readonly DependencyProperty PropertyDefinitionsProperty
|
||||
= DependencyProperty.RegisterAttached("PropertyDefinitions", typeof(INotifyCollectionChanged), typeof(PropertyDefinitionsBehavior),
|
||||
new PropertyMetadata(new PropertyChangedCallback(OnPropertyDefinitionsPropertyChanged)));
|
||||
|
||||
public static void SetPropertyDefinitions(DependencyObject dependencyObject, INotifyCollectionChanged PropertyDefinitions)
|
||||
{
|
||||
dependencyObject.SetValue(PropertyDefinitionsProperty, PropertyDefinitions);
|
||||
}
|
||||
|
||||
public static INotifyCollectionChanged GetPropertyDefinitions(DependencyObject dependencyObject)
|
||||
{
|
||||
return (INotifyCollectionChanged)dependencyObject.GetValue(PropertyDefinitionsProperty);
|
||||
}
|
||||
|
||||
private static void OnPropertyDefinitionsPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
RadPropertyGrid propertyGrid = dependencyObject as RadPropertyGrid;
|
||||
INotifyCollectionChanged PropertyDefinitions = e.NewValue as INotifyCollectionChanged;
|
||||
|
||||
if (propertyGrid != null && PropertyDefinitions != null)
|
||||
{
|
||||
PropertyDefinitionsBehavior behavior = new PropertyDefinitionsBehavior(propertyGrid, PropertyDefinitions);
|
||||
behavior.Attach();
|
||||
}
|
||||
}
|
||||
|
||||
private void Attach()
|
||||
{
|
||||
if (propertyGrid != null && PropertyDefinitions != null)
|
||||
{
|
||||
Transfer(GetPropertyDefinitions(propertyGrid) as IList, propertyGrid.PropertyDefinitions);
|
||||
|
||||
PropertyDefinitions.CollectionChanged -= ContextPropertyDefinitions_CollectionChanged;
|
||||
PropertyDefinitions.CollectionChanged += ContextPropertyDefinitions_CollectionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public PropertyDefinitionsBehavior(RadPropertyGrid propertyGrid, INotifyCollectionChanged PropertyDefinitions)
|
||||
{
|
||||
this.propertyGrid = propertyGrid;
|
||||
this.PropertyDefinitions = PropertyDefinitions;
|
||||
}
|
||||
|
||||
void ContextPropertyDefinitions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
UnsubscribeFromEvents();
|
||||
|
||||
Transfer(GetPropertyDefinitions(propertyGrid) as IList, propertyGrid.PropertyDefinitions);
|
||||
|
||||
SubscribeToEvents();
|
||||
}
|
||||
|
||||
void propertyGridPropertyDefinitions_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
UnsubscribeFromEvents();
|
||||
|
||||
Transfer(propertyGrid.PropertyDefinitions, GetPropertyDefinitions(propertyGrid) as IList);
|
||||
|
||||
SubscribeToEvents();
|
||||
}
|
||||
|
||||
private void SubscribeToEvents()
|
||||
{
|
||||
propertyGrid.PropertyDefinitions.CollectionChanged += propertyGridPropertyDefinitions_CollectionChanged;
|
||||
|
||||
if (GetPropertyDefinitions(propertyGrid) != null)
|
||||
{
|
||||
GetPropertyDefinitions(propertyGrid).CollectionChanged += ContextPropertyDefinitions_CollectionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void UnsubscribeFromEvents()
|
||||
{
|
||||
propertyGrid.PropertyDefinitions.CollectionChanged -= propertyGridPropertyDefinitions_CollectionChanged;
|
||||
|
||||
if (GetPropertyDefinitions(propertyGrid) != null)
|
||||
{
|
||||
GetPropertyDefinitions(propertyGrid).CollectionChanged -= ContextPropertyDefinitions_CollectionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Transfer(IList source, IList target)
|
||||
{
|
||||
if (source == null || target == null)
|
||||
return;
|
||||
|
||||
target.Clear();
|
||||
|
||||
foreach (object o in source)
|
||||
{
|
||||
target.Add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
##Binding PropertyDefinitions From ViewModel##
|
||||
This example demonstrates how to implement a custom attached behavior in order to bind the PropertyDefinitions property to a collection from your ViewModel. You can check the code in PropertyDefinitionsBehavior.cs.
|
||||
|
||||
<KeyWords: attached, behavior, binding, property, definitions, viewmodel>
|
|
@ -0,0 +1,8 @@
|
|||
namespace BindPropertyDefinitionsViewModel
|
||||
{
|
||||
public class Setting
|
||||
{
|
||||
public string Key { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<startup></startup>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
<connectionStrings>
|
||||
<add name="ScheduleViewEntities" connectionString="data source=(LocalDb)\MSSQLLocalDB;initial catalog=DatabaseEntityFramework;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
</configuration>
|
|
@ -0,0 +1,13 @@
|
|||
<Application x:Class="DatabaseEntityFramework.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/System.Windows.xaml" />
|
||||
<ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.xaml" />
|
||||
<ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.Input.xaml" />
|
||||
<ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
|
||||
<ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.ScheduleView.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class Category
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public Category()
|
||||
{
|
||||
SqlAppointments = new HashSet<SqlAppointment>();
|
||||
SqlExceptionAppointments = new HashSet<SqlExceptionAppointment>();
|
||||
}
|
||||
|
||||
[Key]
|
||||
public int CategoryID { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string CategoryName { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string CategoryBrushName { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlAppointment> SqlAppointments { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlExceptionAppointment> SqlExceptionAppointments { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System.Data.Entity;
|
||||
|
||||
public class CustomCreateDatabaseIfNotExists<TContext> : CreateDatabaseIfNotExists<TContext>
|
||||
where TContext : ScheduleViewEntities
|
||||
{
|
||||
protected override void Seed(TContext context)
|
||||
{
|
||||
context.Categories.Add(new Category()
|
||||
{
|
||||
CategoryName = "Yellow Category",
|
||||
DisplayName = "Yellow Category",
|
||||
CategoryBrushName = "Yellow"
|
||||
});
|
||||
|
||||
context.Categories.Add(new Category()
|
||||
{
|
||||
CategoryName = "Red Category",
|
||||
DisplayName = "Red Category",
|
||||
CategoryBrushName = "Red"
|
||||
});
|
||||
|
||||
context.Categories.Add(new Category()
|
||||
{
|
||||
CategoryName = "Green Category",
|
||||
DisplayName = "Green Category",
|
||||
CategoryBrushName = "Green"
|
||||
});
|
||||
|
||||
context.TimeMarkers.Add(new TimeMarker()
|
||||
{
|
||||
TimeMarkerName = "Free",
|
||||
TimeMarkerBrushName = "Green"
|
||||
});
|
||||
|
||||
context.TimeMarkers.Add(new TimeMarker()
|
||||
{
|
||||
TimeMarkerName = "Busy",
|
||||
TimeMarkerBrushName = "Red"
|
||||
});
|
||||
|
||||
context.TimeMarkers.Add(new TimeMarker()
|
||||
{
|
||||
TimeMarkerName = "Out of Office",
|
||||
TimeMarkerBrushName = "Yellow"
|
||||
});
|
||||
|
||||
base.Seed(context);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DatabaseEntityFramework</RootNamespace>
|
||||
<AssemblyName>DatabaseEntityFramework</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>DatabaseEntityFramework.App</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Controls">
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Controls.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Controls.Input">
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Controls.Input.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Controls.Navigation">
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Controls.Navigation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Controls.ScheduleView">
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Controls.ScheduleView.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Data">
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Themes.Office2016">
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries.NoXaml\WPF40\Telerik.Windows.Themes.Office2016.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Category.cs" />
|
||||
<Compile Include="CustoCreateDatabaseIfNotExists.cs" />
|
||||
<Compile Include="Migrations\201905311155532_Initial.cs" />
|
||||
<Compile Include="Migrations\201905311155532_Initial.Designer.cs">
|
||||
<DependentUpon>201905311155532_Initial.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\Configuration.cs" />
|
||||
<Compile Include="ModelExtensions\Category.cs" />
|
||||
<Compile Include="ModelExtensions\SqlAppointment.cs" />
|
||||
<Compile Include="ModelExtensions\SqlExceptionAppointment.cs" />
|
||||
<Compile Include="ModelExtensions\SqlExceptionOccurrence.cs" />
|
||||
<Compile Include="ModelExtensions\SqlRecurrenceRule.cs" />
|
||||
<Compile Include="ModelExtensions\SqlResource.cs" />
|
||||
<Compile Include="ModelExtensions\SqlResourceType.cs" />
|
||||
<Compile Include="ModelExtensions\TimeMarker.cs" />
|
||||
<Compile Include="RecurrenceHelper.cs" />
|
||||
<Compile Include="ScheduleViewEntities.cs" />
|
||||
<Compile Include="ScheduleViewRepository.cs" />
|
||||
<Compile Include="ScheduleViewViewModel.cs" />
|
||||
<Compile Include="SolidColorBrushHelper.cs" />
|
||||
<Compile Include="SqlAppointmentResource.cs" />
|
||||
<Compile Include="SqlAppointment.cs" />
|
||||
<Compile Include="SqlExceptionAppointment.cs" />
|
||||
<Compile Include="SqlExceptionOccurrence.cs" />
|
||||
<Compile Include="SqlExceptionResource.cs" />
|
||||
<Compile Include="SqlResource.cs" />
|
||||
<Compile Include="SqlResourceType.cs" />
|
||||
<Compile Include="TimeMarker.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Migrations\201905311155532_Initial.resx">
|
||||
<DependentUpon>201905311155532_Initial.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
<None Include="Readme.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,39 @@
|
|||
<Window x:Class="DatabaseEntityFramework.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||
xmlns:local="clr-namespace:DatabaseEntityFramework"
|
||||
Title="MainWindow" Height="550" Width="1025">
|
||||
<Window.DataContext>
|
||||
<local:ScheduleViewViewModel/>
|
||||
</Window.DataContext>
|
||||
<Grid x:Name="LayoutRoot" Background="White">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<telerik:RadBusyIndicator IsBusy="{Binding IsLoading}">
|
||||
<telerik:RadScheduleView Grid.Row="0"
|
||||
AppointmentsSource="{Binding Appointments}"
|
||||
ResourceTypesSource="{Binding ResourceTypes}"
|
||||
TimeMarkersSource="{Binding TimeMarkers}"
|
||||
CategoriesSource="{Binding Categories}"
|
||||
VisibleRangeChangedCommand="{Binding VisibleRangeChanged}"
|
||||
VisibleRangeChangedCommandParameter="{Binding VisibleRange, RelativeSource={RelativeSource Self}}">
|
||||
<telerik:RadScheduleView.ViewDefinitions>
|
||||
<telerik:WeekViewDefinition />
|
||||
<telerik:MonthViewDefinition />
|
||||
<telerik:TimelineViewDefinition />
|
||||
</telerik:RadScheduleView.ViewDefinitions>
|
||||
<telerik:RadScheduleView.GroupDescriptionsSource>
|
||||
<telerik:GroupDescriptionCollection>
|
||||
<telerik:DateGroupDescription />
|
||||
<telerik:ResourceGroupDescription ResourceType="Level" ShowNullGroup="True" />
|
||||
<telerik:ResourceGroupDescription ResourceType="Speaker" ShowNullGroup="True" />
|
||||
</telerik:GroupDescriptionCollection>
|
||||
</telerik:RadScheduleView.GroupDescriptionsSource>
|
||||
</telerik:RadScheduleView>
|
||||
</telerik:RadBusyIndicator>
|
||||
<Button Grid.Row="1" Content="Save data" HorizontalAlignment="Center" Command="{Binding SaveCommand}" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
29
ScheduleView/DatabaseEntityFramework/Migrations/201905311155532_Initial.Designer.cs
сгенерированный
Normal file
29
ScheduleView/DatabaseEntityFramework/Migrations/201905311155532_Initial.Designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,29 @@
|
|||
// <auto-generated />
|
||||
namespace DatabaseEntityFramework.Migrations
|
||||
{
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Data.Entity.Migrations.Infrastructure;
|
||||
using System.Resources;
|
||||
|
||||
[GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")]
|
||||
public sealed partial class Initial : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(Initial));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "201905311155532_Initial"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
namespace DatabaseEntityFramework.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class Initial : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
CreateTable(
|
||||
"dbo.Categories",
|
||||
c => new
|
||||
{
|
||||
CategoryID = c.Int(nullable: false, identity: true),
|
||||
CategoryName = c.String(maxLength: 100, unicode: false),
|
||||
DisplayName = c.String(maxLength: 100, unicode: false),
|
||||
CategoryBrushName = c.String(maxLength: 100, unicode: false),
|
||||
})
|
||||
.PrimaryKey(t => t.CategoryID);
|
||||
|
||||
CreateTable(
|
||||
"dbo.SqlAppointments",
|
||||
c => new
|
||||
{
|
||||
SqlAppointmentId = c.Int(nullable: false, identity: true),
|
||||
Subject = c.String(maxLength: 100),
|
||||
Body = c.String(maxLength: 500),
|
||||
Start = c.DateTime(nullable: false),
|
||||
End = c.DateTime(nullable: false),
|
||||
IsAllDayEvent = c.Boolean(nullable: false),
|
||||
RecurrencePattern = c.String(maxLength: 100, unicode: false),
|
||||
TimeZoneString = c.String(maxLength: 100, unicode: false),
|
||||
Importance = c.Int(nullable: false),
|
||||
TimeMarkerID = c.Int(),
|
||||
CategoryID = c.Int(),
|
||||
})
|
||||
.PrimaryKey(t => t.SqlAppointmentId)
|
||||
.ForeignKey("dbo.Categories", t => t.CategoryID)
|
||||
.ForeignKey("dbo.TimeMarkers", t => t.TimeMarkerID)
|
||||
.Index(t => t.TimeMarkerID)
|
||||
.Index(t => t.CategoryID);
|
||||
|
||||
CreateTable(
|
||||
"dbo.SqlAppointmentResources",
|
||||
c => new
|
||||
{
|
||||
SqlAppointment_SqlAppointmentId = c.Int(nullable: false),
|
||||
SqlResource_SqlResourceId = c.Int(nullable: false),
|
||||
ManyToManyWorkaround = c.Boolean(),
|
||||
})
|
||||
.PrimaryKey(t => new { t.SqlAppointment_SqlAppointmentId, t.SqlResource_SqlResourceId })
|
||||
.ForeignKey("dbo.SqlResources", t => t.SqlResource_SqlResourceId, cascadeDelete: true)
|
||||
.ForeignKey("dbo.SqlAppointments", t => t.SqlAppointment_SqlAppointmentId, cascadeDelete: true)
|
||||
.Index(t => t.SqlAppointment_SqlAppointmentId)
|
||||
.Index(t => t.SqlResource_SqlResourceId);
|
||||
|
||||
CreateTable(
|
||||
"dbo.SqlResources",
|
||||
c => new
|
||||
{
|
||||
SqlResourceId = c.Int(nullable: false, identity: true),
|
||||
ResourceType = c.String(),
|
||||
SqlResourceTypeId = c.Int(),
|
||||
ResourceName = c.String(maxLength: 100),
|
||||
DisplayName = c.String(maxLength: 100),
|
||||
})
|
||||
.PrimaryKey(t => t.SqlResourceId)
|
||||
.ForeignKey("dbo.SqlResourceTypes", t => t.SqlResourceTypeId)
|
||||
.Index(t => t.SqlResourceTypeId);
|
||||
|
||||
CreateTable(
|
||||
"dbo.SqlExceptionResources",
|
||||
c => new
|
||||
{
|
||||
SqlExceptionAppointment_ExceptionId = c.Int(nullable: false),
|
||||
SqlResource_SqlResourceId = c.Int(nullable: false),
|
||||
ManyToManyWorkaround = c.Boolean(),
|
||||
})
|
||||
.PrimaryKey(t => new { t.SqlExceptionAppointment_ExceptionId, t.SqlResource_SqlResourceId })
|
||||
.ForeignKey("dbo.SqlExceptionAppointments", t => t.SqlExceptionAppointment_ExceptionId, cascadeDelete: true)
|
||||
.ForeignKey("dbo.SqlResources", t => t.SqlResource_SqlResourceId, cascadeDelete: true)
|
||||
.Index(t => t.SqlExceptionAppointment_ExceptionId)
|
||||
.Index(t => t.SqlResource_SqlResourceId);
|
||||
|
||||
CreateTable(
|
||||
"dbo.SqlExceptionAppointments",
|
||||
c => new
|
||||
{
|
||||
ExceptionId = c.Int(nullable: false),
|
||||
Subject = c.String(maxLength: 100),
|
||||
Body = c.String(maxLength: 500),
|
||||
Start = c.DateTime(nullable: false),
|
||||
End = c.DateTime(nullable: false),
|
||||
IsAllDayEvent = c.Boolean(nullable: false),
|
||||
TimeZoneString = c.String(maxLength: 100, unicode: false),
|
||||
Importance = c.Int(nullable: false),
|
||||
TimeMarkerID = c.Int(),
|
||||
CategoryID = c.Int(),
|
||||
})
|
||||
.PrimaryKey(t => t.ExceptionId)
|
||||
.ForeignKey("dbo.Categories", t => t.CategoryID)
|
||||
.ForeignKey("dbo.SqlExceptionOccurrences", t => t.ExceptionId, cascadeDelete: true)
|
||||
.ForeignKey("dbo.TimeMarkers", t => t.TimeMarkerID)
|
||||
.Index(t => t.ExceptionId)
|
||||
.Index(t => t.TimeMarkerID)
|
||||
.Index(t => t.CategoryID);
|
||||
|
||||
CreateTable(
|
||||
"dbo.SqlExceptionOccurrences",
|
||||
c => new
|
||||
{
|
||||
ExceptionId = c.Int(nullable: false, identity: true),
|
||||
MasterSqlAppointmentId = c.Int(nullable: false),
|
||||
ExceptionDate = c.DateTime(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.ExceptionId)
|
||||
.ForeignKey("dbo.SqlAppointments", t => t.MasterSqlAppointmentId, cascadeDelete: true)
|
||||
.Index(t => t.MasterSqlAppointmentId);
|
||||
|
||||
CreateTable(
|
||||
"dbo.TimeMarkers",
|
||||
c => new
|
||||
{
|
||||
TimeMarkerId = c.Int(nullable: false, identity: true),
|
||||
TimeMarkerName = c.String(maxLength: 50),
|
||||
TimeMarkerBrushName = c.String(maxLength: 50),
|
||||
})
|
||||
.PrimaryKey(t => t.TimeMarkerId);
|
||||
|
||||
CreateTable(
|
||||
"dbo.SqlResourceTypes",
|
||||
c => new
|
||||
{
|
||||
SqlResourceTypeId = c.Int(nullable: false, identity: true),
|
||||
Name = c.String(nullable: false, maxLength: 100),
|
||||
DisplayName = c.String(maxLength: 100),
|
||||
AllowMultipleSelection = c.Boolean(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.SqlResourceTypeId);
|
||||
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropForeignKey("dbo.SqlExceptionOccurrences", "MasterSqlAppointmentId", "dbo.SqlAppointments");
|
||||
DropForeignKey("dbo.SqlAppointmentResources", "SqlAppointment_SqlAppointmentId", "dbo.SqlAppointments");
|
||||
DropForeignKey("dbo.SqlResources", "SqlResourceTypeId", "dbo.SqlResourceTypes");
|
||||
DropForeignKey("dbo.SqlExceptionResources", "SqlResource_SqlResourceId", "dbo.SqlResources");
|
||||
DropForeignKey("dbo.SqlExceptionAppointments", "TimeMarkerID", "dbo.TimeMarkers");
|
||||
DropForeignKey("dbo.SqlAppointments", "TimeMarkerID", "dbo.TimeMarkers");
|
||||
DropForeignKey("dbo.SqlExceptionResources", "SqlExceptionAppointment_ExceptionId", "dbo.SqlExceptionAppointments");
|
||||
DropForeignKey("dbo.SqlExceptionAppointments", "ExceptionId", "dbo.SqlExceptionOccurrences");
|
||||
DropForeignKey("dbo.SqlExceptionAppointments", "CategoryID", "dbo.Categories");
|
||||
DropForeignKey("dbo.SqlAppointmentResources", "SqlResource_SqlResourceId", "dbo.SqlResources");
|
||||
DropForeignKey("dbo.SqlAppointments", "CategoryID", "dbo.Categories");
|
||||
DropIndex("dbo.SqlExceptionOccurrences", new[] { "MasterSqlAppointmentId" });
|
||||
DropIndex("dbo.SqlExceptionAppointments", new[] { "CategoryID" });
|
||||
DropIndex("dbo.SqlExceptionAppointments", new[] { "TimeMarkerID" });
|
||||
DropIndex("dbo.SqlExceptionAppointments", new[] { "ExceptionId" });
|
||||
DropIndex("dbo.SqlExceptionResources", new[] { "SqlResource_SqlResourceId" });
|
||||
DropIndex("dbo.SqlExceptionResources", new[] { "SqlExceptionAppointment_ExceptionId" });
|
||||
DropIndex("dbo.SqlResources", new[] { "SqlResourceTypeId" });
|
||||
DropIndex("dbo.SqlAppointmentResources", new[] { "SqlResource_SqlResourceId" });
|
||||
DropIndex("dbo.SqlAppointmentResources", new[] { "SqlAppointment_SqlAppointmentId" });
|
||||
DropIndex("dbo.SqlAppointments", new[] { "CategoryID" });
|
||||
DropIndex("dbo.SqlAppointments", new[] { "TimeMarkerID" });
|
||||
DropTable("dbo.SqlResourceTypes");
|
||||
DropTable("dbo.TimeMarkers");
|
||||
DropTable("dbo.SqlExceptionOccurrences");
|
||||
DropTable("dbo.SqlExceptionAppointments");
|
||||
DropTable("dbo.SqlExceptionResources");
|
||||
DropTable("dbo.SqlResources");
|
||||
DropTable("dbo.SqlAppointmentResources");
|
||||
DropTable("dbo.SqlAppointments");
|
||||
DropTable("dbo.Categories");
|
||||
}
|
||||
}
|
||||
}
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,15 @@
|
|||
namespace DatabaseEntityFramework.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Linq;
|
||||
|
||||
internal sealed class Configuration : DbMigrationsConfiguration<DatabaseEntityFramework.ScheduleViewEntities>
|
||||
{
|
||||
public Configuration()
|
||||
{
|
||||
AutomaticMigrationsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Windows.Media;
|
||||
using Telerik.Windows.Controls;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public partial class Category : ICategory
|
||||
{
|
||||
private Brush categoryBrush;
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public Brush CategoryBrush
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.categoryBrush == null)
|
||||
{
|
||||
this.categoryBrush = SolidColorBrushHelper.FromNameString(this.CategoryBrushName);
|
||||
}
|
||||
|
||||
return this.categoryBrush;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.CategoryBrushName = (this.categoryBrush as SolidColorBrush).Color.ToString().Substring(1);
|
||||
this.categoryBrush = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(ICategory other)
|
||||
{
|
||||
return this.DisplayName == other.DisplayName &&
|
||||
this.CategoryName == other.CategoryName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Telerik.Windows.Controls;
|
||||
using Telerik.Windows.Controls.ScheduleView;
|
||||
using Telerik.Windows.Controls.ScheduleView.ICalendar;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public partial class SqlAppointment : ViewModelBase, IAppointment, IExtendedAppointment, IObjectGenerator<IRecurrenceRule>
|
||||
{
|
||||
public event EventHandler RecurrenceRuleChanged;
|
||||
private List<SqlExceptionOccurrence> exceptionOccurrences;
|
||||
private List<SqlExceptionAppointment> exceptionAppointments;
|
||||
private IList resources;
|
||||
private TimeZoneInfo timeZone;
|
||||
private IRecurrenceRule recurrenceRule;
|
||||
|
||||
ITimeMarker IExtendedAppointment.TimeMarker
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.TimeMarker as ITimeMarker;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.TimeMarker = value as TimeMarker;
|
||||
}
|
||||
}
|
||||
|
||||
ICategory IExtendedAppointment.Category
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Category as ICategory;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Category = value as Category;
|
||||
}
|
||||
}
|
||||
|
||||
Importance IExtendedAppointment.Importance
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Importance)this.Importance;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Importance = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public TimeZoneInfo TimeZone
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.timeZone == null)
|
||||
{
|
||||
return TimeZoneInfo.Local;
|
||||
}
|
||||
|
||||
return this.timeZone;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.timeZone != value)
|
||||
{
|
||||
this.timeZone = value;
|
||||
this.OnPropertyChanged("TimeZone");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IList Resources
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.resources == null)
|
||||
{
|
||||
this.resources = this.SqlAppointmentResources.Select(ar => ar.SqlResource).ToList();
|
||||
}
|
||||
|
||||
return this.resources;
|
||||
}
|
||||
}
|
||||
|
||||
public IRecurrenceRule RecurrenceRule
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.recurrenceRule == null)
|
||||
{
|
||||
this.recurrenceRule = this.GetRecurrenceRule(this.RecurrencePattern);
|
||||
}
|
||||
|
||||
return this.recurrenceRule;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.recurrenceRule != value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
this.RecurrencePattern = null;
|
||||
}
|
||||
this.recurrenceRule = value;
|
||||
this.OnPropertyChanged("RecurrenceRule");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IAppointment Copy()
|
||||
{
|
||||
IAppointment appointment = new SqlAppointment();
|
||||
appointment.CopyFrom(this);
|
||||
return appointment;
|
||||
}
|
||||
|
||||
void IEditableObject.BeginEdit()
|
||||
{
|
||||
if (this.exceptionOccurrences == null)
|
||||
{
|
||||
this.exceptionOccurrences = new List<SqlExceptionOccurrence>();
|
||||
}
|
||||
|
||||
if (this.exceptionAppointments == null)
|
||||
{
|
||||
this.exceptionAppointments = new List<SqlExceptionAppointment>();
|
||||
}
|
||||
|
||||
this.exceptionOccurrences.Clear();
|
||||
this.exceptionOccurrences.AddRange(this.SqlExceptionOccurrences.ToList());
|
||||
|
||||
this.exceptionAppointments.Clear();
|
||||
this.exceptionAppointments.AddRange(this.SqlExceptionOccurrences.Select(o => o.SqlAppointment).Where(a => a != null).ToList());
|
||||
}
|
||||
|
||||
void IEditableObject.CancelEdit()
|
||||
{
|
||||
var exceptionOccurencesToRemove = this.SqlExceptionOccurrences.Except(this.exceptionOccurrences).ToList();
|
||||
foreach (var ex in exceptionOccurencesToRemove)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlExceptionOccurrences.Remove(ex);
|
||||
if (ex.Appointment != null)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlExceptionAppointments.Remove((SqlExceptionAppointment)ex.Appointment);
|
||||
foreach (var resource in (ex.Appointment as SqlExceptionAppointment).SqlExceptionResources)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlExceptionResources.Remove(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IEditableObject.EndEdit()
|
||||
{
|
||||
var temp = this.SqlAppointmentResources.ToList();
|
||||
var resources = this.Resources.OfType<SqlResource>().ToList();
|
||||
|
||||
foreach (var item in temp)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlAppointmentResources.Remove(item);
|
||||
}
|
||||
|
||||
foreach (var sqlResource in resources)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlAppointmentResources.Add(new SqlAppointmentResource { SqlAppointment = this, SqlResource_SqlResourceId = sqlResource.SqlResourceId });
|
||||
}
|
||||
|
||||
var removedExceptionAppointments = this.exceptionAppointments.Except(this.SqlExceptionOccurrences.Select(o => o.Appointment).OfType<SqlExceptionAppointment>());
|
||||
foreach (var exceptionAppointment in removedExceptionAppointments)
|
||||
{
|
||||
var excResources = exceptionAppointment.SqlExceptionResources.ToList();
|
||||
foreach (var item in excResources)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlExceptionResources.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(IAppointment other)
|
||||
{
|
||||
var otherAppointment = other as SqlAppointment;
|
||||
return otherAppointment != null &&
|
||||
other.Start == this.Start &&
|
||||
other.End == this.End &&
|
||||
other.Subject == this.Subject &&
|
||||
this.CategoryID == otherAppointment.CategoryID &&
|
||||
this.TimeMarker == otherAppointment.TimeMarker &&
|
||||
this.TimeZone == otherAppointment.TimeZone &&
|
||||
this.IsAllDayEvent == other.IsAllDayEvent &&
|
||||
this.RecurrenceRule == other.RecurrenceRule;
|
||||
}
|
||||
|
||||
public IRecurrenceRule CreateNew()
|
||||
{
|
||||
return this.CreateDefaultRecurrenceRule();
|
||||
}
|
||||
|
||||
public IRecurrenceRule CreateNew(IRecurrenceRule item)
|
||||
{
|
||||
var sqlRecurrenceRule = this.CreateNew();
|
||||
sqlRecurrenceRule.CopyFrom(item);
|
||||
return sqlRecurrenceRule;
|
||||
}
|
||||
|
||||
public IAppointment ShallowCopy()
|
||||
{
|
||||
var appointment = new SqlExceptionAppointment();
|
||||
appointment.CopyFrom(this);
|
||||
return appointment;
|
||||
}
|
||||
|
||||
void ICopyable<IAppointment>.CopyFrom(IAppointment other)
|
||||
{
|
||||
this.IsAllDayEvent = other.IsAllDayEvent;
|
||||
this.Start = other.Start;
|
||||
this.End = other.End;
|
||||
this.Subject = other.Subject;
|
||||
|
||||
var otherAppointment = other as SqlAppointment;
|
||||
if (otherAppointment == null)
|
||||
return;
|
||||
|
||||
this.CategoryID = otherAppointment.CategoryID;
|
||||
this.TimeMarker = otherAppointment.TimeMarker;
|
||||
this.RecurrenceRule = other.RecurrenceRule == null ? null : other.RecurrenceRule.Copy() as SqlRecurrenceRule;
|
||||
this.RecurrencePattern = otherAppointment.RecurrencePattern;
|
||||
|
||||
this.Resources.Clear();
|
||||
this.Resources.AddRange(otherAppointment.Resources);
|
||||
|
||||
this.Body = otherAppointment.Body;
|
||||
}
|
||||
|
||||
private IRecurrenceRule GetRecurrenceRule(string pattern)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pattern))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var recurrenceRuleGenerator = this as IObjectGenerator<IRecurrenceRule>;
|
||||
var recurrenceRule = recurrenceRuleGenerator != null ? recurrenceRuleGenerator.CreateNew() : this.CreateDefaultRecurrenceRule();
|
||||
var recurrencePattern = new RecurrencePattern();
|
||||
RecurrencePatternHelper.TryParseRecurrencePattern(pattern, out recurrencePattern);
|
||||
recurrenceRule.Pattern = recurrencePattern;
|
||||
foreach (SqlExceptionOccurrence exception in this.SqlExceptionOccurrences)
|
||||
{
|
||||
recurrenceRule.Exceptions.Add(exception);
|
||||
}
|
||||
|
||||
return recurrenceRule;
|
||||
}
|
||||
|
||||
private IRecurrenceRule CreateDefaultRecurrenceRule()
|
||||
{
|
||||
return new SqlRecurrenceRule(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using Telerik.Windows.Controls;
|
||||
using Telerik.Windows.Controls.ScheduleView;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public partial class SqlExceptionAppointment : ViewModelBase, IEditableObject, IAppointment, IExtendedAppointment, IObjectGenerator<IRecurrenceRule>
|
||||
{
|
||||
public event EventHandler RecurrenceRuleChanged;
|
||||
|
||||
private TimeZoneInfo timeZone;
|
||||
private IRecurrenceRule recurrenceRule;
|
||||
private IList resource;
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public TimeZoneInfo TimeZone
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.timeZone == null)
|
||||
{
|
||||
return TimeZoneInfo.Local;
|
||||
}
|
||||
|
||||
return this.timeZone;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.timeZone != value)
|
||||
{
|
||||
this.timeZone = value;
|
||||
this.OnPropertyChanged("TimeZone");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IRecurrenceRule RecurrenceRule
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.recurrenceRule;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.recurrenceRule != value)
|
||||
{
|
||||
this.recurrenceRule = value;
|
||||
this.OnPropertyChanged("RecurrenceRule");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IList Resources
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.resource == null)
|
||||
{
|
||||
this.resource = new ObservableCollection<SqlResource>();
|
||||
var resources = ScheduleViewRepository.Context.SqlExceptionResources.Where(x => x.SqlExceptionAppointment_ExceptionId == this.ExceptionId).Select(x => x.SqlResource);
|
||||
this.resource.AddRange(resources);
|
||||
|
||||
((INotifyCollectionChanged)this.resource).CollectionChanged += resource_CollectionChanged;
|
||||
}
|
||||
return this.resource;
|
||||
}
|
||||
}
|
||||
|
||||
ITimeMarker IExtendedAppointment.TimeMarker
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.TimeMarker as ITimeMarker;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.TimeMarker = value as TimeMarker;
|
||||
}
|
||||
}
|
||||
|
||||
ICategory IExtendedAppointment.Category
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Category as ICategory;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Category = value as Category;
|
||||
}
|
||||
}
|
||||
|
||||
Importance IExtendedAppointment.Importance
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Importance)this.Importance;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Importance = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
public IAppointment Copy()
|
||||
{
|
||||
IAppointment appointment = new SqlExceptionAppointment();
|
||||
appointment.CopyFrom(this);
|
||||
return appointment;
|
||||
}
|
||||
|
||||
public void BeginEdit()
|
||||
{
|
||||
}
|
||||
|
||||
public void CancelEdit()
|
||||
{
|
||||
}
|
||||
|
||||
public void EndEdit()
|
||||
{
|
||||
}
|
||||
|
||||
public bool Equals(IAppointment other)
|
||||
{
|
||||
var otherAppointment = other as SqlExceptionAppointment;
|
||||
return otherAppointment != null &&
|
||||
other.Start == this.Start &&
|
||||
other.End == this.End &&
|
||||
other.Subject == this.Subject &&
|
||||
this.CategoryID == otherAppointment.CategoryID &&
|
||||
this.TimeMarker == otherAppointment.TimeMarker &&
|
||||
this.TimeZone == otherAppointment.TimeZone &&
|
||||
this.IsAllDayEvent == other.IsAllDayEvent &&
|
||||
this.RecurrenceRule == other.RecurrenceRule;
|
||||
}
|
||||
|
||||
public IRecurrenceRule CreateNew()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public IRecurrenceRule CreateNew(IRecurrenceRule item)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public void CopyFrom(IAppointment other)
|
||||
{
|
||||
this.IsAllDayEvent = other.IsAllDayEvent;
|
||||
this.Start = other.Start;
|
||||
this.End = other.End;
|
||||
this.Subject = other.Subject;
|
||||
|
||||
var otherAppointment = other as SqlAppointment;
|
||||
if (otherAppointment == null)
|
||||
return;
|
||||
|
||||
this.CategoryID = otherAppointment.CategoryID;
|
||||
this.TimeMarker = otherAppointment.TimeMarker;
|
||||
|
||||
this.Resources.Clear();
|
||||
this.Resources.AddRange(otherAppointment.Resources);
|
||||
|
||||
this.Body = otherAppointment.Body;
|
||||
}
|
||||
|
||||
void resource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
switch (e.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
foreach (var resource in e.NewItems.OfType<SqlResource>())
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlExceptionResources.Add(
|
||||
new SqlExceptionResource
|
||||
{
|
||||
SqlExceptionAppointment_ExceptionId = this.ExceptionId,
|
||||
SqlResource_SqlResourceId = resource.SqlResourceId
|
||||
});
|
||||
}
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
foreach (var sqlres in e.OldItems.OfType<SqlResource>())
|
||||
{
|
||||
var itemsToRemove = ScheduleViewRepository.Context.SqlExceptionResources.Where(x => x.SqlResource_SqlResourceId == sqlres.SqlResourceId && x.SqlExceptionAppointment_ExceptionId == this.ExceptionId).ToList();
|
||||
if (itemsToRemove.Any())
|
||||
{
|
||||
foreach (var item in itemsToRemove)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlExceptionResources.Remove(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itemsToRemove = sqlres.SqlExceptionResources.Where(x => x.SqlResource_SqlResourceId == sqlres.SqlResourceId && x.SqlExceptionAppointment_ExceptionId == this.ExceptionId).ToList();
|
||||
foreach (var item in itemsToRemove)
|
||||
{
|
||||
ScheduleViewRepository.Context.Entry(item).State = System.Data.Entity.EntityState.Detached;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using Telerik.Windows.Controls;
|
||||
using Telerik.Windows.Controls.ScheduleView;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public partial class SqlExceptionOccurrence : ViewModelBase, IExceptionOccurrence
|
||||
{
|
||||
public IAppointment Appointment
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.SqlExceptionAppointment;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.SqlExceptionAppointment != value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlExceptionAppointments.Remove(this.SqlExceptionAppointment);
|
||||
}
|
||||
|
||||
this.SqlExceptionAppointment = value as SqlExceptionAppointment;
|
||||
this.OnPropertyChanged("Appointment");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IExceptionOccurrence Copy()
|
||||
{
|
||||
var exception = new SqlExceptionOccurrence();
|
||||
exception.CopyFrom(this);
|
||||
return exception;
|
||||
}
|
||||
|
||||
public void CopyFrom(IExceptionOccurrence other)
|
||||
{
|
||||
if (this.GetType().FullName != other.GetType().FullName)
|
||||
throw new ArgumentException("Invalid type");
|
||||
|
||||
this.ExceptionDate = other.ExceptionDate;
|
||||
if (other.Appointment != null)
|
||||
this.Appointment = other.Appointment.Copy();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Telerik.Windows.Controls.ScheduleView;
|
||||
using System.Collections.ObjectModel;
|
||||
using Telerik.Windows.Controls.ScheduleView.ICalendar;
|
||||
using System.Collections.Specialized;
|
||||
using Telerik.Windows.Controls;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public class SqlRecurrenceRule : ViewModelBase, IRecurrenceRule
|
||||
{
|
||||
private RecurrencePattern pattern;
|
||||
|
||||
public SqlRecurrenceRule()
|
||||
{
|
||||
this.Exceptions = new ObservableCollection<IExceptionOccurrence>();
|
||||
}
|
||||
|
||||
public SqlRecurrenceRule(SqlAppointment appointment)
|
||||
: this()
|
||||
{
|
||||
this.MasterAppointment = appointment;
|
||||
}
|
||||
|
||||
public SqlAppointment MasterAppointment { get; private set; }
|
||||
|
||||
public RecurrencePattern Pattern
|
||||
{
|
||||
get
|
||||
{
|
||||
return pattern;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.pattern != value)
|
||||
{
|
||||
this.pattern = value;
|
||||
this.MasterAppointment.RecurrencePattern = RecurrencePatternHelper.RecurrencePatternToString(pattern);
|
||||
this.OnPropertyChanged("Pattern");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<IExceptionOccurrence> Exceptions
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public IRecurrenceRule Copy()
|
||||
{
|
||||
var rule = new SqlRecurrenceRule();
|
||||
rule.CopyFrom(this);
|
||||
return rule;
|
||||
}
|
||||
|
||||
public IExceptionOccurrence CreateNew()
|
||||
{
|
||||
var excOcc = new SqlExceptionOccurrence();
|
||||
excOcc.SqlAppointment = this.MasterAppointment;
|
||||
ScheduleViewRepository.Context.SqlExceptionOccurrences.Add(excOcc);
|
||||
return excOcc;
|
||||
}
|
||||
|
||||
public IExceptionOccurrence CreateNew(IExceptionOccurrence item)
|
||||
{
|
||||
var sqlExceptionOccurrence = this.CreateNew();
|
||||
sqlExceptionOccurrence.CopyFrom(item);
|
||||
return sqlExceptionOccurrence;
|
||||
}
|
||||
|
||||
public void CopyFrom(IRecurrenceRule other)
|
||||
{
|
||||
if (this.GetType().FullName != other.GetType().FullName)
|
||||
{
|
||||
throw new ArgumentException("Invalid type");
|
||||
}
|
||||
|
||||
if (other is SqlRecurrenceRule)
|
||||
{
|
||||
this.MasterAppointment = (other as SqlRecurrenceRule).MasterAppointment;
|
||||
}
|
||||
|
||||
this.Pattern = other.Pattern.Copy();
|
||||
this.Exceptions.Clear();
|
||||
|
||||
var exceptions = other.Exceptions.ToList();
|
||||
other.Exceptions.Clear();
|
||||
|
||||
this.Exceptions = exceptions;
|
||||
}
|
||||
|
||||
public IAppointment CreateExceptionAppointment(IAppointment master)
|
||||
{
|
||||
return (master as SqlAppointment).ShallowCopy();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
using System.ComponentModel;
|
||||
using Telerik.Windows.Controls;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public partial class SqlResource : ViewModelBase, IResource
|
||||
{
|
||||
public string ResourceType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.SqlResourceType.Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.SqlResourceType.Name != value)
|
||||
{
|
||||
this.SqlResourceType.Name = value;
|
||||
this.OnPropertyChanged("ResourceType");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.DisplayName;
|
||||
}
|
||||
|
||||
public bool Equals(IResource other)
|
||||
{
|
||||
return other != null && other.ResourceName == this.ResourceName && other.ResourceType == this.ResourceType;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
using System.Linq;
|
||||
using Telerik.Windows.Controls;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public partial class SqlResourceType : IResourceType
|
||||
{
|
||||
public System.Collections.IList Resources
|
||||
{
|
||||
get { return this.SqlResources.ToList(); }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Windows.Media;
|
||||
using Telerik.Windows.Controls;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public partial class TimeMarker : ITimeMarker
|
||||
{
|
||||
private Brush timeMarkerBrush;
|
||||
|
||||
[NotMapped]
|
||||
public Brush TimeMarkerBrush
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.timeMarkerBrush == null)
|
||||
{
|
||||
this.timeMarkerBrush = SolidColorBrushHelper.FromNameString(this.TimeMarkerBrushName);
|
||||
}
|
||||
|
||||
return this.timeMarkerBrush;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.TimeMarkerBrushName = (this.timeMarkerBrush as SolidColorBrush).Color.ToString().Substring(1);
|
||||
this.timeMarkerBrush = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(ITimeMarker other)
|
||||
{
|
||||
return this.TimeMarkerName != other.TimeMarkerName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("BindToDatabase")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BindToDatabase")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
ScheduleView/DatabaseEntityFramework/Properties/Resources.Designer.cs
сгенерированный
Normal file
63
ScheduleView/DatabaseEntityFramework/Properties/Resources.Designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,63 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DatabaseEntityFramework.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DatabaseEntityFramework.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DatabaseEntityFramework.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -0,0 +1,4 @@
|
|||
## Binding to Database using Entity Framework##
|
||||
This example demonstrates how to bind the RadScheduleView to a database using Entity Framework with Code-First Migrations.
|
||||
|
||||
<keywords: entityframework, database, code-first, migrations, sqlserver>
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Telerik.Windows.Controls.ScheduleView;
|
||||
using Telerik.Windows.Controls.ScheduleView.ICalendar;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public class RecurrenceHelper
|
||||
{
|
||||
public static bool IsOccurrenceInRange(string valueToParse, DateTime start, DateTime end)
|
||||
{
|
||||
RecurrencePattern pattern = new RecurrencePattern();
|
||||
if (RecurrencePatternHelper.TryParseRecurrencePattern(valueToParse, out pattern))
|
||||
{
|
||||
return pattern.GetOccurrences(start, start, end).Count() > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class ScheduleViewEntities : DbContext
|
||||
{
|
||||
public ScheduleViewEntities()
|
||||
: base("name=ScheduleViewEntities")
|
||||
{
|
||||
Database.SetInitializer(new CustomCreateDatabaseIfNotExists<ScheduleViewEntities>());
|
||||
}
|
||||
|
||||
public virtual DbSet<Category> Categories { get; set; }
|
||||
public virtual DbSet<SqlAppointmentResource> SqlAppointmentResources { get; set; }
|
||||
public virtual DbSet<SqlAppointment> SqlAppointments { get; set; }
|
||||
public virtual DbSet<SqlExceptionAppointment> SqlExceptionAppointments { get; set; }
|
||||
public virtual DbSet<SqlExceptionOccurrence> SqlExceptionOccurrences { get; set; }
|
||||
public virtual DbSet<SqlExceptionResource> SqlExceptionResources { get; set; }
|
||||
public virtual DbSet<SqlResource> SqlResources { get; set; }
|
||||
public virtual DbSet<SqlResourceType> SqlResourceTypes { get; set; }
|
||||
public virtual DbSet<TimeMarker> TimeMarkers { get; set; }
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Category>()
|
||||
.Property(e => e.CategoryName)
|
||||
.IsUnicode(false);
|
||||
|
||||
modelBuilder.Entity<Category>()
|
||||
.Property(e => e.DisplayName)
|
||||
.IsUnicode(false);
|
||||
|
||||
modelBuilder.Entity<Category>()
|
||||
.Property(e => e.CategoryBrushName)
|
||||
.IsUnicode(false);
|
||||
|
||||
modelBuilder.Entity<SqlAppointment>()
|
||||
.Property(e => e.RecurrencePattern)
|
||||
.IsUnicode(false);
|
||||
|
||||
modelBuilder.Entity<SqlAppointment>()
|
||||
.Property(e => e.TimeZoneString)
|
||||
.IsUnicode(false);
|
||||
|
||||
modelBuilder.Entity<SqlAppointment>()
|
||||
.HasMany(e => e.SqlAppointmentResources)
|
||||
.WithRequired(e => e.SqlAppointment)
|
||||
.HasForeignKey(e => e.SqlAppointment_SqlAppointmentId);
|
||||
|
||||
modelBuilder.Entity<SqlAppointment>()
|
||||
.HasMany(e => e.SqlExceptionOccurrences)
|
||||
.WithRequired(e => e.SqlAppointment)
|
||||
.HasForeignKey(e => e.MasterSqlAppointmentId);
|
||||
|
||||
modelBuilder.Entity<SqlExceptionAppointment>()
|
||||
.Property(e => e.TimeZoneString)
|
||||
.IsUnicode(false);
|
||||
|
||||
modelBuilder.Entity<SqlExceptionAppointment>()
|
||||
.HasMany(e => e.SqlExceptionResources)
|
||||
.WithRequired(e => e.SqlExceptionAppointment)
|
||||
.HasForeignKey(e => e.SqlExceptionAppointment_ExceptionId);
|
||||
|
||||
modelBuilder.Entity<SqlExceptionOccurrence>()
|
||||
.HasOptional(e => e.SqlExceptionAppointment)
|
||||
.WithRequired(e => e.SqlExceptionOccurrence)
|
||||
.WillCascadeOnDelete();
|
||||
|
||||
modelBuilder.Entity<SqlResource>()
|
||||
.HasMany(e => e.SqlAppointmentResources)
|
||||
.WithRequired(e => e.SqlResource)
|
||||
.HasForeignKey(e => e.SqlResource_SqlResourceId);
|
||||
|
||||
modelBuilder.Entity<SqlResource>()
|
||||
.HasMany(e => e.SqlExceptionResources)
|
||||
.WithRequired(e => e.SqlResource)
|
||||
.HasForeignKey(e => e.SqlResource_SqlResourceId);
|
||||
|
||||
modelBuilder.Entity<TimeMarker>()
|
||||
.HasMany(e => e.SqlAppointments)
|
||||
.WithOptional(e => e.TimeMarker)
|
||||
.HasForeignKey(e => e.TimeMarkerID);
|
||||
|
||||
modelBuilder.Entity<TimeMarker>()
|
||||
.HasMany(e => e.SqlExceptionAppointments)
|
||||
.WithOptional(e => e.TimeMarker)
|
||||
.HasForeignKey(e => e.TimeMarkerID);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public class ScheduleViewRepository
|
||||
{
|
||||
private static ScheduleViewEntities context;
|
||||
public static ScheduleViewEntities Context
|
||||
{
|
||||
get
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
context = new ScheduleViewEntities();
|
||||
}
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SaveData(Action action)
|
||||
{
|
||||
var isSubmited = ScheduleViewRepository.Context.SaveChanges() >= 0;
|
||||
if (action != null && isSubmited)
|
||||
{
|
||||
action();
|
||||
}
|
||||
return isSubmited;
|
||||
}
|
||||
|
||||
public static IQueryable<SqlAppointment> GetSqlAppointmentsByRange(DateTime start, DateTime end)
|
||||
{
|
||||
var ids = GetSqlAppointmentsIdsByRange(start, end);
|
||||
|
||||
var result = context.SqlAppointments.Where(a => ids.Contains(a.SqlAppointmentId)).ToList<SqlAppointment>();
|
||||
|
||||
// Load the recurrent appointments
|
||||
foreach (var item in context.SqlAppointments.Where(a => !string.IsNullOrEmpty(a.RecurrencePattern)))
|
||||
{
|
||||
if (RecurrenceHelper.IsOccurrenceInRange(item.RecurrencePattern, start, end) && !result.Contains(item))
|
||||
{
|
||||
result.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
// Load the exceptions
|
||||
foreach (var item in context.SqlAppointments.Where(a => a.Start < end && a.SqlExceptionOccurrences.Count != 0))
|
||||
{
|
||||
if (item.SqlExceptionOccurrences.Any(e => e.SqlExceptionAppointment != null && e.SqlExceptionAppointment.Start >= start && e.SqlExceptionAppointment.End <= end) && !result.Contains(item))
|
||||
{
|
||||
result.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return result.AsQueryable<SqlAppointment>();
|
||||
}
|
||||
|
||||
private static int[] GetSqlAppointmentsIdsByRange(DateTime start, DateTime end)
|
||||
{
|
||||
var result = context.SqlAppointments.Where(a => ((a.Start >= start && a.End <= end) || (a.Start <= start && a.End <= end) || (a.Start >= start && a.End >= end) || (a.Start <= start && a.End >= end))).ToList<SqlAppointment>();
|
||||
|
||||
return result.OfType<SqlAppointment>().Select(e => e.SqlAppointmentId).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Telerik.Windows.Controls;
|
||||
using Telerik.Windows.Controls.ScheduleView;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
public class ScheduleViewViewModel : ViewModelBase
|
||||
{
|
||||
private bool isBusy;
|
||||
private bool isInitialLoad;
|
||||
|
||||
public ScheduleViewViewModel()
|
||||
{
|
||||
this.isInitialLoad = true;
|
||||
this.VisibleRangeChanged = new DelegateCommand(this.VisibleRangeExecuted, (param) => true);
|
||||
this.SaveCommand = new DelegateCommand(OnSaveExecuted, (param) => true);
|
||||
this.ResourceTypes = new ObservableCollection<SqlResourceType>();
|
||||
this.Appointments = new ObservableCollection<SqlAppointment>();
|
||||
this.TimeMarkers = new ObservableCollection<TimeMarker>();
|
||||
this.Categories = new ObservableCollection<Category>();
|
||||
|
||||
this.Appointments.CollectionChanged += OnAppointmentsCollectionChanged;
|
||||
|
||||
this.LoadData();
|
||||
}
|
||||
|
||||
public bool IsLoading
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.isBusy;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.isBusy != value)
|
||||
{
|
||||
this.isBusy = value;
|
||||
this.OnPropertyChanged(() => this.IsLoading);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand VisibleRangeChanged
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ObservableCollection<SqlAppointment> Appointments
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ObservableCollection<SqlResourceType> ResourceTypes
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ObservableCollection<TimeMarker> TimeMarkers
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ObservableCollection<Category> Categories
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private void OnSaveExecuted(object param)
|
||||
{
|
||||
ScheduleViewRepository.SaveData(null);
|
||||
}
|
||||
|
||||
private void VisibleRangeExecuted(object param)
|
||||
{
|
||||
if (!IsLoading)
|
||||
{
|
||||
this.GenerateAppointments(param as DateSpan);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAppointmentsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
//Synchronization with the DB
|
||||
if (e.Action == NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
var app = e.NewItems == null ? null : e.NewItems[0] as SqlAppointment;
|
||||
if (app != null)
|
||||
{
|
||||
if (ScheduleViewRepository.Context.Entry(app).State != EntityState.Unchanged)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlAppointments.Add(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Action == NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
var app = e.OldItems == null ? null : e.OldItems[0] as SqlAppointment;
|
||||
if (app != null && ScheduleViewRepository.Context.SqlAppointments.Any(a => a.SqlAppointmentId == app.SqlAppointmentId))
|
||||
{
|
||||
if (app.RecurrenceRule != null)
|
||||
{
|
||||
var tempList = app.RecurrenceRule.Exceptions.ToList();
|
||||
|
||||
foreach (SqlExceptionOccurrence item in tempList)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlExceptionOccurrences.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
var tempAppList = ScheduleViewRepository.Context.SqlAppointmentResources.Where(i => i.SqlAppointment_SqlAppointmentId == app.SqlAppointmentId).ToList();
|
||||
|
||||
foreach (var item in tempAppList)
|
||||
{
|
||||
ScheduleViewRepository.Context.SqlAppointmentResources.Remove(item);
|
||||
}
|
||||
|
||||
ScheduleViewRepository.Context.SqlAppointments.Remove(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateAppointments(DateSpan dateSpan)
|
||||
{
|
||||
if (!this.isInitialLoad)
|
||||
{
|
||||
ScheduleViewRepository.SaveData(() => this.LoadAppointments(dateSpan));
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadAppointments(dateSpan);
|
||||
|
||||
isInitialLoad = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadAppointments(DateSpan dateSpan)
|
||||
{
|
||||
this.Appointments.Clear();
|
||||
|
||||
this.IsLoading = true;
|
||||
|
||||
this.Appointments.AddRange(ScheduleViewRepository.GetSqlAppointmentsByRange(dateSpan.Start, dateSpan.End));
|
||||
|
||||
this.IsLoading = false;
|
||||
}
|
||||
|
||||
void LoadData()
|
||||
{
|
||||
|
||||
//this is needed to order resources
|
||||
foreach (var resType in ScheduleViewRepository.Context.SqlResourceTypes)
|
||||
{
|
||||
var a = resType.SqlResources as IEnumerable<SqlResource>;
|
||||
}
|
||||
this.ResourceTypes.AddRange(ScheduleViewRepository.Context.SqlResourceTypes);
|
||||
|
||||
this.TimeMarkers.AddRange(ScheduleViewRepository.Context.TimeMarkers);
|
||||
|
||||
this.Categories.AddRange(ScheduleViewRepository.Context.Categories);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DatabaseEntityFramework
|
||||
{
|
||||
internal static class SolidColorBrushHelper
|
||||
{
|
||||
public static Brush FromNameString(string brushName)
|
||||
{
|
||||
string s = "<SolidColorBrush " + "xmlns=" + "'http://schemas.microsoft.com/winfx/2006/xaml/presentation'" + " Color='" + brushName + "' />";
|
||||
|
||||
byte[] byteArray = Encoding.ASCII.GetBytes(s);
|
||||
|
||||
MemoryStream stream = new MemoryStream(byteArray);
|
||||
|
||||
try
|
||||
{
|
||||
return (Brush) XamlReader.Load(stream);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return FromHexString(brushName);
|
||||
}
|
||||
}
|
||||
|
||||
private static Brush FromHexString(string colorArgb)
|
||||
{
|
||||
var colorHex = uint.Parse(colorArgb, NumberStyles.HexNumber);
|
||||
byte a = (byte) ((0xFF000000 & colorHex) / 0x01000000);
|
||||
byte r = (byte) ((0x00FF0000 & colorHex) / 0x00010000);
|
||||
byte g = (byte) ((0x0000FF00 & colorHex) / 0x00000100);
|
||||
byte b = (byte) ((0x000000FF & colorHex) / 0x00000001);
|
||||
return new SolidColorBrush(Color.FromArgb(a, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
using Telerik.Windows.Controls.ScheduleView;
|
||||
|
||||
public partial class SqlAppointment
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public SqlAppointment()
|
||||
{
|
||||
SqlAppointmentResources = new HashSet<SqlAppointmentResource>();
|
||||
SqlExceptionOccurrences = new HashSet<SqlExceptionOccurrence>();
|
||||
}
|
||||
|
||||
[Key]
|
||||
public int SqlAppointmentId { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string Subject { get; set; }
|
||||
|
||||
[StringLength(500)]
|
||||
public string Body { get; set; }
|
||||
|
||||
public DateTime Start { get; set; }
|
||||
|
||||
public DateTime End { get; set; }
|
||||
|
||||
public bool IsAllDayEvent { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string RecurrencePattern { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string TimeZoneString { get; set; }
|
||||
|
||||
public int Importance { get; set; }
|
||||
|
||||
public int? TimeMarkerID { get; set; }
|
||||
|
||||
public int? CategoryID { get; set; }
|
||||
|
||||
public virtual Category Category { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlAppointmentResource> SqlAppointmentResources { get; set; }
|
||||
|
||||
public virtual TimeMarker TimeMarker { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlExceptionOccurrence> SqlExceptionOccurrences { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class SqlAppointmentResource
|
||||
{
|
||||
[Key]
|
||||
[Column(Order = 0)]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public int SqlAppointment_SqlAppointmentId { get; set; }
|
||||
|
||||
[Key]
|
||||
[Column(Order = 1)]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public int SqlResource_SqlResourceId { get; set; }
|
||||
|
||||
public bool? ManyToManyWorkaround { get; set; }
|
||||
|
||||
public virtual SqlAppointment SqlAppointment { get; set; }
|
||||
|
||||
public virtual SqlResource SqlResource { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class SqlExceptionAppointment
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public SqlExceptionAppointment()
|
||||
{
|
||||
SqlExceptionResources = new HashSet<SqlExceptionResource>();
|
||||
}
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public int ExceptionId { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string Subject { get; set; }
|
||||
|
||||
[StringLength(500)]
|
||||
public string Body { get; set; }
|
||||
|
||||
public DateTime Start { get; set; }
|
||||
|
||||
public DateTime End { get; set; }
|
||||
|
||||
public bool IsAllDayEvent { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string TimeZoneString { get; set; }
|
||||
|
||||
public int Importance { get; set; }
|
||||
|
||||
public int? TimeMarkerID { get; set; }
|
||||
|
||||
public int? CategoryID { get; set; }
|
||||
|
||||
public virtual Category Category { get; set; }
|
||||
|
||||
public virtual SqlExceptionOccurrence SqlExceptionOccurrence { get; set; }
|
||||
|
||||
public virtual TimeMarker TimeMarker { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlExceptionResource> SqlExceptionResources { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class SqlExceptionOccurrence
|
||||
{
|
||||
[Key]
|
||||
public int ExceptionId { get; set; }
|
||||
|
||||
public int MasterSqlAppointmentId { get; set; }
|
||||
|
||||
public DateTime ExceptionDate { get; set; }
|
||||
|
||||
public virtual SqlAppointment SqlAppointment { get; set; }
|
||||
|
||||
public virtual SqlExceptionAppointment SqlExceptionAppointment { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class SqlExceptionResource
|
||||
{
|
||||
[Key]
|
||||
[Column(Order = 0)]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public int SqlExceptionAppointment_ExceptionId { get; set; }
|
||||
|
||||
[Key]
|
||||
[Column(Order = 1)]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public int SqlResource_SqlResourceId { get; set; }
|
||||
|
||||
public bool? ManyToManyWorkaround { get; set; }
|
||||
|
||||
public virtual SqlExceptionAppointment SqlExceptionAppointment { get; set; }
|
||||
|
||||
public virtual SqlResource SqlResource { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class SqlResource
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public SqlResource()
|
||||
{
|
||||
SqlAppointmentResources = new HashSet<SqlAppointmentResource>();
|
||||
SqlExceptionResources = new HashSet<SqlExceptionResource>();
|
||||
}
|
||||
|
||||
[Key]
|
||||
public int SqlResourceId { get; set; }
|
||||
|
||||
public int? SqlResourceTypeId { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string ResourceName { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlAppointmentResource> SqlAppointmentResources { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlExceptionResource> SqlExceptionResources { get; set; }
|
||||
|
||||
public virtual SqlResourceType SqlResourceType { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class SqlResourceType
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public SqlResourceType()
|
||||
{
|
||||
SqlResources = new HashSet<SqlResource>();
|
||||
}
|
||||
|
||||
[Key]
|
||||
public int SqlResourceTypeId { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public bool AllowMultipleSelection { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlResource> SqlResources { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
namespace DatabaseEntityFramework
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data.Entity.Spatial;
|
||||
|
||||
public partial class TimeMarker
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
|
||||
public TimeMarker()
|
||||
{
|
||||
SqlAppointments = new HashSet<SqlAppointment>();
|
||||
SqlExceptionAppointments = new HashSet<SqlExceptionAppointment>();
|
||||
}
|
||||
|
||||
[Key]
|
||||
public int TimeMarkerId { get; set; }
|
||||
|
||||
[StringLength(50)]
|
||||
public string TimeMarkerName { get; set; }
|
||||
|
||||
[StringLength(50)]
|
||||
public string TimeMarkerBrushName { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlAppointment> SqlAppointments { get; set; }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public virtual ICollection<SqlExceptionAppointment> SqlExceptionAppointments { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.1.3" targetFramework="net461" />
|
||||
</packages>
|
|
@ -53,6 +53,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingSelectedAppointments
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomReadOnlyBehavior_WPF", "CustomReadOnlyBehavior\CustomReadOnlyBehavior_WPF.csproj", "{00081E9B-4F39-4541-A8C8-5FA2F00A7FFC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseEntityFramework_WPF", "DatabaseEntityFramework\DatabaseEntityFramework_WPF.csproj", "{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -305,6 +307,18 @@ Global
|
|||
{00081E9B-4F39-4541-A8C8-5FA2F00A7FFC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{00081E9B-4F39-4541-A8C8-5FA2F00A7FFC}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{00081E9B-4F39-4541-A8C8-5FA2F00A7FFC}.Release|x86.Build.0 = Release|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{19FAA770-5C50-48AC-9CB5-641AAF1EE9B3}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Загрузка…
Ссылка в новой задаче