using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;


namespace FLY.Thick.Base.UI
{
    /// <summary>
    /// Window_AHelper.xaml 的交互逻辑
    /// </summary>
    public partial class WdAHelper : FLY.ControlLibrary.WindowBigClose
    {
        private WdAHelperVm viewModel;
        public double A { get { return viewModel.A; } }
        private double a;
        public WdAHelper()
        {
            InitializeComponent();
            viewModel = new WdAHelperVm();
            this.DataContext = viewModel;
        }

        public void Init(double a)
        {
            this.a = a;
            viewModel.A = a;
        }

        private void button_cal_Click(object sender, RoutedEventArgs e)
        {
            if (viewModel.X == 0 || viewModel.Y == 0)
            {
                FLY.ControlLibrary.Window_WarningTip.Show("异常!!!!",
                    "X=0 或 Y=0",
                    TimeSpan.FromSeconds(2));
                return;
            }
            else if (a == 0)
            {
                FLY.ControlLibrary.Window_WarningTip.Show("异常!!!!",
                    "A==0",
                    TimeSpan.FromSeconds(2));
                return;
            }
            double x = (viewModel.X) / a;

            viewModel.A = viewModel.Y / x;
        }
        private void button_apply_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

    }

    public class WdAHelperVm : INotifyPropertyChanged
    {

        public double X { get; set; }
        public double Y { get; set; }

        public double A { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}