This commit is contained in:
NaBian committed 2020-07-14 23:09:13 +08:00
1 parent 25a6117ee1
commit d4e32272a2
19 files changed
+349 -148

No files matched your search

@@ -4,6 +4,6 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
<hc:TransitioningContentControl>
<hc:TimeBar BorderThickness="0" Margin="32" Width="600" VerticalAlignment="Center"/>
<hc:TimeBar Name="TimeBarDemo" BorderThickness="0" Margin="32" Width="600" VerticalAlignment="Center"/>
</hc:TransitioningContentControl>
</UserControl>
@@ -1,10 +1,20 @@
namespace HandyControlDemo.UserControl
using System;
using HandyControl.Data;
namespace HandyControlDemo.UserControl
{
public partial class TimeBarDemoCtl
{
public TimeBarDemoCtl()
{
InitializeComponent();
for (int i = 0; i < 10; i++)
{
var hour = 6 * i;
TimeBarDemo.Hotspots.Add(new DateTimeRange(DateTime.Today.AddHours(hour), DateTime.Today.AddHours(hour + 1)));
TimeBarDemo.Hotspots.Add(new DateTimeRange(DateTime.Today.AddHours(-hour), DateTime.Today.AddHours(-hour + 1)));
}
}
}
}
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using HandyControl.Data;
namespace HandyControl.Collections
{
public class DateTimeRangeComparer : IComparer<DateTimeRange>
{
public int Compare(DateTimeRange x, DateTimeRange y)
{
if (x.Start > y.Start && x.End > y.End) return 1;
if (x.Start < y.Start && x.End < y.End) return -1;
return 0;
}
}
}
@@ -131,33 +131,33 @@ namespace HandyControl.Controls
{
new ColorRange
{
Color1 = Color.FromRgb(255, 0, 0),
Color2 = Color.FromRgb(255, 0, 255)
Start = Color.FromRgb(255, 0, 0),
End = Color.FromRgb(255, 0, 255)
},
new ColorRange
{
Color1 = Color.FromRgb(255, 0, 255),
Color2 = Color.FromRgb(0, 0, 255)
Start = Color.FromRgb(255, 0, 255),
End = Color.FromRgb(0, 0, 255)
},
new ColorRange
{
Color1 = Color.FromRgb(0, 0, 255),
Color2 = Color.FromRgb(0, 255, 255)
Start = Color.FromRgb(0, 0, 255),
End = Color.FromRgb(0, 255, 255)
},
new ColorRange
{
Color1 = Color.FromRgb(0, 255, 255),
Color2 = Color.FromRgb(0, 255, 0)
Start = Color.FromRgb(0, 255, 255),
End = Color.FromRgb(0, 255, 0)
},
new ColorRange
{
Color1 = Color.FromRgb(0, 255, 0),
Color2 = Color.FromRgb(255, 255, 0)
Start = Color.FromRgb(0, 255, 0),
End = Color.FromRgb(255, 255, 0)
},
new ColorRange
{
Color1 = Color.FromRgb(255, 255, 0),
Color2 = Color.FromRgb(255, 0, 0)
Start = Color.FromRgb(255, 255, 0),
End = Color.FromRgb(255, 0, 0)
}
};
@@ -77,19 +77,19 @@ namespace HandyControl.Controls
private static void OnValueStartChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctrl = (TwoWayRangeBase)d;
ctrl.OnValueChanged(new TwoWayRange
ctrl.OnValueChanged(new DoubleRange
{
ValueStart = (double)e.OldValue,
ValueEnd = ctrl.ValueEnd
}, new TwoWayRange
Start = (double)e.OldValue,
End = ctrl.ValueEnd
}, new DoubleRange
{
ValueStart = (double)e.NewValue,
ValueEnd = ctrl.ValueEnd
Start = (double)e.NewValue,
End = ctrl.ValueEnd
});
}
protected virtual void OnValueChanged(TwoWayRange oldValue, TwoWayRange newValue) => RaiseEvent(
new RoutedPropertyChangedEventArgs<TwoWayRange>(oldValue, newValue) {RoutedEvent = ValueChangedEvent});
protected virtual void OnValueChanged(DoubleRange oldValue, DoubleRange newValue) => RaiseEvent(
new RoutedPropertyChangedEventArgs<DoubleRange>(oldValue, newValue) {RoutedEvent = ValueChangedEvent});
public double ValueStart
{
@@ -106,14 +106,14 @@ namespace HandyControl.Controls
private static void OnValueEndChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctrl = (TwoWayRangeBase)d;
ctrl.OnValueChanged(new TwoWayRange
ctrl.OnValueChanged(new DoubleRange
{
ValueStart = ctrl.ValueStart,
ValueEnd = (double)e.OldValue
}, new TwoWayRange
Start = ctrl.ValueStart,
End = (double)e.OldValue
}, new DoubleRange
{
ValueStart = ctrl.ValueStart,
ValueEnd = (double)e.NewValue
Start = ctrl.ValueStart,
End = (double)e.NewValue
});
}
@@ -163,19 +163,12 @@ namespace HandyControl.Controls
}
public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent("ValueChanged",
RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<TwoWayRange>), typeof(TwoWayRangeBase));
RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<DoubleRange>), typeof(TwoWayRangeBase));
public event RoutedPropertyChangedEventHandler<TwoWayRange> ValueChanged
public event RoutedPropertyChangedEventHandler<DoubleRange> ValueChanged
{
add => AddHandler(ValueChangedEvent, value);
remove => RemoveHandler(ValueChangedEvent, value);
}
}
public struct TwoWayRange
{
public double ValueStart { get; set; }
public double ValueEnd { get; set; }
}
}
@@ -1,11 +1,17 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using HandyControl.Data;
using HandyControl.Interactivity;
using HandyControl.Tools;
namespace HandyControl.Controls
@@ -17,6 +23,7 @@ namespace HandyControl.Controls
[TemplatePart(Name = ElementTextBlockMove, Type = typeof(TextBlock))]
[TemplatePart(Name = ElementTextBlockSelected, Type = typeof(TextBlock))]
[TemplatePart(Name = ElementCanvasSpe, Type = typeof(Canvas))]
[TemplatePart(Name = ElementHotspots, Type = typeof(Panel))]
public class TimeBar : Control
{
#region Constants
@@ -29,8 +36,10 @@ namespace HandyControl.Controls
private const string ElementCanvasSpe = "PART_CanvasSpe";
private const string ElementHotspots = "PART_Hotspots";
#endregion Constants
#region Data
private Border _borderTop;
@@ -41,14 +50,38 @@ namespace HandyControl.Controls
private Canvas _canvasSpe;
private Panel _panelHotspots;
#endregion Data
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Bindable(true)]
public Collection<DateTimeRange> Hotspots { get; }
public static readonly DependencyProperty HotspotsBrushProperty = DependencyProperty.Register(
"HotspotsBrush", typeof(Brush), typeof(TimeBar), new PropertyMetadata(default(Brush)));
public Brush HotspotsBrush
{
get => (Brush) GetValue(HotspotsBrushProperty);
set => SetValue(HotspotsBrushProperty, value);
}
/// <summary>
/// 是否显示刻度字符串
/// </summary>
public static readonly DependencyProperty ShowSpeStrProperty = DependencyProperty.Register(
"ShowSpeStr", typeof(bool), typeof(TimeBar), new PropertyMetadata(ValueBoxes.FalseBox));
/// <summary>
/// 是否显示刻度字符串
/// </summary>
public bool ShowSpeStr
{
get => (bool)GetValue(ShowSpeStrProperty);
set => SetValue(ShowSpeStrProperty, ValueBoxes.BooleanBox(value));
}
public static readonly DependencyProperty TimeFormatProperty = DependencyProperty.Register(
"TimeFormat", typeof(string), typeof(TimeBar), new PropertyMetadata("yyyy-MM-dd HH:mm:ss"));
@@ -64,6 +97,15 @@ namespace HandyControl.Controls
internal static readonly DependencyProperty SpeStrProperty = DependencyProperty.Register(
"SpeStr", typeof(string), typeof(TimeBar), new PropertyMetadata(Properties.Langs.Lang.Interval1h));
/// <summary>
/// 刻度字符串
/// </summary>
internal string SpeStr
{
get => (string)GetValue(SpeStrProperty);
set => SetValue(SpeStrProperty, value);
}
/// <summary>
/// 选中时间
/// </summary>
@@ -78,6 +120,15 @@ namespace HandyControl.Controls
}
}
/// <summary>
/// 选中时间
/// </summary>
public DateTime SelectedTime
{
get => (DateTime)GetValue(SelectedTimeProperty);
set => SetValue(SelectedTimeProperty, value);
}
private void OnSelectedTimeChanged(DateTime time)
{
_textBlockSelected.Text = time.ToString(TimeFormat);
@@ -162,12 +213,53 @@ namespace HandyControl.Controls
private readonly bool _isLoaded;
private readonly SortedSet<DateTimeRange> _dateTimeRanges;
public TimeBar()
{
_starTime = DateTime.Now;
SelectedTime = new DateTime(_starTime.Year, _starTime.Month, _starTime.Day, 0, 0, 0);
_starTime = SelectedTime;
_isLoaded = true;
var hotspots = new ObservableCollection<DateTimeRange>();
_dateTimeRanges = new SortedSet<DateTimeRange>(ComparerGenerator.GetComparer<DateTimeRange>());
hotspots.CollectionChanged += Items_CollectionChanged;
Hotspots = hotspots;
}
private void Items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (DateTimeRange item in e.NewItems)
{
_dateTimeRanges.Add(item);
}
}
else if(e.Action == NotifyCollectionChangedAction.Remove)
{
foreach (DateTimeRange item in e.OldItems)
{
_dateTimeRanges.Remove(item);
}
}
else if (e.Action == NotifyCollectionChangedAction.Replace)
{
foreach (DateTimeRange item in e.OldItems)
{
_dateTimeRanges.Remove(item);
}
foreach (DateTimeRange item in e.NewItems)
{
_dateTimeRanges.Add(item);
}
}
else if (e.Action == NotifyCollectionChangedAction.Reset)
{
_dateTimeRanges.Clear();
}
}
public override void OnApplyTemplate()
@@ -184,6 +276,7 @@ namespace HandyControl.Controls
_textBlockMove = GetTemplateChild(ElementTextBlockMove) as TextBlock;
_textBlockSelected = GetTemplateChild(ElementTextBlockSelected) as TextBlock;
_canvasSpe = GetTemplateChild(ElementCanvasSpe) as Canvas;
_panelHotspots = GetTemplateChild(ElementHotspots) as Panel;
CheckNull();
_borderTop.MouseLeftButtonDown += BorderTop_OnMouseLeftButtonDown;
@@ -210,33 +303,6 @@ namespace HandyControl.Controls
if (_borderTop == null || _textBlockMove == null|| _textBlockSelected == null || _canvasSpe == null) throw new Exception();
}
/// <summary>
/// 是否显示刻度字符串
/// </summary>
public bool ShowSpeStr
{
get => (bool)GetValue(ShowSpeStrProperty);
set => SetValue(ShowSpeStrProperty, ValueBoxes.BooleanBox(value));
}
/// <summary>
/// 刻度字符串
/// </summary>
internal string SpeStr
{
get => (string)GetValue(SpeStrProperty);
set => SetValue(SpeStrProperty, value);
}
/// <summary>
/// 选中时间
/// </summary>
public DateTime SelectedTime
{
get => (DateTime)GetValue(SelectedTimeProperty);
set => SetValue(SelectedTimeProperty, value);
}
/// <summary>
/// 刻度区间编号
/// </summary>
@@ -323,6 +389,11 @@ namespace HandyControl.Controls
for (var i = 0; i < _speCount; i++)
_speBlockList[i].Time = TimeConvert(SelectedTime).AddMilliseconds((i - sub) * _timeSpeList[_speIndex]);
if (_panelHotspots != null && _dateTimeRanges.Any())
{
UpdateHotspots();
}
}
/// <summary>
@@ -467,6 +538,18 @@ namespace HandyControl.Controls
_textBlockMove.Margin = new Thickness(p.X - _textBlockMove.ActualWidth / 2, 2, 0, 0);
}
private void UpdateHotspots()
{
var mlliseconds = ActualWidth * 0.5 / _itemWidth * _timeSpeList[_speIndex];
if (double.IsNaN(mlliseconds) || double.IsInfinity(mlliseconds)) return;
_panelHotspots.Children.Clear();
foreach (var rect in GetHotspotsRectangle(mlliseconds))
{
_panelHotspots.Children.Add(rect);
}
}
private void BorderTop_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) => _borderTopIsMouseLeftButtonDown = true;
private void BorderTop_OnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
@@ -487,5 +570,31 @@ namespace HandyControl.Controls
});
}
}
private IEnumerable<Rectangle> GetHotspotsRectangle(double mlliseconds)
{
var timeSpan = TimeSpan.FromMilliseconds(mlliseconds);
var selectedTime = SelectedTime;
var start = selectedTime - timeSpan;
var end = selectedTime + timeSpan;
var set = _dateTimeRanges.GetViewBetween(new DateTimeRange(start), new DateTimeRange(end));
var unitLength = ActualWidth / mlliseconds * 0.5;
foreach (var range in set)
{
var width = range.TotalMilliseconds * unitLength;
var sub = range.Start - start;
var x = sub.TotalMilliseconds * unitLength;
yield return new Rectangle
{
Fill = HotspotsBrush,
Height = 4,
Width = width,
Margin = new Thickness(x, 0, 0, 0),
HorizontalAlignment = HorizontalAlignment.Left
};
}
}
}
}
@@ -1,75 +0,0 @@
using System.Windows.Media;
namespace HandyControl.Data
{
/// <summary>
/// 颜色范围
/// </summary>
public class ColorRange
{
/// <summary>
/// 颜色1
/// </summary>
private Color _color1;
/// <summary>
/// 颜色1
/// </summary>
public Color Color1
{
get => _color1;
set
{
_color1 = value;
Update();
}
}
/// <summary>
/// 颜色2
/// </summary>
private Color _color2;
/// <summary>
/// 颜色2
/// </summary>
public Color Color2
{
get => _color2;
set
{
_color2 = value;
Update();
}
}
/// <summary>
/// 颜色差值
/// </summary>
private readonly int[] _subColorArr = new int[4];
/// <summary>
/// 更新
/// </summary>
private void Update()
{
_subColorArr[0] = Color1.A - Color2.A;
_subColorArr[1] = Color1.R - Color2.R;
_subColorArr[2] = Color1.G - Color2.G;
_subColorArr[3] = Color1.B - Color2.B;
}
/// <summary>
/// 获取指定比例处的颜色
/// </summary>
/// <param name="range">范围(0-1)</param>
/// <returns></returns>
public Color GetColor(double range)
{
if (range < 0 || range > 1) return default;
return Color.FromArgb((byte)(_color1.A - _subColorArr[0] * range), (byte)(_color1.R - _subColorArr[1] * range),
(byte)(_color1.G - _subColorArr[2] * range), (byte)(_color1.B - _subColorArr[3] * range));
}
}
}
@@ -5,7 +5,7 @@ using System;
namespace HandyControl.Data
{
public struct SystemVersionInfo
public readonly struct SystemVersionInfo
{
public static SystemVersionInfo Windows10 => new SystemVersionInfo(10, 0, 10240);
@@ -0,0 +1,63 @@
using System.Windows.Media;
namespace HandyControl.Data
{
/// <summary>
/// 颜色范围
/// </summary>
public class ColorRange : IValueRange<Color>
{
private Color _start;
public Color Start
{
get => _start;
set
{
_start = value;
Update();
}
}
private Color _end;
public Color End
{
get => _end;
set
{
_end = value;
Update();
}
}
/// <summary>
/// 颜色差值
/// </summary>
private readonly int[] _subColorArr = new int[4];
/// <summary>
/// 更新
/// </summary>
private void Update()
{
_subColorArr[0] = _start.A - _end.A;
_subColorArr[1] = _start.R - _end.R;
_subColorArr[2] = _start.G - _end.G;
_subColorArr[3] = _start.B - _end.B;
}
/// <summary>
/// 获取指定比例处的颜色
/// </summary>
/// <param name="range">范围(0-1)</param>
/// <returns></returns>
public Color GetColor(double range)
{
if (range < 0 || range > 1) return default;
return Color.FromArgb((byte)(_start.A - _subColorArr[0] * range), (byte)(_start.R - _subColorArr[1] * range),
(byte)(_start.G - _subColorArr[2] * range), (byte)(_start.B - _subColorArr[3] * range));
}
}
}
@@ -0,0 +1,25 @@
using System;
namespace HandyControl.Data
{
public struct DateTimeRange : IValueRange<DateTime>
{
public DateTimeRange(DateTime start)
{
Start = start;
End = start;
}
public DateTimeRange(DateTime start, DateTime end)
{
Start = start;
End = end;
}
public DateTime Start { get; set; }
public DateTime End { get; set; }
public double TotalMilliseconds => (End - Start).TotalMilliseconds;
}
}
@@ -0,0 +1,9 @@
namespace HandyControl.Data
{
public struct DoubleRange : IValueRange<double>
{
public double Start { get; set; }
public double End { get; set; }
}
}
@@ -0,0 +1,9 @@
namespace HandyControl.Data
{
public interface IValueRange<T>
{
T Start { get; set; }
T End { get; set; }
}
}
@@ -72,8 +72,10 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Block\RunningBlock.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Text\SimpleText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Window\GlowWindow.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Collections\DateTimeRangeComparer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Range\DateTimeRange.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\DisposableObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\EnumDataProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\EnumDataProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\DrawerShowMode.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\HatchStyle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\HitMode.cs" />
@@ -88,7 +90,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Data\GlowWindow\GlowDrawingContext.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\GlowWindow\GlowEdge.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\HwndWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\ImageCodecInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Info\ImageCodecInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Range\DoubleRange.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Range\IValueRange.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\CloseWindowCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\OpenLinkCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\StartScreenshotCommand.cs" />
@@ -126,6 +130,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\LangExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\StringExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\ValueExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Generator\ComparerGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\GlobalShortcut.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\StatusSwitchElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\TipElement.cs" />
@@ -223,7 +228,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Data\Args\FunctionEventArgs!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Args\KeyboardHookEventArgs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Args\MouseHookEventArgs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\ColorRange.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Range\ColorRange.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\BadgeStatus.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\ChatMessageType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\ChatRoleType.cs" />
@@ -243,14 +248,14 @@
<Compile Include="$(MSBuildThisFileDirectory)Data\Gif\GifPropertyItem.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Gif\GifPropertyItemInternal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Gif\GPStream.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\GrowlInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Info\GrowlInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\HandyControlConfig.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\MessageBoxInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Info\MessageBoxInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\MouseHookMessageType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Operation\OperationResult!1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Operation\OperationResult.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\ResourceToken.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\SystemVersionInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\Info\SystemVersionInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Data\ValueBoxes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Drawing\BezierCurveFlattener.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Expression\Drawing\CommonExtensions.cs" />
@@ -1084,6 +1089,7 @@
<None Include="$(MSBuildThisFileDirectory)Resources\Effects\GrayScaleEffect.fx" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Data\Info\" />
<Folder Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\" />
</ItemGroup>
</Project>
@@ -9,6 +9,7 @@
</ResourceDictionary.MergedDictionaries>
<Style TargetType="hc:TimeBar">
<Setter Property="HotspotsBrush" Value="{DynamicResource AccentBrush}"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="BorderThickness" Value="0,1,0,0"/>
@@ -46,8 +47,9 @@
</Border>
<TextBlock Visibility="{TemplateBinding ShowSpeStr,Converter={StaticResource Boolean2VisibilityConverter}}" Text="{TemplateBinding SpeStr}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,14,10,0"/>
<TextBlock Visibility="Collapsed" Name="PART_TextBlockMove" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,2,0,0"/>
<Border Width="1" Background="{DynamicResource DangerBrush}"/>
<Canvas Name="PART_CanvasSpe" VerticalAlignment="Bottom" Height="28"/>
<hc:SimplePanel x:Name="PART_Hotspots" Margin="0,48,0,0" VerticalAlignment="Top" Visibility="{Binding Hotspots,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Object2VisibilityConverter}}"/>
<Border Width="1" Background="{DynamicResource DangerBrush}"/>
<Border Name="PART_BorderTop" Background="Transparent" Cursor="Hand"/>
</hc:SimplePanel>
</Border>
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using HandyControl.Collections;
using HandyControl.Data;
namespace HandyControl.Tools
{
public class ComparerGenerator
{
private static readonly Dictionary<Type, ComparerTypeCode> TypeCodeDic = new Dictionary<Type, ComparerTypeCode>
{
[typeof(DateTimeRange)] = ComparerTypeCode.DateTimeRange,
};
public static IComparer<T> GetComparer<T>()
{
if (TypeCodeDic.TryGetValue(typeof(T), out var comparerType))
{
if (comparerType == ComparerTypeCode.DateTimeRange)
{
return (IComparer<T>)new DateTimeRangeComparer();
}
return null;
}
return null;
}
private enum ComparerTypeCode
{
DateTimeRange
}
}
}