@cpp:Protected prop EditModeCommand : ToolstripCommand* = null {const}

@cpp:Private func SetEditMode(editMode: GuiDocumentEditMode) : void { var command = editMode == GuiDocumentEditMode::ViewOnly ? commandViewOnly : editMode == GuiDocumentEditMode::Selectable ? commandSelectable : commandEditable;

document.EditMode = editMode; commandViewOnly.Selected = (command == commandViewOnly); commandSelectable.Selected = (command == commandSelectable); commandEditable.Selected = (command == commandEditable); SetEditModeCommand(command); self.UpdateSubscriptions(); }

@cpp:Protected func SelectAlignmentCommand() : ToolstripCommand* { var alignment = document.SummarizeParagraphAlignment(document.CaretBegin, document.CaretEnd); return alignment == Alignment::Left ? commandAlignLeft : alignment == Alignment::Center ? commandAlignCenter : alignment == Alignment::Right ? commandAlignRight : commandAlignDefault; }

@cpp:Private func SetAlignment(alignment : Alignment?) : void { document.SetParagraphAlignment(document.CaretBegin, document.CaretEnd, alignment); self.UpdateSubscriptions(); }

@cpp:Private prop HasEditableSelection : bool = false {}

@cpp:Private prop HasEditableSelectionInSingleParagraph : bool = false {}

@cpp:Private func HasEditableCursor() : bool { return document.EditMode == GuiDocumentEditMode::Editable; }

@cpp:Private func HasEditableHyperlink(forEdit : bool) : bool { var a = document.CaretBegin; var b = document.CaretEnd; return a.row == b.row and a.column != b.column; }

@cpp:Protected func GetMenuContainer() : GraphicsComposition* { return menuContainer; }

@cpp:Protected func GetToolstripContainer() : GraphicsComposition* { return toolstripContainer; }

@cpp:UserImpl func LoadAsPrivateFormat(fileName: string): void { dialogNotImpl.Text = $"You want to load from \"$(fileName)\" as private format, but this function is not implemented in Workflow script."; dialogNotImpl.ShowDialog(); }

@cpp:UserImpl func SaveAsPrivateFormat(fileName: string): void { dialogNotImpl.Text = $"You want to save to \"$(fileName)\" as private format, but this function is not implemented in Workflow script."; dialogNotImpl.ShowDialog(); }

@cpp:UserImpl func SaveAsRTF(fileName: string): void { dialogNotImpl.Text = $"You want to save to \"$(fileName)\" as RTF, but this function is not implemented in Workflow script."; dialogNotImpl.ShowDialog(); }

@cpp:UserImpl func SaveAsHTML(fileName: string): void { dialogNotImpl.Text = $"You want to save to \"$(fileName)\" as HTML, but this function is not implemented in Workflow script."; dialogNotImpl.ShowDialog(); }

@cpp:Private func SaveDocument(): void { if (dialogSaveDoc.ShowDialog()) { switch (dialogSaveDoc.FilterIndex) { case 0: { self.SaveAsPrivateFormat(dialogSaveDoc.FileName); document.NotifyModificationSaved(); } case 1: { self.SaveAsRTF(dialogSaveDoc.FileName); } case 2: { self.SaveAsHTML(dialogSaveDoc.FileName); } } } }

func CancelWindowClose(): bool { if (document.Modified) { switch (dialogQueryClose.ShowDialog()) { case SelectYes: { if (dialogSaveDocPrivate.ShowDialog()) { self.SaveAsPrivateFormat(dialogSaveDocPrivate.FileName); return false; } else { return true; } } case SelectNo: { return false; } default: { return true; } } } else { return false; } }

prop MenuContainer : GraphicsComposition* {GetMenuContainer} prop ToolstripContainer : GraphicsComposition* {GetToolstripContainer}
{ SetEditMode(Editable); }
document.observe as _(_.CanCut() on _.SelectionChanged)

You Clicked a Hyperlink!

Select an Image

Load a GacUI Document

Save a GacUI Document

Save a GacUI Document

<_>composeType:MinSize <_>composeType:MinSize <_>composeType:Percentage percentage:1.0
<_>composeType:Percentage percentage:1.0

D

{ dialogMessage.Text = document.ActiveHyperlinkReference; dialogMessage.ShowDialog(); }

