# officedev/office-custom-ui-editor architecture

> Architecture diagram of the GitHub repository officedev/office-custom-ui-editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/officedev/office-custom-ui-editor
- Repository: https://github.com/officedev/office-custom-ui-editor

## Overview

1. **What this repo is**
   - A **standalone Windows desktop application** built in C#/.NET for editing the **Office Custom UI XML** stored inside Office Open XML documents.
   - It is not a web app or library-only repo; the architecture centers on a **single WinForms UI** that edits a document payload and ships with sample content and deployment artifacts.

2. **Main application shell**
   - `CustomUIEditor.csproj` / `CustomUIEditor.sln` define the app.
   - `MainForm.cs` is the primary workspace where editing happens.
   - `AboutBox.cs` and `ClientEULA.rtf` are standard desktop-app support pieces rather than core logic.

3. **Document lifecycle boundary**
   - `OfficeDocument.cs` and `DocumentLifeCycle.cs` form the core boundary between the editor UI and the Office file/package being edited.
   - This is where the app likely handles loading, opening, tracking changes, and saving the custom UI part inside an Office document.

4. **XML content editing layer**
   - `CustomUIContent.cs`, `MainFormRichTextBox.cs`, and `XmlColorizer.cs` suggest the UI edits raw XML with syntax coloring and a richer text editor surface.
   - This layer is responsible for presenting the customUI markup as editable text while keeping it readable and structured for users.

5. **Office-specific authoring helpers**
   - `CallbacksBuilder.cs` indicates tooling for generating or managing Office Ribbon/backstage callback definitions.
   - `CustomUIEditor.cs` appears to hold editor-specific logic that ties the UI, content model, and Office custom UI concepts together.

6. **Schema awareness and validation**
   - `Schemas/customUI.xsd` and `Schemas/customui14.xsd` are the two supported schema boundaries.
   - The README makes clear the tool supports **Office 2007** and **Office 2010+** custom UI schemas, which is a major architectural constraint because it defines what XML the editor must understand.

7. **Undo/redo subsystem**
   - The `UndoRedo` folder is a self-contained implementation of editing history.
   - It includes model types like stacks, lists, and nodes plus control commands, indicating the editor keeps its own undo/redo state rather than relying on the framework.

8. **Resource and localization layer**
   - `StringsResource.resx`, `ImagesResource.resx`, and their designer files hold UI text and image assets.
   - This separates the visual/editor chrome from logic and supports the small desktop UI with reusable icons and strings.

9. **Sample-driven workflow**
   - The `Samples` folder contains example XML files such as custom tabs, groups, repurposing examples, and Office-type-specific samples for Word, Excel, and PowerPoint.
   - These samples function as reference inputs and likely as quick-start templates for users editing Office ribbon customizations.

10. **Office-type visual cues**
   - Bitmap assets under `Resources` (`worddoc.bmp`, `excelwkb.bmp`, `pptpre.bmp`, `callbacks.bmp`) suggest the UI distinguishes document types and callback-related features visually.
   - This reinforces that the app is organized around Office document categories and Ribbon callback editing tasks.

11. **Desktop app configuration**
   - `app.config` and `app.manifest` define runtime settings and Windows application metadata.
   - This is typical of a .NET Framework WinForms tool and confirms the app runs locally with standard Windows deployment behavior.

12. **Distribution/publishing boundary**
   - The `publish` folder contains ClickOnce-style output: application manifests, deployment files, and `setup.exe`.
   - This is separate from source and shows the project is packaged for end-user installation rather than just source checkout.

13. **Overall data flow**
   - User opens an Office document or sample XML in the WinForms shell.
   - The document lifecycle layer loads the customUI XML.
   - The editor presents and colors the XML, validates/anchors it against the supported schemas, and tracks edits through the undo/redo subsystem.
   - On save, the modified custom UI part is written back into the Office document/package.

14. **Architectural takeaway**
   - The repo is a **single-process, client-side XML editor** with clear internal boundaries: UI shell, Office document lifecycle, XML editing/validation, undo/redo, resources, and deployment.
   - The key external dependency is the **Office Open XML custom UI schema ecosystem**, which defines the domain the app edits.

