Esempio n. 1
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (MainPanel.PalSource != null)
                {
                    switch (MyMessageBox.Show(Language.DICT["MainTitle"], Language.DICT["MsgInfoHintForSave"], MyMessageBoxButtons.YesNoCancel))
                    {
                    case DialogResult.Yes:
                        SaveToolStripMenuItem_Click(null, new EventArgs());
                        break;

                    case DialogResult.No:
                        break;

                    default:
                        return;
                    }
                }
                OpenFileDialog openFileDialog = new OpenFileDialog
                {
                    Filter           = "Palette File|*.pal|All Files|*.*",
                    InitialDirectory = Application.StartupPath,
                    Title            = Language.DICT["MainTitle"],
                    DefaultExt       = "pal",
                    CheckPathExists  = true
                };
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    if (SavePath.EndsWith(".ini"))
                    {
                        //TODO
                    }
                    else
                    {
                        SavePath = openFileDialog.FileName;
                        IsSaved  = true;
                        Undos.Clear();
                        Redos.Clear();
                        MainPanel.Selections.Clear();
                        MainPanel.PalSource = new PalFile(SavePath);
                        MainPanel.Refresh();
                        MainPanel_SelectedIndexChanged(null, new EventArgs());
                        MainPanel_BackColorChanged(null, new EventArgs());
                        UpdateTitle(Language.DICT["MainTitleEmptyName"]);
                        CurrentStatusLabel.Text = Language.DICT["StslblOpenSucceed"];
                    }
                }
            }
            catch (Exception ex)
            {
                SavePath = "";
                IsSaved  = false;
                MainPanel.Close();
                CurrentStatusLabel.Text = Language.DICT["StslblOpenFailed"];
                UpdateTitle(Language.DICT["MainTitleEmptyName"]);
                MyMessageBox.Show(Language.DICT["MainTitle"], Language.DICT["MsgFatalOpen"] + ex.Message);
            }
        }
Esempio n. 2
0
 /// <inheritdoc/>
 public void Clear()
 {
     Undos.Clear();
     Redos.Clear();
     _canUndo.OnNext(false);
     _canRedo.OnNext(false);
     _canClear.OnNext(false);
 }
 /// <inheritdoc/>
 public void Dispose()
 {
     Undos.Clear();
     Redos.Clear();
     _canUndo.Dispose();
     _canRedo.Dispose();
     _canClear.Dispose();
 }
Esempio n. 4
0
 private void CloseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         MainPanel.Close();
         IsSaved  = false;
         SavePath = "";
         UpdateTitle(Language.DICT["MainTitleEmptyName"]);
         Undos.Clear();
         Redos.Clear();
         CurrentStatusLabel.Text = Language.DICT["StslblCloseSucceed"];
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(Language.DICT["MainText"], Language.DICT["MsgFatalClose"] + ex.Message);
         CurrentStatusLabel.Text = Language.DICT["StslblCloseFailed"];
     }
 }
Esempio n. 5
0
        /// <inheritdoc/>
        public void Snapshot(Action undo, Action redo)
        {
            if (undo == null)
            {
                throw new ArgumentNullException(nameof(undo));
            }

            if (redo == null)
            {
                throw new ArgumentNullException(nameof(redo));
            }

            if (Redos.Count > 0)
            {
                Redos.Clear();
                _canRedo.OnNext(false);
            }
            Undos.Push(new State(undo, redo));
            _canUndo.OnNext(true);
            _canClear.OnNext(true);
        }