Example #1
0
        public AdditionalSelfCondtions()
        {
            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 OpenAdditionalSelfConditions_ButtonClick(object sender, RoutedEventArgs e)
        {
            if (AdditionalSelfCondtions.Instance != null ||
                ((ViewModel)this.DataContext)?.SelectedBot?.Engine?.SelfHealBuffHandler?.SelectedRule == null)  //
            {
                return;
            }

            var unitsForm = new AdditionalSelfCondtions();

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