# yoshi-782/mainscreencapture4wpf architecture

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

- Interactive diagram: https://gitdiagram.com/yoshi-782/mainscreencapture4wpf
- Repository: https://github.com/yoshi-782/mainscreencapture4wpf

## Overview

##### Project Type and Purpose
- This is a single-application desktop tool designed for screen capturing. Its features include selecting specific monitors for capture, automatically copying the captured images to the clipboard or saving them to a file, and displaying a history of screenshots with options to further copy, save, preview, or delete these images.
- The README confirms that the application is built with Visual Studio 2019, employing MaterialDesignThemes for styling and System.Drawing.Common for image processing.

##### Analyzing the File Structure
- Key files like App.xaml, App.xaml.cs, MainWindow.xaml, and MainWindow.xaml.cs indicate a WPF-based UI with clearly defined application entry points and view elements.
- The MonitorInfo.cs file suggests dedicated functionality to access and manage monitor/display information, which is critical to the screenshot selection process.
- The presence of a solution file (.sln) and a project file (.csproj) indicates a standard .NET project structure with likely separation between UI presentation and underlying logic.

##### Components
a. User Interface / Presentation Layer:
- MainWindow (defined in MainWindow.xaml and MainWindow.xaml.cs) that hosts controls such as buttons for “撮影” (capture), “画像をコピーボタン” (copy image), “保存” (save image), preview, and a history panel.
- App.xaml and App.xaml.cs for overall application styling and resource management.
- UI elements utilizing MaterialDesignThemes components for a modern visual experience.

b. Business Logic / Application Core:
- Screenshot Capture Module:
- Responsible for handling the screenshot functionality.
- Interfaces with System.Drawing.Common and Windows API calls.
- Logic to temporarily hide the application window if it is in the capture area.
- Image Processing & Clipboard Management:
- Handles conversion of screenshots into appropriate file formats (jpg, png, bmp).
- Logic for copying images to the clipboard and optionally saving them as files.
- History Management:
- Maintains and displays a history of captured images.
- Provides user controls to copy, save, preview, or delete individual history items.
- Monitor Management:
- Based on MonitorInfo.cs, this module manages monitor selection and ensures the screenshot corresponds to the correct display.

c. External Services / Libraries:
- MaterialDesignThemes:
- Used within the UI to improve aesthetics.
- System.Drawing.Common:
- Used for image manipulation and handling behind the scenes.
- .NET Core/WPF Framework:
- Serves as the backbone for the entire application, handling UI rendering, event handling, and resource management.

##### Relationships and Interactions
- How the UI components in MainWindow trigger interactions with the capture module.
- How the Monitor Management component provides display details to the capture module.
- Flow where the processed image is then passed to either the clipboard manager (for direct copy) or to the file handling module, depending on user settings.
- History Management component, which collects and displays past screenshots along with associated action buttons.

##### Architectural Patterns and Design Principles
- While the application might not explicitly implement formal patterns, the separation between presentation (XAML-based UI), business logic (image capture, processing), and system integration (interaction with OS APIs and external libraries) is key.
- Event-driven architecture where user actions propagate to service modules which then update the UI accordingly.

## Diagram (Mermaid)

```mermaid
graph TD
    %% UI Layer
    subgraph "UI Layer"
        subgraph "Application Resources"
            A1["App.xaml"]:::ui
            A2["App.xaml.cs"]:::ui
        end
        subgraph "Main Window"
            M1["MainWindow.xaml"]:::ui
            M2["MainWindow.xaml.cs"]:::ui
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        SC["Screenshot Capture Module"]:::business
        IP["Image Processing & Clipboard/File Operations"]:::business
        HM["History Management"]:::business
        MM["Monitor Management"]:::business
    end

    %% External Services
    subgraph "External Services"
        MD["MaterialDesignThemes"]:::external
        SD["System.Drawing.Common"]:::external
        FRAME[".NET Core/WPF Framework"]:::external
        PROJ["Project Dependencies"]:::external
    end

    %% Relationships
    M1 -->|"triggers_capture"| SC
    MM -->|"provides_display_info"| SC
    SC -->|"sends_image"| IP
    IP -->|"updates_history"| HM
    HM -->|"refreshes_UI"| M1

    A1 -->|"applies_theme"| MD
    M1 -->|"applies_theme"| MD

    SC -->|"uses_imagemanipulation"| SD
    IP -->|"uses_conversion"| SD

    A1 -->|"rendered_by"| FRAME
    M1 -->|"rendered_by"| FRAME
    SC -->|"runs_on"| FRAME
    IP -->|"runs_on"| FRAME

    PROJ --> SC
    PROJ --> IP
    PROJ --> HM
    PROJ --> MM

    %% Click Events
    click A1 "https://github.com/yoshi-782/mainscreencapture4wpf/blob/master/App.xaml"
    click A2 "https://github.com/yoshi-782/mainscreencapture4wpf/blob/master/App.xaml.cs"
    click M1 "https://github.com/yoshi-782/mainscreencapture4wpf/blob/master/MainWindow.xaml"
    click M2 "https://github.com/yoshi-782/mainscreencapture4wpf/blob/master/MainWindow.xaml.cs"
    click MM "https://github.com/yoshi-782/mainscreencapture4wpf/blob/master/MonitorInfo.cs"
    click PROJ "https://github.com/yoshi-782/mainscreencapture4wpf/blob/master/MainScreenCapture4WPF.csproj"

    %% Styles
    classDef ui fill:#FFDDC1,stroke:#333,stroke-width:2px;
    classDef business fill:#C1E1C1,stroke:#333,stroke-width:2px;
    classDef external fill:#C9C9FF,stroke:#333,stroke-width:2px;
```
