mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-05 08:46:34 +08:00
程序添加绘图元素,Demo完成一半
This commit is contained in:
65
AIStudio.Wpf.DiagramApp/ViewModels/DrawingViewModel.cs
Normal file
65
AIStudio.Wpf.DiagramApp/ViewModels/DrawingViewModel.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using AIStudio.Wpf.DiagramApp.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Additionals;
|
||||
using AIStudio.Wpf.Mind.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
public class DrawingViewModel : PageViewModel
|
||||
{
|
||||
public DrawingViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
|
||||
{
|
||||
|
||||
}
|
||||
public DrawingViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
|
||||
{
|
||||
foreach (var vm in DiagramViewModels)
|
||||
{
|
||||
vm.Init(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void InitDiagramViewModel()
|
||||
{
|
||||
base.InitDiagramViewModel();
|
||||
|
||||
DiagramViewModel.DiagramOption.LayoutOption.GridCellSize = new Size(100, 100);
|
||||
DiagramViewModel.DiagramOption.LayoutOption.ShowGrid = false;
|
||||
DiagramViewModel.DiagramOption.LayoutOption.AllowDrop = true;
|
||||
}
|
||||
|
||||
|
||||
protected override void Init(bool initNew)
|
||||
{
|
||||
DiagramViewModels = new ObservableCollection<IDiagramViewModel>()
|
||||
{
|
||||
GetDiagramViewModel("页-1", DiagramType, initNew),
|
||||
};
|
||||
DiagramViewModel = DiagramViewModels.FirstOrDefault();
|
||||
|
||||
DesignerItemViewModelBase line = new LineDrawingDesignerItemViewModel(DiagramViewModel, new List<Point> { new Point(38, 38), new Point(118, 118) }, true);
|
||||
DiagramViewModel.Add(line);
|
||||
|
||||
DesignerItemViewModelBase rectangle = new RectangleDrawingDesignerItemViewModel(DiagramViewModel, new List<Point> { new Point(138, 38), new Point(218, 118) }, true);
|
||||
DiagramViewModel.Add(rectangle);
|
||||
|
||||
DesignerItemViewModelBase ellipse = new EllipseDrawingDesignerItemViewModel(DiagramViewModel, new List<Point> { new Point(238, 38), new Point(318, 118) }, true);
|
||||
DiagramViewModel.Add(ellipse);
|
||||
|
||||
TextDrawingDesignerItemViewModel text = new TextDrawingDesignerItemViewModel(DiagramViewModel, new Point(338, 38), "文字", true);
|
||||
DiagramViewModel.Add(text);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,13 @@
|
||||
using AIStudio.Wpf.DiagramApp.Models;
|
||||
using AIStudio.Wpf.DiagramApp.ViewModels;
|
||||
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramApp.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.Flowchart;
|
||||
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Flowchart
|
||||
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
public class FlowchartViewModel : PageViewModel
|
||||
{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using AIStudio.Wpf.DiagramApp.Models;
|
||||
using AIStudio.Wpf.DiagramApp.ViewModels;
|
||||
using AIStudio.Wpf.Logical.ViewModels;
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramApp.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.Logical;
|
||||
using AIStudio.Wpf.Logical.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Logical
|
||||
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
public class LogicalViewModel : PageViewModel
|
||||
{
|
||||
|
||||
@@ -541,6 +541,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
flow = new ScriptViewModel(filename, diagram);
|
||||
}
|
||||
else if (diagram.DiagramType == DiagramType.Drawing)
|
||||
{
|
||||
flow = new DrawingViewModel(filename, diagram);
|
||||
}
|
||||
else
|
||||
{
|
||||
flow = new PageViewModel(filename, diagram);
|
||||
@@ -660,6 +664,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
PageViewModel = new ScriptViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
||||
}
|
||||
else if (type == DiagramType.Drawing.ToString())
|
||||
{
|
||||
PageViewModel = new DrawingViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
||||
}
|
||||
else
|
||||
{
|
||||
PageViewModel = new PageViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
||||
|
||||
@@ -16,7 +16,7 @@ using AIStudio.Wpf.DiagramDesigner.Additionals;
|
||||
using AIStudio.Wpf.Mind.Helpers;
|
||||
using AIStudio.Wpf.Mind.Models;
|
||||
|
||||
namespace AIStudio.Wpf.Flowchart
|
||||
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
public class MindViewModel : PageViewModel
|
||||
{
|
||||
@@ -119,10 +119,7 @@ namespace AIStudio.Wpf.Flowchart
|
||||
{
|
||||
base.Dispose();
|
||||
|
||||
foreach (var viewModel in DiagramViewModels)
|
||||
{
|
||||
FlowchartService.Dispose(viewModel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
using AIStudio.Wpf.DiagramApp.Models;
|
||||
using AIStudio.Wpf.DiagramApp.ViewModels;
|
||||
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||
using AIStudio.Wpf.SFC;
|
||||
using AIStudio.Wpf.SFC.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramApp.Models;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.SFC;
|
||||
using AIStudio.Wpf.SFC.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Flowchart
|
||||
namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
{
|
||||
public class SFCViewModel : PageViewModel
|
||||
{
|
||||
|
||||
@@ -100,6 +100,9 @@
|
||||
<Button Margin="5" ToolTip="C#脚本" Command="{Binding NewCommand}" CommandParameter="Script" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
|
||||
<Path Stretch="Uniform" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M490.666667 681.386667l17.493333 104.106666c-11.093333 5.973333-29.013333 11.52-52.906667 16.64-24.32 5.546667-52.906667 8.533333-85.76 8.533334-94.293333-1.706667-165.12-29.866667-212.48-83.626667C109.226667 672.853333 85.333333 604.16 85.333333 520.96c2.133333-98.56 30.72-174.08 85.333334-226.986667C226.986667 240.64 296.96 213.333333 381.44 213.333333c32 0 59.733333 2.986667 82.773333 8.106667s40.106667 10.666667 51.2 17.066667l-24.746666 106.24-45.226667-14.506667c-17.066667-4.266667-36.693333-6.4-59.306667-6.4-49.493333-0.426667-90.453333 15.36-122.453333 46.933333-32.426667 31.146667-49.066667 78.933333-50.346667 142.506667 0 58.026667 15.786667 103.253333 46.08 136.533333 30.293333 32.853333 72.96 49.92 127.573334 50.346667l56.746666-5.12c18.346667-3.413333 33.706667-8.106667 46.933334-13.653333M592.64 810.666667l26.026667-170.666667H554.666667l14.506666-85.333333h64l13.653334-85.333334h-64L597.333333 384h64l26.026667-170.666667h85.333333l-26.026666 170.666667h42.666666l26.026667-170.666667h85.333333l-26.026666 170.666667H938.666667l-14.506667 85.333333h-64l-13.653333 85.333334h64L896 640h-64l-26.026667 170.666667h-85.333333l26.026667-170.666667h-42.666667l-26.026667 170.666667h-85.333333m125.866667-256h42.666666l13.653334-85.333334h-42.666667l-13.653333 85.333334z" ></Path>
|
||||
</Button>
|
||||
<Button Margin="5" ToolTip="画板" Command="{Binding NewCommand}" CommandParameter="Drawing" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
|
||||
<Path Stretch="Uniform" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M9.75 20.85C11.53 20.15 11.14 18.22 10.24 17C9.35 15.75 8.12 14.89 6.88 14.06C6 13.5 5.19 12.8 4.54 12C4.26 11.67 3.69 11.06 4.27 10.94C4.86 10.82 5.88 11.4 6.4 11.62C7.31 12 8.21 12.44 9.05 12.96L10.06 11.26C8.5 10.23 6.5 9.32 4.64 9.05C3.58 8.89 2.46 9.11 2.1 10.26C1.78 11.25 2.29 12.25 2.87 13.03C4.24 14.86 6.37 15.74 7.96 17.32C8.3 17.65 8.71 18.04 8.91 18.5C9.12 18.94 9.07 18.97 8.6 18.97C7.36 18.97 5.81 18 4.8 17.36L3.79 19.06C5.32 20 7.88 21.47 9.75 20.85M20.84 5.25C21.06 5.03 21.06 4.67 20.84 4.46L19.54 3.16C19.33 2.95 18.97 2.95 18.76 3.16L17.74 4.18L19.82 6.26M11 10.92V13H13.08L19.23 6.85L17.15 4.77L11 10.92Z" ></Path>
|
||||
</Button>
|
||||
</WrapPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="思维导图" >
|
||||
|
||||
Reference in New Issue
Block a user