Exemple #1
0
    public static void RegisterAction(BlockInstance prevBlock, BlockInstance newBlock)
    {
        List <BlockInstance> prevBlocks = new List <BlockInstance>();
        List <BlockInstance> newBlocks  = new List <BlockInstance>();

        prevBlocks.Add(prevBlock);
        newBlocks.Add(newBlock);

        Modification mod = new Modification(prevBlocks, newBlocks);

        undoStack.Push(mod);

        redoStack.Clear();
    }
Exemple #2
0
        /// <inheritdoc />
        public async Task ExecuteUserActionAsync()
        {
            var openPicker = new FileOpenPicker();

            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            openPicker.FileTypeFilter.Add(".json");
            openPicker.ViewMode = PickerViewMode.List;

            StorageFile file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                string jsonString = await FileIO.ReadTextAsync(file);

                List <PaintBase> newShapeList = DeserializeJsonSave(jsonString);

                // Clear undo, redo and master list
                UndoStack.Clear();
                RedoStack.Clear();
                ShapeList.Clear();
                // Add deserialized master list to main page
                ShapeList.AddRange(newShapeList);

                // Send draw and update list commands to main page
                _page.Draw();
                _page.UpdateList();
            }
        }
 internal void Clear()
 {
     LastSave = 0;
     UndoStack.Clear();
     RedoStack.Clear();
     UpdateUI();
 }
Exemple #4
0
 /// <summary>
 /// 記録されている操作をクリアします。
 /// </summary>
 public void Clear()
 {
     UndoStack.Clear();
     RedoStack.Clear();
     LastCommittedOperation = null;
     OperationHistoryChanged?.Invoke(this, EventArgs.Empty);
 }
    public void UndoAll()
    {
        //move every modified constituent back into its original district
        MoveConstituents(new Dictionary <Constituent, District>(OriginalDistricts));

        //clear the undo stack since it isn't of much use anymore
        UndoStack.Clear();
    }
Exemple #6
0
 public void Reset()
 {
     UndoStack.Clear();
     RedoStack.Clear();
     StrokeManager.Clear();
     TransactionId            = 0;
     HighestUsedTransactionId = 0;
     ActiveTransactionIdCount = 0;
 }
Exemple #7
0
        private void SetCards(int count)
        {
            UndoStack.Clear();
            RedoStack.Clear();

            flp_cards.Controls.Clear();

            AddCard(count);
        }
Exemple #8
0
 private void import_Click(object sender, EventArgs e)
 {
     new IOElements(battlefields, IOMode.Import, Index, "IMPORT BATTLEFIELDS...").ShowDialog();
     foreach (var paletteSet in Model.PaletteSets)
     {
         paletteSet.Buffer = Model.ROM;
     }
     LoadProperties();
     commandStack.Clear();
     commandCount = 0;
 }
        public virtual void Initialize(int startCellIdx)
        {
            Solved     = false;
            Iterations = 0;
            int numPegs = board.NumCells;

            // Start with one peg removed.
            board.FillAllCells();
            board.RemovePeg(startCellIdx);
            UndoStack.Clear();
        }
Exemple #10
0
        private void ResetStacks()
        {
            if (undoStack != null)
            {
                undoStack.Clear();
            }

            if (redoStack != null)
            {
                redoStack.Clear();
            }
        }
        private void OnOpenFromFileCommandExecute()
        {
            OpenFileDialog dialog = new OpenFileDialog()
            {
                Filter = filterString, Title = "Open file..."
            };

            if (dialog.ShowDialog().Value == true)
            {
                Text = new StreamReader(dialog.FileName).ReadToEnd();
                UndoStack.Clear();
                RedoStack.Clear();
            }
        }
        private void SaveAsImage(string path)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return;
            }


            var fileext = path.Split('.');


            // recalculate this canvas
            var size = new Size(double.NaN.Equals(Width) ? ActualWidth : Width,
                                double.NaN.Equals(Height) ? ActualHeight : Height);

            Measure(size);
            Arrange(new Rect(size));

            // convert VisualObject to Bitmap
            var renderBitmap = new RenderTargetBitmap((int)size.Width,       // width
                                                      (int)size.Height,      // Height
                                                      96.0d,                 // Horizonal 96.0DPI
                                                      96.0d,                 // Vertual 96.0DPI
                                                      PixelFormats.Pbgra32); // 32bit(RGBA 8bit)

            renderBitmap.Render(this);

            // Default encoder is PNG
            BitmapEncoder encoder = new PngBitmapEncoder();;

            if (fileext.Length >= 2 && fileext[fileext.Length - 1] == "jpg")
            {
                encoder = new JpegBitmapEncoder();
            }


            // Output FileStream
            using (var os = new FileStream(path, FileMode.Create))
            {
                // Create the Bitmap FileStream
                encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                encoder.Save(os);
            }

            UndoStack.Clear();
            RedoStack.Clear();
        }
