refactor PreviewSlider
This commit is contained in:
1 parent
0546207f1a
commit
47a986270d
6 files changed
+535
-393
No files matched your search
@@ -40,7 +40,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private ButtonBase _dropDownButton;
|
||||
|
||||
private Popup _popUp;
|
||||
private Popup _popup;
|
||||
|
||||
private bool _disablePopupReopen;
|
||||
|
||||
@@ -135,9 +135,9 @@ namespace HandyControl.Controls
|
||||
var dp = d as DateTimePicker;
|
||||
|
||||
var newValue = (bool)e.NewValue;
|
||||
if (dp?._popUp != null && dp._popUp.IsOpen != newValue)
|
||||
if (dp?._popup != null && dp._popup.IsOpen != newValue)
|
||||
{
|
||||
dp._popUp.IsOpen = newValue;
|
||||
dp._popup.IsOpen = newValue;
|
||||
if (newValue)
|
||||
{
|
||||
dp._originalSelectedDateTime = dp.SelectedDateTime;
|
||||
@@ -275,12 +275,12 @@ namespace HandyControl.Controls
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
if (DesignerProperties.GetIsInDesignMode(this)) return;
|
||||
if (_popUp != null)
|
||||
if (_popup != null)
|
||||
{
|
||||
_popUp.PreviewMouseLeftButtonDown -= PopUp_PreviewMouseLeftButtonDown;
|
||||
_popUp.Opened -= PopUp_Opened;
|
||||
_popUp.Closed -= PopUp_Closed;
|
||||
_popUp.Child = null;
|
||||
_popup.PreviewMouseLeftButtonDown -= PopupPreviewMouseLeftButtonDown;
|
||||
_popup.Opened -= PopupOpened;
|
||||
_popup.Closed -= PopupClosed;
|
||||
_popup.Child = null;
|
||||
}
|
||||
|
||||
if (_dropDownButton != null)
|
||||
@@ -298,20 +298,20 @@ namespace HandyControl.Controls
|
||||
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_popUp = GetTemplateChild(ElementPopup) as Popup;
|
||||
_popup = GetTemplateChild(ElementPopup) as Popup;
|
||||
_dropDownButton = GetTemplateChild(ElementButton) as Button;
|
||||
_textBox = GetTemplateChild(ElementTextBox) as WatermarkTextBox;
|
||||
|
||||
CheckNull();
|
||||
|
||||
_popUp.PreviewMouseLeftButtonDown += PopUp_PreviewMouseLeftButtonDown;
|
||||
_popUp.Opened += PopUp_Opened;
|
||||
_popUp.Closed += PopUp_Closed;
|
||||
_popUp.Child = _calendarWithClock;
|
||||
_popup.PreviewMouseLeftButtonDown += PopupPreviewMouseLeftButtonDown;
|
||||
_popup.Opened += PopupOpened;
|
||||
_popup.Closed += PopupClosed;
|
||||
_popup.Child = _calendarWithClock;
|
||||
|
||||
if (IsDropDownOpen)
|
||||
{
|
||||
_popUp.IsOpen = true;
|
||||
_popup.IsOpen = true;
|
||||
}
|
||||
|
||||
_dropDownButton.Click += DropDownButton_Click;
|
||||
@@ -397,7 +397,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private void CheckNull()
|
||||
{
|
||||
if (_dropDownButton == null || _popUp == null || _textBox == null)
|
||||
if (_dropDownButton == null || _popup == null || _textBox == null)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ namespace HandyControl.Controls
|
||||
_calendarWithClock.Confirmed += CalendarWithClock_Confirmed;
|
||||
}
|
||||
|
||||
private void CalendarWithClock_Confirmed() => TogglePopUp();
|
||||
private void CalendarWithClock_Confirmed() => TogglePopup();
|
||||
|
||||
private void CalendarWithClock_SelectedDateTimeChanged(object sender, FunctionEventArgs<DateTime?> e) => SelectedDateTime = e.Info;
|
||||
|
||||
@@ -468,7 +468,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
|
||||
{
|
||||
TogglePopUp();
|
||||
TogglePopup();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ namespace HandyControl.Controls
|
||||
return _isHandlerSuspended != null && _isHandlerSuspended.ContainsKey(property);
|
||||
}
|
||||
|
||||
private void PopUp_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
private void PopupPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is Popup popup && !popup.StaysOpen)
|
||||
{
|
||||
@@ -515,7 +515,7 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void PopUp_Opened(object sender, EventArgs e)
|
||||
private void PopupOpened(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsDropDownOpen)
|
||||
{
|
||||
@@ -527,7 +527,7 @@ namespace HandyControl.Controls
|
||||
OnPickerOpened(new RoutedEventArgs());
|
||||
}
|
||||
|
||||
private void PopUp_Closed(object sender, EventArgs e)
|
||||
private void PopupClosed(object sender, EventArgs e)
|
||||
{
|
||||
if (IsDropDownOpen)
|
||||
{
|
||||
@@ -542,9 +542,9 @@ namespace HandyControl.Controls
|
||||
OnPickerClosed(new RoutedEventArgs());
|
||||
}
|
||||
|
||||
private void DropDownButton_Click(object sender, RoutedEventArgs e) => TogglePopUp();
|
||||
private void DropDownButton_Click(object sender, RoutedEventArgs e) => TogglePopup();
|
||||
|
||||
private void TogglePopUp()
|
||||
private void TogglePopup()
|
||||
{
|
||||
if (IsDropDownOpen)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user