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 System;
using AppKit;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac namespace Xamarin.PropertyEditing.Mac
{ {
internal class DateTimeEditorControl : PropertyEditorControl<PropertyViewModel<DateTime>> internal class DateTimeEditorControl : BaseDateTimeEditorControl<DateTime>
{ {
private readonly NSDatePicker datePicker;
public DateTimeEditorControl (IHostResourceProvider hostResources) public DateTimeEditorControl (IHostResourceProvider hostResources)
: base (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; protected override void Editor_Activated (object sender, EventArgs e)
public override NSView LastKeyView => this.datePicker; {
ViewModel.Value = DatePicker.DateValue.ToDateTime ();
}
protected override void UpdateValue () protected override void UpdateValue ()
{ {
this.datePicker.DateValue = ViewModel.Value.ToNSDate (); 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);
} }
} }
} }

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

@ -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 (ObjectPropertyViewModel), typeof (ObjectEditorControl)},
{typeof (TypePropertyViewModel), typeof (TypeEditorControl)}, {typeof (TypePropertyViewModel), typeof (TypeEditorControl)},
{typeof (CollectionPropertyViewModel), typeof (CollectionInlineEditorControl)}, {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); AddProperty<FilePath> ("FilePath", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding);
AddReadOnlyProperty<FilePath> ("ReadOnlyFilePath", ReadOnly); AddReadOnlyProperty<FilePath> ("ReadOnlyFilePath", ReadOnly);
AddProperty<DateTime> ("DateTime", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding); 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"); AddEvents ("Click", "Hover", "Focus");
@ -140,6 +144,9 @@ namespace Xamarin.PropertyEditing.Tests.MockControls
public async Task SetInitialValuesAsync (IObjectEditor editor) public async Task SetInitialValuesAsync (IObjectEditor editor)
{ {
await editor.SetValueAsync (Properties["FilePath"], new ValueInfo<FilePath> { Value = new FilePath ("/Desktop/MyTestFile") }); 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) public async Task SetBrushInitialValueAsync (IObjectEditor editor, CommonBrush brush)

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

@ -64,6 +64,7 @@ namespace Xamarin.PropertyEditing.Windows.Standalone
inspectedObject = mockedControl.MockedControl; inspectedObject = mockedControl.MockedControl;
if (mockedControl is MockedSampleControlButton mockedButton) { if (mockedControl is MockedSampleControlButton mockedButton) {
IObjectEditor editor = await this.panel.TargetPlatform.EditorProvider.GetObjectEditorAsync (inspectedObject); 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.SetBrushInitialValueAsync (editor, new CommonSolidBrush (20, 120, 220, 240, "sRGB"));
await mockedButton.MockedControl.SetMaterialDesignBrushInitialValueAsync (editor, new CommonSolidBrush (0x65, 0x1F, 0xFF, 200)); await mockedButton.MockedControl.SetMaterialDesignBrushInitialValueAsync (editor, new CommonSolidBrush (0x65, 0x1F, 0xFF, 200));
await mockedButton.MockedControl.SetReadOnlyBrushInitialValueAsync (editor, new CommonSolidBrush (240, 220, 15, 190)); 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.Collections.Generic;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Xamarin.PropertyEditing.Common;
using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.Drawing;
using Xamarin.PropertyEditing.ViewModels; using Xamarin.PropertyEditing.ViewModels;
@ -113,7 +114,11 @@ namespace Xamarin.PropertyEditing.Windows
{ typeof(TypePropertyViewModel), typeof(TypeEditorControl) }, { typeof(TypePropertyViewModel), typeof(TypeEditorControl) },
{ typeof(CollectionPropertyViewModel), typeof(CollectionEditor) }, { typeof(CollectionPropertyViewModel), typeof(CollectionEditor) },
{ typeof(RatioViewModel), typeof(RatioEditorControl) }, { 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:NegativeThicknessConverter x:Key="NegativeThicknessConverter" />
<local:GroupedEditorPropertySelector x:Key="GroupedEditorSelector" /> <local:GroupedEditorPropertySelector x:Key="GroupedEditorSelector" />
<local:MultiplierConverter x:Key="MultiplierConverter" /> <local:MultiplierConverter x:Key="MultiplierConverter" />
<local:DateToTextConverter x:Key="DateToTextConverter" />
<local:TimeToTextConverter x:Key="TimeToTextConverter" />
<Style TargetType="local:CombinablePredefinedValuesEditor"> <Style TargetType="local:CombinablePredefinedValuesEditor">
<Setter Property="Template"> <Setter Property="Template">
@ -301,6 +303,38 @@
</Setter> </Setter>
</Style> </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"> <Style TargetType="local:BoolEditorControl">
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <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"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <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')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{60AF04BE-1B6B-411B-BCBA-C95EAFBD7AC0}</ProjectGuid> <ProjectGuid>{60AF04BE-1B6B-411B-BCBA-C95EAFBD7AC0}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xamarin.PropertyEditing.Windows</RootNamespace> <RootNamespace>Xamarin.PropertyEditing.Windows</RootNamespace>
<AssemblyName>Xamarin.PropertyEditing.Windows</AssemblyName> <AssemblyName>Xamarin.PropertyEditing.Windows</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="PresentationFramework.Aero" /> <Reference Include="PresentationFramework.Aero" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Presentation" /> <Reference Include="System.Windows.Presentation" />
<Reference Include="System.Xaml" /> <Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" /> <Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Xamarin.PropertyEditing\Properties\GlobalAssemblyInfo.cs"> <Compile Include="..\Xamarin.PropertyEditing\Properties\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link> <Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="ArrangeModeLocalizedConverter.cs" /> <Compile Include="ArrangeModeLocalizedConverter.cs" />
<Compile Include="AutoResizingMaskEditorControl.cs" /> <Compile Include="AutoResizingMaskEditorControl.cs" />
<Compile Include="BoolEditorControl.cs" /> <Compile Include="BoolEditorControl.cs" />
<Compile Include="BoolsToVisibilityConverter.cs" /> <Compile Include="BoolsToVisibilityConverter.cs" />
<Compile Include="BrushBoxControl.cs" /> <Compile Include="BrushBoxControl.cs" />
<Compile Include="BrushChoiceTemplateSelector.cs" /> <Compile Include="BrushChoiceTemplateSelector.cs" />
<Compile Include="BrushEditorControl.cs" /> <Compile Include="BrushEditorControl.cs" />
<Compile Include="BrushTabbedEditorControl.cs" /> <Compile Include="BrushTabbedEditorControl.cs" />
<Compile Include="BrushToDarknessConverter.cs" /> <Compile Include="BrushToDarknessConverter.cs" />
<Compile Include="ButtonEx.cs" /> <Compile Include="ButtonEx.cs" />
<Compile Include="ByteToDoubleConverter.cs" /> <Compile Include="ByteToDoubleConverter.cs" />
<Compile Include="CategoryExpander.cs" /> <Compile Include="CategoryExpander.cs" />
<Compile Include="CollectionEditor.cs" /> <Compile Include="CollectionEditor.cs" />
<Compile Include="CollectionEditorWindow.xaml.cs"> <Compile Include="CollectionEditorWindow.xaml.cs">
<DependentUpon>CollectionEditorWindow.xaml</DependentUpon> <DependentUpon>CollectionEditorWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="CombinablePredefinedValuesEditorControl.cs" /> <Compile Include="CombinablePredefinedValuesEditorControl.cs" />
<Compile Include="ComboBoxEx.cs" /> <Compile Include="ComboBoxEx.cs" />
<Compile Include="CommonBrushToBrushConverter.cs" /> <Compile Include="CommonBrushToBrushConverter.cs" />
<Compile Include="ByteToPercentageConverter.cs" /> <Compile Include="ByteToPercentageConverter.cs" />
<Compile Include="ChoiceControl.cs" /> <Compile Include="ChoiceControl.cs" />
<Compile Include="ColorComponentBox.cs" /> <Compile Include="ColorComponentBox.cs" />
<Compile Include="ColorComponentModel.cs" /> <Compile Include="ColorComponentModel.cs" />
<Compile Include="ColorComponentsEditorControl.cs" /> <Compile Include="ColorComponentsEditorControl.cs" />
<Compile Include="ColorComponentToBrushConverter.cs" /> <Compile Include="ColorComponentToBrushConverter.cs" />
<Compile Include="ColorEditorControlBase.cs" /> <Compile Include="ColorEditorControlBase.cs" />
<Compile Include="ColorHelper.cs" /> <Compile Include="ColorHelper.cs" />
<Compile Include="CommonColorToColorConverter.cs" /> <Compile Include="CommonColorToColorConverter.cs" />
<Compile Include="CreateBindingWindow.xaml.cs"> <Compile Include="CreateBindingWindow.xaml.cs">
<DependentUpon>CreateBindingWindow.xaml</DependentUpon> <DependentUpon>CreateBindingWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="CreateResourceWindow.xaml.cs"> <Compile Include="CreateResourceWindow.xaml.cs">
<DependentUpon>CreateResourceWindow.xaml</DependentUpon> <DependentUpon>CreateResourceWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="CreateVariantWindow.xaml.cs"> <Compile Include="CreateVariantWindow.xaml.cs">
<DependentUpon>CreateVariantWindow.xaml</DependentUpon> <DependentUpon>CreateVariantWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="DoubleToAngleConverter.cs" /> <Compile Include="DateEditorControl.cs" />
<Compile Include="CreateValueConverterWindow.xaml.cs"> <Compile Include="DateToTextConverter.cs" />
<DependentUpon>CreateValueConverterWindow.xaml</DependentUpon> <Compile Include="DoubleToAngleConverter.cs" />
</Compile> <Compile Include="CreateValueConverterWindow.xaml.cs">
<Compile Include="EntryPopup.cs" /> <DependentUpon>CreateValueConverterWindow.xaml</DependentUpon>
<Compile Include="CurrentColorEditorControl.cs" /> </Compile>
<Compile Include="DoubleToPercentageConverter.cs" /> <Compile Include="EntryPopup.cs" />
<Compile Include="DoubleToQuantityConverter.cs" /> <Compile Include="CurrentColorEditorControl.cs" />
<Compile Include="FilterExpander.cs" /> <Compile Include="DoubleToPercentageConverter.cs" />
<Compile Include="HasItemsToVisibilityConverter.cs" /> <Compile Include="DoubleToQuantityConverter.cs" />
<Compile Include="InvertedVisibilityConverter.cs" /> <Compile Include="FilterExpander.cs" />
<Compile Include="InvokePropertyButtonCommand.cs" /> <Compile Include="HasItemsToVisibilityConverter.cs" />
<Compile Include="IPropertiesHost.cs" /> <Compile Include="InvertedVisibilityConverter.cs" />
<Compile Include="MaterialDesignColorEditorControl.cs" /> <Compile Include="InvokePropertyButtonCommand.cs" />
<Compile Include="MultiplierConverter.cs" /> <Compile Include="IPropertiesHost.cs" />
<Compile Include="MultiplyMarginConverter.cs" /> <Compile Include="MaterialDesignColorEditorControl.cs" />
<Compile Include="NegativeThicknessConverter.cs" /> <Compile Include="MultiplierConverter.cs" />
<Compile Include="NullVisibilityConverter.cs" /> <Compile Include="MultiplyMarginConverter.cs" />
<Compile Include="ObjectEditorControl.cs" /> <Compile Include="NegativeThicknessConverter.cs" />
<Compile Include="PreviewTemplateSelector.cs" /> <Compile Include="NullVisibilityConverter.cs" />
<Compile Include="ResourceBrushEditorControl.cs" /> <Compile Include="ObjectEditorControl.cs" />
<Compile Include="ResourceSelectorWindow.xaml.cs"> <Compile Include="PreviewTemplateSelector.cs" />
<DependentUpon>ResourceSelectorWindow.xaml</DependentUpon> <Compile Include="ResourceBrushEditorControl.cs" />
</Compile> <Compile Include="ResourceSelectorWindow.xaml.cs">
<Compile Include="Spinner.cs" /> <DependentUpon>ResourceSelectorWindow.xaml</DependentUpon>
<Compile Include="TextBoxEx.cs" /> </Compile>
<Compile Include="ToggleButtonEx.cs" /> <Compile Include="Spinner.cs" />
<Compile Include="EditorPropertySelector.cs" /> <Compile Include="TextBoxEx.cs" />
<Compile Include="EnumEditorControl.cs" /> <Compile Include="TimeEditorControl.cs" />
<Compile Include="HexColorConverter.cs" /> <Compile Include="TimeToTextConverter.cs" />
<Compile Include="HeaderedContextMenu.cs" /> <Compile Include="ToggleButtonEx.cs" />
<Compile Include="GroupEditorControl.cs" /> <Compile Include="EditorPropertySelector.cs" />
<Compile Include="HostEnvironment.cs" /> <Compile Include="EnumEditorControl.cs" />
<Compile Include="MenuButton.cs" /> <Compile Include="HexColorConverter.cs" />
<Compile Include="NumericEditorControl.cs" /> <Compile Include="HeaderedContextMenu.cs" />
<Compile Include="NumericTemplateSelector.cs" /> <Compile Include="GroupEditorControl.cs" />
<Compile Include="NumericUpDownControl.cs" /> <Compile Include="HostEnvironment.cs" />
<Compile Include="OppositeBoolConverter.cs" /> <Compile Include="MenuButton.cs" />
<Compile Include="PointEditorControl.cs" /> <Compile Include="NumericEditorControl.cs" />
<Compile Include="PointHelper.cs" /> <Compile Include="NumericTemplateSelector.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="NumericUpDownControl.cs" />
<Compile Include="PropertyButton.cs" /> <Compile Include="OppositeBoolConverter.cs" />
<Compile Include="PropertyEditorControl.cs" /> <Compile Include="PointEditorControl.cs" />
<Compile Include="PropertyEditorPanel.cs" /> <Compile Include="PointHelper.cs" />
<Compile Include="PropertyMenuItemContainerStyleSelector.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyPresenter.cs" /> <Compile Include="PropertyButton.cs" />
<Compile Include="ShadeEditorControl.cs" /> <Compile Include="PropertyEditorControl.cs" />
<Compile Include="RatioEditorControl.cs" /> <Compile Include="PropertyEditorPanel.cs" />
<Compile Include="SizeEditorControl.cs" /> <Compile Include="PropertyMenuItemContainerStyleSelector.cs" />
<Compile Include="HueEditorControl.cs" /> <Compile Include="PropertyPresenter.cs" />
<Compile Include="SolidBrushEditorControl.cs" /> <Compile Include="ShadeEditorControl.cs" />
<Compile Include="ThicknessEditorControl.cs" /> <Compile Include="RatioEditorControl.cs" />
<Compile Include="StringEditorControl.cs" /> <Compile Include="SizeEditorControl.cs" />
<Compile Include="TreeViewItemEx.cs" /> <Compile Include="HueEditorControl.cs" />
<Compile Include="TypeEditorControl.cs" /> <Compile Include="SolidBrushEditorControl.cs" />
<Compile Include="TypeSelectorControl.xaml.cs"> <Compile Include="ThicknessEditorControl.cs" />
<DependentUpon>TypeSelectorControl.xaml</DependentUpon> <Compile Include="StringEditorControl.cs" />
</Compile> <Compile Include="TreeViewItemEx.cs" />
<Compile Include="TypeSelectorWindow.xaml.cs"> <Compile Include="TypeEditorControl.cs" />
<DependentUpon>TypeSelectorWindow.xaml</DependentUpon> <Compile Include="TypeSelectorControl.xaml.cs">
</Compile> <DependentUpon>TypeSelectorControl.xaml</DependentUpon>
<Compile Include="WindowEx.cs" /> </Compile>
<Compile Include="XamlHelper.cs" /> <Compile Include="TypeSelectorWindow.xaml.cs">
</ItemGroup> <DependentUpon>TypeSelectorWindow.xaml</DependentUpon>
<ItemGroup> </Compile>
<Page Include="CollectionEditorWindow.xaml"> <Compile Include="WindowEx.cs" />
<SubType>Designer</SubType> <Compile Include="XamlHelper.cs" />
<Generator>MSBuild:Compile</Generator> </ItemGroup>
</Page> <ItemGroup>
<Page Include="CreateBindingWindow.xaml"> <Page Include="CollectionEditorWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="CreateResourceWindow.xaml"> <Page Include="CreateBindingWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="CreateValueConverterWindow.xaml"> <Page Include="CreateResourceWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="CreateVariantWindow.xaml"> <Page Include="CreateValueConverterWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="ResourceSelectorWindow.xaml"> <Page Include="CreateVariantWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\DialogResources.xaml"> <Page Include="ResourceSelectorWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\Resources.xaml"> <Page Include="Themes\DialogResources.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\PropertyEditorPanelStyle.xaml"> <Page Include="Themes\Resources.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\VS.Dark.xaml"> <Page Include="Themes\PropertyEditorPanelStyle.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\VS.Light.xaml"> <Page Include="Themes\VS.Dark.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="TypeSelectorControl.xaml"> <Page Include="Themes\VS.Light.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="TypeSelectorWindow.xaml"> <Page Include="TypeSelectorControl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
</ItemGroup> <Page Include="TypeSelectorWindow.xaml">
<ItemGroup> <SubType>Designer</SubType>
<ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj"> <Generator>MSBuild:Compile</Generator>
<Project>{A0B6FE73-D046-4E1C-BA9D-F20683889C5A}</Project> </Page>
<Name>Xamarin.PropertyEditing</Name> </ItemGroup>
</ProjectReference> <ItemGroup>
</ItemGroup> <ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj">
<ItemGroup> <Project>{A0B6FE73-D046-4E1C-BA9D-F20683889C5A}</Project>
<Page Include="Themes\MenuButtonStyle.xaml"> <Name>Xamarin.PropertyEditing</Name>
<SubType>Designer</SubType> </ProjectReference>
<Generator>MSBuild:Compile</Generator> </ItemGroup>
</Page> <ItemGroup>
</ItemGroup> <Page Include="Themes\MenuButtonStyle.xaml">
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <SubType>Designer</SubType>
</Project> <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(ITypeInfo), (tp,p,e,v) => new TypePropertyViewModel (tp, p, e, v) },
{ typeof(CommonRatio), (tp, p, e, v) => new RatioViewModel (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(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) },
}; };
} }
} }