Exemple #13
0
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Performs the work of the clear operation.  Called by the public Clear() method,
        /// or by UndoManager itself if it wants to clear its stacks without regard to
        /// whether or not it's enabled.
        /// </summary>
        private void DoClear()
        {
            Invariant.Assert(!_imeSupportModeEnabled); // We can't clear the undo stack while ime code depends on it.

            if (UndoStack.Count > 0)
            {
                UndoStack.Clear();
                UndoStack.TrimExcess();
            }

            if (RedoStack.Count > 0)
            {
                RedoStack.Clear();
            }

            SetLastUnit(null);
            SetOpenedUnit(null);
            _topUndoIndex    = -1;
            _bottomUndoIndex = 0;
        }
Exemple #14
0
 public void Flush()
 {
     PreStackChanged();
     _undoStack.Clear();
     OnStackChanged(OperationStackChangedEvent.Clear);
 }
Exemple #15
0
 public void Reset(GameFile file, string filePath)
 {
     m_UndoStack.Clear();
     m_FileView.File = file;
     m_FilePath      = filePath;
 }
Exemple #16
0
 public void ClearStack()
 {
     UndoStack.Clear();
     RedoStack.Clear();
     InitialStack.Clear();
 }
Exemple #17
0
 /// <summary>
 /// リセット
 /// </summary>
 public static void Reset()
 {
     UndoStack.Clear();
     RedoStack.Clear();
     OnUpdateData();
 }
