Skip to content

Commit

Permalink
close #253
Browse files Browse the repository at this point in the history
  • Loading branch information
NaBian committed Jul 14, 2020
1 parent 25a6117 commit d4e3227
Show file tree
Hide file tree
Showing 19 changed files with 349 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
@@ -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)));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
24 changes: 12 additions & 12 deletions src/Shared/HandyControl_Shared/Controls/ColorPicker/ColorPicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,33 +131,33 @@ public class ColorPicker : Control, ISingleOpen
{
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)
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ public double Maximum
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
{
Expand All @@ -106,14 +106,14 @@ public double ValueStart
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
});
}

Expand Down Expand Up @@ -163,19 +163,12 @@ public double SmallChange
}

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; }
}
}
Loading

0 comments on commit d4e3227

Please sign in to comment.