Exemplo n.º 1
0
        public AdditionalPartyCondtions()
        {
            InitializeComponent();
            Instance = this;

            this.Closed    += delegate { Instance = null; };
            this.MouseDown += delegate {
                try
                {
                    BindingExpression exp = ((TextBox)Keyboard.FocusedElement).GetBindingExpression(TextBox.TextProperty);
                    exp?.UpdateSource();
                    if (exp?.HasValidationError != null && (bool)exp?.HasValidationError)
                    {
                        ((TextBox)Keyboard.FocusedElement).Text = "0";
                    }

                    exp?.UpdateSource();
                    Keyboard.ClearFocus();
                }
                catch (Exception)
                {
                    // ignored
                }
            };
        }
        private void OpenAdditionalPartyConditions_ButtonClick(object sender, RoutedEventArgs e)
        {
            if (AdditionalPartyCondtions.Instance != null ||
                ((ViewModel)this.DataContext)?.SelectedBot?.Engine?.PartyHealBuffHandler?.SelectedRule == null)  //
            {
                return;
            }

            var unitsForm = new AdditionalPartyCondtions();

            unitsForm.DataContext = this.DataContext;
            Dispatcher.BeginInvoke((Action)(() => unitsForm.ShowDialog()));
        }