{ if (dialogOpenDoc.ShowDialog()) { self.LoadAsPrivateFormat(dialogOpenDoc.FileName); } }
{ dialogSaveDoc.FilterIndex = 0; self.SaveDocument(); }
{ dialogSaveDoc.FilterIndex = 1; self.SaveDocument(); }
{ dialogSaveDoc.FilterIndex = 2; self.SaveDocument(); }
document.observe as _(_.CanUndo() on _.UndoRedoChanged)
document.Undo();
document.observe as _(_.CanRedo() on _.UndoRedoChanged)
document.Redo();
document.observe as _(_.CanCopy() on _.SelectionChanged)
document.Copy();
self.HasEditableSelection
document.Cut();
self.observe as _(document.CanPaste() on _.BoundsComposition.clipboardNotify)
document.Paste();
self.HasEditableSelection
document.SetSelectionText("");
document.SelectAll();
self.HasEditableCursor()
{ if (dialogOpen.ShowDialog()) { var imageService = INativeController::GetCurrentController().ImageService(); var image = imageService.CreateImageFromFile(dialogOpen.FileName); var imageData = new ImageData^(image, 0); document.EditImage(document.CaretBegin, document.CaretEnd, imageData); } }
document.observe as _(self.HasEditableHyperlink(true) on _.SelectionChanged)
$Async{ var mainWindow = self.RelatedControlHost as controls::GuiWindow*;

var window = new HyperlinkWindow*(); window.MoveToScreenCenter(mainWindow.RelatedScreen); $Await window.ShowModalAsync(mainWindow);

if (window.Url is not null) { var row = document.CaretBegin.row; var begin = document.CaretBegin.column; var end = document.CaretEnd.column; document.EditHyperlink(row, begin, end, cast string window.Url, "#NormalLink", "#ActiveLink"); } delete window; }
document.observe as _(self.HasEditableHyperlink(false) on _.SelectionChanged)
{ var row = document.CaretBegin.row; var begin = document.CaretBegin.column; var end = document.CaretEnd.column; document.RemoveHyperlink(row, begin, end); }
self.HasEditableSelection
document.observe as _(_.SummarizeStyle(_.CaretBegin, _.CaretEnd).bold == true on _.SelectionChanged, _.ModifiedChanged)
{ var style = new DocumentStyleProperties^(); style.bold = not commandBold.Selected; document.EditStyle(document.CaretBegin, document.CaretEnd, style); }
self.HasEditableSelection
document.observe as _(_.SummarizeStyle(_.CaretBegin, _.CaretEnd).italic == true on _.SelectionChanged, _.ModifiedChanged)
{ var style = new DocumentStyleProperties^(); style.italic = not commandItalic.Selected; document.EditStyle(document.CaretBegin, document.CaretEnd, style); }
self.HasEditableSelection
document.observe as _(_.SummarizeStyle(_.CaretBegin, _.CaretEnd).underline == true on _.SelectionChanged, _.ModifiedChanged)
{ var style = new DocumentStyleProperties^(); style.underline = not commandUnderline.Selected; document.EditStyle(document.CaretBegin, document.CaretEnd, style); }
self.HasEditableSelection
document.observe as _(_.SummarizeStyle(_.CaretBegin, _.CaretEnd).strikeline == true on _.SelectionChanged, _.ModifiedChanged)
{ var style = new DocumentStyleProperties^(); style.strikeline = not commandStrike.Selected; document.EditStyle(document.CaretBegin, document.CaretEnd, style); }
self.HasEditableSelection
{ var begin = document.CaretBegin; var end = document.CaretEnd; var style = document.SummarizeStyle(begin, end);

var baselineFont = document.DisplayFont; dialogFont.SelectedFont = { fontFamily: ( style.face is null ? baselineFont.fontFamily : cast string style.face ) size: ( style.size is null ? baselineFont.size : cast int style.size.size ) };

if (dialogFont.ShowDialog()) { style = new DocumentStyleProperties^(); var selectedFont = dialogFont.SelectedFont;

style.face = selectedFont.fontFamily; style.size = {size:selectedFont.size relative:false}; document.EditStyle(begin, end, style); } }
self.HasEditableSelection
{ var begin = document.CaretBegin; var end = document.CaretEnd; var selectedColor = document.SummarizeStyle(begin, end).color; if (selectedColor is null) { dialogColor.SelectedColor = cast Color "#000000"; } else { dialogColor.SelectedColor = cast Color selectedColor; } if (dialogColor.ShowDialog()) { var style = new DocumentStyleProperties^(); style.color = dialogColor.SelectedColor; document.EditStyle(begin, end, style); } }
self.HasEditableSelection
{ var begin = document.CaretBegin; var end = document.CaretEnd; var selectedColor = document.SummarizeStyle(begin, end).backgroundColor; if (selectedColor is null) { dialogColor.SelectedColor = cast Color "#000000"; } else { dialogColor.SelectedColor = cast Color selectedColor; } if (dialogColor.ShowDialog()) { var style = new DocumentStyleProperties^(); style.backgroundColor = dialogColor.SelectedColor; document.EditStyle(begin, end, style); } }
self.SetEditMode(ViewOnly);
self.SetEditMode(Selectable);
self.SetEditMode(Editable);
self.HasEditableCursor()
self.SetAlignment(null);
self.HasEditableCursor()
document.observe as _(self.SelectAlignmentCommand() == commandAlignLeft on _.SelectionChanged)
self.SetAlignment(Left);
self.HasEditableCursor()
document.observe as _(self.SelectAlignmentCommand() == commandAlignCenter on _.SelectionChanged)
self.SetAlignment(Center);
self.HasEditableCursor()
document.observe as _(self.SelectAlignmentCommand() == commandAlignRight on _.SelectionChanged)
self.SetAlignment(Right);