Exemplo n.º 1
0
        public void SelectResult(Solver.Result result)
        {
            var o = m_FileView.SelectResult(result);

            o.Do();
            m_UndoStack.Add(o);
        }
Exemplo n.º 2
0
        private void StepForwardImpl()
        {
            HistoryMemento     topMemento           = RedoStack[0];
            ToolHistoryMemento asToolHistoryMemento = topMemento as ToolHistoryMemento;

            if (asToolHistoryMemento != null && asToolHistoryMemento.ToolType != this.documentWorkspace.GetToolType())
            {
                this.documentWorkspace.SetToolFromType(asToolHistoryMemento.ToolType);
                StepForward();
            }
            else
            {
                OnChanging();

                ExecutingHistoryMementoEventArgs ehaea1 = new ExecutingHistoryMementoEventArgs(topMemento, true, false);

                if (asToolHistoryMemento == null && topMemento.SeriesGuid != Guid.Empty)
                {
                    ehaea1.SuspendTool = true;
                }

                OnExecutingHistoryMemento(ehaea1);

                if (ehaea1.SuspendTool)
                {
                    this.documentWorkspace.PushNullTool();
                }

                HistoryMemento redoMemento = RedoStack[0];

                // Possibly useful invariant here:
                //     ehaea1.HistoryMemento.SeriesGuid == ehaea2.HistoryMemento.SeriesGuid == ehaea3.HistoryMemento.SeriesGuid
                ExecutingHistoryMementoEventArgs ehaea2 = new ExecutingHistoryMementoEventArgs(redoMemento, false, ehaea1.SuspendTool);
                OnExecutingHistoryMemento(ehaea2);

                HistoryMemento undoMemento = redoMemento.PerformUndo();

                RedoStack.RemoveAt(0);
                UndoStack.Add(undoMemento);

                ExecutedHistoryMementoEventArgs ehaea3 = new ExecutedHistoryMementoEventArgs(undoMemento);
                OnExecutedHistoryMemento(ehaea3);

                OnChanged();
                OnSteppedForward();

                undoMemento.Flush();

                if (ehaea1.SuspendTool)
                {
                    this.documentWorkspace.PopNullTool();
                }
            }

            if (this.stepGroupDepth == 0)
            {
                OnFinishedStepGroup();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Add a new stage to the undo stack
 /// </summary>
 /// <param name="stage"></param>
 private void AddUndoStage(UndoStage stage, bool clearRedo = true)
 {
     if (stage != null && stage.Count > 0)
     {
         UndoStack.Add(stage);
         if (UndoStack.Count > MaxStackSize)
         {
             UndoStack.RemoveAt(0);
         }
         if (clearRedo)
         {
             RedoStack.Clear();
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// When the user does something new, it will clear out the redo stack.
        /// </summary>
        public void PushNewMemento(HistoryMemento value)
        {
            Utility.GCFullCollect();

            OnChanging();

            ClearRedoStack();
            UndoStack.Add(value);
            OnNewHistoryMemento();

            OnChanged();

            value.Flush();
            Utility.GCFullCollect();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Replaces the last undo point with the one being passed in.
        /// </summary>
        /// <param name="portfolio">The current state of the <c>KimonoPortfolio</c>.</param>
        public void ReplaceLastUndoPoint(KimonoPortfolio portfolio)
        {
            // Clear the redo stack
            RedoStack.Clear();

            // Save point
            if (UndoStack.Count > 0)
            {
                UndoStack[0] = portfolio;
            }
            else
            {
                UndoStack.Add(portfolio);
            }
            RaiseUndoStateChanged();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Adds an undo unit to the undo/redo stack, depending on current state.
        /// </summary>
        /// <param name="unit">
        /// IUndoUnit to add
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// Thrown if:
        ///     UndoManager is disabled
        ///     unit is not IParentUndoUnit and there is no open IParentUndoUnit
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown if unit is null
        /// </exception>
        internal void Add(IUndoUnit unit)
        {
            IParentUndoUnit parent;

            if (!IsEnabled)
            {
                throw new InvalidOperationException(SR.Get(SRID.UndoServiceDisabled));
            }

            if (unit == null)
            {
                throw new ArgumentNullException("unit");
            }

            parent = DeepestOpenUnit;
            if (parent != null)
            {
                parent.Add(unit);
            }
            else if (unit is IParentUndoUnit)
            {
                ((IParentUndoUnit)unit).Container = this;
                if (LastUnit is IParentUndoUnit)
                {
                    ((IParentUndoUnit)LastUnit).OnNextAdd();
                }

                SetLastUnit(unit);
                if (State == UndoState.Normal || State == UndoState.Redo)
                {
                    if (++_topUndoIndex == UndoLimit)
                    {
                        _topUndoIndex = 0;
                    }
                    if (!(_topUndoIndex < UndoStack.Count && PeekUndoStack() == null) && // Non-null topmost stack item
                        (UndoLimit == -1 || UndoStack.Count < UndoLimit))
                    {
                        UndoStack.Add(unit);
                    }
                    else
                    {
                        if (PeekUndoStack() != null)
                        {
                            if (++_bottomUndoIndex == UndoLimit)
                            {
                                _bottomUndoIndex = 0;
                            }
                        }
                        UndoStack[_topUndoIndex] = unit;
                    }
                }
                else if (State == UndoState.Undo)
                {
                    RedoStack.Push(unit);
                }
                else if (State == UndoState.Rollback)
                {
                    // do nothing, throwing out the unit
                }
            }
            else
            {
                throw new InvalidOperationException(SR.Get(SRID.UndoNoOpenParentUnit));
            }
        }
        public static void Render(FMAT material, UVViewport UVViewport, bool onLoad)
        {
            float width = ImGui.GetWindowWidth();

            if (ImGui.BeginChild("TEXTURE_MAP_LIST", new System.Numerics.Vector2(width, 100)))
            {
                int index = 0;
                foreach (var texMap in material.TextureMaps)
                {
                    var tex = SearchTextureInstance(texMap.Name);
                    if (tex != null)
                    {
                        if (tex.RenderableTex == null)
                        {
                            tex.LoadRenderableTexture();
                        }

                        if (tex.RenderableTex != null)
                        {
                            IconManager.LoadTexture(tex.Name, tex);
                        }
                        else
                        {
                            IconManager.LoadIcon("TEXTURE");
                        }
                    }
                    else
                    {
                        IconManager.LoadIcon("TEXTURE");
                    }
                    ImGui.SameLine();

                    if (dialogOpened && SelectedIndices.Contains(index))
                    {
                        if (TextureSelectionDialog.Render(texMap.Name, ref dialogOpened))
                        {
                            var input = TextureSelectionDialog.OutputName;
                            //Only undo matching textures, not typed names
                            if (tex != null)
                            {
                                UndoStack.Add(new UndoStringOperation($"Texture Map",
                                                                      texMap, "Name", input));
                            }

                            texMap.Name = input;
                        }
                    }
                    else
                    {
                        if (ImGui.Selectable(texMap.Name, SelectedIndices.Contains(index)))
                        {
                            SelectedIndices.Clear();
                            SelectedIndices.Add(index);
                        }
                        if (ImGui.IsItemClicked() && ImGui.IsMouseDoubleClicked(0))
                        {
                            dialogOpened = true;
                        }
                    }

                    index++;
                }
            }
            ImGui.EndChild();

            if (material.TextureMaps.Count == 0)
            {
                return;
            }

            //Make sure there is atleast 1 selection used
            if (SelectedIndices.Count == 0)
            {
                SelectedIndices.Add(0);
            }

            if (ImGui.BeginChild("SAMPLER_DATA"))
            {
                SelectSampler(material, UVViewport, SelectedIndices.FirstOrDefault(), onLoad);
            }
            ImGui.EndChild();
        }
Exemplo n.º 8
0
 private void Push(IObservableCollection <IUndoableAction> stack, IUndoableAction action)
 {
     UndoStack.Add(action);
 }