public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { bool ongoing = pnlView.OngoingShape != null; pnlView.ConcludeOngoing(); if (ongoing) { return; // we cancelled the current; better to not also undo a previous - that can look like 2 operations } if (CurrentDocument.UndoTransactions.Count == 0) { return; } CurrentPage.DeselectAll(); // in case undo deletes something in selected list Transaction actualTransaction = CurrentDocument.UndoTransactions[CurrentDocument.UndoTransactions.Count - 1]; CurrentDocument.UndoTransactions.RemoveAt(CurrentDocument.UndoTransactions.Count - 1); actualTransaction.Undo(); pnlView.InvalidateAll(); CurrentDocument.RedoTransactions.Add(actualTransaction); if (CurrentDocument.Changed != actualTransaction.ChangedAtStart) { CurrentDocument.Changed = actualTransaction.ChangedAtStart; } Editor.IndirectEffectsUndoRedo(actualTransaction, true); Shape.RestoreCaretState(actualTransaction); // Ignored unless objTransaction.CaretState is defined }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { pnlView.ConcludeOngoing(); if (MessageBox.Show(Strings.Item("Confirm_ClearPage"), RootApplication.AppName, MessageBoxButtons.OKCancel) == DialogResult.OK) { CurrentPage.Clear(transaction); } }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { pnlView.ConcludeOngoing(); string filename = FileDialog.ShowOpen(FileDialog.Context.Image); if (!string.IsNullOrEmpty(filename)) { pnlView.ImportImage(filename); } }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { pnlView.ConcludeOngoing(); string path = FileDialog.ShowOpen(FileDialog.Context.Document, Document.LoadFilter()); if (string.IsNullOrEmpty(path)) { return; } Globals.Root.OpenFile(path); }
private void Print(EditableView pnlView) { pnlView.ConcludeOngoing(); try { m_PrintDocument = new System.Drawing.Printing.PrintDocument(); m_PrintDocument.PrinterSettings.MaximumPage = CurrentDocument.Count; m_PrintDocument.PrinterSettings.MinimumPage = 1; m_PrintDocument.PrinterSettings.FromPage = 1; m_PrintDocument.PrinterSettings.ToPage = CurrentDocument.Count; m_PrintDocument.PrinterSettings.PrintRange = PrintRange.CurrentPage; m_PrintDocument.DefaultPageSettings.Landscape = CurrentPage.IsLandscape; m_PrintDocument.BeginPrint += m_PrintDocument_BeginPrint; m_PrintDocument.PrintPage += PrintDocument_PrintPage; if (!Direct) { var dlgPrint = new PrintDialog { AllowSelection = CurrentPage.SelectedCount > 0, Document = m_PrintDocument, AllowCurrentPage = true, AllowSomePages = true, UseEXDialog = true }; if (dlgPrint.ShowDialog() != DialogResult.OK) { return; } } PrintMeasures = false; m_PrintDocument.Print(); } catch (Exception EX) { Utilities.LogSubError(EX); MessageBox.Show(Strings.Item("Print_Error") + " " + EX.Message); } finally { m_PrintDocument.Dispose(); m_PrintDocument = null; } }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { if (CurrentDocument.RedoTransactions.Count == 0) { return; } pnlView.ConcludeOngoing(); CurrentPage.DeselectAll(); // in case undo deletes something in selected list Transaction actualTransaction = CurrentDocument.RedoTransactions[CurrentDocument.RedoTransactions.Count - 1]; CurrentDocument.RedoTransactions.RemoveAt(CurrentDocument.RedoTransactions.Count - 1); actualTransaction.Undo(); pnlView.InvalidateAll(); CurrentDocument.UndoTransactions.Add(actualTransaction); if (!CurrentDocument.Changed) { CurrentDocument.Changed = true; } Editor.IndirectEffectsUndoRedo(actualTransaction, false); }
public static void SaveFile(EditableView pnlView) { pnlView.ConcludeOngoing(); Bitmap thumbnail = CurrentDocument.Page(0).GenerateThumbnail2(Page.FILEDOCUMENTTHUMBNAILSIZE, CurrentDocument.ApproxUnitScale, 96); try { using (DataWriter writer = new DataWriter(CurrentDocument.Filename, FileMarkers.Splash, thumbnail: thumbnail)) { writer.Write(CurrentDocument); } } catch (Exception ex) when(!Globals.Root.IsDebug) { MessageBox.Show(Strings.Item("Save_Failed").Replace("%0", ex.Message), Strings.Item("App"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; // functions can detect this failed (e.g. save before close)by detecting now m_Document.Changed is still True } CurrentDocument.Changed = false; Config.UserUser.RememberFile(CurrentDocument.Filename); Editor.SetWindowTitle(); // in case filename was changed }