| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 | using InABox.Wpf;using System.Windows;namespace InABox.WPF{    /// <summary>    ///     Interaction logic for NumberEdit.xaml    /// </summary>    public partial class DoubleEdit : ThemableWindow    {        public DoubleEdit(string title, double min, double max, int decimals, double value)        {            InitializeComponent();            Title = title;            Value = value;            Editor.NumberDecimalDigits = decimals;            Editor.MinValue = min;            Editor.MaxValue = max;        }        public int DecimalPlaces        {            get => Editor.NumberDecimalDigits;            set => Editor.NumberDecimalDigits = value;        }                public double Value        {            get => Editor.Value.HasValue ? Editor.Value.Value : 0;            set => Editor.Value = value;        }        private void Confirm()        {            if (Editor.Value >= Editor.MinValue && Editor.Value <= Editor.MaxValue)            {                DialogResult = true;                Close();            }            else            {                MessageBox.Show($"Value must be in range [{Editor.MinValue}, {Editor.MaxValue}]");            }        }        private void OK_Click(object sender, RoutedEventArgs e)        {            Confirm();        }        private void Cancel_Click(object sender, RoutedEventArgs e)        {            DialogResult = false;            Close();        }        public static bool Execute(string title, double min, double max, int decimals, ref double value)        {            var edit = new DoubleEdit(title, min, max, decimals, value);            if (edit.ShowDialog() == true)            {                value = edit.Value;                return true;            }            return false;        }        private void ThemableWindow_Loaded(object sender, RoutedEventArgs e)        {            Editor.Focus();        }        private void Editor_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)        {            if(e.Key == System.Windows.Input.Key.Enter)            {                Confirm();            }        }    }}
 |