Vixen
dd8b0a81

EditableDocument

class Core/Vixen.Ui/Documents.cs:68
csharp
public abstract class EditableDocument

The ordinary implementation: two signals it owns and two methods to fill in.

Read the guide page for this →

Remarks

⚠ Save writes whether or not it is dirty, and it is IsDirty that greys the menu item. The two are not the same question — Save As on an unchanged document must still write — and a base class that short-circuited a clean save would make the difference unreachable from a subclass.

Fields and properties (3)

  • public IReadOnlySignal<string> Name

    What to call it: a file name, or something like "Untitled 2".

  • public IReadOnlySignal<string?> Location

    Where it lives, or if it has never been saved.

  • public IReadOnlySignal<bool> IsDirty

    Whether it has changes that saving would write.

Methods (8)

  • protected EditableDocument(string name, string? location = null)

    Creates one.

  • public void MarkDirty()

    Says something changed.

  • public void MarkClean()

    Says there is nothing left to write.

  • public void Rename(string newName, string? newLocation = null)

    Renames it, which is what a Save As does after it has chosen a path.

  • public bool Save()

    Writes it out.

  • public bool Revert()

    Throws the changes away and reloads what is on disk.

  • protected abstract bool OnSave()

    Writes it out. Returning leaves it dirty.

  • protected abstract bool OnRevert()

    Reloads it, discarding the changes. Returning leaves it dirty.

Used by (7)

  • MaterialDocumentHelloUi
  • DerivedDirtyStateTestsVixen.Ui.Tests
  • DocumentClosePromptTestsVixen.Ui.Controls.Tests
  • EditableDocumentTestsVixen.Ui.Tests
  • NoteVixen.Ui.Tests
  • NoteVixen.Ui.Controls.Tests
  • SheetVixen.Ui.Tests