Пример #1
0
 public void SetTrigger(Lazurite.MainDomain.TriggerBase trigger, Action callback = null)
 {
     StuckUILoadingWindow.Show(
         "Компоновка окна...",
         () =>
     {
         if (trigger != null)
         {
             _originalTrigger = trigger;
             _clonedTrigger   = (Lazurite.MainDomain.TriggerBase)Lazurite.Windows.Utils.Utils.CloneObject(_originalTrigger);
             _clonedTrigger.Initialize();
             buttonsView.SetTrigger(_clonedTrigger);
             IsModified                 = false;
             _constructorView           = new TriggerView(_clonedTrigger);
             _constructorView.Modified += () => Modified?.Invoke();
             _constructorView.Modified += () => buttonsView.TriggerModified();
             _constructorView.Modified += () => IsModified = true;
             _constructorView.Failed   += () => buttonsView.Failed();
             _constructorView.Succeed  += () => buttonsView.Success();
             contentPresenter.Content   = _constructorView;
             EmptyTriggerModeOff();
         }
         else
         {
             EmptyTriggerModeOn();
         }
         callback?.Invoke();
     }
         );
 }
        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);
        }
Пример #3
0
        public bool LoadSVG(string fileName)
        {
            SvgScraper svgScraper = new SvgScraper();
            Size       svgSize;

            try
            {
                SvgDocument svgDocument = SvgDocument.Open(fileName);
                svgSize = new Size(svgScraper.GetWidth(svgDocument), svgScraper.GetHeight(svgDocument));
                svgDocument.Draw(svgScraper);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(false);
            }

            Drawing svgDrawing = svgScraper.CreateDrawing(new Rect(0.0, -svgSize.Height, svgSize.Width, svgSize.Height));

            FileName = fileName;
            Drawing  = svgDrawing;
            Size     = svgSize;
            Modified?.Invoke(this, null);

            return(true);
        }
Пример #4
0
 public void OnModified(bool newThread)
 {
     if (Modified != null)
     {
         Modified.Invoke(this, EventArgs.Empty);
     }
 }
Пример #5
0
        private void DirectionLayout_DragDrop(object sender, DragEventArgs e)
        {
            if (_panel_to_add == null)
            {
                return;
            }
            if (e.Data.GetDataPresent("Frame") || e.Data.GetDataPresent("ImageFrame"))
            {
                // commit to the removal of the frame from the dragged_from direction:
                if (_panel_to_add.Parent != null)
                {
                    DirectionLayout last_dir = ((DirectionLayout)_panel_to_add.Parent.Parent);
                    last_dir._direction.Frames.RemoveAt(last_dir._direction.Frames.IndexOf(_panel_to_add.Frame));
                }

                ImagesPanel.Controls.Add(_panel_to_add);

                Point      Location    = ImagesPanel.PointToClient(new Point(e.X, e.Y));
                FramePanel place_panel = (FramePanel)ImagesPanel.GetChildAtPoint(Location);
                ImagesPanel.Controls.SetChildIndex(_panel_to_add, ImagesPanel.Controls.IndexOf(place_panel));

                // and add the frame to the dragged_to direction:
                int pos = _direction.Frames.Count - (ImagesPanel.Controls.IndexOf(_panel_to_add));
                _direction.Frames.Insert(pos, _panel_to_add.Frame);

                _panel_to_add = null;
                Invalidate(true);
                Modified?.Invoke(this, new EventArgs());
            }
        }
Пример #6
0
 public override void OnEndUpdate(ItemBase updatedAttribute)
 {
     Modified?.Invoke(this);
     // clear selected solutions
     while (_selectedSolutions.Count > 0)
     {
         UnSelectSolution(_selectedSolutions[0]);
     }
     // clear solutions
     _solutions.Clear();
     // get default analysis solver
     if (null != _solver)
     {
         _solver.ProcessAnalysis(this);
     }
     else
     {
         _log.Error("_solver == null : solver was not set");
     }
     if (_solutions.Count == 0)
     {
         _log.Debug("Recomputed analysis has no solutions");
     }
     // set modified / propagate modifications
     Modify();
 }
Пример #7
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);
     }
 }
