# punker76/gong-wpf-dragdrop architecture

> Architecture diagram of the GitHub repository punker76/gong-wpf-dragdrop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/punker76/gong-wpf-dragdrop
- Repository: https://github.com/punker76/gong-wpf-dragdrop

## Overview

##### Project type and purpose
- This is an open-source .NET library (GongSolutions.WPF.DragDrop) providing drag-and-drop functionality for WPF items controls (ListBox, TreeView, DataGrid, etc.) with MVVM support.
- It also includes a “Showcase” WPF application demonstrating usage of the library.

##### File structure
- Top-level: build scripts (Cake, PowerShell), CI configs (.github/workflows, AppVeyor), solution files, README, LICENSE.
- src/GongSolutions.WPF.DragDrop: the class library containing
- Interfaces (IDragInfo, IDropInfo, IDragSource, IDropTarget, etc.)
- Core engine (DragDrop.cs, handlers, builders)
- Adorners & preview classes (DropTargetAdorner, DragDropEffectPreview, etc.)
- Utilities for hit testing, visual tree traversal, DPI.
- src/Showcase: WPF demo app with MVVM structure (Views, ViewModels, Models), showing sample controls wired to the library.

##### README
- Emphasizes MVVM integration via attached properties.
- Lists supported controls and features (multiple selection, insertion/move/copy, adorners, previews).
- Points to build instructions and usage wiki.

##### Main components & interactions
a. WPF Host & ItemsControls
- Represents the WPF runtime and controls (ListBox, TreeView, DataGrid).
b. GongSolutions.WPF.DragDrop Library
- Attached-Properties Layer: DragDrop.IsDragSource, .IsDropTarget
- Core Engine:
- DragInfoBuilder / DropInfoBuilder
- DefaultDragHandler / DefaultDropHandler
- Interfaces (IDragInfo, IDropInfo, …)
- Visual Feedback: Adorners, Preview renderers, IconFactory
- Utilities: HitTestUtilities, VisualTreeExtensions, DPI helpers
c. MVVM Application (Showcase)
- ViewModels implement ICommand or handler interfaces (IDragSource, IDropTarget)
- Models (ItemModel, TreeNode, etc.)
- Views wired via attached properties to ViewModel handlers
d. Build & Distribution
- Cake build script → NuGet package
- CI (GitHub Actions, AppVeyor)
- Versioning (GitVersion, GitReleaseManager)

##### Relationships & data flow
- Flow into Core Engine → builds DragInfo → invokes DragHandler → optionally shows Preview.
- On drop: Input flows into DropInfoBuilder → DefaultDropHandler or custom handler in ViewModel.
- Adorners rendered on VisualLayer to give feedback.
- App uses library’s attached properties to bind its ViewModels to controls.

##### Architectural patterns & design principles
- MVVM: Separation of View (XAML) and logic (ViewModels implementing drag/drop interfaces).
- Attached-Property pattern: exposes drag/drop behavior without code-behind.
- Strategy/Handler pattern: pluggable drag and drop handlers via interfaces.
- Layered design: UI → Attached Properties → Core Engine → Utilities.

