Esempio n. 1
0
 public void BeginEditAction()
 {
     try
     {
         ActionControlResolver.UserInitialize(
             (result) =>
         {
             if (result)
             {
                 Model.Refresh(ActionHolder);
                 Modified?.Invoke(this);
                 if (MasterAction != null && MasterAction.ValueType.GetType() != ActionHolder.Action.ValueType.GetType())
                 {
                     MessageView.ShowMessage(
                         "Тип действия не совпадает с типом главного действия. Нужно настроить подчиненное действие еще раз.",
                         "Внимание!",
                         Icons.Icon.WarningCircle, null,
                         () => BeginEditAction()
                         );
                 }
             }
         },
             ActionHolder.Action,
             MasterAction?.ValueType,
             MasterAction != null,
             MasterAction);
     }
     catch (Exception e)
     {
         Log.Error("Ошибка во время настройки действия", e);
     }
 }
        private void Insert(ActionHolder actionHolder, int position = -1)
        {
            if (position == -1)
            {
                position = Children.Count;
            }
            var constructorElement = ActionControlResolver.Create(actionHolder, AlgorithmContext);
            var control            = ((FrameworkElement)constructorElement);

            control.Margin = new Thickness(0, 1, 0, 0);
            constructorElement.Refresh(actionHolder, AlgorithmContext);
            constructorElement.Modified   += (element) => Modified?.Invoke(element);
            constructorElement.NeedRemove += (element) => {
                _action.ActionHolders.Remove(actionHolder);
                Children.Remove(control);
                Modified?.Invoke(this);
            };
            constructorElement.NeedAddNext += (element) => {
                SelectCoreActionView.Show((type) => {
                    var index           = Children.IndexOf(control) + 1;
                    var newActionHolder = new ActionHolder()
                    {
                        Action = _manager.CreateInstance(type, AlgorithmContext)
                    };
                    _action.ActionHolders.Insert(index, newActionHolder);
                    Insert(newActionHolder, index);
                    Modified?.Invoke(this);
                });
            };
            Children.Insert(position, control);
        }
        public void BeginSelectAction()
        {
            ActionInstanceSide actionInstanceSide;

            if (AlgorithmContext is SingleActionScenario)
            {
                actionInstanceSide = ActionInstanceSide.Both;
            }
            else if (MasterAction == null)
            {
                actionInstanceSide = ActionInstanceSide.OnlyLeft;
            }
            else
            {
                actionInstanceSide = ActionInstanceSide.OnlyRight;
            }
            SelectActionView.Show(
                (type) => {
                var newAction = Singleton.Resolve <PluginsManager>().CreateInstance(type, AlgorithmContext);
                if (newAction != null)
                {
                    ActionControlResolver.UserInitialize(
                        (result) => {
                        if (result)
                        {
                            ActionHolder.Action = newAction;
                            Model.Refresh(ActionHolder);
                            Modified?.Invoke(this);

                            if (MasterAction != null && !MasterAction.ValueType.IsCompatibleWith(newAction.ValueType))
                            {
                                MessageView.ShowMessage(
                                    "Тип действия не совпадает с типом действия главного действия. Нужно настроить подчиненное действие еще раз.",
                                    "Внимание!",
                                    Icons.Icon.WarningCircle);
                            }
                        }
                    },
                        newAction,
                        MasterAction?.ValueType,
                        true,
                        MasterAction);
                }
            },
                MasterAction?.ValueType.GetType(),
                actionInstanceSide,
                ActionHolder?.Action.GetType());
        }
Esempio n. 4
0
 public void BeginSelectAction()
 {
     SelectActionView.Show(
         (type) =>
     {
         try
         {
             var newAction = Singleton.Resolve <PluginsManager>().CreateInstance(type, AlgorithmContext);
             if (newAction != null)
             {
                 ActionControlResolver.UserInitialize(
                     (result) =>
                 {
                     if (result)
                     {
                         ActionHolder.Action = newAction;
                         Model.Refresh(ActionHolder);
                         Modified?.Invoke(this);
                     }
                 },
                     newAction,
                     MasterAction?.ValueType,
                     true,
                     MasterAction);
                 if (MasterAction != null && MasterAction.ValueType.GetType() != newAction.ValueType.GetType())
                 {
                     MessageView.ShowMessage(
                         "Тип действия не совпадает с типом действия главного действия. Нужно настроить подчиненное действие еще раз.",
                         "Внимание!",
                         Icons.Icon.WarningCircle, null,
                         () =>
                     {
                         BeginSelectAction();
                     });
                 }
             }
         }
         catch (Exception e)
         {
             Log.Error("Ошибка во время настройки действия", e);
         }
     },
         MasterAction?.ValueType.GetType(),
         ActionInstanceSide.OnlyRight,
         ActionHolder?.Action.GetType());
 }
 public void BeginEditAction()
 {
     ActionControlResolver.UserInitialize(
         (result) => {
         if (result)
         {
             Model.Refresh(ActionHolder);
             Modified?.Invoke(this);
             if (MasterAction != null && !MasterAction.ValueType.IsCompatibleWith(ActionHolder.Action.ValueType))
             {
                 MessageView.ShowMessage(
                     "Тип действия не совпадает с типом главного действия. Нужно настроить подчиненное действие еще раз.",
                     "Внимание!",
                     Icons.Icon.WarningCircle, null,
                     () => BeginEditAction()
                     );
             }
         }
     },
         ActionHolder.Action,
         MasterAction?.ValueType,
         MasterAction != null,
         MasterAction);
 }