This commit is contained in:
jkuehner 2016-04-09 11:20:05 +02:00
Родитель 240cd065a6
Коммит ccf1918046
3 изменённых файлов: 117 добавлений и 49 удалений

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

@ -1,4 +1,5 @@
using System.Windows;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@ -14,5 +15,17 @@ namespace SimpleSample
public static readonly DependencyProperty TestColorProperty =
DependencyProperty.Register("TestColor", typeof(Color), typeof(TestControl), new PropertyMetadata());
public TimeSpan TestTimeSpan
{
get { return (TimeSpan)GetValue(TestTimeSpanProperty); }
set { SetValue(TestTimeSpanProperty, value); }
}
// Using a DependencyProperty as the backing store for TestTimeSpan. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TestTimeSpanProperty =
DependencyProperty.Register("TestTimeSpan", typeof(TimeSpan), typeof(TestControl), new PropertyMetadata(new TimeSpan(4, 3, 55, 34, 345)));
}
}

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

@ -1,7 +1,19 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" />
<!--<xctk:TimeSpanUpDown x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.TimeSpanEditor"
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.TimeSpanEditor"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:widgets="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
Value="{Binding Value}">
</xctk:TimeSpanUpDown>-->
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<StackPanel Orientation="Horizontal" >
<widgets:NumericUpDown Value="{Binding Days}" />
<TextBlock Text="d" />
<widgets:NumericUpDown Value="{Binding Hours}" />
<TextBlock Text="h" />
<widgets:NumericUpDown Value="{Binding Minutes}" />
<TextBlock Text="m" />
<widgets:NumericUpDown Value="{Binding Seconds}" />
<TextBlock Text="s" />
<widgets:NumericUpDown Value="{Binding MiliSeconds}" />
<TextBlock Text="ms" />
</StackPanel>
</UserControl>

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

@ -1,45 +1,88 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//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;
//using ICSharpCode.WpfDesign.PropertyGrid;
//using ICSharpCode.WpfDesign.Designer.themes;
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows;
using ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.themes;
//namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
//{
// [TypeEditor(typeof(TimeSpan))]
// public partial class TimeSpanEditor
// {
// public TimeSpanEditor()
// {
// SpecialInitializeComponent();
// }
// /// <summary>
// /// Fixes InitializeComponent with multiple Versions of same Assembly loaded
// /// </summary>
// public void SpecialInitializeComponent()
// {
// if (!this._contentLoaded) {
// this._contentLoaded = true;
// Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
// Application.LoadComponent(this, resourceLocator);
// }
// this.InitializeComponent();
// }
// }
//}
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
[TypeEditor(typeof(TimeSpan))]
public partial class TimeSpanEditor
{
public TimeSpanEditor()
{
SpecialInitializeComponent();
}
/// <summary>
/// Fixes InitializeComponent with multiple Versions of same Assembly loaded
/// </summary>
public void SpecialInitializeComponent()
{
if (!this._contentLoaded)
{
this._contentLoaded = true;
Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
Application.LoadComponent(this, resourceLocator);
}
this.InitializeComponent();
}
public int Days
{
get { return (int)GetValue(DaysProperty); }
set { SetValue(DaysProperty, value); }
}
// Using a DependencyProperty as the backing store for Days. This enables animation, styling, binding, etc...
public static readonly DependencyProperty DaysProperty =
DependencyProperty.Register("Days", typeof(int), typeof(TimeSpanEditor), new PropertyMetadata());
public int Hours
{
get { return (int)GetValue(HoursProperty); }
set { SetValue(HoursProperty, value); }
}
// Using a DependencyProperty as the backing store for Hours. This enables animation, styling, binding, etc...
public static readonly DependencyProperty HoursProperty =
DependencyProperty.Register("Hours", typeof(int), typeof(TimeSpanEditor), new PropertyMetadata());
public int Minutes
{
get { return (int)GetValue(MinutesProperty); }
set { SetValue(MinutesProperty, value); }
}
// Using a DependencyProperty as the backing store for Minutes. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MinutesProperty =
DependencyProperty.Register("Minutes", typeof(int), typeof(TimeSpanEditor), new PropertyMetadata());
public int Seconds
{
get { return (int)GetValue(SecondsProperty); }
set { SetValue(SecondsProperty, value); }
}
// Using a DependencyProperty as the backing store for Seconds. This enables animation, styling, binding, etc...
public static readonly DependencyProperty SecondsProperty =
DependencyProperty.Register("Seconds", typeof(int), typeof(TimeSpanEditor), new PropertyMetadata());
public int MiliSeconds
{
get { return (int)GetValue(MiliSecondsProperty); }
set { SetValue(MiliSecondsProperty, value); }
}
// Using a DependencyProperty as the backing store for MiliSeconds. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MiliSecondsProperty =
DependencyProperty.Register("MiliSeconds", typeof(int), typeof(TimeSpanEditor), new PropertyMetadata());
}
}