Exemple #18
0
 /// <summary>
 /// Empty both the undo and redo stack
 /// </summary>
 public virtual void ClearUndoStack()
 {
     BeginStage();
     UndoStack.Clear();
     RedoStack.Clear();
 }
        private void RefreshLayoutInCanvas()
        {
            if (LayoutDataContext == null ||
                this.Children == null ||
                (Children.Count == 0))
            {
                return;
            }

            //    _innerMapLayout =  LayoutDataContext;

            //var diagrams = (_innerMapLayout ?? (_innerMapLayout =  LayoutDataContext)).Diagrams;
            var diagrams = LayoutDataContext.Diagrams;

            int diagramsum = this.Children.Cast <UIElement>().Sum(child =>
            {
                if (child is ConnectionDiagramBase)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            });

            if (diagrams == null || diagrams.Count() > diagramsum)
            {
                diagrams = (from child in this.Children.Cast <UIElement>()
                            where child is ConnectionDiagramBase
                            select Activator.CreateInstance(LayoutDataContext.DiagramLayoutType)).Cast <IDiagramLayout>().ToArray();
            }
            else if (diagrams.Count() < diagramsum)
            {
                Array.Resize(ref diagrams, diagramsum);
            }

            var idx = 0;

            //set the diagramUI position and properties
            foreach (var child in this.Children)
            {
                if (!(child is ConnectionDiagramBase))
                {
                    continue;
                }

                var diagramUI = child as ConnectionDiagramBase;

                if (diagrams[idx] == null)
                {
                    diagrams[idx] = Activator.CreateInstance(LayoutDataContext.DiagramLayoutType) as IDiagramLayout;
                }

                diagrams[idx].X             = Canvas.GetLeft(diagramUI);
                diagrams[idx].Y             = Canvas.GetTop(diagramUI);
                diagrams[idx].DiagramUUID   = diagramUI.DiagramUUID;
                diagrams[idx].DiagramUIType = diagramUI.GetType();
                diagrams[idx].DataContext   = diagramUI.DataContext;

                //set the Line properties
                if (diagramUI.DepartureLines != null && diagramUI.DepartureLines.Any())
                {
                    diagrams[idx].DepartureLines = (from line in diagramUI.DepartureLines
                                                    select Activator.CreateInstance(diagrams[idx].LineLayouType)).Cast <ILineLayout>().ToArray <ILineLayout>();

                    int lidx = 0;

                    foreach (var lineui in diagramUI.DepartureLines)
                    {
                        diagrams[idx].DepartureLines[lidx].LineUUID            = lineui.LineUUID;
                        diagrams[idx].DepartureLines[lidx].LineUIType          = lineui.GetType();
                        diagrams[idx].DepartureLines[lidx].TerminalDiagramUUID = lineui.TerminalDiagram?.DiagramUUID;
                        diagrams[idx].DepartureLines[lidx].DataContext         = lineui.DataContext;
                        lidx++;
                    }
                }

                idx++;
            }


            LayoutDataContext.Diagrams = diagrams;

            LayoutDataContext.Height = Height;
            LayoutDataContext.Width  = Width;

            var map = RefreshMapLayout(LayoutDataContext);

            SetValue(LayoutDataContextProperty, map);

            UndoStack.Clear();
            RedoStack.Clear();
        }
 public void Clear()
 {
     UndoStack.Clear();
     RedoStack.Clear();
     IsDirty = false;
 }
 public void Clear()
 {
     UndoStack.Clear();
     RedoStack.Clear();
     CanExecuteChanged();
 }
        private void ReloadLayoutInCanvas(IMapLayout map)
        {
            Children.Clear();

            UndoStack.Clear();
            RedoStack.Clear();


            var diagrams = map.Diagrams;

            if (diagrams == null || !diagrams.Any())
            {
                return;
            }

            Dictionary <string, ILineLayout[]> uuidLines = new Dictionary <string, ILineLayout[]>();

            foreach (var diagram in diagrams)
            {
                var clnele = Activator.CreateInstance(diagram.DiagramUIType) as UIElement;

                if (clnele is ContentControl)
                {
                    (clnele as ContentControl).DataContext = diagram.DataContext;
                }

                //add the line by Diagram ActionComment after finish all diagrams
                uuidLines.Add(diagram.DiagramUUID, diagram.DepartureLines);

                Application.Current.Dispatcher.Invoke(() =>
                {
                    Canvas.SetRight(clnele, diagram.X);
                    Canvas.SetLeft(clnele, diagram.X);
                    Canvas.SetBottom(clnele, diagram.Y);
                    Canvas.SetTop(clnele, diagram.Y);


                    Children.Add(clnele);
                });
            }

            //update the canvas.
            UpdateLayout();


            foreach (var dialines in uuidLines)
            {
                ConnectionDiagramBase origindiagram = GetDiagramByUUID(dialines.Key);
                if (origindiagram != null && dialines.Value != null)
                {
                    foreach (var defline in dialines.Value)
                    {
                        var terminaldiagram = GetDiagramByUUID(defline.TerminalDiagramUUID);

                        dynamic conline;

                        if (terminaldiagram != null)
                        {
                            conline = Activator.CreateInstance(defline.LineUIType);

                            Assist.FrameworkElementAssist.SetOriginDiagram(conline, origindiagram);
                            Assist.FrameworkElementAssist.SetTerminalDiagram(conline, terminaldiagram);

                            if (conline is ConnectionLineBase)
                            {
                                //(conline as ConnectionLineBase).OriginDiagram = origindiagram;
                                //(conline as ConnectionLineBase).TerminalDiagram = terminaldiagram;
                                (conline as ConnectionLineBase).DataContext = defline.DataContext;
                                (conline as ConnectionLineBase).LineUUID    = string.IsNullOrWhiteSpace(defline.LineUUID) ? $"{conline.GetType().Name}_{Guid.NewGuid().ToString()}" : defline.LineUUID;


                                //TODOTODOTODO!!!!
                                //TODO: Posistion Recaluter
                                if (conline is ILinePosition)
                                {
                                    (conline as ILinePosition).X1 = (double)origindiagram.GetValue(Canvas.LeftProperty) - (double)terminaldiagram.GetValue(Canvas.LeftProperty) + origindiagram.CenterPosition.X;
                                    (conline as ILinePosition).Y1 = (double)origindiagram.GetValue(Canvas.TopProperty) - (double)terminaldiagram.GetValue(Canvas.TopProperty) + origindiagram.CenterPosition.Y;;
                                    (conline as ILinePosition).X2 = terminaldiagram.CenterPosition.X;
                                    (conline as ILinePosition).Y2 = terminaldiagram.CenterPosition.Y;
                                }

                                origindiagram.DepartureLines.Add(conline);
                                terminaldiagram.ArrivalLines.Add(conline);
                            }
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                Canvas.SetTop(conline, (double)terminaldiagram.GetValue(Canvas.TopProperty));
                                Canvas.SetLeft(conline, (double)terminaldiagram.GetValue(Canvas.LeftProperty));

                                Children.Add(conline);
                            });
                        }
                    }
                }
            }
        }
 /// <summary>
 /// clean out both lists of actions
 /// </summary>
 public void Flush()
 {
     UndoStack.Clear();
     RedoStack.Clear();
 }
 public void Close()
 {
     UndoStack.Clear();
     RedoStack.Clear();
 }