Main entry points: [`MainForm.cs`](https://github.com/officedev/office-custom-ui-editor/blob/master/MainForm.cs) (Main form), [`CustomUIEditor.csproj`](https://github.com/officedev/office-custom-ui-editor/blob/master/CustomUIEditor.csproj) (App project), [`publish`](https://github.com/officedev/office-custom-ui-editor/tree/master/publish) (Publish), [`UndoRedo/Model/UndoRedoStack.cs`](https://github.com/officedev/office-custom-ui-editor/blob/master/UndoRedo/Model/UndoRedoStack.cs) (Undo stack)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_shell["Desktop shell"]
  node_node_mainform["Main form<br/>WinForms workspace<br/>[MainForm.cs]"]
  node_node_about["About box<br/>WinForms dialog<br/>[AboutBox.cs]"]
  node_node_project["App project<br/>.NET app"]
end

subgraph group_group_doc["Document lifecycle"]
  node_node_doclife["Lifecycle<br/>document workflow"]
  node_node_officedoc[("Office document<br/>package boundary<br/>[OfficeDocument.cs]")]
end

subgraph group_group_xml["XML editing"]
  node_node_content["Content model<br/>XML model<br/>[CustomUIContent.cs]"]
  node_node_richbox["Rich editor<br/>text editor surface"]
  node_node_colorizer["Colorizer<br/>syntax highlighting<br/>[XmlColorizer.cs]"]
  node_node_callbacks["Callbacks<br/>Office authoring helper"]
end

subgraph group_group_history["Undo/redo"]
  node_node_undo["Undo stack<br/>history controller<br/>[UndoRedoStack.cs]"]
  node_node_commands["Commands<br/>[Commands.cs]"]
  node_node_stack["Stacks<br/>history model<br/>[Stack.cs]"]
  node_node_list["Lists<br/>history model<br/>[List.cs]"]
end

subgraph group_group_assets["Assets and delivery"]
  node_node_strings["Strings<br/>resources"]
  node_node_images["Images<br/>resources"]
  node_node_samples["Samples<br/>example XML"]
  node_node_schemas["Schemas<br/>XSD set"]
  node_node_publish["Publish<br/>deployment output"]
end

node_node_project -->|"defines"| node_node_mainform
node_node_project -->|"includes"| node_node_about
node_node_project -->|"compiles"| node_node_doclife
node_node_mainform -->|"opens/saves"| node_node_doclife
node_node_doclife -->|"wraps"| node_node_officedoc
node_node_mainform -->|"edits in"| node_node_richbox
node_node_richbox -->|"colors"| node_node_colorizer
node_node_mainform -->|"binds"| node_node_content
node_node_content -->|"constrained by"| node_node_schemas
node_node_mainform -->|"uses"| node_node_callbacks
node_node_mainform -->|"tracks edits"| node_node_undo
node_node_undo -->|"executes"| node_node_commands
node_node_undo -->|"stores"| node_node_stack
node_node_stack -->|"backed by"| node_node_list
node_node_mainform -->|"loads examples"| node_node_samples
node_node_mainform -->|"uses"| node_node_strings
node_node_mainform -->|"uses"| node_node_images
node_node_publish -.->|"packages"| node_node_project
node_node_publish -.->|"includes"| node_node_samples
node_node_publish -.->|"includes"| node_node_schemas
node_node_about -->|"supports"| node_node_mainform

click node_node_mainform "https://github.com/officedev/office-custom-ui-editor/blob/master/MainForm.cs"
click node_node_about "https://github.com/officedev/office-custom-ui-editor/blob/master/AboutBox.cs"
click node_node_project "https://github.com/officedev/office-custom-ui-editor/blob/master/CustomUIEditor.csproj"
click node_node_doclife "https://github.com/officedev/office-custom-ui-editor/blob/master/DocumentLifeCycle.cs"
click node_node_officedoc "https://github.com/officedev/office-custom-ui-editor/blob/master/OfficeDocument.cs"
click node_node_content "https://github.com/officedev/office-custom-ui-editor/blob/master/CustomUIContent.cs"
click node_node_richbox "https://github.com/officedev/office-custom-ui-editor/blob/master/MainFormRichTextBox.cs"
click node_node_colorizer "https://github.com/officedev/office-custom-ui-editor/blob/master/XmlColorizer.cs"
click node_node_callbacks "https://github.com/officedev/office-custom-ui-editor/blob/master/CallbacksBuilder.cs"
click node_node_undo "https://github.com/officedev/office-custom-ui-editor/blob/master/UndoRedo/Model/UndoRedoStack.cs"
click node_node_commands "https://github.com/officedev/office-custom-ui-editor/blob/master/UndoRedo/Control/Commands.cs"
click node_node_stack "https://github.com/officedev/office-custom-ui-editor/blob/master/UndoRedo/Model/Stack.cs"
click node_node_list "https://github.com/officedev/office-custom-ui-editor/blob/master/UndoRedo/Model/List.cs"
click node_node_strings "https://github.com/officedev/office-custom-ui-editor/blob/master/StringsResource.resx"
click node_node_images "https://github.com/officedev/office-custom-ui-editor/blob/master/ImagesResource.resx"
click node_node_samples "https://github.com/officedev/office-custom-ui-editor/tree/master/Samples"
click node_node_schemas "https://github.com/officedev/office-custom-ui-editor/tree/master/Schemas"
click node_node_publish "https://github.com/officedev/office-custom-ui-editor/tree/master/publish"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_mainform,node_node_about,node_node_project toneBlue
class node_node_doclife,node_node_officedoc toneAmber
class node_node_content,node_node_richbox,node_node_colorizer,node_node_callbacks toneMint
class node_node_undo,node_node_commands,node_node_stack,node_node_list toneRose
class node_node_strings,node_node_images,node_node_samples,node_node_schemas,node_node_publish toneIndigo
```

## Components

### Desktop shell

WinForms application entry points and main editor window

- [Main form](https://github.com/officedev/office-custom-ui-editor/blob/master/MainForm.cs): WinForms workspace · Primary editor window for loading, editing, and saving custom UI XML · `MainForm.cs`
- [About box](https://github.com/officedev/office-custom-ui-editor/blob/master/AboutBox.cs): WinForms dialog · Standard application information dialog · `AboutBox.cs`
- [App project](https://github.com/officedev/office-custom-ui-editor/blob/master/CustomUIEditor.csproj): .NET app · Project and solution defining the desktop application · `CustomUIEditor.csproj`

### Document lifecycle

Boundary between the editor and Office Open XML payloads

- [Lifecycle](https://github.com/officedev/office-custom-ui-editor/blob/master/DocumentLifeCycle.cs): document workflow · Loads, tracks, and persists document state across edits · `DocumentLifeCycle.cs`
- [Office document](https://github.com/officedev/office-custom-ui-editor/blob/master/OfficeDocument.cs): package boundary · Represents the Office Open XML document being edited · `OfficeDocument.cs`

### XML editing

Raw customUI text editing, coloring, and schema-aware authoring

- [Content model](https://github.com/officedev/office-custom-ui-editor/blob/master/CustomUIContent.cs): XML model · Represents editable customUI content · `CustomUIContent.cs`
- [Rich editor](https://github.com/officedev/office-custom-ui-editor/blob/master/MainFormRichTextBox.cs): text editor surface · Rich text editing surface used for XML input · `MainFormRichTextBox.cs`
- [Colorizer](https://github.com/officedev/office-custom-ui-editor/blob/master/XmlColorizer.cs): syntax highlighting · Applies XML coloring and readability cues · `XmlColorizer.cs`
- [Callbacks](https://github.com/officedev/office-custom-ui-editor/blob/master/CallbacksBuilder.cs): Office authoring helper · Builds or manages Ribbon and backstage callback definitions · `CallbacksBuilder.cs`

### Undo/redo

Standalone editing history implementation

- [Undo stack](https://github.com/officedev/office-custom-ui-editor/blob/master/UndoRedo/Model/UndoRedoStack.cs): history controller · Coordinates undo and redo actions for edits · `UndoRedo/Model/UndoRedoStack.cs`
- [Commands](https://github.com/officedev/office-custom-ui-editor/blob/master/UndoRedo/Control/Commands.cs): edit commands · Undo and redo command operations for the editor · `UndoRedo/Control/Commands.cs`
- [Stacks](https://github.com/officedev/office-custom-ui-editor/blob/master/UndoRedo/Model/Stack.cs): history model · Stack abstractions used by the undo and redo system · `UndoRedo/Model/Stack.cs`
- [Lists](https://github.com/officedev/office-custom-ui-editor/blob/master/UndoRedo/Model/List.cs): history model · Linked-list structures supporting change history · `UndoRedo/Model/List.cs`

### Assets and delivery

Resources, samples, schemas, and deployment artifacts

- [Strings](https://github.com/officedev/office-custom-ui-editor/blob/master/StringsResource.resx): resources · Localized UI strings and labels · `StringsResource.resx`
- [Images](https://github.com/officedev/office-custom-ui-editor/blob/master/ImagesResource.resx): resources · UI image resources and icons · `ImagesResource.resx`
- [Samples](https://github.com/officedev/office-custom-ui-editor/tree/master/Samples): example XML · Reference Office custom UI sample documents · `Samples`
- [Schemas](https://github.com/officedev/office-custom-ui-editor/tree/master/Schemas): XSD set · Supported Office 2007 and Office 2010 plus customUI schemas · `Schemas`
- [Publish](https://github.com/officedev/office-custom-ui-editor/tree/master/publish): deployment output · ClickOnce-style published application artifacts · `publish`

## Connections

- App project → Main form: defines · Project wires up the main WinForms workspace
- App project → About box: includes · Project includes the auxiliary dialog
- App project → Lifecycle: compiles · Project contains the document workflow boundary
- Main form → Lifecycle: opens/saves · UI delegates document workflow to lifecycle management
- Lifecycle → Office document: wraps · Lifecycle operates on the Office document boundary
- Main form → Rich editor: edits in · The form uses a rich text surface for XML editing
- Rich editor → Colorizer: colors · Text surface is syntax-colored for XML readability
- Main form → Content model: binds · Workspace edits the customUI content model
- Content model → Schemas: constrained by · Content must conform to supported customUI schemas
- Main form → Callbacks: uses · Editor workflow includes callback generation support
- Main form → Undo stack: tracks edits · User edits are recorded in undo and redo state
- Undo stack → Commands: executes · History controller applies commands
- Undo stack → Stacks: stores · Undo and redo state uses stack structures
- Stacks → Lists: backed by · Stack implementation relies on list nodes
- Main form → Samples: loads examples · Samples provide starter XML and references
- Main form → Strings: uses · UI text is sourced from resources
- Main form → Images: uses · UI chrome uses image resources
- Publish → App project: packages · Published artifacts are built from the desktop app
- Publish → Samples: includes · Deployment output carries sample files
- Publish → Schemas: includes · Deployment output carries schema files
- About box → Main form: supports · About dialog is auxiliary to the main workspace
