add datetimepicker
This commit is contained in:
1 parent
4d56cc121e
commit
ed8ef8c7a9
32 files changed
+1611
-106
No files matched your search
@@ -1,7 +1,6 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class BackgroundSwitchElement : DependencyObject
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Windows;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class BorderElement : DependencyObject
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class DataGridAttach : DependencyObject
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class TitleElement : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached(
|
||||
"Background", typeof(Brush), typeof(TitleElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
|
||||
|
||||
public static void SetBackground(DependencyObject element, Brush value)
|
||||
=> element.SetValue(BackgroundProperty, value);
|
||||
|
||||
public static Brush GetBackground(DependencyObject element)
|
||||
=> (Brush) element.GetValue(BackgroundProperty);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,690 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Interactivity;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// 时间日期选择器
|
||||
/// </summary>
|
||||
[TemplatePart(Name = ElementRoot, Type = typeof(Grid))]
|
||||
[TemplatePart(Name = ElementTextBox, Type = typeof(WatermarkTextBox))]
|
||||
[TemplatePart(Name = ElementButton, Type = typeof(Button))]
|
||||
[TemplatePart(Name = ElementPopup, Type = typeof(Popup))]
|
||||
public class DateTimePicker : Control, IDataInput
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const string ElementRoot = "PART_Root";
|
||||
|
||||
private const string ElementTextBox = "PART_TextBox";
|
||||
|
||||
private const string ElementButton = "PART_Button";
|
||||
|
||||
private const string ElementPopup = "PART_Popup";
|
||||
|
||||
#endregion Constants
|
||||
|
||||
#region Data
|
||||
|
||||
private CalendarWithClock _calendarWithClock;
|
||||
|
||||
private string _defaultText;
|
||||
|
||||
private ButtonBase _dropDownButton;
|
||||
|
||||
private Popup _popUp;
|
||||
|
||||
private bool _disablePopupReopen;
|
||||
|
||||
private WatermarkTextBox _textBox;
|
||||
|
||||
private IDictionary<DependencyProperty, bool> _isHandlerSuspended;
|
||||
|
||||
private DateTime? _originalSelectedDateTime;
|
||||
|
||||
#endregion Data
|
||||
|
||||
#region Public Events
|
||||
|
||||
public static readonly RoutedEvent SelectedDateTimeChangedEvent =
|
||||
EventManager.RegisterRoutedEvent("SelectedDateTimeChanged", RoutingStrategy.Direct,
|
||||
typeof(EventHandler<FunctionEventArgs<DateTime?>>), typeof(DateTimePicker));
|
||||
|
||||
public event EventHandler<FunctionEventArgs<DateTime?>> SelectedDateTimeChanged
|
||||
{
|
||||
add => AddHandler(SelectedDateTimeChangedEvent, value);
|
||||
remove => RemoveHandler(SelectedDateTimeChangedEvent, value);
|
||||
}
|
||||
|
||||
public event RoutedEventHandler PickerClosed;
|
||||
|
||||
public event RoutedEventHandler PickerOpened;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
static DateTimePicker()
|
||||
{
|
||||
EventManager.RegisterClassHandler(typeof(DateTimePicker), GotFocusEvent, new RoutedEventHandler(OnGotFocus));
|
||||
KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(DateTimePicker), new FrameworkPropertyMetadata(KeyboardNavigationMode.Once));
|
||||
KeyboardNavigation.IsTabStopProperty.OverrideMetadata(typeof(DateTimePicker), new FrameworkPropertyMetadata(false));
|
||||
}
|
||||
|
||||
public DateTimePicker()
|
||||
{
|
||||
InitCalendarWithClock();
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) =>
|
||||
{
|
||||
ClearValue(SelectedDateTimeProperty);
|
||||
ClearValue(TextProperty);
|
||||
_textBox.Text = string.Empty;
|
||||
}));
|
||||
}
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static readonly DependencyProperty DateTimeFormatProperty = DependencyProperty.Register(
|
||||
"DateTimeFormat", typeof(string), typeof(DateTimePicker), new PropertyMetadata("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
public string DateTimeFormat
|
||||
{
|
||||
get => (string) GetValue(DateTimeFormatProperty);
|
||||
set => SetValue(DateTimeFormatProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ClockStyleProperty = DependencyProperty.Register(
|
||||
"ClockStyle", typeof(Style), typeof(DateTimePicker), new PropertyMetadata(default(Style)));
|
||||
|
||||
public Style ClockStyle
|
||||
{
|
||||
get => (Style) GetValue(ClockStyleProperty);
|
||||
set => SetValue(ClockStyleProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty CalendarStyleProperty = DependencyProperty.Register(
|
||||
"CalendarStyle", typeof(Style), typeof(DateTimePicker), new PropertyMetadata(default(Style)));
|
||||
|
||||
public Style CalendarStyle
|
||||
{
|
||||
get => (Style) GetValue(CalendarStyleProperty);
|
||||
set => SetValue(CalendarStyleProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DisplayDateTimeProperty = DependencyProperty.Register(
|
||||
"DisplayDateTime", typeof(DateTime), typeof(DateTimePicker), new FrameworkPropertyMetadata(DateTime.Now, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, null, CoerceDisplayDateTime));
|
||||
|
||||
private static object CoerceDisplayDateTime(DependencyObject d, object value)
|
||||
{
|
||||
var dp = (DateTimePicker)d;
|
||||
dp._calendarWithClock.DisplayDateTime = (DateTime)value;
|
||||
|
||||
return dp._calendarWithClock.DisplayDateTime;
|
||||
}
|
||||
|
||||
public DateTime DisplayDateTime
|
||||
{
|
||||
get => (DateTime) GetValue(DisplayDateTimeProperty);
|
||||
set => SetValue(DisplayDateTimeProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsDropDownOpenProperty = DependencyProperty.Register(
|
||||
"IsDropDownOpen", typeof(bool), typeof(DateTimePicker), new FrameworkPropertyMetadata(ValueBoxes.FalseBox, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDropDownOpenChanged, OnCoerceIsDropDownOpen));
|
||||
|
||||
private static object OnCoerceIsDropDownOpen(DependencyObject d, object baseValue) => d is DateTimePicker dp && !dp.IsEnabled ? false : baseValue;
|
||||
|
||||
private static void OnIsDropDownOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var dp = d as DateTimePicker;
|
||||
|
||||
var newValue = (bool)e.NewValue;
|
||||
if (dp?._popUp != null && dp._popUp.IsOpen != newValue)
|
||||
{
|
||||
dp._popUp.IsOpen = newValue;
|
||||
if (newValue)
|
||||
{
|
||||
dp._originalSelectedDateTime = dp.SelectedDateTime;
|
||||
|
||||
dp.Dispatcher.BeginInvoke(DispatcherPriority.Input, (Action)delegate
|
||||
{
|
||||
dp._calendarWithClock.Focus();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDropDownOpen
|
||||
{
|
||||
get => (bool) GetValue(IsDropDownOpenProperty);
|
||||
set => SetValue(IsDropDownOpenProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SelectedDateTimeProperty = DependencyProperty.Register(
|
||||
"SelectedDateTime", typeof(DateTime?), typeof(DateTimePicker), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedDateTimeChanged, CoerceSelectedDateTime));
|
||||
|
||||
private static object CoerceSelectedDateTime(DependencyObject d, object value)
|
||||
{
|
||||
var dp = (DateTimePicker)d;
|
||||
dp._calendarWithClock.SelectedDateTime = (DateTime?)value;
|
||||
return dp._calendarWithClock.SelectedDateTime;
|
||||
}
|
||||
|
||||
private static void OnSelectedDateTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DateTimePicker dp)) return;
|
||||
|
||||
if (dp.SelectedDateTime.HasValue)
|
||||
{
|
||||
var time = dp.SelectedDateTime.Value;
|
||||
dp.SetTextInternal(dp.DateTimeToString(time));
|
||||
}
|
||||
|
||||
dp.RaiseEvent(new FunctionEventArgs<DateTime?>(SelectedDateTimeChangedEvent, dp)
|
||||
{
|
||||
Info = dp.SelectedDateTime
|
||||
});
|
||||
}
|
||||
|
||||
public DateTime? SelectedDateTime
|
||||
{
|
||||
get => (DateTime?) GetValue(SelectedDateTimeProperty);
|
||||
set => SetValue(SelectedDateTimeProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
||||
"Text", typeof(string), typeof(DateTimePicker), new FrameworkPropertyMetadata(string.Empty, OnTextChanged));
|
||||
|
||||
private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is DateTimePicker dp && !dp.IsHandlerSuspended(TextProperty))
|
||||
{
|
||||
if (e.NewValue is string newValue)
|
||||
{
|
||||
if (dp._textBox != null)
|
||||
{
|
||||
dp._textBox.Text = newValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
dp._defaultText = newValue;
|
||||
}
|
||||
|
||||
dp.SetSelectedDateTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
dp.SetValueNoCallback(SelectedDateTimeProperty, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => (string) GetValue(TextProperty);
|
||||
set => SetValue(TextProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the local Text property without breaking bindings
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
private void SetTextInternal(string value)
|
||||
{
|
||||
SetCurrentValue(TextProperty, value);
|
||||
}
|
||||
|
||||
public Func<string, OperationResult<bool>> VerifyFunc { get; set; }
|
||||
|
||||
public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register(
|
||||
"IsError", typeof(bool), typeof(DateTimePicker), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
|
||||
public bool IsError
|
||||
{
|
||||
get => (bool) GetValue(IsErrorProperty);
|
||||
set => SetValue(IsErrorProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ErrorStrProperty = DependencyProperty.Register(
|
||||
"ErrorStr", typeof(string), typeof(DateTimePicker), new PropertyMetadata(default(string)));
|
||||
|
||||
public string ErrorStr
|
||||
{
|
||||
get => (string) GetValue(ErrorStrProperty);
|
||||
set => SetValue(ErrorStrProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TextTypeProperty = DependencyProperty.Register(
|
||||
"TextType", typeof(TextType), typeof(DateTimePicker), new PropertyMetadata(default(TextType)));
|
||||
|
||||
public TextType TextType
|
||||
{
|
||||
get => (TextType) GetValue(TextTypeProperty);
|
||||
set => SetValue(TextTypeProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.Register(
|
||||
"ShowClearButton", typeof(bool), typeof(DateTimePicker), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
|
||||
public bool ShowClearButton
|
||||
{
|
||||
get => (bool) GetValue(ShowClearButtonProperty);
|
||||
set => SetValue(ShowClearButtonProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
if (DesignerProperties.GetIsInDesignMode(this)) return;
|
||||
if (_popUp != null)
|
||||
{
|
||||
_popUp.PreviewMouseLeftButtonDown -= PopUp_PreviewMouseLeftButtonDown;
|
||||
_popUp.Opened -= PopUp_Opened;
|
||||
_popUp.Closed -= PopUp_Closed;
|
||||
_popUp.Child = null;
|
||||
}
|
||||
|
||||
if (_dropDownButton != null)
|
||||
{
|
||||
_dropDownButton.Click -= DropDownButton_Click;
|
||||
_dropDownButton.MouseLeave -= DropDownButton_MouseLeave;
|
||||
}
|
||||
|
||||
if (_textBox != null)
|
||||
{
|
||||
_textBox.KeyDown -= TextBox_KeyDown;
|
||||
_textBox.TextChanged -= TextBox_TextChanged;
|
||||
_textBox.LostFocus -= TextBox_LostFocus;
|
||||
}
|
||||
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_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;
|
||||
|
||||
if (IsDropDownOpen)
|
||||
{
|
||||
_popUp.IsOpen = true;
|
||||
}
|
||||
|
||||
_dropDownButton.Click += DropDownButton_Click;
|
||||
_dropDownButton.MouseLeave += DropDownButton_MouseLeave;
|
||||
if (SelectedDateTime == null)
|
||||
{
|
||||
_textBox.Text = DateTime.Now.ToString(DateTimeFormat);
|
||||
}
|
||||
_textBox.KeyDown += TextBox_KeyDown;
|
||||
_textBox.TextChanged += TextBox_TextChanged;
|
||||
_textBox.LostFocus += TextBox_LostFocus;
|
||||
|
||||
if (SelectedDateTime == null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_defaultText))
|
||||
{
|
||||
_textBox.Text = _defaultText;
|
||||
SetSelectedDateTime();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_textBox.Text = DateTimeToString(SelectedDateTime.Value);
|
||||
}
|
||||
|
||||
if (_originalSelectedDateTime == null)
|
||||
{
|
||||
_originalSelectedDateTime = DateTime.Now;
|
||||
}
|
||||
SetCurrentValue(DisplayDateTimeProperty, _originalSelectedDateTime);
|
||||
}
|
||||
|
||||
public virtual bool VerifyData()
|
||||
{
|
||||
OperationResult<bool> result;
|
||||
|
||||
if (VerifyFunc != null)
|
||||
{
|
||||
result = VerifyFunc.Invoke(Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Text))
|
||||
{
|
||||
result = OperationResult.Success();
|
||||
}
|
||||
else if (InfoElement.GetNecessary(this))
|
||||
{
|
||||
result = OperationResult.Failed(Properties.Langs.Lang.IsNecessary);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = OperationResult.Success();
|
||||
}
|
||||
}
|
||||
|
||||
IsError = !result.Data;
|
||||
ErrorStr = result.Message;
|
||||
return result.Data;
|
||||
}
|
||||
|
||||
public override string ToString() => SelectedDateTime?.ToString(DateTimeFormat) ?? string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected virtual void OnPickerClosed(RoutedEventArgs e)
|
||||
{
|
||||
var handler = PickerClosed;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
|
||||
protected virtual void OnPickerOpened(RoutedEventArgs e)
|
||||
{
|
||||
var handler = PickerOpened;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void CheckNull()
|
||||
{
|
||||
if (_dropDownButton == null || _popUp == null || _textBox == null)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
private void InitCalendarWithClock()
|
||||
{
|
||||
_calendarWithClock = new CalendarWithClock
|
||||
{
|
||||
ShowConfirmButton = true
|
||||
};
|
||||
_calendarWithClock.SelectedDateTimeChanged += CalendarWithClock_SelectedDateTimeChanged;
|
||||
_calendarWithClock.Confirmed += CalendarWithClock_Confirmed;
|
||||
}
|
||||
|
||||
private void CalendarWithClock_Confirmed() => TogglePopUp();
|
||||
|
||||
private void CalendarWithClock_SelectedDateTimeChanged(object sender, FunctionEventArgs<DateTime?> e) => SelectedDateTime = e.Info;
|
||||
|
||||
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetSelectedDateTime();
|
||||
}
|
||||
|
||||
private void SetIsHandlerSuspended(DependencyProperty property, bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (_isHandlerSuspended == null)
|
||||
{
|
||||
_isHandlerSuspended = new Dictionary<DependencyProperty, bool>(2);
|
||||
}
|
||||
|
||||
_isHandlerSuspended[property] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isHandlerSuspended?.Remove(property);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetValueNoCallback(DependencyProperty property, object value)
|
||||
{
|
||||
SetIsHandlerSuspended(property, true);
|
||||
try
|
||||
{
|
||||
SetCurrentValue(property, value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
SetIsHandlerSuspended(property, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
SetValueNoCallback(TextProperty, _textBox.Text);
|
||||
VerifyData();
|
||||
}
|
||||
|
||||
private bool ProcessDateTimePickerKey(KeyEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.System:
|
||||
{
|
||||
switch (e.SystemKey)
|
||||
{
|
||||
case Key.Down:
|
||||
{
|
||||
if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
|
||||
{
|
||||
TogglePopUp();
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Key.Enter:
|
||||
{
|
||||
SetSelectedDateTime();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void TextBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
e.Handled = ProcessDateTimePickerKey(e) || e.Handled;
|
||||
}
|
||||
|
||||
private void DropDownButton_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
_disablePopupReopen = false;
|
||||
}
|
||||
|
||||
private bool IsHandlerSuspended(DependencyProperty property)
|
||||
{
|
||||
return _isHandlerSuspended != null && _isHandlerSuspended.ContainsKey(property);
|
||||
}
|
||||
|
||||
private void PopUp_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is Popup popup && !popup.StaysOpen)
|
||||
{
|
||||
if (_dropDownButton?.InputHitTest(e.GetPosition(_dropDownButton)) != null)
|
||||
{
|
||||
_disablePopupReopen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PopUp_Opened(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsDropDownOpen)
|
||||
{
|
||||
SetCurrentValue(IsDropDownOpenProperty, ValueBoxes.TrueBox);
|
||||
}
|
||||
|
||||
_calendarWithClock?.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
|
||||
|
||||
OnPickerOpened(new RoutedEventArgs());
|
||||
}
|
||||
|
||||
private void PopUp_Closed(object sender, EventArgs e)
|
||||
{
|
||||
if (IsDropDownOpen)
|
||||
{
|
||||
SetCurrentValue(IsDropDownOpenProperty, ValueBoxes.FalseBox);
|
||||
}
|
||||
|
||||
if (_calendarWithClock.IsKeyboardFocusWithin)
|
||||
{
|
||||
MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
|
||||
}
|
||||
|
||||
OnPickerClosed(new RoutedEventArgs());
|
||||
}
|
||||
|
||||
private void DropDownButton_Click(object sender, RoutedEventArgs e) => TogglePopUp();
|
||||
|
||||
private void TogglePopUp()
|
||||
{
|
||||
if (IsDropDownOpen)
|
||||
{
|
||||
SetCurrentValue(IsDropDownOpenProperty, ValueBoxes.FalseBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_disablePopupReopen)
|
||||
{
|
||||
_disablePopupReopen = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSelectedDateTime();
|
||||
SetCurrentValue(IsDropDownOpenProperty, ValueBoxes.TrueBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SafeSetText(string s)
|
||||
{
|
||||
if (string.Compare(Text, s, StringComparison.Ordinal) != 0)
|
||||
{
|
||||
SetCurrentValue(TextProperty, s);
|
||||
}
|
||||
}
|
||||
|
||||
private DateTime? ParseText(string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
return DateTime.Parse(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private DateTime? SetTextBoxValue(string s)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s))
|
||||
{
|
||||
SafeSetText(s);
|
||||
return SelectedDateTime;
|
||||
}
|
||||
|
||||
var d = ParseText(s);
|
||||
|
||||
if (d != null)
|
||||
{
|
||||
SafeSetText(DateTimeToString((DateTime)d));
|
||||
return d;
|
||||
}
|
||||
|
||||
if (SelectedDateTime != null)
|
||||
{
|
||||
var newtext = DateTimeToString(SelectedDateTime.Value);
|
||||
SafeSetText(newtext);
|
||||
return SelectedDateTime;
|
||||
}
|
||||
SafeSetText(DateTimeToString(DisplayDateTime));
|
||||
return DisplayDateTime;
|
||||
}
|
||||
|
||||
private void SetSelectedDateTime()
|
||||
{
|
||||
if (_textBox != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_textBox.Text))
|
||||
{
|
||||
var s = _textBox.Text;
|
||||
|
||||
if (SelectedDateTime != null)
|
||||
{
|
||||
var selectedTime = DateTimeToString(SelectedDateTime.Value);
|
||||
|
||||
if (string.Compare(selectedTime, s, StringComparison.Ordinal) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var d = SetTextBoxValue(s);
|
||||
if (!SelectedDateTime.Equals(d))
|
||||
{
|
||||
SetCurrentValue(SelectedDateTimeProperty, d);
|
||||
SetCurrentValue(DisplayDateTimeProperty, d);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SelectedDateTime.HasValue)
|
||||
{
|
||||
SetCurrentValue(SelectedDateTimeProperty, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var d = SetTextBoxValue(_defaultText);
|
||||
if (!SelectedDateTime.Equals(d))
|
||||
{
|
||||
SetCurrentValue(SelectedDateTimeProperty, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string DateTimeToString(DateTime d) => d.ToString(DateTimeFormat);
|
||||
|
||||
private static void OnGotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var picker = (DateTimePicker)sender;
|
||||
if (!e.Handled && picker._textBox != null)
|
||||
{
|
||||
if (Equals(e.OriginalSource, picker))
|
||||
{
|
||||
picker._textBox.Focus();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (Equals(e.OriginalSource, picker._textBox))
|
||||
{
|
||||
picker._textBox.SelectAll();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -18,28 +18,36 @@ namespace HandyControl.Controls
|
||||
[TemplatePart(Name = ElementTextBox, Type = typeof(WatermarkTextBox))]
|
||||
[TemplatePart(Name = ElementButton, Type = typeof(Button))]
|
||||
[TemplatePart(Name = ElementPopup, Type = typeof(Popup))]
|
||||
[TemplatePart(Name = ElementClock, Type = typeof(Clock))]
|
||||
public class TimePicker : Control, IDataInput
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const string ElementRoot = "PART_Root";
|
||||
|
||||
private const string ElementTextBox = "PART_TextBox";
|
||||
|
||||
private const string ElementButton = "PART_Button";
|
||||
|
||||
private const string ElementPopup = "PART_Popup";
|
||||
private const string ElementClock = "PART_Clock";
|
||||
|
||||
#endregion Constants
|
||||
|
||||
#region Data
|
||||
|
||||
private Clock _clock;
|
||||
|
||||
private string _defaultText;
|
||||
|
||||
private ButtonBase _dropDownButton;
|
||||
|
||||
private Popup _popUp;
|
||||
|
||||
private bool _disablePopupReopen;
|
||||
|
||||
private WatermarkTextBox _textBox;
|
||||
|
||||
private IDictionary<DependencyProperty, bool> _isHandlerSuspended;
|
||||
|
||||
private DateTime? _originalSelectedTime;
|
||||
|
||||
#endregion Data
|
||||
@@ -71,10 +79,12 @@ namespace HandyControl.Controls
|
||||
|
||||
public TimePicker()
|
||||
{
|
||||
InitClock();
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) =>
|
||||
{
|
||||
ClearValue(SelectedTimeProperty);
|
||||
ClearValue(TextProperty);
|
||||
_textBox.Text = string.Empty;
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -142,7 +152,7 @@ namespace HandyControl.Controls
|
||||
"IsDropDownOpen",
|
||||
typeof(bool),
|
||||
typeof(TimePicker),
|
||||
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDropDownOpenChanged, OnCoerceIsDropDownOpen));
|
||||
new FrameworkPropertyMetadata(ValueBoxes.FalseBox, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDropDownOpenChanged, OnCoerceIsDropDownOpen));
|
||||
|
||||
private static object OnCoerceIsDropDownOpen(DependencyObject d, object baseValue) => d is TimePicker dp && !dp.IsEnabled ? false : baseValue;
|
||||
|
||||
@@ -334,7 +344,7 @@ namespace HandyControl.Controls
|
||||
if (DesignerProperties.GetIsInDesignMode(this)) return;
|
||||
if (_popUp != null)
|
||||
{
|
||||
_popUp.RemoveHandler(PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(PopUp_PreviewMouseLeftButtonDown));
|
||||
_popUp.PreviewMouseLeftButtonDown -= PopUp_PreviewMouseLeftButtonDown;
|
||||
_popUp.Opened -= PopUp_Opened;
|
||||
_popUp.Closed -= PopUp_Closed;
|
||||
_popUp.Child = null;
|
||||
@@ -343,36 +353,25 @@ namespace HandyControl.Controls
|
||||
if (_dropDownButton != null)
|
||||
{
|
||||
_dropDownButton.Click -= DropDownButton_Click;
|
||||
_dropDownButton.RemoveHandler(MouseLeaveEvent, new MouseEventHandler(DropDownButton_MouseLeave));
|
||||
_dropDownButton.MouseLeave -= DropDownButton_MouseLeave;
|
||||
}
|
||||
|
||||
if (_textBox != null)
|
||||
{
|
||||
_textBox.RemoveHandler(KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
|
||||
_textBox.RemoveHandler(TextBoxBase.TextChangedEvent, new TextChangedEventHandler(TextBox_TextChanged));
|
||||
_textBox.RemoveHandler(LostFocusEvent, new RoutedEventHandler(TextBox_LostFocus));
|
||||
}
|
||||
|
||||
if (_clock != null)
|
||||
{
|
||||
_clock.RemoveHandler(Clock.SelectedTimeChangedEvent, new EventHandler<FunctionEventArgs<DateTime?>>(Clock_SelectedTimeChangedEvent));
|
||||
_clock.Confirmed -= Clock_Confirmed;
|
||||
_textBox.KeyDown -= TextBox_KeyDown;
|
||||
_textBox.TextChanged -= TextBox_TextChanged;
|
||||
_textBox.LostFocus -= TextBox_LostFocus;
|
||||
}
|
||||
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_clock = GetTemplateChild(ElementClock) as Clock;
|
||||
_popUp = GetTemplateChild(ElementPopup) as Popup;
|
||||
_dropDownButton = GetTemplateChild(ElementButton) as Button;
|
||||
_textBox = GetTemplateChild(ElementTextBox) as WatermarkTextBox;
|
||||
|
||||
CheckNull();
|
||||
|
||||
_clock.ApplyTemplate();
|
||||
_clock.AddHandler(Clock.SelectedTimeChangedEvent, new EventHandler<FunctionEventArgs<DateTime?>>(Clock_SelectedTimeChangedEvent));
|
||||
_clock.Confirmed += Clock_Confirmed;
|
||||
|
||||
_popUp.AddHandler(PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(PopUp_PreviewMouseLeftButtonDown));
|
||||
_popUp.PreviewMouseLeftButtonDown += PopUp_PreviewMouseLeftButtonDown;
|
||||
_popUp.Opened += PopUp_Opened;
|
||||
_popUp.Closed += PopUp_Closed;
|
||||
_popUp.Child = _clock;
|
||||
@@ -383,14 +382,14 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
_dropDownButton.Click += DropDownButton_Click;
|
||||
_dropDownButton.AddHandler(MouseLeaveEvent, new MouseEventHandler(DropDownButton_MouseLeave), true);
|
||||
_dropDownButton.MouseLeave += DropDownButton_MouseLeave;
|
||||
if (SelectedTime == null)
|
||||
{
|
||||
_textBox.Text = DateTime.Now.ToString(TimeFormat);
|
||||
}
|
||||
_textBox.AddHandler(KeyDownEvent, new KeyEventHandler(TextBox_KeyDown), true);
|
||||
_textBox.AddHandler(TextBoxBase.TextChangedEvent, new TextChangedEventHandler(TextBox_TextChanged), true);
|
||||
_textBox.AddHandler(LostFocusEvent, new RoutedEventHandler(TextBox_LostFocus), true);
|
||||
_textBox.KeyDown += TextBox_KeyDown;
|
||||
_textBox.TextChanged += TextBox_TextChanged;
|
||||
_textBox.LostFocus += TextBox_LostFocus;
|
||||
|
||||
if (SelectedTime == null)
|
||||
{
|
||||
@@ -436,10 +435,20 @@ namespace HandyControl.Controls
|
||||
|
||||
private void CheckNull()
|
||||
{
|
||||
if (_clock == null || _dropDownButton == null || _popUp == null || _textBox == null)
|
||||
if (_dropDownButton == null || _popUp == null || _textBox == null)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
private void InitClock()
|
||||
{
|
||||
_clock = new Clock
|
||||
{
|
||||
ShowConfirmButton = true
|
||||
};
|
||||
_clock.SelectedTimeChanged += Clock_SelectedTimeChanged;
|
||||
_clock.Confirmed += Clock_Confirmed;
|
||||
}
|
||||
|
||||
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetSelectedTime();
|
||||
@@ -540,7 +549,7 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void Clock_SelectedTimeChangedEvent(object sender, FunctionEventArgs<DateTime?> e) => SelectedTime = e.Info;
|
||||
private void Clock_SelectedTimeChanged(object sender, FunctionEventArgs<DateTime?> e) => SelectedTime = e.Info;
|
||||
|
||||
private void Clock_Confirmed() => TogglePopUp();
|
||||
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
[TemplatePart(Name = ElementButtonConfirm, Type = typeof(Button))]
|
||||
[TemplatePart(Name = ElementClockPresenter, Type = typeof(ContentPresenter))]
|
||||
[TemplatePart(Name = ElementCalendarPresenter, Type = typeof(ContentPresenter))]
|
||||
public class CalendarWithClock : Control
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const string ElementButtonConfirm = "PART_ButtonConfirm";
|
||||
|
||||
private const string ElementClockPresenter = "PART_ClockPresenter";
|
||||
|
||||
private const string ElementCalendarPresenter = "PART_CalendarPresenter";
|
||||
|
||||
#endregion Constants
|
||||
|
||||
#region Data
|
||||
|
||||
private ContentPresenter _clockPresenter;
|
||||
|
||||
private ContentPresenter _calendarPresenter;
|
||||
|
||||
private Clock _clock;
|
||||
|
||||
private Calendar _calendar;
|
||||
|
||||
private Button _buttonConfirm;
|
||||
|
||||
private bool _isLoaded;
|
||||
|
||||
private IDictionary<DependencyProperty, bool> _isHandlerSuspended;
|
||||
|
||||
#endregion Data
|
||||
|
||||
#region Public Events
|
||||
|
||||
public static readonly RoutedEvent SelectedDateTimeChangedEvent =
|
||||
EventManager.RegisterRoutedEvent("SelectedDateTimeChanged", RoutingStrategy.Direct,
|
||||
typeof(EventHandler<FunctionEventArgs<DateTime?>>), typeof(CalendarWithClock));
|
||||
|
||||
public event EventHandler<FunctionEventArgs<DateTime?>> SelectedDateTimeChanged
|
||||
{
|
||||
add => AddHandler(SelectedDateTimeChangedEvent, value);
|
||||
remove => RemoveHandler(SelectedDateTimeChangedEvent, value);
|
||||
}
|
||||
|
||||
public event EventHandler<FunctionEventArgs<DateTime>> DisplayDateTimeChanged;
|
||||
|
||||
public event Action Confirmed;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
public CalendarWithClock()
|
||||
{
|
||||
InitCalendarAndClock();
|
||||
Loaded += (s, e) =>
|
||||
{
|
||||
if (_isLoaded) return;
|
||||
_isLoaded = true;
|
||||
DisplayDateTime = SelectedDateTime ?? DateTime.Now;
|
||||
};
|
||||
}
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static readonly DependencyProperty DateTimeFormatProperty = DependencyProperty.Register(
|
||||
"DateTimeFormat", typeof(string), typeof(CalendarWithClock), new PropertyMetadata("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
public string DateTimeFormat
|
||||
{
|
||||
get => (string)GetValue(DateTimeFormatProperty);
|
||||
set => SetValue(DateTimeFormatProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ShowConfirmButtonProperty = DependencyProperty.Register(
|
||||
"ShowConfirmButton", typeof(bool), typeof(CalendarWithClock), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
|
||||
public bool ShowConfirmButton
|
||||
{
|
||||
get => (bool)GetValue(ShowConfirmButtonProperty);
|
||||
set => SetValue(ShowConfirmButtonProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SelectedDateTimeProperty = DependencyProperty.Register(
|
||||
"SelectedDateTime", typeof(DateTime?), typeof(CalendarWithClock), new PropertyMetadata(default(DateTime?), OnSelectedDateTimeChanged));
|
||||
|
||||
private static void OnSelectedDateTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ctl = (CalendarWithClock)d;
|
||||
var v = (DateTime?)e.NewValue;
|
||||
ctl.OnSelectedDateTimeChanged(new FunctionEventArgs<DateTime?>(SelectedDateTimeChangedEvent, ctl)
|
||||
{
|
||||
Info = v
|
||||
});
|
||||
}
|
||||
|
||||
public DateTime? SelectedDateTime
|
||||
{
|
||||
get => (DateTime?)GetValue(SelectedDateTimeProperty);
|
||||
set => SetValue(SelectedDateTimeProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DisplayDateTimeProperty = DependencyProperty.Register(
|
||||
"DisplayDateTime", typeof(DateTime), typeof(CalendarWithClock), new FrameworkPropertyMetadata(DateTime.MinValue, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnDisplayDateTimeChanged));
|
||||
|
||||
private static void OnDisplayDateTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ctl = (CalendarWithClock)d;
|
||||
if (ctl.IsHandlerSuspended(DisplayDateTimeProperty)) return;
|
||||
var v = (DateTime)e.NewValue;
|
||||
ctl._clock.SelectedTime = v;
|
||||
ctl._calendar.SelectedDate = v;
|
||||
ctl.OnDisplayDateTimeChanged(new FunctionEventArgs<DateTime>(v));
|
||||
}
|
||||
|
||||
public DateTime DisplayDateTime
|
||||
{
|
||||
get => (DateTime)GetValue(DisplayDateTimeProperty);
|
||||
set => SetValue(DisplayDateTimeProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
if (_buttonConfirm != null)
|
||||
{
|
||||
_buttonConfirm.Click -= ButtonConfirm_OnClick;
|
||||
}
|
||||
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_buttonConfirm = GetTemplateChild(ElementButtonConfirm) as Button;
|
||||
_clockPresenter = GetTemplateChild(ElementClockPresenter) as ContentPresenter;
|
||||
_calendarPresenter = GetTemplateChild(ElementCalendarPresenter) as ContentPresenter;
|
||||
|
||||
CheckNull();
|
||||
|
||||
_clockPresenter.Content = _clock;
|
||||
_calendarPresenter.Content = _calendar;
|
||||
|
||||
_buttonConfirm.Click += ButtonConfirm_OnClick;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected virtual void OnSelectedDateTimeChanged(FunctionEventArgs<DateTime?> e) => RaiseEvent(e);
|
||||
|
||||
protected virtual void OnDisplayDateTimeChanged(FunctionEventArgs<DateTime> e)
|
||||
{
|
||||
var handler = DisplayDateTimeChanged;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void SetIsHandlerSuspended(DependencyProperty property, bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (_isHandlerSuspended == null)
|
||||
{
|
||||
_isHandlerSuspended = new Dictionary<DependencyProperty, bool>(2);
|
||||
}
|
||||
|
||||
_isHandlerSuspended[property] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isHandlerSuspended?.Remove(property);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetValueNoCallback(DependencyProperty property, object value)
|
||||
{
|
||||
SetIsHandlerSuspended(property, true);
|
||||
try
|
||||
{
|
||||
SetCurrentValue(property, value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
SetIsHandlerSuspended(property, false);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsHandlerSuspended(DependencyProperty property)
|
||||
{
|
||||
return _isHandlerSuspended != null && _isHandlerSuspended.ContainsKey(property);
|
||||
}
|
||||
|
||||
private void CheckNull()
|
||||
{
|
||||
if (_buttonConfirm == null || _clockPresenter == null || _calendarPresenter == null) throw new Exception();
|
||||
}
|
||||
|
||||
private void ButtonConfirm_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SelectedDateTime = DisplayDateTime;
|
||||
Confirmed?.Invoke();
|
||||
}
|
||||
|
||||
private void InitCalendarAndClock()
|
||||
{
|
||||
_clock = new Clock
|
||||
{
|
||||
BorderThickness = new Thickness(),
|
||||
Background = Brushes.Transparent
|
||||
};
|
||||
TitleElement.SetBackground(_clock, Brushes.Transparent);
|
||||
_clock.DisplayTimeChanged += Clock_DisplayTimeChanged;
|
||||
|
||||
_calendar = new Calendar
|
||||
{
|
||||
BorderThickness = new Thickness(),
|
||||
Background = Brushes.Transparent,
|
||||
Focusable = false
|
||||
};
|
||||
TitleElement.SetBackground(_calendar, Brushes.Transparent);
|
||||
_calendar.SelectedDatesChanged += Calendar_SelectedDatesChanged;
|
||||
}
|
||||
|
||||
private void Calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Mouse.Capture(null);
|
||||
UpdateDisplayTime();
|
||||
}
|
||||
|
||||
private void Clock_DisplayTimeChanged(object sender, FunctionEventArgs<DateTime> e) => UpdateDisplayTime();
|
||||
|
||||
private void UpdateDisplayTime()
|
||||
{
|
||||
if (_calendar.SelectedDate != null)
|
||||
{
|
||||
var date = _calendar.SelectedDate.Value;
|
||||
var time = _clock.DisplayTime;
|
||||
|
||||
var result = new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);
|
||||
SetValueNoCallback(DisplayDateTimeProperty, result);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
[TemplatePart(Name = ElementButtonAm, Type = typeof(RadioButton))]
|
||||
@@ -61,8 +60,6 @@ namespace HandyControl.Controls
|
||||
|
||||
private int _secValue;
|
||||
|
||||
private bool _isLoaded;
|
||||
|
||||
private bool _appliedTemplate;
|
||||
|
||||
#endregion Data
|
||||
@@ -79,22 +76,12 @@ namespace HandyControl.Controls
|
||||
remove => RemoveHandler(SelectedTimeChangedEvent, value);
|
||||
}
|
||||
|
||||
public event EventHandler<FunctionEventArgs<DateTime?>> DisplayTimeChanged;
|
||||
public event EventHandler<FunctionEventArgs<DateTime>> DisplayTimeChanged;
|
||||
|
||||
public event Action Confirmed;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
public Clock()
|
||||
{
|
||||
Loaded += (s, e) =>
|
||||
{
|
||||
if (_isLoaded) return;
|
||||
_isLoaded = true;
|
||||
DisplayTime = DateTime.Now;
|
||||
};
|
||||
}
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static readonly DependencyProperty SelectedTimeProperty = DependencyProperty.Register(
|
||||
@@ -104,6 +91,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
var ctl = (Clock)d;
|
||||
var v = (DateTime?)e.NewValue;
|
||||
ctl.DisplayTime = v ?? DateTime.Now;
|
||||
ctl.OnSelectedTimeChanged(new FunctionEventArgs<DateTime?>(SelectedTimeChangedEvent, ctl)
|
||||
{
|
||||
Info = v
|
||||
@@ -135,14 +123,14 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DisplayTimeProperty = DependencyProperty.Register(
|
||||
"DisplayTime", typeof(DateTime), typeof(Clock), new FrameworkPropertyMetadata(DateTime.MinValue, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnDisplayTimeChanged));
|
||||
"DisplayTime", typeof(DateTime), typeof(Clock), new FrameworkPropertyMetadata(DateTime.Now, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnDisplayTimeChanged));
|
||||
|
||||
private static void OnDisplayTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ctl = (Clock) d;
|
||||
var v = (DateTime) e.NewValue;
|
||||
ctl.Update(v);
|
||||
ctl.OnDisplayTimeChanged(new FunctionEventArgs<DateTime?>(v));
|
||||
ctl.OnDisplayTimeChanged(new FunctionEventArgs<DateTime>(v));
|
||||
}
|
||||
|
||||
public DateTime DisplayTime
|
||||
@@ -187,16 +175,31 @@ namespace HandyControl.Controls
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
_appliedTemplate = false;
|
||||
_buttonAm?.RemoveHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonAm_OnClick));
|
||||
_buttonPm?.RemoveHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonPm_OnClick));
|
||||
_buttonConfirm?.RemoveHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonConfirm_OnClick));
|
||||
_borderTitle?.RemoveHandler(MouseWheelEvent, new MouseWheelEventHandler(BorderTitle_OnMouseWheel));
|
||||
if (_buttonAm != null)
|
||||
{
|
||||
_buttonAm.Click -= ButtonAm_OnClick;
|
||||
}
|
||||
|
||||
if (_buttonPm != null)
|
||||
{
|
||||
_buttonPm.Click -= ButtonPm_OnClick;
|
||||
}
|
||||
|
||||
if (_buttonConfirm != null)
|
||||
{
|
||||
_buttonConfirm.Click -= ButtonConfirm_OnClick;
|
||||
}
|
||||
|
||||
if (_borderTitle != null)
|
||||
{
|
||||
_borderTitle.MouseWheel -= BorderTitle_OnMouseWheel;
|
||||
}
|
||||
|
||||
if (_canvas != null)
|
||||
{
|
||||
_canvas.RemoveHandler(MouseWheelEvent, new MouseWheelEventHandler(MyCanvas_OnMouseWheel));
|
||||
_canvas.RemoveHandler(ButtonBase.ClickEvent, new RoutedEventHandler(MyCanvas_OnClick));
|
||||
_canvas.RemoveHandler(MouseMoveEvent, new MouseEventHandler(MyCanvas_OnMouseMove));
|
||||
_canvas.MouseWheel -= Canvas_OnMouseWheel;
|
||||
_canvas.RemoveHandler(ButtonBase.ClickEvent, new RoutedEventHandler(Canvas_OnClick));
|
||||
_canvas.MouseMove -= Canvas_OnMouseMove;
|
||||
}
|
||||
|
||||
base.OnApplyTemplate();
|
||||
@@ -212,14 +215,14 @@ namespace HandyControl.Controls
|
||||
|
||||
CheckNull();
|
||||
|
||||
_buttonAm.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonAm_OnClick));
|
||||
_buttonPm.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonPm_OnClick));
|
||||
_buttonConfirm.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonConfirm_OnClick));
|
||||
_borderTitle.AddHandler(MouseWheelEvent, new MouseWheelEventHandler(BorderTitle_OnMouseWheel));
|
||||
_buttonAm.Click += ButtonAm_OnClick;
|
||||
_buttonPm.Click += ButtonPm_OnClick;
|
||||
_buttonConfirm.Click += ButtonConfirm_OnClick;
|
||||
_borderTitle.MouseWheel += BorderTitle_OnMouseWheel;
|
||||
|
||||
_canvas.AddHandler(MouseWheelEvent, new MouseWheelEventHandler(MyCanvas_OnMouseWheel));
|
||||
_canvas.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(MyCanvas_OnClick));
|
||||
_canvas.AddHandler(MouseMoveEvent, new MouseEventHandler(MyCanvas_OnMouseMove));
|
||||
_canvas.MouseWheel += Canvas_OnMouseWheel;
|
||||
_canvas.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(Canvas_OnClick));
|
||||
_canvas.MouseMove += Canvas_OnMouseMove;
|
||||
|
||||
_rotateTransformClock = new RotateTransform();
|
||||
_borderClock.RenderTransform = _rotateTransformClock;
|
||||
@@ -239,9 +242,14 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
_appliedTemplate = true;
|
||||
if (_isLoaded)
|
||||
if (SelectedTime.HasValue)
|
||||
{
|
||||
Update(SelectedTime ?? DisplayTime);
|
||||
Update(SelectedTime.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayTime = DateTime.Now;
|
||||
Update(DisplayTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +259,7 @@ namespace HandyControl.Controls
|
||||
|
||||
protected virtual void OnSelectedTimeChanged(FunctionEventArgs<DateTime?> e) => RaiseEvent(e);
|
||||
|
||||
protected virtual void OnDisplayTimeChanged(FunctionEventArgs<DateTime?> e)
|
||||
protected virtual void OnDisplayTimeChanged(FunctionEventArgs<DateTime> e)
|
||||
{
|
||||
var handler = DisplayTimeChanged;
|
||||
handler?.Invoke(this, e);
|
||||
@@ -284,7 +292,7 @@ namespace HandyControl.Controls
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void MyCanvas_OnMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
private void Canvas_OnMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
var value = (int)_rotateTransformClock.Angle;
|
||||
if (e.Delta < 0)
|
||||
@@ -305,7 +313,7 @@ namespace HandyControl.Controls
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void MyCanvas_OnClick(object sender, RoutedEventArgs e)
|
||||
private void Canvas_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_currentButton = e.OriginalSource as ClockRadioButton;
|
||||
if (_currentButton != null)
|
||||
@@ -314,7 +322,7 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void MyCanvas_OnMouseMove(object sender, MouseEventArgs e)
|
||||
private void Canvas_OnMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
@@ -359,7 +367,7 @@ namespace HandyControl.Controls
|
||||
/// 更新
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
private void Update(DateTime time)
|
||||
internal void Update(DateTime time)
|
||||
{
|
||||
if (!_appliedTemplate) return;
|
||||
var h = time.Hour;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -43,17 +43,20 @@
|
||||
<Compile Include="Controls\Attach\PasswordBoxMonitor.cs" />
|
||||
<Compile Include="Controls\Attach\StatusSwitchElement.cs" />
|
||||
<Compile Include="Controls\Attach\TipElement.cs" />
|
||||
<Compile Include="Controls\Attach\TitleElement.cs" />
|
||||
<Compile Include="Controls\Button\ContextMenuButton.cs" />
|
||||
<Compile Include="Controls\Button\ContextMenuToggleButton.cs" />
|
||||
<Compile Include="Controls\Carousel.cs" />
|
||||
<Compile Include="Controls\CirclePanel.cs" />
|
||||
<Compile Include="Controls\CircleProgressBar.cs" />
|
||||
<Compile Include="Controls\Clock\Clock.cs" />
|
||||
<Compile Include="Controls\Clock\ClockRadioButton.cs" />
|
||||
<Compile Include="Controls\Time\CalendarWithClock.cs" />
|
||||
<Compile Include="Controls\Time\Clock\Clock.cs" />
|
||||
<Compile Include="Controls\Time\Clock\ClockRadioButton.cs" />
|
||||
<Compile Include="Controls\Growl.cs" />
|
||||
<Compile Include="Controls\ImageViewer.cs" />
|
||||
<Compile Include="Controls\Input\ComboBox.cs" />
|
||||
<Compile Include="Controls\Input\DatePicker.cs" />
|
||||
<Compile Include="Controls\Input\DateTimePicker.cs" />
|
||||
<Compile Include="Controls\Input\IDataInput.cs" />
|
||||
<Compile Include="Controls\Input\PasswordBox.cs" />
|
||||
<Compile Include="Controls\Input\TextBox.cs" />
|
||||
@@ -121,9 +124,9 @@
|
||||
<Compile Include="Controls\TabControl\TabControl.cs" />
|
||||
<Compile Include="Controls\TabControl\TabItem.cs" />
|
||||
<Compile Include="Controls\TabControl\TabPanel.cs" />
|
||||
<Compile Include="Controls\TimeBar\SpeTextBlock.cs" />
|
||||
<Compile Include="Controls\Time\TimeBar\SpeTextBlock.cs" />
|
||||
<Compile Include="Controls\Input\TimePicker.cs" />
|
||||
<Compile Include="Controls\TimeBar\TimeBar.cs" />
|
||||
<Compile Include="Controls\Time\TimeBar\TimeBar.cs" />
|
||||
<Compile Include="Controls\TransitioningContentControl.cs" />
|
||||
<Compile Include="Controls\WatermarkTextBox.cs" />
|
||||
<Compile Include="Controls\Window\ImageBrowser.cs" />
|
||||
@@ -260,6 +263,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\DateTimePickerBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\LabelBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -356,6 +363,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\CalendarWithClock.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Carousel.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -392,6 +403,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\DateTimePicker.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Expander.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="../../Basic/Converters.xaml"/>
|
||||
<ResourceDictionary Source="../../Basic/Geometries.xaml"/>
|
||||
<ResourceDictionary Source="../Button.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="DateTimePickerBaseStyle" TargetType="controls:DateTimePicker">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="controls:BorderElement.CornerRadius" Value="4"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="Height" Value="30"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:DateTimePicker">
|
||||
<Border x:Name="templateRoot" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||
<Grid x:Name="PART_Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="1" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" Padding="5,6" Margin="0,0,0,1" x:Name="PART_TextBox" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="templateRoot" Value="0.4"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true"/>
|
||||
<Condition Property="IsOpen" Value="false" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryBorderBrush}"/>
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true"/>
|
||||
<Condition Property="IsOpen" Value="true" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsFocused" Value="true" SourceName="PART_TextBox">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsOpen" Value="True" SourceName="PART_Popup">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="DateTimePickerExtendTopTemplate" TargetType="controls:DateTimePicker">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Path=(controls:InfoElement.ContentHeight),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Visibility="{Binding Path=(controls:InfoElement.Title),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource String2VisibilityConverter}}" Orientation="Horizontal" Margin="7,4">
|
||||
<TextBlock Margin="1,0,0,0" Text="{Binding Path=(controls:InfoElement.Title),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<ContentPresenter TextElement.Foreground="{DynamicResource DangerBrush}" Margin="4,0,0,0" Content="{Binding Path=(controls:InfoElement.Symbol),RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding Path=(controls:InfoElement.Necessary),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
</StackPanel>
|
||||
<Border Grid.Row="1" x:Name="templateRoot" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||
<Grid x:Name="PART_Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="1" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" x:Name="PART_TextBox" Padding="5,6" Margin="0,0,0,1" Watermark="{Binding Path=(controls:InfoElement.Placeholder),RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="templateRoot" Value="0.4"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="IsOpen" Value="false" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryBorderBrush}"/>
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="IsOpen" Value="true" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsFocused" Value="true" SourceName="PART_TextBox">
|
||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsOpen" Value="True" SourceName="PART_Popup">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="DateTimePickerExtendLeftTemplate" TargetType="controls:DateTimePicker">
|
||||
<Grid Height="{Binding Path=(controls:InfoElement.ContentHeight),RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding Path=(controls:InfoElement.TitleWidth),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Visibility="{Binding Path=(controls:InfoElement.Title),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource String2VisibilityConverter}}" Orientation="Horizontal" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="0,7,6,8">
|
||||
<TextBlock Text="{Binding Path=(controls:InfoElement.Title),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<ContentPresenter TextElement.Foreground="{DynamicResource DangerBrush}" Margin="4,0,0,0" Content="{Binding Path=(controls:InfoElement.Symbol),RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding Path=(controls:InfoElement.Necessary),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
</StackPanel>
|
||||
<Border Grid.Column="1" x:Name="templateRoot" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||
<Grid x:Name="PART_Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="1" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" x:Name="PART_TextBox" Padding="5,6" Margin="0,0,0,1" Watermark="{Binding Path=(controls:InfoElement.Placeholder),RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="templateRoot" Value="0.4"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="IsOpen" Value="false" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryBorderBrush}"/>
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="IsOpen" Value="true" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsFocused" Value="true" SourceName="PART_TextBox">
|
||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsOpen" Value="True" SourceName="PART_Popup">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="DateTimePickerExtendBaseStyle" BasedOn="{StaticResource DateTimePickerBaseStyle}" TargetType="controls:DateTimePicker">
|
||||
<Setter Property="Height" Value="{x:Static system:Double.NaN}"/>
|
||||
<Setter Property="Padding" Value="7,6"/>
|
||||
<Setter Property="controls:InfoElement.Symbol" Value="●"/>
|
||||
<Setter Property="Template" Value="{StaticResource DateTimePickerExtendTopTemplate}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="controls:InfoElement.TitleAlignment" Value="Left">
|
||||
<Setter Property="Template" Value="{StaticResource DateTimePickerExtendLeftTemplate}"/>
|
||||
<Setter Property="Width" Value="{x:Static system:Double.NaN}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="DateTimePickerPlusTopTemplate" TargetType="controls:DateTimePicker">
|
||||
<ControlTemplate.Resources>
|
||||
<Storyboard x:Key="StoryboardShow">
|
||||
<ThicknessAnimation Storyboard.TargetName="TextBlockError" Storyboard.TargetProperty="Margin" To="8,0,0,-18" Duration="0:0:.2"/>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="StoryboardHidden">
|
||||
<ThicknessAnimation Storyboard.TargetName="TextBlockError" Storyboard.TargetProperty="Margin" To="8,0,0,4" Duration="0:0:0"/>
|
||||
</Storyboard>
|
||||
</ControlTemplate.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Path=(controls:InfoElement.ContentHeight),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Visibility="{Binding Path=(controls:InfoElement.Title),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource String2VisibilityConverter}}" Orientation="Horizontal" Margin="7,4">
|
||||
<TextBlock Margin="1,0,0,0" Text="{Binding Path=(controls:InfoElement.Title),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<ContentPresenter TextElement.Foreground="{DynamicResource DangerBrush}" Margin="4,0,0,0" Content="{Binding Path=(controls:InfoElement.Symbol),RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding Path=(controls:InfoElement.Necessary),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="1" Text="{TemplateBinding ErrorStr}" Name="TextBlockError" VerticalAlignment="Bottom" Margin="8,0,0,4" Foreground="{DynamicResource DangerBrush}"/>
|
||||
<Border Grid.Row="1" x:Name="templateRoot" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||
<Grid x:Name="PART_Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="25"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Command="interactivity:ControlCommands.Clear" Visibility="Collapsed" Name="ButtonClear" Width="16" Grid.Column="1" Style="{StaticResource ButtonIcon}" Padding="0,6" controls:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}" Foreground="{Binding BorderBrush,ElementName=templateRoot}"/>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="2,7,7,7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="2" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" x:Name="PART_TextBox" Padding="5,6" Margin="0,0,0,1" Watermark="{Binding Path=(controls:InfoElement.Placeholder),RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="templateRoot" Value="0.4"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="IsOpen" Value="false" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryBorderBrush}"/>
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="IsOpen" Value="true" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="ShowClearButton" Value="True"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Visibility" Value="Visible" TargetName="ButtonClear"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsFocused" Value="true" SourceName="PART_TextBox">
|
||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsOpen" Value="True" SourceName="PART_Popup">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsError" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource DangerBrush}"/>
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource StoryboardShow}"/>
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource StoryboardHidden}"/>
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="DateTimePickerPlusLeftTemplate" TargetType="controls:DateTimePicker">
|
||||
<ControlTemplate.Resources>
|
||||
<Storyboard x:Key="StoryboardShow">
|
||||
<ThicknessAnimation Storyboard.TargetName="TextBlockError" Storyboard.TargetProperty="Margin" To="8,0,0,-18" Duration="0:0:.2"/>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="StoryboardHidden">
|
||||
<ThicknessAnimation Storyboard.TargetName="TextBlockError" Storyboard.TargetProperty="Margin" To="8,0,0,4" Duration="0:0:0"/>
|
||||
</Storyboard>
|
||||
</ControlTemplate.Resources>
|
||||
<Grid Height="{Binding Path=(controls:InfoElement.ContentHeight),RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding Path=(controls:InfoElement.TitleWidth),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Visibility="{Binding Path=(controls:InfoElement.Title),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource String2VisibilityConverter}}" Orientation="Horizontal" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="0,7,6,8">
|
||||
<TextBlock Text="{Binding Path=(controls:InfoElement.Title),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<ContentPresenter TextElement.Foreground="{DynamicResource DangerBrush}" Margin="4,0,0,0" Content="{Binding Path=(controls:InfoElement.Symbol),RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding Path=(controls:InfoElement.Necessary),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Text="{TemplateBinding ErrorStr}" Name="TextBlockError" VerticalAlignment="Bottom" Margin="8,0,0,4" Foreground="{DynamicResource DangerBrush}" Grid.Column="1"/>
|
||||
<Border Grid.Column="1" x:Name="templateRoot" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||
<Grid x:Name="PART_Root" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="25"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Command="interactivity:ControlCommands.Clear" Visibility="Collapsed" Name="ButtonClear" Width="16" Grid.Column="1" Style="{StaticResource ButtonIcon}" Padding="0,6" controls:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}" Foreground="{Binding BorderBrush,ElementName=templateRoot}"/>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="2,7,7,7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="2" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" x:Name="PART_TextBox" Padding="5,6" Margin="0,0,0,1" Watermark="{Binding Path=(controls:InfoElement.Placeholder),RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="templateRoot" Value="0.4"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="IsOpen" Value="false" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryBorderBrush}"/>
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="IsOpen" Value="true" SourceName="PART_Popup"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</MultiTrigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="true" SourceName="templateRoot"/>
|
||||
<Condition Property="ShowClearButton" Value="True"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Visibility" Value="Visible" TargetName="ButtonClear"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsFocused" Value="true" SourceName="PART_TextBox">
|
||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsOpen" Value="True" SourceName="PART_Popup">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsError" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{DynamicResource DangerBrush}"/>
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource StoryboardShow}"/>
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource StoryboardHidden}"/>
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="DateTimePickerPlusBaseStyle" BasedOn="{StaticResource DateTimePickerExtendBaseStyle}" TargetType="controls:DateTimePicker">
|
||||
<Setter Property="Template" Value="{StaticResource DateTimePickerPlusTopTemplate}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="controls:InfoElement.TitleAlignment" Value="Left">
|
||||
<Setter Property="Template" Value="{StaticResource DateTimePickerPlusLeftTemplate}"/>
|
||||
<Setter Property="Width" Value="{x:Static system:Double.NaN}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -29,9 +29,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="1" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" Padding="5,6" Margin="0,0,0,1" x:Name="PART_TextBox" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False">
|
||||
<controls:Clock x:Name="PART_Clock" ShowConfirmButton="True"/>
|
||||
</Popup>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
@@ -82,9 +80,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="1" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" x:Name="PART_TextBox" Padding="5,6" Margin="0,0,0,1" Watermark="{Binding Path=(controls:InfoElement.Placeholder),RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False">
|
||||
<controls:Clock x:Name="PART_Clock" ShowConfirmButton="True"/>
|
||||
</Popup>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
@@ -133,9 +129,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="1" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" x:Name="PART_TextBox" Padding="5,6" Margin="0,0,0,1" Watermark="{Binding Path=(controls:InfoElement.Placeholder),RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False">
|
||||
<controls:Clock x:Name="PART_Clock" ShowConfirmButton="True"/>
|
||||
</Popup>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
@@ -208,9 +202,7 @@
|
||||
<Button Command="interactivity:ControlCommands.Clear" Visibility="Collapsed" Name="ButtonClear" Width="16" Grid.Column="1" Style="{StaticResource ButtonIcon}" Padding="0,6" controls:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}" Foreground="{Binding BorderBrush,ElementName=templateRoot}"/>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="2,7,7,7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="2" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" x:Name="PART_TextBox" Padding="5,6" Margin="0,0,0,1" Watermark="{Binding Path=(controls:InfoElement.Placeholder),RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False">
|
||||
<controls:Clock x:Name="PART_Clock" ShowConfirmButton="True"/>
|
||||
</Popup>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
@@ -286,9 +278,7 @@
|
||||
<Button Command="interactivity:ControlCommands.Clear" Visibility="Collapsed" Name="ButtonClear" Width="16" Grid.Column="1" Style="{StaticResource ButtonIcon}" Padding="0,6" controls:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}" Foreground="{Binding BorderBrush,ElementName=templateRoot}"/>
|
||||
<Button Style="{StaticResource ButtonIcon}" Padding="2,7,7,7" controls:IconElement.Geometry="{StaticResource ClockGeometry}" x:Name="PART_Button" Grid.Column="2" Foreground="{Binding BorderBrush,ElementName=templateRoot}" Focusable="False" Grid.Row="0"/>
|
||||
<controls:WatermarkTextBox CaretBrush="{TemplateBinding Foreground}" x:Name="PART_TextBox" Padding="5,6" Margin="0,0,0,1" Watermark="{Binding Path=(controls:InfoElement.Placeholder),RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Grid.Row="0" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False">
|
||||
<controls:Clock x:Name="PART_Clock" ShowConfirmButton="True"/>
|
||||
</Popup>
|
||||
<Popup Grid.Column="0" VerticalOffset="1" x:Name="PART_Popup" PopupAnimation="Fade" Placement="Bottom" PlacementTarget="{Binding ElementName=PART_TextBox}" StaysOpen="False"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="CalendarDayButtonStyle" TargetType="CalendarDayButton">
|
||||
<Setter Property="MinWidth" Value="10"/>
|
||||
<Setter Property="MinHeight" Value="10"/>
|
||||
@@ -139,6 +140,7 @@
|
||||
|
||||
<Style TargetType="CalendarItem">
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
<Setter Property="Focusable" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="CalendarItem">
|
||||
@@ -170,9 +172,9 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Background="{DynamicResource TitleBrush}" Grid.ColumnSpan="3"/>
|
||||
<Border Background="{Binding Path=(controls:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" Grid.ColumnSpan="3"/>
|
||||
<Button x:Name="PART_PreviousButton" Width="50" HorizontalAlignment="Left" Grid.Column="0" Height="50" Padding="16" Focusable="False" Grid.Row="0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource LeftGeometry}"/>
|
||||
<Button x:Name="PART_HeaderButton" Foreground="White" Grid.Column="1" FontWeight="Bold" FontSize="16" HorizontalAlignment="Center" Grid.Row="0" Style="{StaticResource ButtonCustom}"/>
|
||||
<Button x:Name="PART_HeaderButton" Foreground="White" Grid.Column="1" FontSize="20" HorizontalAlignment="Center" Grid.Row="0" Style="{StaticResource ButtonCustom}"/>
|
||||
<Button x:Name="PART_NextButton" Width="50" HorizontalAlignment="Right" Height="50" Padding="16" Grid.Column="2" Focusable="False" Grid.Row="0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource RightGeometry}"/>
|
||||
<Grid Width="240" Height="240" x:Name="PART_MonthView" Margin="10" Grid.ColumnSpan="3" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" Visibility="Visible">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -233,6 +235,7 @@
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="CalendarDayButtonStyle" Value="{StaticResource CalendarDayButtonStyle}"/>
|
||||
<Setter Property="CalendarButtonStyle" Value="{StaticResource CalendarButtonStyle}"/>
|
||||
<Setter Property="controls:TitleElement.Background" Value="{DynamicResource TitleBrush}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Calendar">
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls"
|
||||
xmlns:langs="clr-namespace:HandyControl.Properties.Langs">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="../Basic/Converters.xaml"/>
|
||||
<ResourceDictionary Source="Button.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="controls:CalendarWithClock">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="controls:TitleElement.Background" Value="{DynamicResource TitleBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="ShowConfirmButton" Value="True"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:CalendarWithClock">
|
||||
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.ColumnSpan="2" Grid.Row="0" Height="50" VerticalAlignment="Top" Background="{Binding Path=(controls:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<ContentPresenter Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" x:Name="PART_CalendarPresenter"/>
|
||||
<ContentPresenter Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" x:Name="PART_ClockPresenter"/>
|
||||
<Button Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Visibility="{TemplateBinding ShowConfirmButton,Converter={StaticResource Boolean2VisibilityConverter}}" Name="PART_ButtonConfirm" Content="{x:Static langs:Lang.Confirm}" HorizontalAlignment="Center" Margin="0,0,0,19" Width="180" VerticalAlignment="Bottom" Style="{StaticResource ButtonPrimary}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -61,22 +61,23 @@
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||
<Setter Property="Width" Value="210"/>
|
||||
<Setter Property="Height" Value="290"/>
|
||||
<Setter Property="Height" Value="310"/>
|
||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="ClockRadioButtonStyle" Value="{StaticResource ClockRadioButtonStyle}"/>
|
||||
<Setter Property="controls:TitleElement.Background" Value="{DynamicResource TitleBrush}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:Clock">
|
||||
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Background="{DynamicResource TitleBrush}" Name="PART_BorderTitle">
|
||||
<TextBlock x:Name="PART_TimeStr" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="30" Foreground="White"/>
|
||||
<Border Background="{Binding Path=(controls:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" Name="PART_BorderTitle">
|
||||
<TextBlock x:Name="PART_TimeStr" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" Foreground="White"/>
|
||||
</Border>
|
||||
<Border Grid.Row="1" Background="{TemplateBinding Background}">
|
||||
<Grid>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Base/DateTimePickerBaseStyle.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style BasedOn="{StaticResource DateTimePickerBaseStyle}" TargetType="controls:DateTimePicker"/>
|
||||
|
||||
<Style x:Key="DateTimePickerExtend" BasedOn="{StaticResource DateTimePickerExtendBaseStyle}" TargetType="controls:DateTimePicker"/>
|
||||
|
||||
<Style x:Key="DateTimePickerPlus" BasedOn="{StaticResource DateTimePickerPlusBaseStyle}" TargetType="controls:DateTimePicker"/>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -38,6 +38,8 @@
|
||||
<ResourceDictionary Source="Image.xaml"/>
|
||||
<ResourceDictionary Source="Label.xaml"/>
|
||||
<ResourceDictionary Source="ImageViewer.xaml"/>
|
||||
<ResourceDictionary Source="CalendarWithClock.xaml"/>
|
||||
<ResourceDictionary Source="DateTimePicker.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -46,6 +46,10 @@
|
||||
|
||||
public static readonly string DatePickerDemoCtl = nameof(DatePickerDemoCtl);
|
||||
|
||||
public static readonly string DateTimePickerDemoCtl = nameof(DateTimePickerDemoCtl);
|
||||
|
||||
public static readonly string CalendarWithClockDemoCtl = nameof(CalendarWithClockDemoCtl);
|
||||
|
||||
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
|
||||
|
||||
public static readonly string ToggleButtonDemoCtl = nameof(ToggleButtonDemoCtl);
|
||||
|
||||
@@ -25,7 +25,9 @@ var controlList = new List<string>
|
||||
"TextBoxDemoCtl",
|
||||
"ComboBoxDemoCtl",
|
||||
"PasswordBoxDemoCtl",
|
||||
"DatePickerDemoCtl"
|
||||
"DatePickerDemoCtl",
|
||||
"DateTimePickerDemoCtl",
|
||||
"CalendarWithClockDemoCtl"
|
||||
};
|
||||
var styleList = new List<string>
|
||||
{
|
||||
|
||||
@@ -99,6 +99,9 @@
|
||||
<Compile Include="UserControl\Controls\AnimationPathDemoCtl.xaml.cs">
|
||||
<DependentUpon>AnimationPathDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Controls\CalendarWithClockDemoCtl.xaml.cs">
|
||||
<DependentUpon>CalendarWithClockDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Controls\CarouselDemoCtl.xaml.cs">
|
||||
<DependentUpon>CarouselDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -123,6 +126,9 @@
|
||||
<Compile Include="UserControl\Controls\DatePickerDemoCtl.xaml.cs">
|
||||
<DependentUpon>DatePickerDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Controls\DateTimePickerDemoCtl.xaml.cs">
|
||||
<DependentUpon>DateTimePickerDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UserControl\Controls\GrowlDemoCtl.xaml.cs">
|
||||
<DependentUpon>GrowlDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -319,6 +325,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\Controls\CalendarWithClockDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\Controls\CarouselDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -351,6 +361,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="UserControl\Controls\DateTimePickerDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="UserControl\Controls\GrowlDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
+19
-1
@@ -47,7 +47,7 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用此强类型资源类,为所有资源查找
|
||||
/// 重写当前线程的 CurrentUICulture 属性
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
@@ -150,6 +150,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 带时钟的日历 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string CalendarWithClock {
|
||||
get {
|
||||
return ResourceManager.GetString("CalendarWithClock", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 轮播 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -312,6 +321,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 日期时间选择器 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string DateTimePicker {
|
||||
get {
|
||||
return ResourceManager.GetString("DateTimePicker", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 默认 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -399,4 +399,10 @@
|
||||
<data name="Step" xml:space="preserve">
|
||||
<value>Step</value>
|
||||
</data>
|
||||
<data name="CalendarWithClock" xml:space="preserve">
|
||||
<value>CalendarWithClock</value>
|
||||
</data>
|
||||
<data name="DateTimePicker" xml:space="preserve">
|
||||
<value>DateTimePicker</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -379,4 +379,10 @@
|
||||
<data name="Step" xml:space="preserve">
|
||||
<value>步骤</value>
|
||||
</data>
|
||||
<data name="CalendarWithClock" xml:space="preserve">
|
||||
<value>带时钟的日历</value>
|
||||
</data>
|
||||
<data name="DateTimePicker" xml:space="preserve">
|
||||
<value>日期时间选择器</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,9 @@
|
||||
<UserControl x:Class="HandyControlDemo.UserControl.CalendarWithClockDemoCtl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl">
|
||||
<controls:TransitioningContentControl>
|
||||
<controls:CalendarWithClock Margin="32"/>
|
||||
</controls:TransitioningContentControl>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class CalendarWithClockDemoCtl
|
||||
{
|
||||
public CalendarWithClockDemoCtl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||
Background="White">
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<controls:TransitioningContentControl>
|
||||
<StackPanel Margin="32">
|
||||
<controls:DatePicker ShowClearButton="True" SelectedDate="{x:Static system:DateTime.Now}"/>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<UserControl x:Class="HandyControlDemo.UserControl.DateTimePickerDemoCtl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<controls:TransitioningContentControl>
|
||||
<StackPanel Margin="32" Orientation="Horizontal">
|
||||
<StackPanel>
|
||||
<controls:DateTimePicker ShowClearButton="True"/>
|
||||
<controls:DateTimePicker Margin="0,16,0,0" IsEnabled="False"/>
|
||||
|
||||
<controls:DateTimePicker ShowClearButton="True" Style="{StaticResource DateTimePickerExtend}" controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr1}" Margin="0,32,0,0"/>
|
||||
<controls:DateTimePicker controls:InfoElement.Placeholder="{x:Static langs:Lang.PlsEnterContent}" controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr2}" Style="{StaticResource DateTimePickerExtend}" controls:InfoElement.Necessary="True" Margin="0,16,0,0"/>
|
||||
|
||||
<controls:DateTimePicker ShowClearButton="True" Width="380" controls:InfoElement.TitleWidth="140" controls:InfoElement.TitleAlignment="Left" Style="{StaticResource DateTimePickerExtend}" controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr3}" Margin="0,32,0,0"/>
|
||||
<controls:DateTimePicker Width="380" controls:InfoElement.TitleWidth="140" controls:InfoElement.TitleAlignment="Left" controls:InfoElement.Placeholder="{x:Static langs:Lang.PlsEnterContent}" controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr3}" Style="{StaticResource DateTimePickerExtend}" controls:InfoElement.Necessary="True" Margin="0,16,0,0"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="32,0,0,0">
|
||||
<controls:DateTimePicker ShowClearButton="True" Style="{StaticResource DateTimePickerPlus}"/>
|
||||
<controls:DateTimePicker Margin="0,16,0,0" IsEnabled="False" Style="{StaticResource DateTimePickerPlus}"/>
|
||||
|
||||
<controls:DateTimePicker ShowClearButton="True" Style="{StaticResource DateTimePickerPlus}" controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr1}" Margin="0,32,0,0"/>
|
||||
<controls:DateTimePicker controls:InfoElement.Placeholder="{x:Static langs:Lang.PlsEnterContent}" controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr2}" Style="{StaticResource DateTimePickerPlus}" controls:InfoElement.Necessary="True" Margin="0,16,0,0"/>
|
||||
|
||||
<controls:DateTimePicker ShowClearButton="True" Width="380" controls:InfoElement.TitleWidth="140" controls:InfoElement.TitleAlignment="Left" Style="{StaticResource DateTimePickerPlus}" controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr3}" Margin="0,32,0,0"/>
|
||||
<controls:DateTimePicker Width="380" controls:InfoElement.TitleWidth="140" controls:InfoElement.TitleAlignment="Left" controls:InfoElement.Placeholder="{x:Static langs:Lang.PlsEnterContent}" controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr3}" Style="{StaticResource DateTimePickerPlus}" controls:InfoElement.Necessary="True" Margin="0,16,0,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</controls:TransitioningContentControl>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class DateTimePickerDemoCtl
|
||||
{
|
||||
public DateTimePickerDemoCtl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControlDemo.UserControl
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// TimePickerDemoCtl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class TimePickerDemoCtl
|
||||
{
|
||||
public TimePickerDemoCtl()
|
||||
|
||||
@@ -144,16 +144,31 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/PasswordBox_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.DatePickerDemoCtl}" Content="{x:Static langs:Lang.DatePicker}">
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.DatePickerDemoCtl}" Content="{x:Static langs:Lang.DatePicker}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/DatePicker_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.TimePickerDemoCtl}" Content="{x:Static langs:Lang.TimePicker}">
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.ClockDemoCtl}" Content="{x:Static langs:Lang.Clock}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/Time_color_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.TimePickerDemoCtl}" Content="{x:Static langs:Lang.TimePicker}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/TimePicker_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.CalendarWithClockDemoCtl}" Content="{x:Static langs:Lang.CalendarWithClock}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/Calendar_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.DateTimePickerDemoCtl}" Content="{x:Static langs:Lang.DateTimePicker}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/DatePicker_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.CirclePanelDemoCtl}" Content="{x:Static langs:Lang.CirclePanel}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/ColorWheel_16x.png"/>
|
||||
@@ -164,11 +179,6 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/ShapeArcRing_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.ClockDemoCtl}" Content="{x:Static langs:Lang.Clock}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/Time_color_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.StepBarDemoCtl}" Content="{x:Static langs:Lang.StepBar}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/Flow_16x.png"/>
|
||||
|
||||
Reference in new issue
Block a user