Exemple #25
0
        public void LoadQuiz(Quiz quiz = null, string quizPath = null, bool fromRecovery = false)
        {
            if (ChangedSinceLastSave)
            {
                //var msg = MessageBox.Show("You have unsaved changes. Save before loading a new quiz?", "SteelQuiz", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                var saveDontSave = new SaveDontSave(this, SystemIcons.Warning, true, "The project contains unsaved changes. Save before loading a new quiz?",
                                                    "Save before loading new quiz? - SteelQuiz");
                saveDontSave.ShowDialog();
                if (saveDontSave.SaveDialogResult == SaveDontSave.SaveResult.Save)
                {
                    if (!SaveQuiz())
                    {
                        return;
                    }
                }
                else if (saveDontSave.SaveDialogResult == SaveDontSave.SaveResult.Cancel)
                {
                    return;
                }
            }

            if (!fromRecovery)
            {
                DeleteRecovery();
            }

            if (quiz == null)
            {
                //ofd_quiz.InitialDirectory = ConfigManager.Config.SyncConfig.QuizFolders[0];
                var ofd = ofd_quiz.ShowDialog();
                if (ofd == DialogResult.OK)
                {
                    QuizPath = ofd_quiz.FileName;
                }
                else
                {
                    return;
                }

                try
                {
                    quiz = JsonConvert.DeserializeObject <Quiz>(AtomicIO.AtomicRead(QuizPath));
                }
                catch (AtomicException ex)
                {
                    // Should never be reached as path exists
                    throw ex;
                }
            }

            if (quizPath != null)
            {
                QuizPath = quizPath;
            }

            UpdateUndoRedoStacks = false;

            SetCards(quiz.Cards.Count + 2);

            QuizGuid       = quiz.GUID;
            cmb_lang1.Text = quiz.CardFrontType;
            cmb_lang2.Text = quiz.CardBackType;

            for (int i = 0; i < quiz.Cards.Count; ++i)
            {
                var ctrl = flp_cards.Controls.OfType <QuizEditorCard>().ElementAt(i);
                var card = quiz.Cards[i];

                ctrl.Guid                 = card.Guid;
                ctrl.txt_front.Text       = card.Front;
                ctrl.FrontSynonyms        = card.FrontSynonyms;
                ctrl.txt_back.Text        = card.Back;
                ctrl.BackSynonyms         = card.BackSynonyms;
                ctrl.ComparisonRules.Data = (StringComp.Rules)FixEnum(card.SmartComparisonRules);
            }

            if (!fromRecovery)
            {
                QuizRecoveryData     = new QuizRecoveryData(QuizPath);
                ChangedSinceLastSave = false;
            }

            UndoStack.Clear();
            RedoStack.Clear();
            UpdateUndoRedoStacks = true;

            SetGlobalSmartComparisonState();
        }