# xbambinox/imageeditor architecture

> Architecture diagram of the GitHub repository xbambinox/imageeditor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xbambinox/imageeditor
- Repository: https://github.com/xbambinox/imageeditor

## Overview

1. **Application type and architectural style**
   - This is a **WPF desktop image editor** built on **.NET 8+** using **MVVM**.
   - The UI is split into XAML views/windows, ViewModels for state and actions, and services for image manipulation and editor behavior.

2. **Shell and top-level composition**
   - `App.xaml` bootstraps the application, and `Views/MainWindow.xaml` is the main shell.
   - The main workspace is tab-based, matching the README’s multi-document editing model.
   - `MainViewModel` is the central coordinator for editor state, active tab, tool selection, commands, and file operations.

3. **Document/tab model**
   - `Models/ImageTab` represents an open image tab and likely carries the image source plus editor-specific state.
   - `Models/ImageDocument` appears to be the underlying document/data model for the loaded image and file metadata.
   - `Models/ImageInfoModel` and `Services/ImageInfoService` support image metadata display in the info window/status surfaces.

4. **Undo/redo and snapshot strategy**
   - `Models/ImageSnapshot` and `Models/LimitedStack` implement the undo/redo history.
   - The README’s “dirty-region snapshots” indicate the editor avoids full-frame copies and instead stores partial pixel regions for efficient history management.
   - This is a key architectural boundary: editing actions capture state through snapshot services rather than mutating UI directly.

5. **Drawing and selection subsystem**
   - `Services/Toolbar/DrawingService` handles canvas editing actions such as brush strokes, lines, text placement, and likely the raster updates behind them.
   - `Services/Toolbar/SelectionService` handles rectangular selection, copy/cut/paste, and floating paste behavior.
   - These services sit between tool-specific UI input and the image bitmap data, making them core to interaction logic.

6. **Image processing subsystem**
   - `Services/ImageProcessing/*Helper.cs` contains individual filter/transform operations: brightness, gamma, grayscale, invert, blur, sharpen, Sobel, pixelate.
   - Each helper is a focused processing unit rather than a single monolithic filter engine.
   - The filter-specific ViewModels (`BlurViewModel`, `BrightnessViewModel`, etc.) likely gather parameters from dialogs and invoke the corresponding helper.

7. **Editing modes and tool-oriented UI**
   - The application supports multiple tools: brush, selection, line, text, eyedropper, plus color picking.
   - Tool settings are exposed via dedicated windows such as `BrushSettingsWindow`, `LineSettingsWindow`, `TextSettingsWindow`, and `ColorPickerWindow`.
   - `Models/Tooltype` and `Models/ShortcutItem` suggest a structured tool/shortcut system feeding the command layer and toolbar.

8. **File and image lifecycle**
   - Open/save workflows are handled in the main editor flow, with `Services/ImageStatus/SaveImageHelper` likely centralizing persistence and format-specific handling.
   - The README notes PNG and JPEG support, and the presence of `Unsavedchangesdialog` indicates document dirty-state tracking before close or overwrite.
   - New image creation and canvas resizing are handled by dedicated dialogs (`NewImageDialog`, `ExpandCanvasdialog`).

9. **UI structure and dialog boundaries**
   - The repository uses many self-contained modal/dialog windows for secondary interactions: filters, keyboard shortcuts, image info, brush/line/text settings, unsaved changes, etc.
   - `Views/ToolbarView.xaml` separates the editor’s tool palette from the main canvas area.
   - `Views/BindingProxy.cs` suggests some WPF binding bridge to share ViewModel state across disconnected visual tree elements.

10. **Command and interaction layer**
   - `Commands/RelayCommand.cs` is the main command abstraction for MVVM actions.
   - Keyboard shortcuts in the README map directly to commands in the ViewModel layer, not to code-behind logic.
   - This keeps input handling routed through the command system, which is important for drawing a clean architecture diagram.

11. **Cross-cutting utilities**
   - `Services/Math/Tools.cs` holds shared geometric or pixel math used by tools and processing operations.
   - `Services/Logger.cs` is a cross-cutting diagnostic utility rather than a core editor subsystem.
   - `Models/ShortcutItem` and `Properties/Resources*` support UI metadata, icons, text, and localization-style resource usage.

12. **Primary data flow**
   - User input enters through WPF views/windows.
   - Commands and bindings route that input to `MainViewModel` or tool/filter ViewModels.
   - Those ViewModels call into drawing, selection, image processing, or save services.
   - Services mutate the current image/tab state and push snapshots for undo/redo.
   - The updated bitmap is then reflected back into the active tab and canvas via WPF bindings.