Пример #8
0
 public void ClearActions()
 {
     _actionManager.Clear();
     _dsmModel.ClearActions();
     IsModified = true;
     Modified?.Invoke(this, IsModified);
 }
 private void Initialize()
 {
     _actionView = new ActionView();
     _actionView.Refresh(Scenario.ActionHolder, Scenario);
     _actionView.Modified += (element) => Modified?.Invoke();
     gridContent.Children.Add(_actionView);
 }
        public FileChangeWatcherExcludeFirst(string path)
        {
            var fileInfo = new FileInfo(path);

            Watcher = new FileSystemWatcher(fileInfo.DirectoryName ?? throw new InvalidOperationException())
            {
                Filter                = fileInfo.Name,
                NotifyFilter          = NotifyFilters.LastWrite,
                IncludeSubdirectories = false
            };

            void OnModified(object sender, FileSystemEventArgs args)
            {
                if (_ignoreFirst)
                {
                    _ignoreFirst = false;
                }
                else
                {
                    Modified?.Invoke(sender, args);
                }
            }

            Watcher.Created            += OnModified;
            Watcher.Changed            += OnModified;
            Watcher.EnableRaisingEvents = true;
        }
Пример #11
0
 public virtual void UpdateProperty(Guid id, string propertyName, object value)
 {
     Modified.Invoke();
     throw new NotImplementedException("Method " + MethodBase.GetCurrentMethod().Name +
                                       " in " + MethodBase.GetCurrentMethod().DeclaringType
                                       .ToString() + " not implemented.");
 }
Пример #12
0
        /*************************************/

        protected void MarkAsModified(CallerUpdate update)
        {
            if (Modified != null)
            {
                Modified?.Invoke(this, update);
            }
        }
Пример #13
0
        protected virtual void OnModified(object sender, StreamCollectionEventArgs streamCollectionEventArgs)
        {
            var result           = streamCollectionEventArgs.To <T>();
            var modificationType = streamCollectionEventArgs.ModificationType;

            Modified?.Invoke(this, new TypedStreamCollectionEventArgs <T>(result, modificationType));
        }
Пример #14
0
        public async Task SaveModel(string dsmFilename, Progress <ProgressInfo> progress)
        {
            _actionStore.SaveToModel();
            await Task.Run(() => _dsmModel.SaveModel(dsmFilename, _dsmModel.IsCompressed, progress));

            IsModified = false;
            Modified?.Invoke(this, IsModified);
        }
Пример #15
0
        public async Task OpenModel(string dsmFilename, Progress <ProgressInfo> progress)
        {
            await Task.Run(() => _dsmModel.LoadModel(dsmFilename, progress));

            _actionStore.LoadFromModel();
            IsModified = false;
            Modified?.Invoke(this, IsModified);
        }
Пример #16
0
 private void OnModified(ModificationEventArgs e)
 {
     if (!loading)
     {
         isDirty = true;
         Modified?.Invoke(this, e);
     }
 }
Пример #17
0
        /// <summary>
        /// Marks the context as modified and sends the event to the parent context.
        /// </summary>
        /// <param name="graphEdited">True if graph has been edited (nodes structure or parameter value). Otherwise just UI elements has been modified (node moved, comment resized).</param>
        public void MarkAsModified(bool graphEdited = true)
        {
            _isModified = true;

            Modified?.Invoke(this, graphEdited);

            Parent?.MarkAsModified(graphEdited);
        }
Пример #18
0
 private void OnModified(EventArgs e)
 {
     if (!Loading)
     {
         IsDirty = true;
         Modified?.Invoke(this, e);
     }
 }
 public ReturnScenarioValueView()
 {
     InitializeComponent();
     action2View.Modified += (element) => Modified?.Invoke(this);
     buttons.RemoveClick  += () => NeedRemove?.Invoke(this);
     buttons.AddNewClick  += () => NeedAddNext?.Invoke(this);
     action1View.MakeButtonsInvisible();
 }
