| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | using InABox.Wpf;using System;using System.Windows;using System.Windows.Controls.Primitives;namespace InABox.WPF{    /// <summary>    ///     Interaction logic for DateEdit.xaml    /// </summary>    public partial class DateEdit : ThemableWindow    {        public DateEdit(string title, DateTime value)        {            InitializeComponent();            Title = title;            Value = value;        }        public DateTime Value        {            get => Calendar.SelectedDate ?? DateTime.MinValue;            set => Calendar.SelectedDate = value;        }        private void OK_Click(object sender, RoutedEventArgs e)        {            DialogResult = true;            Close();        }        private void Cancel_Click(object sender, RoutedEventArgs e)        {            DialogResult = false;            Close();        }        public static bool Execute(string title, ref DateTime value)        {            var edit = new DateEdit(title, value);            if (edit.ShowDialog() == true)            {                value = edit.Value;                return true;            }            return false;        }        private void Calendar_GotMouseCapture(object sender, System.Windows.Input.MouseEventArgs e)        {            var originalElement = e.OriginalSource as UIElement;            if(originalElement is CalendarDayButton || originalElement is CalendarItem)            {                originalElement.ReleaseMouseCapture();            }        }    }}
 |