Beispiel #1
0
        public static void Show(Action <bool> callback)
        {
            var control = new SelectCheckerTypeView();
            var dialog  = new DialogView(control);

            dialog.ShowUnderCursor = true;
            control.Selected      += (result) => {
                callback?.Invoke(result);
                dialog.Close();
            };
            dialog.Show();
        }
 public void AddFirst()
 {
     SelectCheckerTypeView.Show((isGroup) => {
         CheckerOperatorPair operatorPair = new CheckerOperatorPair();
         if (isGroup)
         {
             operatorPair.Checker = new ComplexCheckerAction();
         }
         _action.CheckerOperations.Insert(0, operatorPair);
         Insert(operatorPair, 0);
         Modified?.Invoke(this);
     });
 }
        private void Insert(CheckerOperatorPair operatorPair, int position = -1)
        {
            if (position == -1)
            {
                position = Children.Count;
            }
            FrameworkElement control = null;

            if (operatorPair.Checker is CheckerAction)
            {
                control = new CheckerOperatorPairView();
            }
            else if (operatorPair.Checker is ComplexCheckerAction)
            {
                control = new ComplexCheckerOperatorPairView();
            }
            var constructorElement = ((IConstructorElement)control);

            control.Margin = new Thickness(0, 1, 0, 0);
            constructorElement.Refresh(new ActionHolder(operatorPair), AlgorithmContext);
            constructorElement.Modified   += (element) => Modified?.Invoke(element);
            constructorElement.NeedRemove += (element) => {
                _action.CheckerOperations.Remove(operatorPair);
                Children.Remove(control);
                Modified?.Invoke(this);
                MakeFirstRowOperatorInvisible();
            };
            constructorElement.NeedAddNext += (element) => {
                SelectCheckerTypeView.Show((isGroup) => {
                    var index = Children.IndexOf(control) + 1;
                    CheckerOperatorPair newOperatorPair = new CheckerOperatorPair();
                    if (isGroup)
                    {
                        newOperatorPair.Checker = new ComplexCheckerAction();
                    }
                    _action.CheckerOperations.Insert(index, newOperatorPair);
                    Insert(newOperatorPair, index);
                    Modified?.Invoke(this);
                });
            };
            Children.Insert(position, control);
            MakeFirstRowOperatorInvisible();
        }