using Elwig.Helpers;
using System.Windows;
using System.Windows.Controls;

namespace Elwig.Dialogs {
    public partial class LinearPriceIncreaseDialog : Window {

        public double Price = 0.0;

        public LinearPriceIncreaseDialog() {
            InitializeComponent();
        }

        private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
            DialogResult = true;
            Price = double.Parse(PriceInput.Text.Replace(Utils.GroupSeparator, ""));
            Close();
        }

        private void UpdateButtons(ValidationResult res) {
            ConfirmButton.IsEnabled = res.IsValid;
        }

        private void PriceInput_TextChanged(object sender, TextChangedEventArgs evt) {
            var res = Validator.CheckDecimal(PriceInput, true, 2, 8);
            UpdateButtons(res);
        }
    }
}