Пример #20
0
        public new void AddRange(IEnumerable <DialogButton> collection)
        {
            base.AddRange(collection);

            if (Modified != null)
            {
                Modified.Invoke(this, new EventArgs());
            }
        }
 /// <summary>
 /// Raises the <see cref="SignalboxHoursModified" /> event.
 /// </summary>
 /// <param name="signalboxHours">The object which has been modified.</param>
 protected virtual void OnSignalboxHoursModified(SignalboxHours signalboxHours)
 {
     SignalboxHoursModified?.Invoke(this, new SignalboxHoursEventArgs {
         SignalboxHours = signalboxHours
     });
     Modified?.Invoke(this, new ModifiedEventArgs {
         ModifiedItem = this
     });
 }
Пример #22
0
 /// <summary>
 /// Invokes the  <see cref="ExecutionReportModified"/> delegate.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="entry">The report entry <see cref="ReportEntry"/>.</param>
 private void RaiseModified(string message, ReportEntry entry)
 {
     Modified?.Invoke(this, new[] {
         new ExecutionReportModifiedArgs {
             Message     = message,
             ReportEntry = entry
         }
     });
 }
Пример #23
0
        public new void Remove(DialogButton button)
        {
            base.Remove(button);

            if (Modified != null)
            {
                Modified.Invoke(this, new EventArgs());
            }
        }
        public CheckerOperatorPairView()
        {
            InitializeComponent();

            operatorView.Modified += (e) => Modified?.Invoke(this);
            actionView.Modified   += (e) => Modified?.Invoke(this);

            actionView.NeedAddNext += (e) => NeedAddNext?.Invoke(this);
            actionView.NeedRemove  += (e) => NeedRemove?.Invoke(this);
        }
Пример #25
0
        /// <summary>
        /// Sets a setting.
        /// </summary>
        /// <param name="name">Name of the setting.</param>
        /// <param name="value">Value of the setting.  Must be serializable to JSON.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> is null.</exception>
        public void SetSetting(string name, object value)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            Settings[name] = value;
            Modified?.Invoke(this, new EventArgs());
        }
Пример #26
0
 public void SetFromSRTMatrix(Vector3 localPosition, Quaternion localRotation, Vector3 localScale)
 {
     _isSRTMatrix      = true;
     _srtLocalPosition = localPosition;
     _srtLocalRotation = localRotation;
     _srtLocalScale    = localScale;
     _isCachedSRTLocalMatrixUpToDate = false;
     _isCachedRTLocalMatrixUpToDate  = false;
     Modified?.Invoke(this, new EventArgs());
 }
Пример #27
0
 public void ResetAsSRTMatrix()
 {
     _isSRTMatrix      = true;
     _srtLocalPosition = Vector3.Zero;
     _srtLocalRotation = Quaternion.Identity;
     _srtLocalScale    = Vector3.One;
     _isCachedSRTLocalMatrixUpToDate = false;
     _isCachedRTLocalMatrixUpToDate  = false;
     Modified?.Invoke(this, new EventArgs());
 }
        public ComplexCheckerOperatorPairView()
        {
            InitializeComponent();

            operatorView.Modified       += (e) => Modified?.Invoke(this);
            complexCheckerView.Modified += (e) => Modified?.Invoke(this);

            buttonsEnd.AddNewClick   += () => NeedAddNext?.Invoke(this);
            buttonsGroup.RemoveClick += () => NeedRemove?.Invoke(this);
            buttonsGroup.AddNewClick += () => complexCheckerView.AddFirst();
        }
        public WhileActionView()
        {
            InitializeComponent();
            buttonsEnd.AddNewClick   += () => NeedAddNext?.Invoke(this);
            buttonsWhile.RemoveClick += () => NeedRemove?.Invoke(this);
            buttonsDo.AddNewClick    += () => actionView.AddFirst();
            buttonsWhile.AddNewClick += () => checkerView.AddFirst();

            actionView.Modified  += (e) => Modified?.Invoke(this);
            checkerView.Modified += (e) => Modified?.Invoke(this);
        }
Пример #30
0
        private void Delete()
        {
            var result = MessageBox.Show("Are you sure you wish to delete this tab? This action cannot be undone.", null, MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            Modified?.Invoke(this, ParentTab);
            DeleteTab?.Invoke(this, ParentTab);
        }