[ ] All major library modules shown: Attached-Properties, Core, Adorners, Utilities
[ ] Controls & WPF host clearly separated from library
[ ] Showcase app layers (Views, ViewModels, Models) connected to library API
[ ] External dependencies (NET Framework/NET 6) noted

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% WPF Host
    WPF["WPF Runtime & ItemsControls"]:::wpf

    %% Library
    subgraph "GongSolutions.WPF.DragDrop Library"
        AP["Attached-Properties<br/>DragDrop.cs<br/>DragDrop.Properties.cs"]:::lib
        subgraph "Core Engine"
            subgraph Handlers
                DDH["DefaultDragHandler"]:::lib
                DPH["DefaultDropHandler"]:::lib
            end
            subgraph "Data Models"
                DI["DragInfo"]:::lib
                DO["DropInfo"]:::lib
                DHD["DropHintData"]:::lib
                DHI["DropHintInfo"]:::lib
                DHS["DropHintState"]:::lib
                DHH["DropHintHelpers"]:::lib
            end
        end
        subgraph Interfaces
            IDI["IDragInfo"]:::lib
            IDO["IDropInfo"]:::lib
            IDS["IDragSource"]:::lib
            IDT["IDropTarget"]:::lib
        end
        subgraph "Visual Feedback"
            AD["Adorners"]:::lib
            PV["Previews"]:::lib
            IF["IconFactory"]:::lib
        end
        subgraph Utilities
            UT["Utilities"]:::lib
        end
    end

    %% Showcase App
    subgraph "Showcase Application"
        VWS["Views"]:::app
        VMS["ViewModels"]:::app
        MDS["Models"]:::app
        CCS["CustomControls"]:::app
        APP["App Entry"]:::app
    end

    %% Build & CI
    subgraph "Build & CI"
        CAKE["Cake Build Script"]:::ci
        CIY["CI Configurations"]:::ci
        VER["Versioning"]:::ci
        NUG["NuGet Props"]:::ci
    end

    %% Relationships
    WPF -->|"events"| AP
    AP -->|"uses"| DDH
    AP -->|"uses"| DPH
    AP -->|"creates"| DI
    AP -->|"creates"| DO
    AP -->|"exposes"| IDI
    AP -->|"exposes"| IDO
    AP -->|"exposes"| IDS
    AP -->|"exposes"| IDT
    DDH -->|"renders"| AD
    DDH -->|"renders"| PV
    DPH -->|"uses"| DHD
    DPH -->|"uses"| DHI
    DPH -->|"uses"| DHS
    AD -->|"uses"| UT
    PV -->|"uses"| IF
    VWS -->|"binds via attached props"| AP
    VMS -->|"implements interfaces"| IDS
    VMS -->|"implements interfaces"| IDT
    MDS -->|"data for drag/drop"| AP
    CCS -->|"extends ItemsControl"| VWS
    APP -->|"starts"| VWS

    CAKE -.->|"builds"| NUG
    CAKE -.->|"executes"| CIY
    CIY -.->|"triggers"| VER

    %% Click events
    click AP "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DragDrop.cs"
    click DDH "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DefaultDragHandler.cs"
    click DPH "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DefaultDropHandler.cs"
    click DI "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DragInfo.cs"
    click DO "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DropInfo.cs"
    click DHD "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DropHintData.cs"
    click DHI "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DropHintInfo.cs"
    click DHS "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DropHintState.cs"
    click DHH "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DropHintHelpers.cs"
    click IDI "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/IDragInfo.cs"
    click IDO "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/IDropInfo.cs"
    click IDS "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/IDragSource.cs"
    click IDT "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/IDropTarget.cs"
    click AD "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DropTargetAdorner.cs"
    click PV "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/DragDropEffectPreview.cs"
    click IF "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/Icons/IconFactory.cs"
    click UT "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/Utilities/HitTestUtilities.cs"
    click VWS "https://github.com/punker76/gong-wpf-dragdrop/tree/develop/src/Showcase/Views/"
    click VMS "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/Showcase/ViewModels/ViewModelBase.cs"
    click MDS "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/Showcase/Models/ItemModel.cs"
    click CCS "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/Showcase/CustomControls/CustomListBox.cs"
    click APP "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/Showcase/App.xaml"
    click CAKE "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/build.cake"
    click CIY "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/.github/workflows/ci.yml"
    click VER "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/GitVersion.yml"
    click NUG "https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/Directory.packages.props"

    %% Styles
    classDef wpf fill:#D0E8FF,stroke:#0050A0,color:#003366;
    classDef lib fill:#DFFFE0,stroke:#228B22,color:#006400;
    classDef app fill:#FFE5B4,stroke:#FF8C00,color:#8B4513;
    classDef ci fill:#F0F0F0,stroke:#888888,color:#555555;
```
