├── .gitattributes
├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── Directory.Build.Props
├── Document
├── 1.png
├── 2.png
├── 3.png
├── 4.png
└── logo.png
├── LICENSE
├── README.md
├── Solution
└── WPF-Diagram.sln
├── Source
├── App
│ ├── HeBianGu.Test.Diagram
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── HeBianGu.Test.Diagram.csproj
│ │ ├── Images
│ │ │ ├── 功率计.png
│ │ │ ├── 开关矩阵.png
│ │ │ ├── 电源.png
│ │ │ └── 频谱分析仪.png
│ │ ├── MainWindow.xaml
│ │ └── MainWindow.xaml.cs
│ └── HeBianGu.Test.DiagramNuget
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── HeBianGu.Test.DiagramNuget.csproj
│ │ ├── Images
│ │ ├── 功率计.png
│ │ ├── 开关矩阵.png
│ │ ├── 电源.png
│ │ └── 频谱分析仪.png
│ │ ├── MainWindow.xaml
│ │ └── MainWindow.xaml.cs
└── Control
│ ├── HeBianGu.Diagram.DrawingBox
│ ├── AssemblyInfo.cs
│ ├── Command.Node.cs
│ ├── Diagram.xaml
│ ├── Diagram.xaml.cs
│ ├── DiagramCommands.cs
│ ├── DiagramEffectKey.cs
│ ├── DiagramFlowableMode.cs
│ ├── DiagramFlowableState.cs
│ ├── DiagramFlowableZoomMode.cs
│ ├── DisplayPortMode.cs
│ ├── Extention.cs
│ ├── Figure
│ │ └── Square.cs
│ ├── Graph1.dgml
│ ├── GraphSource
│ │ ├── GraphSource.cs
│ │ ├── IDataSource.cs
│ │ ├── IGraphSource.cs
│ │ ├── Model
│ │ │ ├── DefaultLinkData.cs
│ │ │ ├── DefaultPort.cs
│ │ │ ├── Socket.cs
│ │ │ ├── Unit.cs
│ │ │ └── Wire.cs
│ │ ├── TreeGraphSource.cs
│ │ ├── TypeTreeGraphSource.cs
│ │ └── UnitGraphSource.cs
│ ├── HeBianGu.Diagram.DrawingBox.csproj
│ ├── Layer
│ │ ├── Base
│ │ │ └── Layer.cs
│ │ ├── LinkLayer.cs
│ │ └── NodeLayer.cs
│ ├── Layout
│ │ ├── Base
│ │ │ ├── ILayout.cs
│ │ │ └── Layout.cs
│ │ ├── CircularLayout.cs
│ │ ├── ForceDirectedLayout.cs
│ │ ├── GridLayout.cs
│ │ ├── LocationLayout.cs
│ │ └── TreeLayout.cs
│ ├── LinkDrawer
│ │ ├── ArcLinkDrawer.cs
│ │ ├── BezierLinkDrawer.cs
│ │ ├── BrokenLinkDrawer.cs
│ │ ├── LineLinkDrawer.cs
│ │ └── LinkDrawer.cs
│ ├── LinkMode.cs
│ ├── NodeResizeAdorner.xaml
│ ├── NodeResizeAdorner.xaml.cs
│ ├── Part
│ │ ├── Base
│ │ │ └── Part.cs
│ │ ├── Link.xaml
│ │ ├── Link.xaml.cs
│ │ ├── Node.xaml
│ │ ├── Node.xaml.cs
│ │ ├── Port.xaml
│ │ ├── Port.xaml.cs
│ │ ├── TreeNode.xaml
│ │ └── TreeNode.xaml.cs
│ ├── Provider
│ │ ├── Adorner
│ │ │ ├── AdornerBase.cs
│ │ │ ├── BorderAdorner.cs
│ │ │ ├── ControlTemplateAdorner.xaml
│ │ │ ├── ControlTemplateAdorner.xaml.cs
│ │ │ ├── DataTemplateAdorner.xaml
│ │ │ ├── DataTemplateAdorner.xaml.cs
│ │ │ ├── DragAdorner.cs
│ │ │ ├── ErrorAdorner.cs
│ │ │ ├── GridLineAdorner.cs
│ │ │ ├── LineAdorner.cs
│ │ │ ├── OverAdorner.cs
│ │ │ ├── PresenterAdorner.cs
│ │ │ ├── ResizeAdorner.xaml
│ │ │ ├── ResizeAdorner.xaml.cs
│ │ │ ├── ScrollAdorner.cs
│ │ │ ├── SelectedAdorner.cs
│ │ │ ├── SelectedControlTemplateAdorner.cs
│ │ │ └── VisualCollectionAdornerBase.cs
│ │ ├── Bindable.cs
│ │ ├── BindableBase.cs
│ │ ├── Cattach.Behaviors.cs
│ │ ├── DisplayEnumConverter.cs
│ │ ├── DisplayNameConverter.cs
│ │ ├── Extension.Dispatcher.cs
│ │ ├── Extension.Geometry.cs
│ │ ├── Extension.Rect.cs
│ │ ├── Extention.Element.cs
│ │ ├── IDragAdorner.cs
│ │ ├── IZoombox.cs
│ │ ├── MarkupCommandBase.cs
│ │ ├── RelayCommand.cs
│ │ └── RoutedEventArgs.cs
│ ├── Service.cs
│ ├── Service
│ │ ├── Bevavior
│ │ │ ├── DiagramAdorner.cs
│ │ │ ├── DiagramDropBehavior
│ │ │ │ ├── DiagramDropBehavior.cs
│ │ │ │ └── DiagramDropNodeBehavior.cs
│ │ │ ├── DynimacLinkBehavior
│ │ │ │ ├── DynimacLinkBehaviorBase.cs
│ │ │ │ ├── DynimacLinkNodeBehavior.cs
│ │ │ │ ├── DynimacLinkPortBehavior.cs
│ │ │ │ └── PortLinkBehavior.cs
│ │ │ ├── NodeAdorner.cs
│ │ │ ├── NodeMouseDragBehavior.cs
│ │ │ ├── NodeMouseOverBehavior.cs
│ │ │ └── NodeSelectionBehavior.cs
│ │ ├── DynamicLinkData.cs
│ │ ├── FlowableResult.cs
│ │ ├── FlowableResultState.cs
│ │ ├── FlowableState.cs
│ │ ├── IData.cs
│ │ ├── IDropable.cs
│ │ ├── IFlowable.cs
│ │ ├── IFlowableLink.cs
│ │ ├── IFlowableNode.cs
│ │ ├── IFlowablePort.cs
│ │ ├── IFlowableResult.cs
│ │ ├── ILinkData.cs
│ │ ├── ILinkDataCreator.cs
│ │ ├── ILinkInitializer.cs
│ │ ├── INodeData.cs
│ │ ├── INoteDisplay.cs
│ │ ├── IPortData.cs
│ │ ├── IPortDataCreator.cs
│ │ ├── ITemplate.cs
│ │ └── PortType.cs
│ ├── Themes
│ │ ├── Default.xaml
│ │ └── Generic.xaml
│ └── obfuscar.xml
│ ├── HeBianGu.Diagram.Presenter.Workflow
│ ├── AssemblyInfo.cs
│ ├── Commands
│ │ └── Command.AddNode.cs
│ ├── HeBianGu.Diagram.Presenter.Workflow.csproj
│ ├── NodeData
│ │ ├── CardNodeData.cs
│ │ ├── CircleNodeData.cs
│ │ ├── ContentNodeData.cs
│ │ ├── CornerRadiusNodeData.cs
│ │ ├── DelayNodeData.cs
│ │ ├── DiamondNodeData.cs
│ │ ├── FileNodeData.cs
│ │ ├── HexagonNodeData.cs
│ │ ├── InputNodeData.cs
│ │ ├── LineRectNodeData.cs
│ │ ├── OperationNodeData.cs
│ │ ├── ParallelNodeData.cs
│ │ ├── ParallelogramNodeData.cs
│ │ ├── PillarNodeData.cs
│ │ ├── PredefineNodeData.cs
│ │ ├── RectNodeData.cs
│ │ ├── ReferenceNodeData.cs
│ │ ├── RunwayNodeData.cs
│ │ ├── StoreInNodeData.cs
│ │ ├── TransforNodeData.cs
│ │ ├── WaveNodeData.cs
│ │ ├── WhileNodeData.cs
│ │ └── WorkflowNodeBase.cs
│ ├── Themes
│ │ └── Generic.xaml
│ ├── Workflow
│ │ ├── AuditWorkflow.cs
│ │ ├── BusinessMarkWorkflow.cs
│ │ ├── DataWorkflow.cs
│ │ ├── EventWorkflow.cs
│ │ ├── IDEFWorkflow.cs
│ │ ├── LaneWorkflow.xaml
│ │ ├── LaneWorkflow.xaml.cs
│ │ ├── SDLWorkflow.cs
│ │ ├── WorkWorkflow.cs
│ │ ├── Workflow.xaml
│ │ ├── Workflow.xaml.cs
│ │ └── WorkflowBase.cs
│ ├── WorkflowNodeAdorner.xaml
│ └── WorkflowNodeAdorner.xaml.cs
│ └── HeBianGu.Diagram.Presenter
│ ├── AssemblyInfo.cs
│ ├── Attribute
│ ├── DiagramType.cs
│ ├── NodeDisplayAttribute.cs
│ └── NodeTypeAttribute.cs
│ ├── Commands
│ ├── Command.AddNode.cs
│ └── Command.Node.cs
│ ├── Converter
│ └── Converter.Node.cs
│ ├── Diagram
│ └── AutoTest
│ │ ├── AutoTestFlowableDiagramBase.cs
│ │ ├── AutoTestReportViewPresenter.cs
│ │ ├── AutoTestResult.cs
│ │ ├── AutoTestResultPresenter.cs
│ │ └── ats_dd_result.cs
│ ├── DiagramBase.cs
│ ├── DiagramFlowableDataSourceConverter.cs
│ ├── FlowableDiagramBase.cs
│ ├── HeBianGu.Diagram.Presenter.csproj
│ ├── IDiagram.cs
│ ├── IFlowableDiagram.cs
│ ├── Presenter
│ ├── Link
│ │ ├── FlowableLinkData.cs
│ │ ├── LinkData.cs
│ │ ├── TextLinkData.xaml
│ │ └── TextLinkData.xaml.cs
│ ├── Node
│ │ ├── Card
│ │ │ ├── CardNodeData.xaml
│ │ │ ├── CardNodeData.xaml.cs
│ │ │ ├── CheckCardNodeData.xaml
│ │ │ ├── CheckCardNodeData.xaml.cs
│ │ │ ├── FlowableDiagramTemplateNodeData.xaml
│ │ │ ├── FlowableDiagramTemplateNodeData.xaml.cs
│ │ │ ├── LineCardNodeData.xaml
│ │ │ ├── LineCardNodeData.xaml.cs
│ │ │ ├── PointCardNodeData.xaml
│ │ │ ├── PointCardNodeData.xaml.cs
│ │ │ ├── TitleCardNodeData.xaml
│ │ │ └── TitleCardNodeData.xaml.cs
│ │ ├── FlowableNodeData.xaml
│ │ ├── FlowableNodeData.xaml.cs
│ │ ├── GeometryNodeData.xaml
│ │ ├── GeometryNodeData.xaml.cs
│ │ ├── ImageNodeData.xaml
│ │ ├── ImageNodeData.xaml.cs
│ │ ├── PropertyNodeData.cs
│ │ ├── Provider
│ │ │ ├── NodeData.cs
│ │ │ ├── NodeFactory.cs
│ │ │ └── SystemNodeData.cs
│ │ ├── TextNodeData.xaml
│ │ └── TextNodeData.xaml.cs
│ └── Port
│ │ ├── FlowablePortData.xaml
│ │ ├── FlowablePortData.xaml.cs
│ │ ├── PortData.cs
│ │ ├── TextPortData.xaml
│ │ └── TextPortData.xaml.cs
│ ├── Provider
│ ├── Behavior.Adorner.Base.cs
│ ├── Behavior.Adorner.Loaded.cs
│ ├── Cattach.cs
│ ├── Converter.MarkupValueBase.cs
│ ├── DiagramDataSourceConverter.cs
│ ├── DiagramDropDispalyNodeBehavior.cs
│ ├── DiagramKeys.cs
│ ├── DiagramTemplate.cs
│ ├── DiagramTheme.cs
│ ├── DiagramThemeGroup.cs
│ ├── DisplayBindableBase.cs
│ ├── DisplayGraphSource.cs
│ ├── DrapAdornerBehavior.cs
│ ├── DropAdornerBehavior.cs
│ ├── ElementAllowDrapBehavior.cs
│ ├── Extension.Observable.cs
│ ├── GeometryFactory.cs
│ ├── IDefaultable.cs
│ ├── IDiagramTemplate.cs
│ ├── IDragAdorner.cs
│ ├── IModelBindable.T.cs
│ ├── IModelBindable.cs
│ ├── ISearchable.cs
│ ├── ISelectBindable.cs
│ ├── ModelBindable.cs
│ ├── NodeGroup.cs
│ ├── SelectBindable.cs
│ ├── Seriliaze
│ │ ├── XmlDiagramData.cs
│ │ └── XmlStringData.cs
│ └── Tree
│ │ ├── ITreeNode.cs
│ │ ├── LinkTreeNode.cs
│ │ ├── NodeTreeNode.cs
│ │ ├── PartTreeNodeBase.cs
│ │ ├── PortTreeNode.cs
│ │ └── TreeNodeBase.cs
│ ├── Service
│ ├── Extention.cs
│ ├── Service.cs
│ └── Setting.cs
│ └── Themes
│ └── Generic.xaml
├── WPF-Package.sln
└── settings.xamlstyler
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: NuGet Push
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | jobs:
9 | build:
10 | runs-on: windows-latest
11 | steps:
12 | - name: Checkout
13 | uses: actions/checkout@v2
14 | - name: Setup
15 | uses: actions/setup-dotnet@v1
16 | - name: Pack
17 | run: dotnet build --configuration Release
18 | - name: Push
19 | run: dotnet nuget push .\Source\*\*\bin\Release\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NuGetAPIKey }} --skip-duplicate --no-symbols 1
20 |
--------------------------------------------------------------------------------
/Directory.Build.Props:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 | logo.png
5 |
7 | MIT
8 | net7.0-windows;
9 | False
10 | 9.0
11 | 1.0.0
12 | 1.0.0
13 | 1.0.0
14 | Copyright © HeBianGu 2024-2024
15 | HeBianGu
16 | https://github.com/HeBianGu/WPF-Diagram
17 | https://github.com/HeBianGu/WPF-Diagram
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | True
30 | \
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Document/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Document/1.png
--------------------------------------------------------------------------------
/Document/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Document/2.png
--------------------------------------------------------------------------------
/Document/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Document/3.png
--------------------------------------------------------------------------------
/Document/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Document/4.png
--------------------------------------------------------------------------------
/Document/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Document/logo.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 HeBianGu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #
WPF-Diagram | [English](README.md)
2 | WPF流程图控件
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | ## 预览
22 |
23 | 
24 | 
25 | 
26 | 
27 |
28 | [演示视频](https://www.bilibili.com/video/BV1qy421i74b/?spm_id_from=333.999.0.0)
29 |
30 | ## 推荐学习官方文档
31 | https://learn.microsoft.com/zh-cn/dotnet/api/system.windows.controls?view=windowsdesktop-8.0?wt.mc_id=MVP_380318
32 | ## 推荐查看在线源码
33 | https://referencesource.microsoft.com/?wt.mc_id=MVP_380318
34 |
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.Diagram/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.Diagram/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace HeBianGu.Test.Diagram
4 | {
5 | ///
6 | /// Interaction logic for App.xaml
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.Diagram/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.Diagram/HeBianGu.Test.Diagram.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net7.0-windows
6 |
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.Diagram/Images/功率计.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Source/App/HeBianGu.Test.Diagram/Images/功率计.png
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.Diagram/Images/开关矩阵.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Source/App/HeBianGu.Test.Diagram/Images/开关矩阵.png
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.Diagram/Images/电源.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Source/App/HeBianGu.Test.Diagram/Images/电源.png
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.Diagram/Images/频谱分析仪.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Source/App/HeBianGu.Test.Diagram/Images/频谱分析仪.png
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.Diagram/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace HeBianGu.Test.Diagram
4 | {
5 | ///
6 | /// Interaction logic for MainWindow.xaml
7 | ///
8 | public partial class MainWindow : Window
9 | {
10 | public MainWindow()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.DiagramNuget/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.DiagramNuget/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace HeBianGu.Test.DiagramNuget
4 | {
5 | ///
6 | /// Interaction logic for App.xaml
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.DiagramNuget/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.DiagramNuget/HeBianGu.Test.DiagramNuget.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net7.0-windows
6 |
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.DiagramNuget/Images/功率计.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Source/App/HeBianGu.Test.DiagramNuget/Images/功率计.png
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.DiagramNuget/Images/开关矩阵.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Source/App/HeBianGu.Test.DiagramNuget/Images/开关矩阵.png
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.DiagramNuget/Images/电源.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Source/App/HeBianGu.Test.DiagramNuget/Images/电源.png
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.DiagramNuget/Images/频谱分析仪.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HeBianGu/WPF-Diagram/3d60284674ccdf48dfe21ea1f524bf12a8f9a72a/Source/App/HeBianGu.Test.DiagramNuget/Images/频谱分析仪.png
--------------------------------------------------------------------------------
/Source/App/HeBianGu.Test.DiagramNuget/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace HeBianGu.Test.DiagramNuget
4 | {
5 | ///
6 | /// Interaction logic for MainWindow.xaml
7 | ///
8 | public partial class MainWindow : Window
9 | {
10 | public MainWindow()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Markup;
5 |
6 | [assembly: ThemeInfo(
7 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
8 | //(used if a resource is not found in the page,
9 | // or application resource dictionaries)
10 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
11 | //(used if a resource is not found in the page,
12 | // app, or any theme specific resource dictionaries)
13 | )]
14 |
15 | [assembly: XmlnsDefinition("QQ:908293466", "HeBianGu.Diagram.DrawingBox")]
16 | [assembly: XmlnsPrefix("QQ:908293466", "h")]
17 |
18 | [assembly: XmlnsDefinition("https://github.com/HeBianGu", "HeBianGu.Diagram.DrawingBox")]
19 | [assembly: XmlnsPrefix("https://github.com/HeBianGu", "h")]
20 |
21 | [assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "HeBianGu.Diagram.DrawingBox")]
22 | [assembly: XmlnsPrefix("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "h")]
23 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Command.Node.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 |
6 | using System.Windows.Controls;
7 |
8 | namespace HeBianGu.Diagram.DrawingBox
9 | {
10 | public class RemoveNodeCommand : MarkupCommandBase
11 | {
12 | public override void Execute(object parameter)
13 | {
14 | if (parameter is Node node)
15 | node.Delete();
16 |
17 | if (parameter is ContextMenu menu)
18 | {
19 | menu.PlacementTarget.GetParent()?.Delete();
20 | }
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/DiagramCommands.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 | using System.Windows.Input;
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | public static class DiagramCommands
10 | {
11 | public static RoutedUICommand Start = new RoutedUICommand() { Text = "开始流程" };
12 | public static RoutedUICommand Stop = new RoutedUICommand() { Text = "停止流程" };
13 | public static RoutedUICommand Reset = new RoutedUICommand() { Text = "重置流程" };
14 | public static RoutedUICommand Clear = new RoutedUICommand() { Text = "清空节点" };
15 | public static RoutedUICommand DeleteSelected = new RoutedUICommand() { Text = "删除选中" };
16 | public static RoutedUICommand ZoomToFit = new RoutedUICommand() { Text = "缩放适配" };
17 | public static RoutedUICommand Aligment = new RoutedUICommand() { Text = "自动布局" };
18 | public static RoutedUICommand SelectAll = new RoutedUICommand() { Text = "全选" };
19 | public static RoutedUICommand Next = new RoutedUICommand() { Text = "下一个" };
20 | public static RoutedUICommand Previous = new RoutedUICommand() { Text = "上一个" };
21 |
22 | public static RoutedUICommand MoveLeft = new RoutedUICommand() { Text = "左移动" };
23 | public static RoutedUICommand MoveRight = new RoutedUICommand() { Text = "右移动" };
24 | public static RoutedUICommand MoveUp = new RoutedUICommand() { Text = "上移动" };
25 | public static RoutedUICommand MoveDown = new RoutedUICommand() { Text = "下移动" };
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/DiagramEffectKey.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public class DiagramEffectKey
8 | {
9 | public static ComponentResourceKey IsDragEnter => new ComponentResourceKey(typeof(DiagramEffectKey), "S.EffectShadow.IsDragEnter");
10 | public static ComponentResourceKey IsCanDrop => new ComponentResourceKey(typeof(DiagramEffectKey), "S.EffectShadow.IsCanDrop");
11 | public static ComponentResourceKey IsSelected => new ComponentResourceKey(typeof(DiagramEffectKey), "S.EffectShadow.IsSelected");
12 | public static ComponentResourceKey MouseOver => new ComponentResourceKey(typeof(DiagramEffectKey), "S.EffectShadow.MouseOver");
13 | public static ComponentResourceKey IsDragging => new ComponentResourceKey(typeof(DiagramEffectKey), "S.EffectShadow.IsDragging");
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/DiagramFlowableMode.cs:
--------------------------------------------------------------------------------
1 | namespace HeBianGu.Diagram.DrawingBox
2 | {
3 | public enum DiagramFlowableMode
4 | {
5 | Node = 0,
6 | Link,
7 | Port
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/DiagramFlowableState.cs:
--------------------------------------------------------------------------------
1 | namespace HeBianGu.Diagram.DrawingBox
2 | {
3 | public enum DiagramFlowableState
4 | {
5 | None = 0,
6 | Running,
7 | Success,
8 | Error,
9 | Stopped,
10 | Canceling,
11 | Canceled
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/DiagramFlowableZoomMode.cs:
--------------------------------------------------------------------------------
1 | namespace HeBianGu.Diagram.DrawingBox
2 | {
3 | public enum DiagramFlowableZoomMode
4 | {
5 | None = 0,
6 | Rect,
7 | Center
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/DisplayPortMode.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 |
6 | using System.ComponentModel;
7 | using System.ComponentModel.DataAnnotations;
8 |
9 | namespace HeBianGu.Diagram.DrawingBox
10 | {
11 | [TypeConverter(typeof(DisplayEnumConverter))]
12 | public enum DisplayPortMode
13 | {
14 | [Display(Name = "始终")]
15 | Always = 0,
16 | [Display(Name = "悬停")]
17 | MouseOver,
18 | [Display(Name = "选中")]
19 | Selected
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Extention.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace System
4 | {
5 |
6 |
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Figure/Square.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System;
4 | using System.Windows.Media;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public abstract class FigureBase : ICloneable
9 | {
10 | public FigureBase()
11 | {
12 | this.Name = this.GetType().Name;
13 | }
14 | public string Name { get; set; }
15 |
16 | public double Width { get; set; } = 100;
17 |
18 | public double Height { get; set; } = 100;
19 |
20 | public Brush Background { get; set; } = Brushes.Gray;
21 |
22 | public Brush Foreground { get; set; } = Brushes.White;
23 |
24 | public object Clone()
25 | {
26 | object n = Activator.CreateInstance(this.GetType());
27 |
28 | System.Reflection.PropertyInfo[] ps = this.GetType().GetProperties();
29 |
30 | foreach (System.Reflection.PropertyInfo p in ps)
31 | {
32 | p.SetValue(n, p.GetValue(this));
33 | }
34 |
35 | return n;
36 | }
37 | }
38 | /// 正方形
39 | public class Square : FigureBase
40 | {
41 | }
42 |
43 | ///
44 | /// 菱形
45 | ///
46 | public class Diamond : FigureBase
47 | {
48 | }
49 |
50 | ///
51 | /// 三角形
52 | ///
53 | public class Trangle : FigureBase
54 | {
55 |
56 | }
57 |
58 | ///
59 | /// 圆形
60 | ///
61 | public class Circle : FigureBase
62 | {
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/GraphSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Collections.Generic;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | ///
8 | /// 子类用于重写 重写Node和Link跟数据源的转换方式
9 | ///
10 | ///
11 | ///
12 | public abstract class GraphSource : IGraphSource, IDataSource
13 | {
14 | public List NodeSource { get; private set; } = new List();
15 |
16 | public GraphSource(List nodeSource)
17 | {
18 | this.NodeSource = nodeSource;
19 | }
20 |
21 | public GraphSource(IEnumerable nodes, IEnumerable links)
22 | {
23 | System.Windows.Application.Current.Dispatcher.Invoke(() =>
24 | {
25 | foreach (NodeDataType unit in nodes)
26 | {
27 | Node n = this.ConvertToNode(unit);
28 | this.NodeSource.Add(n);
29 | }
30 |
31 | foreach (LinkDataType link in links)
32 | {
33 | this.ConvertToLink(link);
34 | }
35 | });
36 |
37 | }
38 |
39 | ///
40 | /// 加载数据,由数据源到节点数据
41 | ///
42 | ///
43 | ///
44 | protected abstract Node ConvertToNode(NodeDataType node);
45 |
46 | ///
47 | /// 加载数据,由数据源到连线数据
48 | ///
49 | ///
50 | ///
51 | protected abstract Link ConvertToLink(LinkDataType node);
52 |
53 | public abstract List GetNodeType();
54 |
55 | public abstract List GetLinkType();
56 | }
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/IDataSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Collections.Generic;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public interface IDataSource
8 | {
9 | List GetNodeType();
10 |
11 | List GetLinkType();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/IGraphSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Collections.Generic;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public interface IGraphSource
8 | {
9 | List NodeSource { get; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/Model/DefaultLinkData.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 |
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | ///
10 | /// 默认端口要显示的效果
11 | ///
12 | public class DefaultLinkData : Bindable, ILinkData
13 | {
14 | private string _message;
15 | /// 说明
16 | public string Message
17 | {
18 | get { return _message; }
19 | set
20 | {
21 | _message = value;
22 | RaisePropertyChanged("Message");
23 | }
24 | }
25 |
26 | public string FromNodeID { get; set; }
27 |
28 | public string ToNodeID { get; set; }
29 |
30 | public string FromPortID { get; set; }
31 |
32 | public string ToPortID { get; set; }
33 |
34 | public void ApplayStyleTo(ILinkData node)
35 | {
36 |
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/Model/DefaultPort.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | ///
10 | /// 默认端口要显示的效果
11 | ///
12 | public class DefaultPortData : IPortData
13 | {
14 | public DefaultPortData()
15 | {
16 |
17 | }
18 | public DefaultPortData(string nodeID)
19 | {
20 | this.NodeID = nodeID;
21 | }
22 |
23 | public string ID { get; set; } = Guid.NewGuid().ToString();
24 |
25 | public string NodeID { get; set; }
26 |
27 | public string Name { get; set; }
28 |
29 |
30 | public Dock Dock { get; set; }
31 |
32 | public PortType PortType { get; set; }
33 |
34 | public Thickness PortMargin { get; set; } = new Thickness(0, 0, 0, 0);
35 |
36 | public virtual void ApplayStyleTo(IPortData node)
37 | {
38 |
39 | }
40 |
41 | public bool CanDrop(Part part, out string message)
42 | {
43 | message = null;
44 | return false;
45 | }
46 |
47 | public ILinkData CreateLinkData()
48 | {
49 | return null;
50 | }
51 |
52 | public void InitLink(Link link)
53 | {
54 |
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/Model/Socket.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows.Controls;
4 | using System.Xml.Serialization;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public class Socket
9 | {
10 | [XmlAttribute("Name")]
11 | public string Name { get; set; }
12 |
13 | [XmlAttribute("Dock")]
14 | public Dock Dock { get; set; }
15 |
16 | [XmlAttribute("Color")]
17 | public string Color { get; set; }
18 |
19 | [XmlAttribute("Index")]
20 | public int Index { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/Model/Unit.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Collections.Generic;
4 | using System.Xml.Serialization;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public class Unit
9 | {
10 | [XmlAttribute("Id")]
11 | public string Id { get; set; }
12 |
13 | [XmlAttribute("X")]
14 | public double X { get; set; }
15 |
16 | [XmlAttribute("Y")]
17 | public double Y { get; set; }
18 |
19 | [XmlAttribute("Text")]
20 | public string Text { get; set; }
21 |
22 | public List Sockets { get; set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/Model/Wire.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Xml.Serialization;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public class Wire
8 | {
9 | [XmlAttribute("From")]
10 | public string From { get; set; }
11 |
12 | [XmlAttribute("To")]
13 | public string To { get; set; }
14 |
15 | [XmlAttribute("FromPort")]
16 | public string FromPort { get; set; }
17 |
18 | [XmlAttribute("ToPort")]
19 | public string ToPort { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/TreeGraphSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | ///
10 | /// 自定义匹配方式的树结构数据源
11 | ///
12 | ///
13 | public class TreeGraphSource : IGraphSource
14 | {
15 | public List NodeSource { get; protected set; } = new List();
16 |
17 | private Func _childFiter;
18 | private Predicate _rootFiter;
19 |
20 | public TreeGraphSource(List nodes, Func childFiter, Predicate rootFiter)
21 | {
22 | _childFiter = childFiter;
23 | _rootFiter = rootFiter;
24 |
25 | this.NodeSource = this.GetSource(nodes);
26 | }
27 |
28 | protected virtual List GetSource(List nodes)
29 | {
30 |
31 | List treeNodes = new List();
32 |
33 | if (nodes == null) return treeNodes;
34 |
35 | NodeType obj = nodes.FirstOrDefault(l => _rootFiter(l));
36 |
37 | TreeNode root = new TreeNode() { Content = obj };
38 |
39 | Action action1 = null;
40 |
41 | action1 = (baseType, from) =>
42 | {
43 | IEnumerable children = nodes.Where(l => _childFiter(l, baseType));
44 |
45 | foreach (NodeType item in children)
46 | {
47 | TreeNode to = new TreeNode() { Content = item };
48 |
49 | Link.Create(from, to);
50 |
51 | treeNodes.Add(to);
52 |
53 | action1(item, to);
54 | }
55 | };
56 |
57 | treeNodes.Add(root);
58 |
59 | action1?.Invoke(obj, root);
60 |
61 | return treeNodes;
62 | }
63 | }
64 |
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/TypeTreeGraphSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Reflection;
7 |
8 | namespace HeBianGu.Diagram.DrawingBox
9 | {
10 | ///
11 | /// 类型树结构数据源
12 | ///
13 | public class TypeTreeGraphSource : TreeGraphSource
14 | {
15 | ///
16 | /// 要构建Type树结构的程序集
17 | ///
18 | ///
19 | public TypeTreeGraphSource(Assembly assembly) : base(null, (child, parent) => child.BaseType == parent, l => l.BaseType == null)
20 | {
21 | List types = assembly.GetTypes()?.ToList();
22 |
23 | types = types.Where(l => l.IsClass && l.IsPublic && !l.IsGenericType && !typeof(Attribute).IsAssignableFrom(l))?.ToList();
24 |
25 | List result = this.Build(types);
26 |
27 | this.NodeSource = this.GetSource(result);
28 |
29 | }
30 |
31 | ///
32 | /// 要构建Type树结构的类型集合
33 | ///
34 | ///
35 | public TypeTreeGraphSource(List types) : base(null, (child, parent) => child.BaseType == parent, l => l.BaseType == null)
36 | {
37 | List result = this.Build(types);
38 |
39 | this.NodeSource = this.GetSource(result);
40 | }
41 |
42 | private List Build(List types)
43 | {
44 | HashSet result = new HashSet();
45 |
46 | Action> action = null;
47 |
48 | action = t =>
49 | {
50 | result.UnionWith(t);
51 |
52 | List child = t.Where(l => l.BaseType != null).Select(l => l.BaseType)?.ToList();
53 |
54 | if (child.Count > 0)
55 | {
56 | action(child);
57 | }
58 | };
59 |
60 | action?.Invoke(types);
61 |
62 | return result.ToList();
63 | }
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/GraphSource/UnitGraphSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Collections.Generic;
4 | using System.Linq;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | ///
9 | /// 根据 Unit和Wire加载的数据源
10 | ///
11 | public class UnitGraphSource : GraphSource
12 | {
13 | public UnitGraphSource(List nodes, List links) : base(nodes, links)
14 | {
15 |
16 | }
17 |
18 | protected override Node ConvertToNode(Unit unit)
19 | {
20 | Node node = new Node() { Content = unit };
21 | //node.Id = unit.Id;
22 | node.Location = new System.Windows.Point(unit.X, unit.Y);
23 |
24 | foreach (Socket socket in unit.Sockets)
25 | {
26 | Port port = Port.Create(node);
27 | //port.Id = socket.Name;
28 | port.Content = socket;
29 | port.Dock = socket.Dock;
30 | }
31 |
32 | return node;
33 | }
34 |
35 | protected override Link ConvertToLink(Wire wire)
36 | {
37 | Node fromNode = this.NodeSource.FirstOrDefault(l => l.Id == wire.From);
38 | Node toNode = this.NodeSource.FirstOrDefault(l => l.Id == wire.To);
39 |
40 | Port fromPort = fromNode.GetPorts(l => l.Id == wire.FromPort)?.FirstOrDefault();
41 | Port toPort = fromNode.GetPorts(l => l.Id == wire.ToPort)?.FirstOrDefault();
42 |
43 | return Link.Create(fromNode, toNode, fromPort, toPort);
44 | }
45 |
46 | public override List GetNodeType()
47 | {
48 | List result = new List();
49 |
50 | foreach (Node node in this.NodeSource)
51 | {
52 | Unit unit = node.Content as Unit;
53 |
54 | IEnumerable sockets = node.GetPorts().Select(l => l.Content).Cast();
55 |
56 | unit.Sockets = sockets.ToList();
57 |
58 | result.Add(unit);
59 | }
60 |
61 | return result;
62 | }
63 |
64 | public override List GetLinkType()
65 | {
66 | List result = new List();
67 |
68 | foreach (Node node in this.NodeSource)
69 | {
70 | foreach (Link link in node.LinksOutOf)
71 | {
72 | Wire wire = new Wire();
73 |
74 | wire.From = link.FromNode?.Id;
75 | wire.To = link.ToNode?.Id;
76 | wire.FromPort = link.FromPort?.Id;
77 | wire.ToPort = link.ToPort?.Id;
78 |
79 | result.Add(wire);
80 | }
81 | }
82 |
83 | return result;
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/HeBianGu.Diagram.DrawingBox.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Layer/Base/Layer.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Input;
7 |
8 | namespace HeBianGu.Diagram.DrawingBox
9 | {
10 | public abstract class Layer : Panel
11 | {
12 | public string Id { get; set; }
13 | public bool UseAnimation
14 | {
15 | get { return (bool)GetValue(UseAnimationProperty); }
16 | set { SetValue(UseAnimationProperty, value); }
17 | }
18 |
19 |
20 | public static readonly DependencyProperty UseAnimationProperty =
21 | DependencyProperty.Register("UseAnimation", typeof(bool), typeof(Layer), new PropertyMetadata(true, (d, e) =>
22 | {
23 | Layer control = d as Layer;
24 |
25 | if (control == null) return;
26 |
27 | //bool config = e.NewValue as bool;
28 |
29 | }));
30 |
31 |
32 |
33 | public TimeSpan Duration
34 | {
35 | get { return (TimeSpan)GetValue(DurationProperty); }
36 | set { SetValue(DurationProperty, value); }
37 | }
38 |
39 |
40 | public static readonly DependencyProperty DurationProperty =
41 | DependencyProperty.Register("Duration", typeof(TimeSpan), typeof(Layer), new PropertyMetadata(TimeSpan.FromMilliseconds(200), (d, e) =>
42 | {
43 | Layer control = d as Layer;
44 |
45 | if (control == null) return;
46 |
47 | //TimeSpan config = e.NewValue as TimeSpan;
48 |
49 | }));
50 |
51 |
52 | protected override Size ArrangeOverride(Size arrangeSize)
53 | {
54 | this.UseAnimation = false;
55 |
56 | return arrangeSize;
57 | }
58 |
59 |
60 | protected override void OnMouseDown(MouseButtonEventArgs e)
61 | {
62 | base.OnMouseDown(e);
63 | }
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Layout/Base/ILayout.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface ILayout
6 | {
7 | Diagram Diagram { get; set; }
8 | void DoLayout(params Node[] nodes);
9 | void UpdateNode(params Node[] nodes);
10 | void RemoveNode(params Node[] nodes);
11 | void AddNode(params Node[] nodes);
12 | void DoLayoutLink(Link link);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Layout/CircularLayout.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 | using System.ComponentModel;
6 | using System.Windows;
7 | using System.Windows.Media;
8 |
9 | namespace HeBianGu.Diagram.DrawingBox
10 | {
11 | /// 圆形布局
12 | [DisplayName("CircularLayout")]
13 | [TypeConverter(typeof(DisplayNameConverter))]
14 | public class CircularLayout : Layout
15 | {
16 | public double Len { get; set; } = 200;
17 |
18 | public override void DoLayout(params Node[] nodes)
19 | {
20 | if (nodes == null) return;
21 |
22 | double height = this.Diagram.ActualHeight;
23 |
24 | double width = this.Diagram.ActualWidth;
25 |
26 | Point center = new Point(width / 2, height / 2);
27 |
28 | double span = 360.0 / nodes.Length;
29 |
30 | // Do :布局Node
31 | for (int i = 0; i < nodes.Length; i++)
32 | {
33 | Node node = nodes[i];
34 |
35 | double angle = i * span;
36 |
37 | Point start = new Point(center.X - this.Len, center.Y);
38 |
39 | Matrix matrix = new Matrix();
40 |
41 | matrix.RotateAt(angle, center.X, center.Y);
42 |
43 | Point end = matrix.Transform(start);
44 |
45 | // Do :设置节点
46 | NodeLayer.SetPosition(node, end);
47 |
48 | this.DoLayoutNode(node);
49 |
50 | this.DoLayoutPort(node);
51 |
52 | this.DoLayoutLink(node);
53 |
54 |
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Layout/ForceDirectedLayout.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | /// 关系布局
8 | public class ForceDirectedLayout : Layout
9 | {
10 | public override void DoLayout(params Node[] nodes)
11 | {
12 | throw new NotImplementedException();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Layout/GridLayout.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 | using System.Collections.Generic;
6 | using System.ComponentModel;
7 | using System.Linq;
8 |
9 | namespace HeBianGu.Diagram.DrawingBox
10 | {
11 | /// 网格布局
12 | [DisplayName("GridLayout")]
13 | [TypeConverter(typeof(DisplayNameConverter))]
14 | public class GridLayout : Layout
15 | {
16 | public override void DoLayout(params Node[] nodes)
17 | {
18 | double height = this.Diagram.ActualHeight;
19 |
20 | List list = nodes.ToList();
21 |
22 | //double space = 50.0;
23 |
24 | //double x = 0.0;
25 |
26 | for (int i = 0; i < list.Count(); i++)
27 | {
28 | Node item = list[i];
29 |
30 | //if (item.VisualElement == null) continue;
31 |
32 | ////item.ApplyTemplate();
33 |
34 | //var size = item.GetEffectiveSize(item.VisualElement);
35 |
36 | //item.Bounds = new Rect(new Point(x, height / 2), size);
37 |
38 | //x += size.Width + space;
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Layout/LocationLayout.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 | using System.ComponentModel;
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | [DisplayName("LocationLayout")]
10 | [TypeConverter(typeof(DisplayNameConverter))]
11 | public class LocationLayout : Layout
12 | {
13 | /// 布局点和线
14 | public override void DoLayout(params Node[] nodes)
15 | {
16 | foreach (Node node in nodes)
17 | {
18 | // Do :布局Node
19 | NodeLayer.SetPosition(node, node.Location);
20 | }
21 |
22 | //this.UpdateNode(nodes);
23 | }
24 |
25 | public override void RemoveNode(params Node[] nodes)
26 | {
27 | foreach (Node node in nodes)
28 | {
29 | node.Delete();
30 | }
31 | }
32 |
33 | public override void AddNode(params Node[] nodes)
34 | {
35 | this.DoLayout(nodes);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/LinkDrawer/LineLinkDrawer.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Media;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public class LineLinkDrawer : LinkDrawer
9 | {
10 | public LineLinkDrawer()
11 | {
12 | this.DisplayName = "直线";
13 | }
14 | public override Geometry DrawPath(Link link, out Point center)
15 | {
16 | Point start = LinkLayer.GetStart(link);
17 | Point end = LinkLayer.GetEnd(link);
18 | Vector v = end - start;
19 | center = new Point((v.X / 2) + start.X, (v.Y / 2) + start.Y);
20 | if (this.IsLinkCrossBound == true)
21 | {
22 | Vector? find_start = Intersects(link.FromPort == null ? link.FromNode.Bound : link.FromPort.Bound, start, end);
23 |
24 | if (find_start.HasValue)
25 | {
26 | start = (Point)find_start.Value;
27 | }
28 |
29 | Vector? find_end = Intersects(link.ToPort == null ? link.ToNode.Bound : link.ToPort.Bound, start, end);
30 | if (find_end.HasValue)
31 | {
32 | end = (Point)find_end.Value;
33 | }
34 | }
35 |
36 | return this.GetLineGeometry(start.X, start.Y, end.X, end.Y);
37 | }
38 |
39 | protected Geometry GetLineGeometry(double x1, double y1, double x2, double y2)
40 | {
41 | Geometry geo = this.GetPolyLineGeometry(new Point(x1, y1), new Point(x2, y2));
42 | if (!this.IsUseArrow)
43 | return geo;
44 | return this.GetArrowGeometry(geo, new Point(x1, y1), new Point(x2, y2));
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/LinkMode.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 |
6 | using System.ComponentModel;
7 | using System.ComponentModel.DataAnnotations;
8 |
9 | namespace HeBianGu.Diagram.DrawingBox
10 | {
11 | [TypeConverter(typeof(DisplayEnumConverter))]
12 | public enum LinkMode
13 | {
14 | [Display(Name = "节点")]
15 | Node = 0,
16 | [Display(Name = "端口")]
17 | Port
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/NodeResizeAdorner.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
33 |
34 |
35 |
36 |
39 |
41 |
47 |
48 |
49 |
52 |
53 |
54 |
55 |
56 |
61 |
62 |
67 |
72 |
73 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Part/TreeNode.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
62 |
63 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/AdornerBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Media;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public abstract class AdornerBase : System.Windows.Documents.Adorner
9 | {
10 | public AdornerBase(UIElement adornedElement) : base(adornedElement)
11 | {
12 |
13 | }
14 |
15 | public static Pen GetPen(DependencyObject obj)
16 | {
17 | return (Pen)obj.GetValue(PenProperty);
18 | }
19 |
20 | public static void SetPen(DependencyObject obj, Pen value)
21 | {
22 | obj.SetValue(PenProperty, value);
23 | }
24 |
25 |
26 | public static readonly DependencyProperty PenProperty =
27 | DependencyProperty.RegisterAttached("Pen", typeof(Pen), typeof(AdornerBase), new PropertyMetadata(new Pen(Brushes.DeepSkyBlue, 1), OnPenChanged));
28 |
29 | public static void OnPenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
30 | {
31 | DependencyObject control = d;
32 |
33 | Pen n = (Pen)e.NewValue;
34 |
35 | Pen o = (Pen)e.OldValue;
36 | }
37 |
38 |
39 | public static Brush GetFill(DependencyObject obj)
40 | {
41 | return (Brush)obj.GetValue(FillProperty);
42 | }
43 |
44 | public static void SetFill(DependencyObject obj, Brush value)
45 | {
46 | obj.SetValue(FillProperty, value);
47 | }
48 |
49 |
50 | public static readonly DependencyProperty FillProperty =
51 | DependencyProperty.RegisterAttached("Fill", typeof(Brush), typeof(AdornerBase), new PropertyMetadata(default(Brush), OnFillChanged));
52 |
53 | public static void OnFillChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
54 | {
55 | DependencyObject control = d;
56 |
57 | Brush n = (Brush)e.NewValue;
58 |
59 | Brush o = (Brush)e.OldValue;
60 | }
61 |
62 |
63 |
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/BorderAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Media;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public class BorderAdorner : AdornerBase
9 | {
10 | public BorderAdorner(UIElement adornedElement) : base(adornedElement)
11 | {
12 | this.Pen = BorderAdorner.GetPen(adornedElement);
13 | this.Fill = BorderAdorner.GetFill(adornedElement);
14 | }
15 |
16 | public Brush Fill { get; set; }
17 | public double ScaleLen { get; set; }
18 | public Pen Pen { get; set; }
19 | protected override void OnRender(DrawingContext dc)
20 | {
21 | Rect rect = new Rect(this.AdornedElement.RenderSize);
22 | dc.DrawRectangle(this.Fill, this.Pen, new Rect(rect.Left - ScaleLen, rect.Top - ScaleLen, rect.Width + (2 * ScaleLen), rect.Height + (2 * ScaleLen)));
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/ControlTemplateAdorner.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/DataTemplateAdorner.xaml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/ErrorAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Media;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public class ErrorAdorner : BorderAdorner
9 | {
10 | public ErrorAdorner(UIElement adornedElement) : base(adornedElement)
11 | {
12 | this.Pen = new Pen(Brushes.Red, 1);
13 | this.ScaleLen = 3;
14 | this.Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.5 };
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/GridLineAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Media;
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | public class GridLineAdorner : AdornerBase
10 | {
11 | public GridLineAdorner(UIElement adornedElement) : base(adornedElement)
12 | {
13 | this.Pen = GridLineAdorner.GetPen(adornedElement);
14 | this.Fill = GridLineAdorner.GetFill(adornedElement);
15 | }
16 |
17 | public Brush Fill { get; set; }
18 | public double ScaleLen { get; set; }
19 | public Pen Pen { get; set; }
20 | protected override void OnRender(DrawingContext dc)
21 | {
22 | Grid grid = this.AdornedElement as Grid;
23 | if (grid == null)
24 | return;
25 | this.Pen = this.Pen ?? new Pen(Brushes.Blue, 1);
26 | foreach (RowDefinition item in grid.RowDefinitions)
27 | {
28 | dc.DrawLine(this.Pen, new Point(0, item.Offset), new Point(this.ActualWidth, item.Offset));
29 | }
30 | dc.DrawLine(this.Pen, new Point(0, grid.ActualHeight), new Point(this.ActualWidth, this.ActualHeight));
31 |
32 | foreach (ColumnDefinition item in grid.ColumnDefinitions)
33 | {
34 | dc.DrawLine(this.Pen, new Point(item.Offset, 0), new Point(item.Offset, this.ActualHeight));
35 | }
36 | dc.DrawLine(this.Pen, new Point(this.ActualWidth, 0), new Point(this.ActualWidth, this.ActualHeight));
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/LineAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Media;
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | public class LineAdorner : BorderAdorner
10 | {
11 | public LineAdorner(UIElement adornedElement) : base(adornedElement)
12 | {
13 | this.Pen = new Pen(Brushes.DeepSkyBlue, 4);
14 | this.Dock = Dock.Top;
15 | this.ScaleLen = 0;
16 | this.Fill = new SolidColorBrush(Colors.LightSkyBlue) { Opacity = 0.2 };
17 | }
18 |
19 | public Dock Dock { get; set; }
20 | protected override void OnRender(DrawingContext dc)
21 | {
22 | Rect rect = new Rect(this.AdornedElement.RenderSize);
23 | rect = new Rect(rect.Left - ScaleLen, rect.Top - ScaleLen, rect.Width + (2 * ScaleLen), rect.Height + (2 * ScaleLen));
24 | dc.DrawRectangle(this.Fill, null, rect);
25 |
26 | if (Dock == Dock.Left)
27 | {
28 | dc.DrawLine(this.Pen, rect.TopLeft, rect.BottomLeft);
29 | }
30 | if (Dock == Dock.Top)
31 | {
32 | dc.DrawLine(this.Pen, rect.TopLeft, rect.TopRight);
33 | }
34 | if (Dock == Dock.Right)
35 | {
36 | dc.DrawLine(this.Pen, rect.BottomRight, rect.TopRight);
37 | }
38 | if (Dock == Dock.Bottom)
39 | {
40 | dc.DrawLine(this.Pen, rect.BottomLeft, rect.BottomRight);
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/OverAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Media;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public class OverAdorner : BorderAdorner
9 | {
10 | public OverAdorner(UIElement adornedElement) : base(adornedElement)
11 | {
12 | this.Fill = new SolidColorBrush(Colors.LightSkyBlue) { Opacity = 0.1 };
13 | this.Pen = new Pen(new SolidColorBrush(Colors.SkyBlue), 1);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/PresenterAdorner.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public class PresenterAdorner : VisualCollectionAdornerBase
9 | {
10 | private ContentPresenter _contentPresenter = new ContentPresenter();
11 | public PresenterAdorner(UIElement adornedElement, object presenter) : base(adornedElement)
12 | {
13 | _contentPresenter.Content = presenter;
14 | _visualCollection.Add(_contentPresenter);
15 | }
16 |
17 | public object Presenter => this._contentPresenter.Content;
18 | protected override Size MeasureOverride(Size constraint)
19 | {
20 | this._contentPresenter.Measure(this.AdornedElement.RenderSize);
21 | return new Size(Math.Max(this._contentPresenter.DesiredSize.Width, this.AdornedElement.DesiredSize.Width), Math.Max(this._contentPresenter.DesiredSize.Height, this.AdornedElement.DesiredSize.Height));
22 | }
23 |
24 | protected override Size ArrangeOverride(Size finalSize)
25 | {
26 | this._contentPresenter.Arrange(new Rect(this.AdornedElement.RenderSize));
27 | return base.ArrangeOverride(finalSize);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/ScrollAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | //public class ScrollAdorner : BorderAdorner
6 | //{
7 | // public ScrollAdorner(UIElement adornedElement) : base(adornedElement)
8 | // {
9 |
10 | // }
11 |
12 | // public Size CornerSize { get; set; } = new Size(5, 5);
13 |
14 | // public Brush CornerFill { get; set; } = Brushes.Red;
15 |
16 | // protected override void OnRender(DrawingContext dc)
17 | // {
18 | // Rect rect = new Rect(this.AdornedElement.RenderSize);
19 |
20 | // dc.DrawRectangle(this.Fill, new Pen(this.Stroke, this.StrokeThickness), rect);
21 |
22 | // // Do :四个角
23 | // {
24 | // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(rect.TopLeft - new Vector(CornerSize.Width, CornerSize.Height), CornerSize));
25 | // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(rect.TopRight - new Vector(0, CornerSize.Height), CornerSize));
26 | // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(rect.BottomLeft - new Vector(CornerSize.Width, 0), CornerSize));
27 | // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(rect.BottomRight - new Vector(0, 0), CornerSize));
28 | // }
29 |
30 | // // Do :四个边
31 | // {
32 | // Point center = rect.GetCenter();
33 |
34 | // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(new Point(rect.Left - CornerSize.Width, center.Y - CornerSize.Height / 2.0), CornerSize));
35 | // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(new Point(rect.Right - 0, center.Y - CornerSize.Height / 2.0), CornerSize));
36 | // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(new Point(center.X - CornerSize.Width / 2.0, rect.Top - CornerSize.Height), CornerSize));
37 | // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(new Point(center.X - CornerSize.Width / 2.0, rect.Bottom - 0), CornerSize));
38 | // }
39 | // }
40 | //}
41 | }
42 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/SelectedAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Media;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public class SelectedAdorner : BorderAdorner
9 | {
10 | public SelectedAdorner(UIElement adornedElement) : base(adornedElement)
11 | {
12 | //this.Fill = new SolidColorBrush(Colors.Blue) { Opacity = 0.5 };
13 | this.Pen = new Pen(new SolidColorBrush(Colors.Orange), 1) { DashStyle = new DashStyle(new double[] { 2, 2 }, 0) };
14 | this.ScaleLen = 0;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/SelectedControlTemplateAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Media;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public class SelectedControlTemplateAdorner : ControlTemplateAdorner
9 | {
10 | public Brush Fill { get; set; }
11 | public double ScaleLen { get; set; }
12 | public Pen Pen { get; set; }
13 |
14 | public SelectedControlTemplateAdorner(UIElement adornedElement) : base(adornedElement)
15 | {
16 | this.Pen = new Pen(new SolidColorBrush(Colors.Orange), 2) { DashStyle = new DashStyle(new double[] { 2, 2 }, 0) };
17 | this.ScaleLen = 0;
18 | }
19 |
20 | protected override void OnRender(DrawingContext drawingContext)
21 | {
22 | base.OnRender(drawingContext);
23 |
24 | Rect rect = new Rect(this.AdornedElement.RenderSize);
25 | drawingContext.DrawRectangle(this.Fill, this.Pen, new Rect(rect.Left - ScaleLen, rect.Top - ScaleLen, rect.Width + (2 * ScaleLen), rect.Height + (2 * ScaleLen)));
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Adorner/VisualCollectionAdornerBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Media;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public abstract class VisualCollectionAdornerBase : AdornerBase
9 | {
10 | protected VisualCollection _visualCollection;
11 |
12 | public VisualCollectionAdornerBase(UIElement adornedElement) : base(adornedElement)
13 | {
14 | _visualCollection = new VisualCollection(this);
15 | }
16 |
17 | protected override Visual GetVisualChild(int index)
18 | {
19 | return _visualCollection[index];
20 | }
21 | protected override int VisualChildrenCount
22 | {
23 | get
24 | {
25 | return _visualCollection.Count;
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Bindable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Linq;
4 | using System.Text.Json.Serialization;
5 | using System.Xml.Serialization;
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | public abstract class Bindable : BindableBase
10 | {
11 | [Browsable(false)]
12 | [JsonIgnore]
13 | [XmlIgnore]
14 | public RelayCommand RelayCommand { get; set; }
15 |
16 | [Browsable(false)]
17 | [JsonIgnore]
18 | [XmlIgnore]
19 | public RelayCommand LoadedCommand => new RelayCommand(Loaded);
20 |
21 | [Browsable(false)]
22 | [JsonIgnore]
23 | [XmlIgnore]
24 | public RelayCommand CallMethodCommand { get; set; }
25 |
26 |
27 | //[Browsable(false)]
28 | //[XmlIgnore]
29 | //public ILogService Logger => ServiceRegistry.Instance.GetInstance();
30 |
31 | protected virtual void RelayMethod(object obj)
32 | {
33 |
34 | }
35 |
36 | public Bindable()
37 | {
38 | RelayCommand = new RelayCommand(RelayMethod);
39 | CallMethodCommand = new RelayCommand(CallMethod);
40 | RelayMethod("init");
41 | }
42 |
43 | protected virtual void Loaded(object obj)
44 | {
45 |
46 | }
47 |
48 | protected virtual void CallMethod(object obj)
49 | {
50 | string methodName = obj?.ToString();
51 |
52 | System.Reflection.MethodInfo method = GetType().GetMethod(methodName);
53 |
54 | if (method == null)
55 | {
56 | throw new ArgumentException("no found method :" + method);
57 | }
58 |
59 | object[] parameters = method.GetParameters().Select(l => l.RawDefaultValue is DBNull ? null : l.RawDefaultValue).ToArray();
60 |
61 | method.Invoke(this, parameters);
62 | }
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/BindableBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Windows;
4 | using System.Windows.Threading;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public abstract class BindableBase : INotifyPropertyChanged
9 | {
10 | public BindableBase()
11 | {
12 | Init();
13 | }
14 |
15 | protected virtual void Init()
16 | {
17 |
18 | }
19 |
20 | #region - MVVM -
21 |
22 | private bool _isRefreshing;
23 |
24 | public event PropertyChangedEventHandler PropertyChanged;
25 |
26 | public virtual void RaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
27 | {
28 | if (PropertyChanged != null)
29 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
30 |
31 | }
32 |
33 | public virtual void DispatcherRaisePropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
34 | {
35 | if (PropertyChanged != null)
36 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
37 |
38 | if (_isRefreshing)
39 | return;
40 | _isRefreshing = true;
41 | Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() =>
42 | {
43 | _isRefreshing = false;
44 | OnDispatcherPropertyChanged();
45 | }));
46 | }
47 |
48 | protected virtual void OnDispatcherPropertyChanged()
49 | {
50 |
51 | }
52 |
53 | #endregion
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Cattach.Behaviors.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using Microsoft.Xaml.Behaviors;
4 | using System;
5 | using System.Collections.ObjectModel;
6 | using System.Linq;
7 | using System.Windows;
8 |
9 | namespace HeBianGu.Diagram.DrawingBox
10 | {
11 | public static partial class BehvaiorAttach
12 | {
13 | public static readonly DependencyProperty BehaviorsProperty = DependencyProperty.RegisterAttached(
14 | "Behaviors", typeof(Behaviors), typeof(BehvaiorAttach), new FrameworkPropertyMetadata(new Behaviors(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBehaviorsChanged));
15 |
16 | public static Behaviors GetBehaviors(DependencyObject d)
17 | {
18 | return (Behaviors)d.GetValue(BehaviorsProperty);
19 | }
20 |
21 | public static void SetBehaviors(DependencyObject obj, Behaviors value)
22 | {
23 | obj.SetValue(BehaviorsProperty, value);
24 | }
25 |
26 | private static void OnBehaviorsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
27 | {
28 | Behaviors o = args.OldValue as Behaviors;
29 |
30 | Behaviors n = args.NewValue as Behaviors;
31 |
32 | BehaviorCollection bc = Interaction.GetBehaviors(sender);
33 |
34 | // Do :先删除
35 | if (o != null)
36 | {
37 | foreach (Behavior b in o)
38 | {
39 | Behavior behavior = bc.FirstOrDefault(beh => beh.GetType() == b.GetType());
40 |
41 | if (behavior != null)
42 | bc.Remove(behavior);
43 | }
44 | }
45 |
46 | // Do :再更新
47 | if (n != null)
48 | {
49 | foreach (Behavior b in n)
50 | {
51 | Behavior behavior = bc.FirstOrDefault(beh => beh.GetType() == b.GetType());
52 |
53 | Behavior instance = Activator.CreateInstance(b.GetType()) as Behavior;
54 |
55 | if (behavior != null)
56 | {
57 | bc.Remove(behavior);
58 | }
59 |
60 |
61 | foreach (System.Reflection.PropertyInfo property in b.GetType().GetProperties())
62 | {
63 | if (property.CanRead && property.CanWrite)
64 | {
65 | property.SetValue(instance, property.GetValue(b));
66 | }
67 | }
68 |
69 | bc.Add(instance);
70 | }
71 | }
72 |
73 | }
74 | }
75 |
76 | public class Behaviors : ObservableCollection
77 | {
78 |
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/DisplayEnumConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System;
4 | using System.ComponentModel;
5 | using System.ComponentModel.DataAnnotations;
6 | using System.Globalization;
7 | using System.Reflection;
8 |
9 | namespace HeBianGu.Diagram.DrawingBox
10 | {
11 | public class DisplayEnumConverter : EnumConverter
12 | {
13 | public DisplayEnumConverter(Type type) : base(type)
14 | {
15 |
16 | }
17 |
18 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
19 | {
20 | if (destinationType == typeof(string))
21 | {
22 | if (value != null)
23 | {
24 | FieldInfo fi = value.GetType().GetField(value.ToString());
25 |
26 | if (fi != null)
27 | {
28 | DisplayAttribute[] attributes = (DisplayAttribute[])fi.GetCustomAttributes(typeof(DisplayAttribute), false);
29 |
30 | return ((attributes.Length > 0) && (!String.IsNullOrEmpty(attributes[0].Name))) ? attributes[0].Name : value.ToString();
31 | }
32 | }
33 | return string.Empty;
34 | }
35 | return base.ConvertTo(context, culture, value, destinationType);
36 | }
37 |
38 | public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
39 | {
40 | return base.ConvertFrom(context, culture, value);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/DisplayNameConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System;
4 | using System.ComponentModel;
5 | using System.Globalization;
6 | using System.Reflection;
7 |
8 | namespace HeBianGu.Diagram.DrawingBox
9 | {
10 | public class DisplayNameConverter : System.ComponentModel.TypeConverter
11 | {
12 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
13 | {
14 | if (destinationType == typeof(string))
15 | {
16 | if (value == null)
17 | return string.Empty;
18 | DisplayNameAttribute attributes = value.GetType().GetCustomAttribute(false);
19 | return attributes?.DisplayName ?? string.Empty;
20 | }
21 | return base.ConvertTo(context, culture, value, destinationType);
22 | }
23 |
24 | public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
25 | {
26 | return base.ConvertFrom(context, culture, value);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Extension.Geometry.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace System.Windows.Media
4 | {
5 | public static class GeometryExtension
6 | {
7 | ///
8 | /// 获取路径总长度
9 | ///
10 | ///
11 | ///
12 | public static double GetTotalLength(this Geometry geometry)
13 | {
14 | if (geometry == null) return 0;
15 |
16 | PathGeometry pathGeometry = PathGeometry.CreateFromGeometry(geometry);
17 | pathGeometry.GetPointAtFractionLength(1e-4, out Point point, out _);
18 | double length = (pathGeometry.Figures[0].StartPoint - point).Length * 1e+4;
19 |
20 | return length;
21 | }
22 |
23 | ///
24 | /// 获取路径总长度
25 | ///
26 | ///
27 | ///
28 | ///
29 | ///
30 | public static double GetTotalLength(this Geometry geometry, Size size, double strokeThickness = 1)
31 | {
32 | if (geometry == null)
33 | return 0;
34 | Predicate match = l =>
35 | {
36 | return Math.Abs(l) < 1E-06;
37 | };
38 |
39 | if (match(size.Width) || match(size.Height))
40 | return 0;
41 | if (geometry.Bounds.Width == 0 || geometry.Bounds.Height == 0)
42 | return 0;
43 |
44 | double length = GetTotalLength(geometry);
45 | double sw = geometry.Bounds.Width / size.Width;
46 | double sh = geometry.Bounds.Height / size.Height;
47 | double min = Math.Min(sw, sh);
48 |
49 | if (match(min) || match(strokeThickness))
50 | return 0;
51 |
52 | length /= min;
53 | return length / strokeThickness;
54 | }
55 |
56 | private static GeometryConverter converter = new GeometryConverter();
57 |
58 | public static Geometry GetGeometry(this string data)
59 | {
60 | return converter.ConvertFromString(data) as Geometry;
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/Extension.Rect.cs:
--------------------------------------------------------------------------------
1 | #if NET
2 | #endif
3 |
4 | using System;
5 | using System.Windows;
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | public static class RectExtenstion
10 | {
11 | public static Point GetCenter(this Rect rect)
12 | {
13 | return new Point((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2);
14 | }
15 |
16 | public static Rect ToRect(this System.Windows.Point point, double len)
17 | {
18 | return new Rect(point.X - len, point.Y - len, 2 * len, 2 * len);
19 | }
20 |
21 | ///
22 | /// 求投影向量
23 | ///
24 | /// 直线
25 | /// 斜线
26 | ///
27 | public static Vector ToProjectionVector(this Vector vector1, Vector vector2)
28 | {
29 | //var perpenddiscular = Vector2.Perpendicular(vector1);
30 | //perpenddiscular.Normalize();
31 | //double angle = Vector2.AngleBetween(vector2, perpenddiscular);
32 | //double distance = vector2.Length;
33 | //double len = distance * Math.Cos(angle);
34 | //return perpenddiscular * len;
35 |
36 | Vector perpenddiscular = new Vector(-vector1.Y, vector1.X);
37 | perpenddiscular.Normalize();
38 | double angle = Vector.AngleBetween(vector2, perpenddiscular);
39 | angle = angle / 180 * Math.PI;
40 | double distance = vector2.Length;
41 | double len = distance * Math.Cos(angle);
42 | return perpenddiscular * len;
43 | }
44 |
45 | ///
46 | /// 正交向量
47 | ///
48 | ///
49 | ///
50 | public static Vector ToPerpendicular(this Vector vector)
51 | {
52 | return new Vector(-vector.Y, vector.X);
53 | }
54 |
55 |
56 | public static double ToAngle(this Vector vector)
57 | {
58 | double angle = Math.Atan(vector.Y / vector.X);
59 | return angle * 180 / Math.PI;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/IDragAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 | using System.Windows;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public interface IDragAdorner
9 | {
10 | Point Offset { get; set; }
11 | void UpdatePosition(Point location);
12 | object GetData();
13 | }
14 | }
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/IZoombox.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface IZoombox
6 | {
7 | void FillToBounds();
8 | void FitToBounds();
9 | void Zoom(double percentage);
10 | void Zoom(double percentage, Point relativeTo);
11 | void ZoomTo(double scale);
12 | void ZoomTo(double scale, Point relativeTo);
13 | void ZoomTo(Point position);
14 | void ZoomTo(Rect region);
15 | }
16 | }
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/MarkupCommandBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 | using System.Windows.Markup;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public abstract class MarkupCommandBase : MarkupExtension, ICommand
8 | {
9 | public event EventHandler CanExecuteChanged
10 | {
11 | add
12 | {
13 | CommandManager.RequerySuggested += value;
14 | }
15 | remove
16 | {
17 | CommandManager.RequerySuggested -= value;
18 | }
19 | }
20 | public virtual bool CanExecute(object parameter)
21 | {
22 | return true;
23 | }
24 |
25 | public abstract void Execute(object parameter);
26 |
27 | public override object ProvideValue(IServiceProvider serviceProvider)
28 | {
29 | return this;
30 | }
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Provider/RoutedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public class RoutedEventArgs : RoutedEventArgs
8 | {
9 | public RoutedEventArgs(T entity)
10 | {
11 | Entity = entity;
12 | }
13 |
14 | public RoutedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source)
15 | {
16 | }
17 | public RoutedEventArgs(RoutedEvent routedEvent, object source, T entity) : base(routedEvent, source)
18 | {
19 | Entity = entity;
20 | }
21 |
22 |
23 | public T Entity { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public class Service : IService
8 | {
9 |
10 | }
11 |
12 | public interface IService
13 | {
14 |
15 | }
16 |
17 | //[Display(Name = "参数设置", GroupName = SystemSetting.GroupStyle)]
18 | //public class Setting : LazySettingInstance
19 | //{
20 |
21 | //}
22 | }
23 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/Bevavior/DiagramAdorner.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 |
6 | //public class DiagramAdorner : BorderAdorner
7 | //{
8 | // internal Link _dynamicLink = new Link();
9 |
10 | // LinkLayer linkLayer = new LinkLayer();
11 |
12 | // private VisualCollection visualCollection;
13 |
14 | // public DiagramAdorner(Diagram adornedElement) : base(adornedElement)
15 | // {
16 | // visualCollection = new VisualCollection(this);
17 |
18 | // linkLayer.Children.Add(_dynamicLink);
19 |
20 | // visualCollection.Add(linkLayer);
21 |
22 | // }
23 |
24 | // protected override void OnRender(DrawingContext dc)
25 | // {
26 | // Rect rect = new Rect(this.AdornedElement.RenderSize);
27 |
28 | // //left.Arrange(new Rect(rect.Left - left.DesiredSize.Width, rect.Height / 2 - left.DesiredSize.Height / 2, left.DesiredSize.Width, left.DesiredSize.Height));
29 | // //right.Arrange(new Rect(rect.Right, rect.Height / 2 - right.DesiredSize.Height / 2, right.DesiredSize.Width, right.DesiredSize.Height));
30 | // //top.Arrange(new Rect(rect.Width / 2 - top.DesiredSize.Height / 2, rect.Top - top.DesiredSize.Height, top.DesiredSize.Width, top.DesiredSize.Height));
31 | // //bottom.Arrange(new Rect(rect.Width / 2 - bottom.DesiredSize.Height / 2, rect.Bottom, bottom.DesiredSize.Width, bottom.DesiredSize.Height));
32 |
33 | // linkLayer.Arrange(rect);
34 |
35 | // dc.DrawRectangle(this.Fill, new Pen(this.Stroke, this.StrokeThickness), rect);
36 |
37 |
38 | // //// Do :四个角
39 | // //{
40 | // // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(rect.TopLeft - new Vector(CornerSize.Width, CornerSize.Height), CornerSize));
41 | // // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(rect.TopRight - new Vector(0, CornerSize.Height), CornerSize));
42 | // // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(rect.BottomLeft - new Vector(CornerSize.Width, 0), CornerSize));
43 | // // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(rect.BottomRight - new Vector(0, 0), CornerSize));
44 | // //}
45 |
46 | // //// Do :四个边
47 | // //{
48 | // // Point center = rect.GetCenter();
49 |
50 | // // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(new Point(rect.Left - CornerSize.Width, center.Y - CornerSize.Height / 2.0), CornerSize));
51 | // // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(new Point(rect.Right - 0, center.Y - CornerSize.Height / 2.0), CornerSize));
52 | // // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(new Point(center.X - CornerSize.Width / 2.0, rect.Top - CornerSize.Height), CornerSize));
53 | // // dc.DrawRectangle(this.CornerFill, new Pen(this.Stroke, this.StrokeThickness), new Rect(new Point(center.X - CornerSize.Width / 2.0, rect.Bottom - 0), CornerSize));
54 | // //}
55 | // }
56 |
57 | // protected override Visual GetVisualChild(int index)
58 | // {
59 | // return visualCollection[index];
60 | // }
61 | // protected override int VisualChildrenCount
62 | // {
63 | // get
64 | // {
65 | // return visualCollection.Count;
66 | // }
67 | // }
68 | //}
69 | }
70 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/Bevavior/DiagramDropBehavior/DiagramDropBehavior.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 |
5 | using Microsoft.Xaml.Behaviors;
6 | using System;
7 | using System.Windows;
8 |
9 | namespace HeBianGu.Diagram.DrawingBox
10 | {
11 | /// Diagram接收放下的操作
12 | public abstract class DiagramDropBehaviorBase : Behavior
13 | {
14 | protected override void OnAttached()
15 | {
16 | this.AssociatedObject.Drop += AssociatedObject_Drop;
17 | }
18 |
19 | private void AssociatedObject_Drop(object sender, DragEventArgs e)
20 | {
21 | IDragAdorner adorner = e.Data.GetData("DragGroup") as IDragAdorner;
22 |
23 | if (adorner == null) return;
24 |
25 | Point offset = adorner.Offset;
26 |
27 | Point location = e.GetPosition(this.AssociatedObject);
28 |
29 | ICloneable obj = ((adorner as System.Windows.Documents.Adorner).AdornedElement as FrameworkElement).DataContext as ICloneable;
30 |
31 | if (obj == null)
32 | {
33 | throw new ArgumentException("没有实现ICloneable接口");
34 | }
35 |
36 | //if (this.AssociatedObject.NodesSource is IList collection)
37 | //{
38 | object content = obj.Clone();
39 |
40 | Node node = this.Create(content as INodeData);
41 |
42 | node.Content = content;
43 |
44 | node.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
45 | node.Location = new Point(location.X - offset.X + (node.DesiredSize.Width / 2), location.Y - offset.Y + (node.DesiredSize.Height / 2));
46 |
47 |
48 | //collection.Add(node);
49 |
50 | //this.AssociatedObject.RefreshData();
51 |
52 | this.AssociatedObject.AddNode(node);
53 | //}
54 |
55 | }
56 |
57 | protected override void OnDetaching()
58 | {
59 | this.AssociatedObject.Drop -= AssociatedObject_Drop;
60 | }
61 |
62 | protected abstract Node Create(INodeData data);
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/Bevavior/DiagramDropBehavior/DiagramDropNodeBehavior.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | /////
6 | ///// 拖拽时放置Node类型
7 | /////
8 | //public class DiagramDropNodeBehavior : DiagramDropBehaviorBase
9 | //{
10 | // protected override Node Create(INodeData nodeData)
11 | // {
12 | // var node = new Node();
13 |
14 | // {
15 | // var port = Port.Create(node);
16 | // port.Dock = Dock.Left;
17 | // port.Id = "s_left";
18 | // port.Visibility = Visibility.Hidden;
19 | // port.PortType = PortType.Both;
20 | // port.Content = new DefaultPort(nodeData.ID);
21 | // node.AddPort(port);
22 | // }
23 |
24 | // {
25 | // var port = Port.Create(node);
26 | // port.Dock = Dock.Top;
27 | // port.Id = "s_top";
28 | // port.Visibility = Visibility.Hidden;
29 | // port.PortType = PortType.Both;
30 | // port.Content = new DefaultPort(nodeData.ID);
31 | // node.AddPort(port);
32 |
33 | // }
34 |
35 | // {
36 | // var port = Port.Create(node);
37 | // port.Dock = Dock.Bottom;
38 | // port.Id = "s_bottom";
39 | // port.Visibility = Visibility.Hidden;
40 | // port.PortType = PortType.Both;
41 | // port.Content = new DefaultPort(nodeData.ID);
42 | // node.AddPort(port);
43 |
44 | // }
45 |
46 | // {
47 | // var port = Port.Create(node);
48 | // port.Dock = Dock.Right;
49 | // port.Id = "s_right";
50 | // port.Visibility = Visibility.Hidden;
51 | // port.PortType = PortType.Both;
52 | // port.Content = new DefaultPort(nodeData.ID);
53 | // node.AddPort(port);
54 |
55 | // }
56 |
57 | // return node;
58 | // }
59 | //}
60 | }
61 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/Bevavior/NodeMouseDragBehavior.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 | using Microsoft.Xaml.Behaviors;
5 | using System.Windows;
6 | using System.Windows.Input;
7 |
8 | namespace HeBianGu.Diagram.DrawingBox
9 | {
10 | public class NodeMouseDragBehavior : Behavior
11 | {
12 | private Point? _start;
13 | private Diagram _layer;
14 | protected override void OnAttached()
15 | {
16 | base.OnAttached();
17 | this.AssociatedObject.Unloaded += AssociatedObject_Unloaded;
18 | this.AssociatedObject.Loaded += AssociatedObject_Loaded;
19 | this.AssociatedObject.MouseDown += AssociatedObject_MouseDown;
20 | }
21 |
22 | private void AssociatedObject_Unloaded(object sender, RoutedEventArgs e)
23 | {
24 | this.AssociatedObject.MouseDown -= AssociatedObject_MouseDown;
25 | }
26 |
27 | protected override void OnDetaching()
28 | {
29 | this.AssociatedObject.Loaded -= AssociatedObject_Loaded;
30 | this.AssociatedObject.MouseDown -= AssociatedObject_MouseDown;
31 | }
32 |
33 | private void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
34 | {
35 | _layer = this.AssociatedObject.GetDiagram();
36 | }
37 |
38 | private void _layer_MouseLeave(object sender, MouseEventArgs e)
39 | {
40 | this.EndDragging();
41 | }
42 |
43 | private void _layer_MouseUp(object sender, MouseButtonEventArgs e)
44 | {
45 | this.EndDragging();
46 | }
47 |
48 | private void _layer_MouseMove(object sender, MouseEventArgs e)
49 | {
50 | e.Handled = true;
51 | if (this._start == null)
52 | return;
53 | if (e.LeftButton == MouseButtonState.Released)
54 | return;
55 |
56 | Node.SetIsDragging(this.AssociatedObject, true);
57 |
58 | Point p = e.GetPosition(_layer);
59 | double x = p.X - _start.Value.X;
60 | double y = p.Y - _start.Value.Y;
61 | // Do :更新Node
62 | Point old = NodeLayer.GetPosition(this.AssociatedObject);
63 | Point point = new Point(old.X + x, old.Y + y);
64 | System.Diagnostics.Debug.WriteLine("Change " + x);
65 | System.Diagnostics.Debug.WriteLine("Change " + y);
66 | NodeLayer.SetPosition(this.AssociatedObject, point);
67 | this._start = p;
68 | }
69 |
70 | private void AssociatedObject_MouseDown(object sender, MouseButtonEventArgs e)
71 | {
72 | this._start = e.GetPosition(_layer);
73 | e.Handled = true;
74 | this.StartDragging();
75 | this.AssociatedObject.GetDiagram().Focus();
76 | }
77 |
78 | private void StartDragging()
79 | {
80 | _layer.MouseMove += _layer_MouseMove;
81 | _layer.MouseUp += _layer_MouseUp;
82 | _layer.MouseLeave += _layer_MouseLeave;
83 | }
84 |
85 | private void EndDragging()
86 | {
87 | _layer.MouseMove -= _layer_MouseMove;
88 | _layer.MouseUp -= _layer_MouseUp;
89 | _layer.MouseLeave -= _layer_MouseLeave;
90 |
91 | this._start = null;
92 | Node.SetIsDragging(this.AssociatedObject, false);
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/Bevavior/NodeMouseOverBehavior.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 | using Microsoft.Xaml.Behaviors;
5 | using System.Windows;
6 | using System.Windows.Input;
7 |
8 | namespace HeBianGu.Diagram.DrawingBox
9 | {
10 | /// Diagram接收放下的操作
11 | public class NodeMouseOverBehavior : Behavior
12 | {
13 | protected override void OnAttached()
14 | {
15 | this.AssociatedObject.MouseEnter += AssociatedObject_MouseEnter;
16 | this.AssociatedObject.MouseLeave += AssociatedObject_MouseLeave;
17 | }
18 |
19 | private void AssociatedObject_MouseLeave(object sender, MouseEventArgs e)
20 | {
21 | //this.AssociatedObject.AdornerVisible(false);
22 |
23 | //this.AssociatedObject.Ports.ForEach(l=>l.Visibility=Visibility.Collapsed);
24 |
25 | //this.AssociatedObject.ShowSystemPort(false);
26 |
27 | this.AssociatedObject.GetPorts().ForEach(l => l.Visibility = Visibility.Hidden);
28 | }
29 |
30 | private void AssociatedObject_MouseEnter(object sender, MouseEventArgs e)
31 | {
32 | //this.AssociatedObject.AdornerVisible(true);
33 |
34 | //this.AssociatedObject.Ports.ForEach(l => l.Visibility = Visibility.Visible);
35 |
36 | //this.AssociatedObject.ShowSystemPort(true);
37 |
38 | this.AssociatedObject.GetPorts(l => l.PortType == PortType.OutPut || l.PortType == PortType.Both).ForEach(l => l.Visibility = Visibility.Visible);
39 |
40 | }
41 |
42 |
43 | protected override void OnDetaching()
44 | {
45 | //this.AssociatedObject.MouseEnter -= AssociatedObject_MouseEnter;
46 |
47 | //this.AssociatedObject.Adorner.MouseLeave -= AssociatedObject_MouseLeave;
48 | }
49 |
50 |
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/Bevavior/NodeSelectionBehavior.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 |
4 | using Microsoft.Xaml.Behaviors;
5 | using System.Windows;
6 |
7 | namespace HeBianGu.Diagram.DrawingBox
8 | {
9 | ///// Diagram接收放下的操作
10 | //public class NodeSelectionAdornerBehavior : Behavior
11 | //{
12 | // protected override void OnAttached()
13 | // {
14 | // this.AssociatedObject.SelectionChanged += AssociatedObject_SelectionChanged;
15 | // }
16 |
17 | // private void AssociatedObject_SelectionChanged(object sender, RoutedEventArgs e)
18 | // {
19 | // this.AssociatedObject.GetPorts(l => l.IsSystem).ForEach(l => l.Visibility = this.AssociatedObject.IsSelected ? Visibility.Visible : Visibility.Hidden);
20 |
21 | // //this.AssociatedObject.GetPorts(l => l.IsSystem).ForEach(l => l.Visibility = Visibility.Visible);
22 | // }
23 | // protected override void OnDetaching()
24 | // {
25 | // this.AssociatedObject.SelectionChanged -= AssociatedObject_SelectionChanged;
26 | // }
27 | //}
28 |
29 | /// Diagram接收放下的操作
30 | public class NodeSelectionBehavior : Behavior
31 | {
32 | protected override void OnAttached()
33 | {
34 | this.AssociatedObject.SelectionChanged += AssociatedObject_SelectionChanged;
35 | }
36 |
37 | private void AssociatedObject_SelectionChanged(object sender, RoutedEventArgs e)
38 | {
39 | if (this.AssociatedObject.IsSelected)
40 | {
41 | this.AssociatedObject.GetPorts(l => l.PortType == PortType.OutPut || l.PortType == PortType.Both).ForEach(l => l.Visibility = Visibility.Visible);
42 | }
43 | else
44 | {
45 | this.AssociatedObject.GetPorts(l => l.PortType == PortType.OutPut || l.PortType == PortType.Both).ForEach(l => l.Visibility = Visibility.Hidden);
46 | }
47 |
48 | }
49 | protected override void OnDetaching()
50 | {
51 | this.AssociatedObject.SelectionChanged -= AssociatedObject_SelectionChanged;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/DynamicLinkData.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public class DynamicLinkData : DefaultLinkData, IFlowable
6 | {
7 | public bool UseInfoLogger { get; set; }
8 |
9 | public FlowableState State { get; set; }
10 |
11 | public void Clear()
12 | {
13 |
14 | }
15 | public virtual void Dispose()
16 | {
17 |
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/FlowableResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public class FlowableResult : IFlowableResult
6 | {
7 | public FlowableResult(string message)
8 | {
9 | this.Message = message;
10 | }
11 | public string Message { get; }
12 |
13 | public FlowableResultState State { get; set; }
14 | }
15 |
16 | public class FlowableResult : FlowableResult
17 | {
18 | public FlowableResult(T t) : base(null)
19 | {
20 | this.State = FlowableResultState.OK;
21 | this.Value = t;
22 | }
23 | public FlowableResult(T t, string message) : base(message)
24 | {
25 | this.State = FlowableResultState.OK;
26 | this.Value = t;
27 | }
28 | public T Value { get; set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/FlowableResultState.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public enum FlowableResultState
6 | {
7 | OK = 0,
8 | //Warn,
9 | Error
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/FlowableState.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public enum FlowableState
6 | {
7 | Ready = 0,
8 | Wait,
9 | Running,
10 | Success,
11 | Error,
12 | Canceling,
13 | Stopped,
14 | Pause
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/IData.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface IData
6 | {
7 |
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/IDropable.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface IDropable
6 | {
7 | ///
8 | /// 检查当前节点是否可以放下
9 | ///
10 | ///
11 | ///
12 | bool CanDrop(Part part, out string message);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/IFlowable.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public interface IFlowable : IDisposable
8 | {
9 | bool UseInfoLogger { get; set; }
10 | //IFlowable FromFlowable { get; }
11 | FlowableState State { get; set; }
12 | void Clear();
13 | }
14 |
15 | public static class FlowableExtension
16 | {
17 | //public static T GetFlowable(this Node flowable, Predicate predicate = null) where T : class, IFlowable
18 | //{
19 | // //if (flowable.FromFlowable == null) return null;
20 |
21 | // //T t = flowable.FromFlowable as T;
22 |
23 | // //if (t != null)
24 | // // if (predicate?.Invoke(t) != false) return t;
25 |
26 | // //return flowable.FromFlowable.GetFlowable(predicate);
27 |
28 | // return null;
29 | //}
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/IFlowableLink.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Threading.Tasks;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public interface IFlowableLink : IFlowable
8 | {
9 | IFlowableResult Invoke(Part previors, Link current);
10 | Task InvokeAsync(Part previors, Link current);
11 | Task TryInvokeAsync(Part previors, Link current);
12 | bool IsMatchResult(FlowableResult flowableResult);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/IFlowableNode.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Threading.Tasks;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public interface IFlowableNode : IFlowable
8 | {
9 | public bool UseStart { get; set; }
10 | IFlowableResult Invoke(Part previors, Node current);
11 | Task InvokeAsync(Part previors, Node current);
12 | Task TryInvokeAsync(Part previors, Node current);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/IFlowablePort.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Threading.Tasks;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public interface IFlowablePort : IFlowable
8 | {
9 | IFlowableResult Invoke(Part previors, Port current);
10 | Task InvokeAsync(Part previors, Port current);
11 | Task TryInvokeAsync(Part previors, Port current);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/IFlowableResult.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface IFlowableResult
6 | {
7 | string Message { get; }
8 |
9 | FlowableResultState State { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/ILinkData.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface ILinkData : IData
6 | {
7 | string FromNodeID { get; set; }
8 |
9 | string ToNodeID { get; set; }
10 |
11 | string FromPortID { get; set; }
12 |
13 | string ToPortID { get; set; }
14 |
15 | void ApplayStyleTo(ILinkData node);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/ILinkDataCreator.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface ILinkDataCreator
6 | {
7 | ILinkData CreateLinkData();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/ILinkInitializer.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface ILinkInitializer
6 | {
7 | void InitLink(Link link);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/INodeData.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 |
5 | namespace HeBianGu.Diagram.DrawingBox
6 | {
7 | public interface INodeData : IData
8 | {
9 | string ID { get; set; }
10 |
11 | Point Location { get; set; }
12 |
13 | void ApplayStyleTo(INodeData node);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/INoteDisplay.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | //public interface INoteDisplay
6 | //{
7 | // FillStyle FillStyle { get; set; }
8 |
9 | // BorderStyle BorderStyle { get; set; }
10 |
11 | // EffectStyle EffectStyle { get; set; }
12 | //}
13 |
14 | //public class FillStyle : NotifyPropertyChangedBase
15 | //{
16 | // public FillStyle()
17 | // {
18 | // this.Background = Application.Current.FindResource(BrushKeys.BackgroundDefault) as Brush;
19 | // }
20 |
21 | // private Color _color;
22 | // /// 说明
23 | // public Color Color
24 | // {
25 | // get { return _color; }
26 | // set
27 | // {
28 | // if (_color == value)
29 | // return;
30 |
31 | // _color = value;
32 | // RaisePropertyChanged();
33 |
34 | // this.Background = new SolidColorBrush(this.Color) { Opacity = this.Opacity };
35 | // }
36 | // }
37 |
38 | // private double _opacity = 1;
39 | // /// 说明
40 | // public double Opacity
41 | // {
42 | // get { return _opacity; }
43 | // set
44 | // {
45 | // if (_opacity == value)
46 | // return;
47 | // _opacity = value;
48 | // RaisePropertyChanged();
49 |
50 | // this.Background = new SolidColorBrush(this.Color) { Opacity = this.Opacity };
51 | // }
52 | // }
53 |
54 | // private Brush _background;
55 | // /// 说明
56 | // public Brush Background
57 | // {
58 | // get { return _background; }
59 | // set
60 | // {
61 | // _background = value;
62 | // RaisePropertyChanged();
63 |
64 | // if (value is SolidColorBrush solid)
65 | // {
66 | // this.Color = solid.Color;
67 | // this.Opacity = solid.Opacity;
68 | // }
69 | // }
70 | // }
71 | //}
72 |
73 | //public class BorderStyle: FillStyle
74 | //{
75 | // public Thickness BorderThickness { get; set; }
76 |
77 | // public CornerRadius CornerRadius { get; set; }
78 | //}
79 |
80 | //public class EffectStyle
81 | //{
82 | // public double BlurRadius { get; set; }
83 |
84 | // public double Direction { get; set; }
85 |
86 | // public RenderingBias RenderingBias { get; set; }
87 |
88 | // public double ShadowDepth { get; set; }
89 | //}
90 | }
91 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/IPortData.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Controls;
5 |
6 | namespace HeBianGu.Diagram.DrawingBox
7 | {
8 | public interface IPortData : ILinkInitializer, IData
9 | {
10 | string ID { get; set; }
11 |
12 | string NodeID { get; set; }
13 |
14 | ///
15 | /// 当前端口的功能名称
16 | ///
17 | string Name { get; set; }
18 |
19 | Dock Dock { get; set; }
20 |
21 | PortType PortType { get; set; }
22 |
23 | Thickness PortMargin { get; set; }
24 |
25 | void ApplayStyleTo(IPortData node);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/IPortDataCreator.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface IPortDataCreator
6 | {
7 | IPortData CreatePortData();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/ITemplate.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public interface ITemplate
6 | {
7 | bool IsTemplate { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Service/PortType.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2024 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | namespace HeBianGu.Diagram.DrawingBox
4 | {
5 | public enum PortType
6 | {
7 | Both = 0,
8 | Input,
9 | OutPut
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/Themes/Generic.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.DrawingBox/obfuscar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.Presenter.Workflow/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright ? 2022 By HeBianGu(QQ:908293466) https://github.com/HeBianGu/WPF-Control
2 |
3 | using System.Windows;
4 | using System.Windows.Markup;
5 |
6 | [assembly: ThemeInfo(
7 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
8 | //(used if a resource is not found in the page,
9 | // or application resource dictionaries)
10 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
11 | //(used if a resource is not found in the page,
12 | // app, or any theme specific resource dictionaries)
13 | )]
14 |
15 | [assembly: XmlnsDefinition("QQ:908293466", "HeBianGu.Diagram.Presenter.Workflow")]
16 | [assembly: XmlnsPrefix("QQ:908293466", "h")]
17 |
18 | [assembly: XmlnsDefinition("https://github.com/HeBianGu", "HeBianGu.Diagram.Presenter.Workflow")]
19 | [assembly: XmlnsPrefix("https://github.com/HeBianGu", "h")]
20 |
21 | [assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "HeBianGu.Diagram.Presenter.Workflow")]
22 | [assembly: XmlnsPrefix("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "h")]
23 |
--------------------------------------------------------------------------------
/Source/Control/HeBianGu.Diagram.Presenter.Workflow/Commands/Command.AddNode.cs:
--------------------------------------------------------------------------------
1 | using HeBianGu.Diagram.DrawingBox;
2 | using System;
3 | using System.Linq;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Threading;
7 |
8 | namespace HeBianGu.Diagram.Presenter.Workflow
9 | {
10 | public class AddWorkflowNodeCommand : AddNodeCommand
11 | {
12 | protected override INodeData CreateData(Node node)
13 | {
14 | return node.Content as INodeData;
15 | }
16 |
17 | public override bool CanExecute(object parameter)
18 | {
19 | if (parameter is Node node)
20 | {
21 | bool r = node.LinksInto.Any(x => x.FromPort?.Dock == this.GetRevertDock());
22 | return !r;
23 | }
24 | return true;
25 | }
26 | }
27 |
28 | public class AddWorkflowNodeFromTemplateCommand : AddWorkflowNodeCommand
29 | {
30 | public override void Execute(object parameter)
31 | {
32 | ContentControl content = parameter as ContentControl;
33 | if (content == null)
34 | return;
35 |
36 | Button btn = content.GetParent