Refactor to have individual Date and Time Controls for better mapping… (#756)

* Refactor to have individual Date and Time Controls for better mapping for .Forms

* Add default control mapping to the TypeMap

* Call our initialise value method.

* Use custom controls and converters for our custom Date/Time

* Let's return the 'broken' string, if an error occurs, until they correct it.
This commit is contained in:
Dominique Louis 2020-10-08 16:09:21 +01:00 коммит произвёл GitHub
Родитель 322d6c8f82
Коммит d820cccf8b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 607 добавлений и 277 удалений

Просмотреть файл

@ -0,0 +1,58 @@
using System;
using AppKit;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
internal abstract class BaseDateTimeEditorControl<T> : PropertyEditorControl<PropertyViewModel<T>>
{
public NSDatePicker DatePicker { get; }
public BaseDateTimeEditorControl (IHostResourceProvider hostResources)
: base (hostResources)
{
DatePicker = new NSDatePicker {
ControlSize = NSControlSize.Small,
DatePickerElements = NSDatePickerElementFlags.HourMinuteSecond | NSDatePickerElementFlags.YearMonthDateDay,
DatePickerStyle = NSDatePickerStyle.TextFieldAndStepper,
Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)),
TimeZone = Foundation.NSTimeZone.FromAbbreviation ("UTC"),
TranslatesAutoresizingMaskIntoConstraints = false,
};
// update the value on keypress
DatePicker.Activated += Editor_Activated;
AddSubview (DatePicker);
AddConstraints (new[] {
NSLayoutConstraint.Create (DatePicker, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
NSLayoutConstraint.Create (DatePicker, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1f, 0f),
NSLayoutConstraint.Create (DatePicker, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, 0),
NSLayoutConstraint.Create (DatePicker, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1f, -6f),
});
}
protected abstract void Editor_Activated (object sender, EventArgs e);
public override NSView FirstKeyView => DatePicker;
public override NSView LastKeyView => DatePicker;
protected override void SetEnabled ()
{
DatePicker.Enabled = ViewModel.Property.CanWrite;
}
protected override void UpdateAccessibilityValues ()
{
DatePicker.AccessibilityTitle = string.Format (Properties.Resources.AccessibilityDateTime, ViewModel.Property.Name);
DatePicker.Enabled = DatePicker.Enabled;
}
protected override void Dispose (bool disposing)
{
DatePicker.Activated -= Editor_Activated;
base.Dispose (disposing);
}
}
}

Просмотреть файл

@ -0,0 +1,27 @@
using System;
using AppKit;
using Xamarin.PropertyEditing.Common;
namespace Xamarin.PropertyEditing.Mac
{
internal class DateEditorControl : BaseDateTimeEditorControl<Date>
{
public DateEditorControl (IHostResourceProvider hostResources)
: base (hostResources)
{
DatePicker.DatePickerElements = NSDatePickerElementFlags.YearMonthDateDay;
}
protected override void Editor_Activated (object sender, EventArgs e)
{
ViewModel.Value = new Date (DatePicker.DateValue.ToDateTime ());
}
protected override void UpdateValue ()
{
if (ViewModel.Value != null)
DatePicker.DateValue = ViewModel.Value.DateTime.ToNSDate ();
}
}
}

Просмотреть файл

