# caoyue/windowresizer architecture

> Architecture diagram of the GitHub repository caoyue/windowresizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/caoyue/windowresizer
- Repository: https://github.com/caoyue/windowresizer

## Overview

##### Main Components

a. GUI Application Layer
- Main WindowResizer application
- Settings window and Tray context components
- Different pages (About, Hotkeys, Processes, Profiles)

b. CLI Application Layer
- Standalone CLI interface
- Command processing components

c. Core Components
- Window Control System
- Hotkey Management System
- DPI Handling
- Theme Detection

d. Configuration Management
- Config file handling
- Profile management
- Window size matching system

##### Component Relationships

**User Interface Layer**

**Core Services Layer**

**Base Infrastructure Layer**

##### Specific Implementation Details

a. User Interface Layer:
- WindowResizer GUI (Main App)
- Settings Form
- Tray Context
- Pages (About, Hotkeys, Processes, Profiles)
- WindowResizer CLI
- Command Parser
- Resize Command

b. Core Services Layer:
- Window Management
- Resizer
- Window Event Handler
- DPI Utils
- Shortcut System
- Global Keyboard Hook
- Hotkey Management
- Theme Detection
- Theme Monitor

c. Base Infrastructure Layer:
- Configuration System
- Config Factory
- Profile Management
- Window Size Matching
- Common Components
- Window Utils
- Exceptions
- Native Methods

##### Important Relationships to Highlight

- How the GUI and CLI applications share the same core window management system
- Event flow from hotkey detection to window resizing
- Demonstrate configuration system integration with both GUI and CLI
- How the native Windows API interactions occur through the Core layer

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI
        GUI["WindowResizer GUI"]:::ui
        click GUI "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer/App.cs"
        Settings["Settings Window"]:::ui
        click Settings "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer/SettingForm.cs"
        Tray["Tray Context"]:::ui
        click Tray "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer/TrayContext.cs"
        
        subgraph Pages
            About["About Page"]:::ui
            click About "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer/Pages/AboutPage.cs"
            Hotkeys["Hotkeys Page"]:::ui
            click Hotkeys "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer/Pages/HotkeysPage.cs"
            Processes["Processes Page"]:::ui
            click Processes "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer/Pages/ProcessesPage.cs"
            Profiles["Profiles Page"]:::ui
            click Profiles "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer/Pages/ProfilesPage.cs"
        end

        CLI["WindowResizer CLI"]:::ui
        click CLI "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.CLI/Program.cs"
        CmdProcess["Command Processor"]:::ui
        click CmdProcess "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.CLI/Commands/ResizeCommand.cs"
    end

    subgraph CoreServices
        WinControl["Window Control System"]:::core
        click WinControl "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.Core/WindowControl/Resizer.cs"
        WinEvent["Window Event Handler"]:::core
        click WinEvent "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.Core/WindowControl/WindowEventHandler.cs"
        HotkeyMgmt["Hotkey Management"]:::core
        click HotkeyMgmt "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.Core/Shortcuts/GlobalKeyboardHook.cs"
        DPIHandler["DPI Handler"]:::core
        click DPIHandler "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.Core/Dpi/Utils.cs"
        ThemeDetect["Theme Detection"]:::core
        click ThemeDetect "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.Core/Theme/ThemeDetect.cs"
    end

    subgraph Infrastructure
        ConfigFactory["Config Factory"]:::infra
        click ConfigFactory "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.Configuration/ConfigFactory.cs"
        ProfileMgmt["Profile Management"]:::infra
        click ProfileMgmt "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.Configuration/Profiles.cs"
        WinSizeMatch["Window Size Matching"]:::infra
        click WinSizeMatch "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.Configuration/MatchWindowSize.cs"
        
        subgraph Common
            WinUtils["Window Utilities"]:::infra
            click WinUtils "https://github.com/caoyue/WindowResizer/tree/master/src/WindowResizer.Common/Windows/"
            Exceptions["Exceptions Handler"]:::infra
            click Exceptions "https://github.com/caoyue/WindowResizer/tree/master/src/WindowResizer.Common/Exceptions/"
            HotkeyDefs["Hotkey Definitions"]:::infra
            click HotkeyDefs "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer.Common/Shortcuts/Hotkeys.cs"
        end

        SysStartup["System Startup"]:::infra
        click SysStartup "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer/Utils/SystemStartup.cs"
        Updater["Squirrel Updater"]:::infra
        click Updater "https://github.com/caoyue/WindowResizer/blob/master/src/WindowResizer/SquirrelUpdater.cs"
    end

    %% Relationships
    GUI --> Settings
    GUI --> Tray
    GUI --> Pages
    GUI --> WinControl
    GUI --> HotkeyMgmt
    GUI --> ConfigFactory
    GUI --> SysStartup
    GUI --> Updater

    CLI --> CmdProcess
    CmdProcess --> WinControl
    CmdProcess --> ConfigFactory

    WinControl --> WinEvent
    WinControl --> DPIHandler
    WinControl --> WinUtils
    WinControl --> Exceptions

    HotkeyMgmt --> HotkeyDefs
    HotkeyMgmt --> WinControl

    ConfigFactory --> ProfileMgmt
    ProfileMgmt --> WinSizeMatch
    WinSizeMatch --> WinUtils

    %% Styles
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef infra fill:#FFC107,stroke:#FFA000,color:black

    %% Legend
    subgraph Legend
        UI_L["UI Component"]:::ui
        Core_L["Core Service"]:::core
        Infra_L["Infrastructure"]:::infra
    end
```