13. **Key architectural boundary to diagram**
   - The most important separation is between:
     - **presentation layer**: `Views/` + XAML dialogs
     - **state/orchestration layer**: `ViewModels/`
     - **editor mechanics**: `Services/`
     - **data/history layer**: `Models/`
   - That boundary keeps UI concerns, command logic, and pixel manipulation distinct, which is the central structure of the repo.

Main entry points: [`ViewModels/MainViewModel.cs`](https://github.com/xbambinox/imageeditor/blob/master/ViewModels/MainViewModel.cs) (Main view-model), [`Services/Toolbar/DrawingService.cs`](https://github.com/xbambinox/imageeditor/blob/master/Services/Toolbar/DrawingService.cs) (Drawing service), [`Services/Toolbar/SelectionService.cs`](https://github.com/xbambinox/imageeditor/blob/master/Services/Toolbar/SelectionService.cs) (Selection service), [`Views/MainWindow.xaml`](https://github.com/xbambinox/imageeditor/blob/master/Views/MainWindow.xaml) (Main window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_app(("App shell<br/>wpf bootstrap<br/>[App.xaml]"))
  node_main_window["Main window<br/>editor shell<br/>[MainWindow.xaml]"]
  node_toolbar_view["Toolbar<br/>tool palette<br/>[ToolbarView.xaml]"]
  node_binding_proxy["Binding proxy<br/>wpf bridge<br/>[BindingProxy.cs]"]
  node_tool_dialogs["Tool dialogs<br/>modal UI"]
  node_filter_dialogs["Filter dialogs<br/>modal UI"]
end

subgraph group_orchestration["Orchestration"]
  node_main_vm{{"Main view-model<br/>mvvm coordinator<br/>[MainViewModel.cs]"}}
  node_base_vm{{"Base VM<br/>mvvm base<br/>[BaseViewModel.cs]"}}
  node_filter_vms{{"Filter VMs<br/>dialog view-models"}}
  node_relay_command["Relay command<br/>command helper<br/>[RelayCommand.cs]"]
end

subgraph group_mechanics["Editor mechanics"]
  node_drawing_service{{"Drawing service<br/>raster editing<br/>[DrawingService.cs]"}}
  node_selection_service{{"Selection service<br/>selection editing"}}
  node_image_processing{{"Image filters<br/>filter helpers"}}
  node_save_helper["Save helper<br/>persistence<br/>[SaveImageHelper.cs]"]
  node_image_info_service["Info service<br/>metadata service"]
  node_tools_math["Math tools<br/>geometry helpers<br/>[Tools.cs]"]
end

subgraph group_data["Data and history"]
  node_image_tab["Image tab<br/>document tab<br/>[ImageTab.cs]"]
  node_image_document["Image document<br/>document model<br/>[ImageDocument.cs]"]
  node_snapshot_stack["History stack<br/>undo/redo<br/>[LimitedStack.cs]"]
  node_image_snapshot["Snapshot<br/>partial state<br/>[ImageSnapshot.cs]"]
  node_image_info_model["Image info<br/>metadata model<br/>[ImageInfoModel.cs]"]
  node_tool_models["Tool models<br/>editor enums<br/>[Tooltype.cs]"]
end

node_app -->|"loads"| node_main_window
node_main_window -->|"binds to"| node_main_vm
node_main_window -->|"hosts"| node_toolbar_view
node_toolbar_view -->|"commands"| node_main_vm
node_binding_proxy -.->|"shares state"| node_main_vm
node_main_vm -->|"uses"| node_relay_command
node_main_vm -->|"manages"| node_image_tab
node_main_vm -->|"opens/saves"| node_image_document
node_main_vm -->|"routes tools"| node_drawing_service
node_main_vm -->|"routes tools"| node_selection_service
node_main_vm -->|"opens dialogs"| node_filter_vms
node_filter_dialogs -.->|"hosts"| node_filter_vms
node_filter_vms -->|"invokes"| node_image_processing
node_drawing_service -->|"captures"| node_image_snapshot
node_drawing_service -->|"pushes"| node_snapshot_stack
node_selection_service -->|"captures"| node_image_snapshot
node_selection_service -->|"pushes"| node_snapshot_stack
node_drawing_service -->|"uses"| node_tools_math
node_selection_service -->|"uses"| node_tools_math
node_save_helper -->|"persists"| node_image_document
node_main_vm -->|"delegates save"| node_save_helper
node_image_info_service -->|"builds"| node_image_info_model
node_main_vm -->|"queries"| node_image_info_service
node_image_tab -->|"wraps"| node_image_document
node_image_tab -->|"tracks history"| node_snapshot_stack
node_main_vm -->|"uses"| node_tool_models
node_tool_dialogs -.->|"drives settings"| node_main_vm

click node_app "https://github.com/xbambinox/imageeditor/blob/master/App.xaml"
click node_main_window "https://github.com/xbambinox/imageeditor/blob/master/Views/MainWindow.xaml"
click node_toolbar_view "https://github.com/xbambinox/imageeditor/blob/master/Views/ToolbarView.xaml"
click node_binding_proxy "https://github.com/xbambinox/imageeditor/blob/master/Views/BindingProxy.cs"
click node_main_vm "https://github.com/xbambinox/imageeditor/blob/master/ViewModels/MainViewModel.cs"
click node_base_vm "https://github.com/xbambinox/imageeditor/blob/master/ViewModels/BaseViewModel.cs"
click node_relay_command "https://github.com/xbambinox/imageeditor/blob/master/Commands/RelayCommand.cs"
click node_drawing_service "https://github.com/xbambinox/imageeditor/blob/master/Services/Toolbar/DrawingService.cs"
click node_selection_service "https://github.com/xbambinox/imageeditor/blob/master/Services/Toolbar/SelectionService.cs"
click node_image_processing "https://github.com/xbambinox/imageeditor/tree/master/Services/ImageProcessing"
click node_save_helper "https://github.com/xbambinox/imageeditor/blob/master/Services/ImageStatus/SaveImageHelper.cs"
click node_image_info_service "https://github.com/xbambinox/imageeditor/blob/master/Services/ImageInfoService.cs"
click node_tools_math "https://github.com/xbambinox/imageeditor/blob/master/Services/Math/Tools.cs"
click node_image_tab "https://github.com/xbambinox/imageeditor/blob/master/Models/ImageTab.cs"
click node_image_document "https://github.com/xbambinox/imageeditor/blob/master/Models/ImageDocument.cs"
click node_snapshot_stack "https://github.com/xbambinox/imageeditor/blob/master/Models/LimitedStack.cs"
click node_image_snapshot "https://github.com/xbambinox/imageeditor/blob/master/Models/ImageSnapshot.cs"
click node_image_info_model "https://github.com/xbambinox/imageeditor/blob/master/Models/ImageInfoModel.cs"
click node_tool_models "https://github.com/xbambinox/imageeditor/blob/master/Models/Tooltype.cs"

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_app,node_main_window,node_toolbar_view,node_binding_proxy,node_tool_dialogs,node_filter_dialogs toneBlue
class node_main_vm,node_base_vm,node_filter_vms,node_relay_command toneAmber
class node_drawing_service,node_selection_service,node_image_processing,node_save_helper,node_image_info_service,node_tools_math toneMint
class node_image_tab,node_image_document,node_snapshot_stack,node_image_snapshot,node_image_info_model,node_tool_models toneRose
```

## Components

### Presentation

WPF shells, views, and dialog surfaces

- [App shell](https://github.com/xbambinox/imageeditor/blob/master/App.xaml): wpf bootstrap · Starts the desktop app and loads the main window · `App.xaml`
- [Main window](https://github.com/xbambinox/imageeditor/blob/master/Views/MainWindow.xaml): editor shell · Top-level workspace and tabbed editor frame · `Views/MainWindow.xaml`
- [Toolbar](https://github.com/xbambinox/imageeditor/blob/master/Views/ToolbarView.xaml): tool palette · Editor tool and mode surface · `Views/ToolbarView.xaml`
- [Binding proxy](https://github.com/xbambinox/imageeditor/blob/master/Views/BindingProxy.cs): wpf bridge · Shares view-model state across WPF visual tree boundaries · `Views/BindingProxy.cs`
- **Tool dialogs**: modal UI · Brush, line, text, color, and canvas dialogs
- **Filter dialogs**: modal UI · Parameter entry windows for image filters and effects

### Orchestration

MVVM coordination and command entry points

- [Main view-model](https://github.com/xbambinox/imageeditor/blob/master/ViewModels/MainViewModel.cs): mvvm coordinator · Owns tabs, commands, active tool, and file workflow · `ViewModels/MainViewModel.cs`
- [Base VM](https://github.com/xbambinox/imageeditor/blob/master/ViewModels/BaseViewModel.cs): mvvm base · Shared view-model behavior · `ViewModels/BaseViewModel.cs`
- **Filter VMs**: dialog view-models · Brightness, gamma, blur, grayscale, pixelate, sharpen, and Sobel parameter models
- [Relay command](https://github.com/xbambinox/imageeditor/blob/master/Commands/RelayCommand.cs): command helper · Command abstraction for view-model actions · `Commands/RelayCommand.cs`

### Editor mechanics

Drawing, selection, image processing, and persistence

- [Drawing service](https://github.com/xbambinox/imageeditor/blob/master/Services/Toolbar/DrawingService.cs): raster editing · Brush, line, text, and canvas paint operations · `Services/Toolbar/DrawingService.cs`
- [Selection service](https://github.com/xbambinox/imageeditor/blob/master/Services/Toolbar/SelectionService.cs): selection editing · Rectangular selection, copy/cut/paste, and floating paste behavior · `Services/Toolbar/SelectionService.cs`
- [Image filters](https://github.com/xbambinox/imageeditor/tree/master/Services/ImageProcessing): filter helpers · Brightness, gamma, blur, grayscale, invert, sharpen, Sobel, and pixelate helpers · `Services/ImageProcessing`
- [Save helper](https://github.com/xbambinox/imageeditor/blob/master/Services/ImageStatus/SaveImageHelper.cs): persistence · Centralized image save workflow and format handling · `Services/ImageStatus/SaveImageHelper.cs`
- [Info service](https://github.com/xbambinox/imageeditor/blob/master/Services/ImageInfoService.cs): metadata service · Builds image information for info surfaces · `Services/ImageInfoService.cs`
- [Math tools](https://github.com/xbambinox/imageeditor/blob/master/Services/Math/Tools.cs): geometry helpers · Shared pixel and geometry utilities · `Services/Math/Tools.cs`

### Data and history

Document state, snapshots, and shared models

- [Image tab](https://github.com/xbambinox/imageeditor/blob/master/Models/ImageTab.cs): document tab · Open image workspace and tab-local editor state · `Models/ImageTab.cs`
- [Image document](https://github.com/xbambinox/imageeditor/blob/master/Models/ImageDocument.cs): document model · Loaded image data and file metadata · `Models/ImageDocument.cs`
- [History stack](https://github.com/xbambinox/imageeditor/blob/master/Models/LimitedStack.cs): undo/redo · Limited undo/redo history with image snapshots · `Models/LimitedStack.cs`
- [Snapshot](https://github.com/xbambinox/imageeditor/blob/master/Models/ImageSnapshot.cs): partial state · Dirty-region snapshot used for efficient history management · `Models/ImageSnapshot.cs`
- [Image info](https://github.com/xbambinox/imageeditor/blob/master/Models/ImageInfoModel.cs): metadata model · Image metadata displayed in info surfaces · `Models/ImageInfoModel.cs`
- [Tool models](https://github.com/xbambinox/imageeditor/blob/master/Models/Tooltype.cs): editor enums · Tool and shortcut metadata used by the shell and command layer · `Models/Tooltype.cs`

## Connections

- App shell → Main window: loads · Bootstraps the main editor shell
- Main window → Main view-model: binds to · Shell state and commands are driven by the main view-model
- Main window → Toolbar: hosts · Places the toolbar alongside the canvas workspace
- Toolbar → Main view-model: commands · Tool selections and actions route into the central coordinator
- Binding proxy → Main view-model: shares state · Exposes view-model data across disconnected visual trees
- Main view-model → Relay command: uses · Executes UI actions through MVVM commands
- Main view-model → Image tab: manages · Tracks the active document tabs
- Main view-model → Image document: opens/saves · Coordinates document lifecycle and file workflow
- Main view-model → Drawing service: routes tools · Sends paint and annotation actions to editing mechanics
- Main view-model → Selection service: routes tools · Sends selection and clipboard actions to editing mechanics
- Main view-model → Filter VMs: opens dialogs · Creates parameter view-models for image effects
- Filter dialogs → Filter VMs: hosts · Modal windows collect filter parameters
- Filter VMs → Image filters: invokes · Runs the selected filter helper
- Drawing service → Snapshot: captures · Stores partial bitmap history for undo/redo
- Drawing service → History stack: pushes · Adds edits to the history stack
- Selection service → Snapshot: captures · Preserves pre-edit pixel regions for selection workflows
- Selection service → History stack: pushes · Records selection edits in history
- Drawing service → Math tools: uses · Relies on shared geometry and pixel math
- Selection service → Math tools: uses · Relies on shared geometry and pixel math
- Save helper → Image document: persists · Writes the current document back to disk
- Main view-model → Save helper: delegates save · Centralizes save and export behavior
- Info service → Image info: builds · Produces metadata for info views and status surfaces
- Main view-model → Info service: queries · Requests image metadata for the UI
- Image tab → Image document: wraps · A tab represents one open image document
- Image tab → History stack: tracks history · Each open tab maintains its own undo/redo state
- Main view-model → Tool models: uses · Tool and shortcut metadata inform editor behavior
- Tool dialogs → Main view-model: drives settings · Brush, line, text, and canvas dialogs feed editor configuration