@ -1,65 +1,22 @@
using System;
using AppKit;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
internal class DateTimeEditorControl : PropertyEditorControl<PropertyViewModel<DateTime>>
{
private readonly NSDatePicker datePicker;
internal class DateTimeEditorControl : BaseDateTimeEditorControl<DateTime>
{
public DateTimeEditorControl (IHostResourceProvider hostResources)
: base (hostResources)
{
this.datePicker = new NSDatePicker {
ControlSize = NSControlSize.Small,
DatePickerElements = NSDatePickerElementFlags.HourMinuteSecond | NSDatePickerElementFlags.YearMonthDateDay,
DatePickerStyle = NSDatePickerStyle.TextFieldAndStepper,
Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)),
TranslatesAutoresizingMaskIntoConstraints = false
};
// update the value on keypress
this.datePicker.Activated += Editor_Activated;
AddSubview (this.datePicker);
AddConstraints (new[] {
NSLayoutConstraint.Create (this.datePicker, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f),
NSLayoutConstraint.Create (this.datePicker, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1f, 0f),
NSLayoutConstraint.Create (this.datePicker, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, 0),
NSLayoutConstraint.Create (this.datePicker, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1f, -6f),
});
}
private void Editor_Activated (object sender, EventArgs e)
{
ViewModel.Value = this.datePicker.DateValue.ToDateTime ();
}
public override NSView FirstKeyView => this.datePicker;
public override NSView LastKeyView => this.datePicker;
protected override void Editor_Activated (object sender, EventArgs e)
{
ViewModel.Value = DatePicker.DateValue.ToDateTime ();
}
protected override void UpdateValue ()
{
this.datePicker.DateValue = ViewModel.Value.ToNSDate ();
}
protected override void SetEnabled ()
{
this.datePicker.Enabled = ViewModel.Property.CanWrite;
}
protected override void UpdateAccessibilityValues ()
{
this.datePicker.AccessibilityTitle = string.Format (Properties.Resources.AccessibilityDateTime, ViewModel.Property.Name);
this.datePicker.Enabled = this.datePicker.Enabled;
}
protected override void Dispose (bool disposing)
{
this.datePicker.Activated -= Editor_Activated;
base.Dispose (disposing);
DatePicker.DateValue = ViewModel.Value.ToNSDate ();
}
}
}

Просмотреть файл

@ -0,0 +1,27 @@
using System;
using AppKit;
using Xamarin.PropertyEditing.Common;
namespace Xamarin.PropertyEditing.Mac
{
internal class TimeEditorControl : BaseDateTimeEditorControl<Time>
{
public TimeEditorControl (IHostResourceProvider hostResources)
: base (hostResources)
{
DatePicker.DatePickerElements = NSDatePickerElementFlags.HourMinuteSecond;
}
protected override void Editor_Activated (object sender, EventArgs e)
{
ViewModel.Value = new Time (DatePicker.DateValue.ToDateTime ());
}
protected override void UpdateValue ()
{
if (ViewModel.Value != null)
DatePicker.DateValue = ViewModel.Value.DateTime.ToNSDate ();
}
}
}

Просмотреть файл

@ -61,7 +61,8 @@ namespace Xamarin.PropertyEditing.Mac
{typeof (ObjectPropertyViewModel), typeof (ObjectEditorControl)},
{typeof (TypePropertyViewModel), typeof (TypeEditorControl)},
{typeof (CollectionPropertyViewModel), typeof (CollectionInlineEditorControl)},
{typeof (PropertyViewModel<Date>), typeof (DateEditorControl)},
{typeof (PropertyViewModel<Time>), typeof (TimeEditorControl)},
};
}
}

Просмотреть файл

@ -102,7 +102,11 @@ namespace Xamarin.PropertyEditing.Tests.MockControls
AddProperty<FilePath> ("FilePath", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding);
AddReadOnlyProperty<FilePath> ("ReadOnlyFilePath", ReadOnly);
AddProperty<DateTime> ("DateTime", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding);
AddReadOnlyProperty<DateTime> ("ReadDateTime", ReadOnly);
AddReadOnlyProperty<DateTime> ("ReadOnlyDateTime", ReadOnly);
AddProperty<Date> ("Date", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding);
AddReadOnlyProperty<Date> ("ReadOnlyDate", ReadOnly);
AddProperty<Time> ("Time", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding);
AddReadOnlyProperty<Time> ("ReadOnlyTime", ReadOnly);
AddEvents ("Click", "Hover", "Focus");
@ -140,6 +144,9 @@ namespace Xamarin.PropertyEditing.Tests.MockControls
public async Task SetInitialValuesAsync (IObjectEditor editor)
{
await editor.SetValueAsync (Properties["FilePath"], new ValueInfo<FilePath> { Value = new FilePath ("/Desktop/MyTestFile") });
await editor.SetValueAsync (Properties["DateTime"], new ValueInfo<DateTime> { Value = DateTime.Now });
await editor.SetValueAsync (Properties["Date"], new ValueInfo<Date> { Value = new Date (DateTime.Now) });
await editor.SetValueAsync (Properties["Time"], new ValueInfo<Time> { Value = new Time (DateTime.Now) });
}
public async Task SetBrushInitialValueAsync (IObjectEditor editor, CommonBrush brush)

Просмотреть файл

@ -64,6 +64,7 @@ namespace Xamarin.PropertyEditing.Windows.Standalone
inspectedObject = mockedControl.MockedControl;
if (mockedControl is MockedSampleControlButton mockedButton) {
IObjectEditor editor = await this.panel.TargetPlatform.EditorProvider.GetObjectEditorAsync (inspectedObject);
await mockedButton.MockedControl.SetInitialValuesAsync (editor);
await mockedButton.MockedControl.SetBrushInitialValueAsync (editor, new CommonSolidBrush (20, 120, 220, 240, "sRGB"));
await mockedButton.MockedControl.SetMaterialDesignBrushInitialValueAsync (editor, new CommonSolidBrush (0x65, 0x1F, 0xFF, 200));
await mockedButton.MockedControl.SetReadOnlyBrushInitialValueAsync (editor, new CommonSolidBrush (240, 220, 15, 190));

Просмотреть файл

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Xamarin.PropertyEditing.Windows
{
class DateEditorControl : PropertyEditorControl
{
}
}

Просмотреть файл

@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
using Xamarin.PropertyEditing.Common;
namespace Xamarin.PropertyEditing.Windows
{
[ValueConversion (typeof (Date), typeof (string))]
internal class DateToTextConverter : MarkupExtension, IValueConverter
{
public object Convert (object value, Type targetType, object parameter, CultureInfo culture)
=> !(value is Date dateValue) ? DependencyProperty.UnsetValue
: dateValue.ToString ();
public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string dateValue) {
var parsedValue = Date.Parse (dateValue);
if (parsedValue != null)
return parsedValue;
else
return value;
} else {
return DependencyProperty.UnsetValue;
}
}
public override object ProvideValue (IServiceProvider serviceProvider) => this;
}
}

Просмотреть файл

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using Xamarin.PropertyEditing.Common;
using Xamarin.PropertyEditing.Drawing;
using Xamarin.PropertyEditing.ViewModels;
@ -113,7 +114,11 @@ namespace Xamarin.PropertyEditing.Windows
{ typeof(TypePropertyViewModel), typeof(TypeEditorControl) },
{ typeof(CollectionPropertyViewModel), typeof(CollectionEditor) },
{ typeof(RatioViewModel), typeof(RatioEditorControl) },
{ typeof(AutoResizingPropertyViewModel), typeof(AutoResizingMaskEditorControl) }
{ typeof(AutoResizingPropertyViewModel), typeof(AutoResizingMaskEditorControl) },
{ typeof(PropertyViewModel<char>), typeof(StringEditorControl) },
{ typeof(PropertyViewModel<FilePath>), typeof(StringEditorControl) },
{ typeof(PropertyViewModel<Date>), typeof(DateEditorControl) },
{ typeof(PropertyViewModel<Time>), typeof(TimeEditorControl) },
};
}
}

Просмотреть файл

@ -49,6 +49,8 @@
<local:NegativeThicknessConverter x:Key="NegativeThicknessConverter" />
<local:GroupedEditorPropertySelector x:Key="GroupedEditorSelector" />
<local:MultiplierConverter x:Key="MultiplierConverter" />
<local:DateToTextConverter x:Key="DateToTextConverter" />
<local:TimeToTextConverter x:Key="TimeToTextConverter" />
<Style TargetType="local:CombinablePredefinedValuesEditor">
<Setter Property="Template">
@ -301,6 +303,38 @@
</Setter>
</Style>
<Style TargetType="local:DateEditorControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:DateEditorControl">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<local:TextBoxEx x:Name="TextBox" Grid.Column="0" FocusSelectsAll="True" AutomationProperties.Name="{Binding Property.Name,Mode=OneTime}" Text="{Binding Value,UpdateSourceTrigger=Explicit,Converter={StaticResource DateToTextConverter}}" VerticalContentAlignment="Center" IsEnabled="{Binding IsInputEnabled}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="local:TimeEditorControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:TimeEditorControl">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<local:TextBoxEx x:Name="TextBox" Grid.Column="0" FocusSelectsAll="True" AutomationProperties.Name="{Binding Property.Name,Mode=OneTime}" Text="{Binding Value,UpdateSourceTrigger=Explicit,Converter={StaticResource TimeToTextConverter}}" VerticalContentAlignment="Center" IsEnabled="{Binding IsInputEnabled}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="local:BoolEditorControl">
<Setter Property="Template">
<Setter.Value>

Просмотреть файл

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Xamarin.PropertyEditing.Windows
{
class TimeEditorControl : PropertyEditorControl
{
}
}

Просмотреть файл

@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
using Xamarin.PropertyEditing.Common;
namespace Xamarin.PropertyEditing.Windows
{
[ValueConversion (typeof (Time), typeof (string))]
internal class TimeToTextConverter : MarkupExtension, IValueConverter
{
public object Convert (object value, Type targetType, object parameter, CultureInfo culture)
=> !(value is Time timeValue) ? DependencyProperty.UnsetValue
: timeValue.ToString ();
public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string dateValue) {
var parsedValue = Time.Parse (dateValue);
if (parsedValue != null)
return parsedValue;
else
return value;
} else {
return DependencyProperty.UnsetValue;
}
}
public override object ProvideValue (IServiceProvider serviceProvider) => this;
}
}

Просмотреть файл

@ -1,223 +1,227 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" 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>{60AF04BE-1B6B-411B-BCBA-C95EAFBD7AC0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xamarin.PropertyEditing.Windows</RootNamespace>
<AssemblyName>Xamarin.PropertyEditing.Windows</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="PresentationFramework.Aero" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Presentation" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Xamarin.PropertyEditing\Properties\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="ArrangeModeLocalizedConverter.cs" />
<Compile Include="AutoResizingMaskEditorControl.cs" />
<Compile Include="BoolEditorControl.cs" />
<Compile Include="BoolsToVisibilityConverter.cs" />
<Compile Include="BrushBoxControl.cs" />
<Compile Include="BrushChoiceTemplateSelector.cs" />
<Compile Include="BrushEditorControl.cs" />
<Compile Include="BrushTabbedEditorControl.cs" />
<Compile Include="BrushToDarknessConverter.cs" />
<Compile Include="ButtonEx.cs" />
<Compile Include="ByteToDoubleConverter.cs" />
<Compile Include="CategoryExpander.cs" />
<Compile Include="CollectionEditor.cs" />
<Compile Include="CollectionEditorWindow.xaml.cs">
<DependentUpon>CollectionEditorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="CombinablePredefinedValuesEditorControl.cs" />
<Compile Include="ComboBoxEx.cs" />
<Compile Include="CommonBrushToBrushConverter.cs" />
<Compile Include="ByteToPercentageConverter.cs" />
<Compile Include="ChoiceControl.cs" />
<Compile Include="ColorComponentBox.cs" />
<Compile Include="ColorComponentModel.cs" />
<Compile Include="ColorComponentsEditorControl.cs" />
<Compile Include="ColorComponentToBrushConverter.cs" />
<Compile Include="ColorEditorControlBase.cs" />
<Compile Include="ColorHelper.cs" />
<Compile Include="CommonColorToColorConverter.cs" />
<Compile Include="CreateBindingWindow.xaml.cs">
<DependentUpon>CreateBindingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="CreateResourceWindow.xaml.cs">
<DependentUpon>CreateResourceWindow.xaml</DependentUpon>
</Compile>
<Compile Include="CreateVariantWindow.xaml.cs">
<DependentUpon>CreateVariantWindow.xaml</DependentUpon>
</Compile>
<Compile Include="DoubleToAngleConverter.cs" />
<Compile Include="CreateValueConverterWindow.xaml.cs">
<DependentUpon>CreateValueConverterWindow.xaml</DependentUpon>
</Compile>
<Compile Include="EntryPopup.cs" />
<Compile Include="CurrentColorEditorControl.cs" />
<Compile Include="DoubleToPercentageConverter.cs" />
<Compile Include="DoubleToQuantityConverter.cs" />
<Compile Include="FilterExpander.cs" />
<Compile Include="HasItemsToVisibilityConverter.cs" />
<Compile Include="InvertedVisibilityConverter.cs" />
<Compile Include="InvokePropertyButtonCommand.cs" />
<Compile Include="IPropertiesHost.cs" />
<Compile Include="MaterialDesignColorEditorControl.cs" />
<Compile Include="MultiplierConverter.cs" />
<Compile Include="MultiplyMarginConverter.cs" />
<Compile Include="NegativeThicknessConverter.cs" />
<Compile Include="NullVisibilityConverter.cs" />
<Compile Include="ObjectEditorControl.cs" />
<Compile Include="PreviewTemplateSelector.cs" />
<Compile Include="ResourceBrushEditorControl.cs" />
<Compile Include="ResourceSelectorWindow.xaml.cs">
<DependentUpon>ResourceSelectorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Spinner.cs" />
<Compile Include="TextBoxEx.cs" />
<Compile Include="ToggleButtonEx.cs" />
<Compile Include="EditorPropertySelector.cs" />
<Compile Include="EnumEditorControl.cs" />
<Compile Include="HexColorConverter.cs" />
<Compile Include="HeaderedContextMenu.cs" />
<Compile Include="GroupEditorControl.cs" />
<Compile Include="HostEnvironment.cs" />
<Compile Include="MenuButton.cs" />
<Compile Include="NumericEditorControl.cs" />
<Compile Include="NumericTemplateSelector.cs" />
<Compile Include="NumericUpDownControl.cs" />
<Compile Include="OppositeBoolConverter.cs" />
<Compile Include="PointEditorControl.cs" />
<Compile Include="PointHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyButton.cs" />
<Compile Include="PropertyEditorControl.cs" />
<Compile Include="PropertyEditorPanel.cs" />
<Compile Include="PropertyMenuItemContainerStyleSelector.cs" />
<Compile Include="PropertyPresenter.cs" />
<Compile Include="ShadeEditorControl.cs" />
<Compile Include="RatioEditorControl.cs" />
<Compile Include="SizeEditorControl.cs" />
<Compile Include="HueEditorControl.cs" />
<Compile Include="SolidBrushEditorControl.cs" />
<Compile Include="ThicknessEditorControl.cs" />
<Compile Include="StringEditorControl.cs" />
<Compile Include="TreeViewItemEx.cs" />
<Compile Include="TypeEditorControl.cs" />
<Compile Include="TypeSelectorControl.xaml.cs">
<DependentUpon>TypeSelectorControl.xaml</DependentUpon>
</Compile>
<Compile Include="TypeSelectorWindow.xaml.cs">
<DependentUpon>TypeSelectorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="WindowEx.cs" />
<Compile Include="XamlHelper.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="CollectionEditorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CreateBindingWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CreateResourceWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CreateValueConverterWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CreateVariantWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ResourceSelectorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\DialogResources.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Resources.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\PropertyEditorPanelStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\VS.Dark.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\VS.Light.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TypeSelectorControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TypeSelectorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj">
<Project>{A0B6FE73-D046-4E1C-BA9D-F20683889C5A}</Project>
<Name>Xamarin.PropertyEditing</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Themes\MenuButtonStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" 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>{60AF04BE-1B6B-411B-BCBA-C95EAFBD7AC0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xamarin.PropertyEditing.Windows</RootNamespace>
<AssemblyName>Xamarin.PropertyEditing.Windows</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="PresentationFramework.Aero" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Presentation" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Xamarin.PropertyEditing\Properties\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="ArrangeModeLocalizedConverter.cs" />
<Compile Include="AutoResizingMaskEditorControl.cs" />
<Compile Include="BoolEditorControl.cs" />
<Compile Include="BoolsToVisibilityConverter.cs" />
<Compile Include="BrushBoxControl.cs" />
<Compile Include="BrushChoiceTemplateSelector.cs" />
<Compile Include="BrushEditorControl.cs" />
<Compile Include="BrushTabbedEditorControl.cs" />
<Compile Include="BrushToDarknessConverter.cs" />
<Compile Include="ButtonEx.cs" />
<Compile Include="ByteToDoubleConverter.cs" />
<Compile Include="CategoryExpander.cs" />
<Compile Include="CollectionEditor.cs" />
<Compile Include="CollectionEditorWindow.xaml.cs">
<DependentUpon>CollectionEditorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="CombinablePredefinedValuesEditorControl.cs" />
<Compile Include="ComboBoxEx.cs" />
<Compile Include="CommonBrushToBrushConverter.cs" />
<Compile Include="ByteToPercentageConverter.cs" />
<Compile Include="ChoiceControl.cs" />
<Compile Include="ColorComponentBox.cs" />
<Compile Include="ColorComponentModel.cs" />
<Compile Include="ColorComponentsEditorControl.cs" />
<Compile Include="ColorComponentToBrushConverter.cs" />
<Compile Include="ColorEditorControlBase.cs" />
<Compile Include="ColorHelper.cs" />
<Compile Include="CommonColorToColorConverter.cs" />
<Compile Include="CreateBindingWindow.xaml.cs">
<DependentUpon>CreateBindingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="CreateResourceWindow.xaml.cs">
<DependentUpon>CreateResourceWindow.xaml</DependentUpon>
</Compile>
<Compile Include="CreateVariantWindow.xaml.cs">
<DependentUpon>CreateVariantWindow.xaml</DependentUpon>
</Compile>
<Compile Include="DateEditorControl.cs" />
<Compile Include="DateToTextConverter.cs" />
<Compile Include="DoubleToAngleConverter.cs" />
<Compile Include="CreateValueConverterWindow.xaml.cs">
<DependentUpon>CreateValueConverterWindow.xaml</DependentUpon>
</Compile>
<Compile Include="EntryPopup.cs" />
<Compile Include="CurrentColorEditorControl.cs" />
<Compile Include="DoubleToPercentageConverter.cs" />
<Compile Include="DoubleToQuantityConverter.cs" />
<Compile Include="FilterExpander.cs" />
<Compile Include="HasItemsToVisibilityConverter.cs" />
<Compile Include="InvertedVisibilityConverter.cs" />
<Compile Include="InvokePropertyButtonCommand.cs" />
<Compile Include="IPropertiesHost.cs" />
<Compile Include="MaterialDesignColorEditorControl.cs" />
<Compile Include="MultiplierConverter.cs" />
<Compile Include="MultiplyMarginConverter.cs" />
<Compile Include="NegativeThicknessConverter.cs" />
<Compile Include="NullVisibilityConverter.cs" />
<Compile Include="ObjectEditorControl.cs" />
<Compile Include="PreviewTemplateSelector.cs" />
<Compile Include="ResourceBrushEditorControl.cs" />
<Compile Include="ResourceSelectorWindow.xaml.cs">
<DependentUpon>ResourceSelectorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Spinner.cs" />
<Compile Include="TextBoxEx.cs" />
<Compile Include="TimeEditorControl.cs" />
<Compile Include="TimeToTextConverter.cs" />
<Compile Include="ToggleButtonEx.cs" />
<Compile Include="EditorPropertySelector.cs" />
<Compile Include="EnumEditorControl.cs" />
<Compile Include="HexColorConverter.cs" />
<Compile Include="HeaderedContextMenu.cs" />
<Compile Include="GroupEditorControl.cs" />
<Compile Include="HostEnvironment.cs" />
<Compile Include="MenuButton.cs" />
<Compile Include="NumericEditorControl.cs" />
<Compile Include="NumericTemplateSelector.cs" />
<Compile Include="NumericUpDownControl.cs" />
<Compile Include="OppositeBoolConverter.cs" />
<Compile Include="PointEditorControl.cs" />
<Compile Include="PointHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyButton.cs" />
<Compile Include="PropertyEditorControl.cs" />
<Compile Include="PropertyEditorPanel.cs" />
<Compile Include="PropertyMenuItemContainerStyleSelector.cs" />
<Compile Include="PropertyPresenter.cs" />
<Compile Include="ShadeEditorControl.cs" />
<Compile Include="RatioEditorControl.cs" />
<Compile Include="SizeEditorControl.cs" />
<Compile Include="HueEditorControl.cs" />
<Compile Include="SolidBrushEditorControl.cs" />
<Compile Include="ThicknessEditorControl.cs" />
<Compile Include="StringEditorControl.cs" />
<Compile Include="TreeViewItemEx.cs" />
<Compile Include="TypeEditorControl.cs" />
<Compile Include="TypeSelectorControl.xaml.cs">
<DependentUpon>TypeSelectorControl.xaml</DependentUpon>
</Compile>
<Compile Include="TypeSelectorWindow.xaml.cs">
<DependentUpon>TypeSelectorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="WindowEx.cs" />
<Compile Include="XamlHelper.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="CollectionEditorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CreateBindingWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CreateResourceWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CreateValueConverterWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CreateVariantWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ResourceSelectorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\DialogResources.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Resources.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\PropertyEditorPanelStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\VS.Dark.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\VS.Light.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TypeSelectorControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TypeSelectorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj">
<Project>{A0B6FE73-D046-4E1C-BA9D-F20683889C5A}</Project>
<Name>Xamarin.PropertyEditing</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Themes\MenuButtonStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,60 @@
using System;
namespace Xamarin.PropertyEditing.Common
{
public class Date : IEquatable<Date>
{
private readonly DateTime dateTime;
public Date (DateTime dateTime)
{
this.dateTime = dateTime;
}
public DateTime DateTime {
get{
return this.dateTime;
}
}
public override bool Equals (object obj)
{
if (obj == null)
return false;
if ((obj is Date d))
return Equals (d);
else
return false;
}
public bool Equals (Date other)
{
if (other == null)
return false;
return this.dateTime.Equals (other);
}
public override int GetHashCode ()
{
var hashCode = 1861433795;
unchecked {
hashCode = hashCode * -1521134295 + this.dateTime.GetHashCode ();
}
return hashCode;
}
public override string ToString ()
{
return this.dateTime.ToShortDateString ();
}
public static Date Parse (string value)
{
try {
return new Date (DateTime.Parse (value));
} catch (Exception) {
return null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,59 @@
using System;
namespace Xamarin.PropertyEditing.Common
{
public class Time : IEquatable<Time>
{
private readonly DateTime dateTime;
public DateTime DateTime {
get {
return this.dateTime;
}
}
public Time (DateTime dateTime)
{
this.dateTime = dateTime;
}
public override bool Equals (object obj)
{
if (obj == null)
return false;
if ((obj is Time d))
return Equals (d);
else
return false;
}
public bool Equals (Time other)
{
if (other == null)
return false;
return this.dateTime.Equals (other.DateTime);
}
public override int GetHashCode ()
{
var hashCode = 1861433795;
unchecked {
hashCode = hashCode * -1521134295 + this.dateTime.GetHashCode ();
}
return hashCode;
}
public override string ToString ()
{
return this.dateTime.ToLongTimeString ();
}
public static Time Parse(string value)
{
try {
return new Time (DateTime.Parse (value));
} catch (Exception) {
return null;
}
}
}
}

Просмотреть файл

@ -656,6 +656,8 @@ namespace Xamarin.PropertyEditing.ViewModels
{ typeof(ITypeInfo), (tp,p,e,v) => new TypePropertyViewModel (tp, p, e, v) },
{ typeof(CommonRatio), (tp, p, e, v) => new RatioViewModel (tp, p, e, v) },
{ typeof(AutoResizingFlags), (tp, p, e, v) => new AutoResizingPropertyViewModel (tp, p, e, v) },
{ typeof(Date), (tp, p, e, v) => new PropertyViewModel<Date> (tp, p, e, v) },
{ typeof(Time), (tp, p, e, v) => new PropertyViewModel<Time> (tp, p, e, v) },
};
}
}