mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-06 17:26:35 +08:00
简单demo继续完善
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:AIStudio.Wpf.DiagramDesigner.Test"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramHelper.Controls;assembly=AIStudio.Wpf.DiagramHelper"
|
||||
xmlns:flowchart="clr-namespace:AIStudio.Wpf.Flowchart;assembly=AIStudio.Wpf.Flowchart"
|
||||
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Window.Resources>
|
||||
@@ -32,5 +35,52 @@
|
||||
<!-- Diagram Control -->
|
||||
<dd:DiagramControl Grid.Column="1" x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
|
||||
<controls:PropertiesView Grid.Column="2" SelectedObject="{Binding SelectedItem}" Width="200">
|
||||
<controls:PropertiesView.Resources>
|
||||
<Color x:Key="Gray8">#FFE0E0E0</Color>
|
||||
<SolidColorBrush x:Key="GrayBrush8" Color="{StaticResource Gray8}" options:Freeze="True" />
|
||||
<Style x:Key="ActTypeStyle" TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
||||
<ComboBox BorderThickness="0" BorderBrush="Transparent" Text="{Binding ActType}" >
|
||||
<ComboBoxItem Content="or"/>
|
||||
<ComboBoxItem Content="and"/>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="UserIdsStyle" TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
||||
<controls:MultiSelectComboBox BorderThickness="0" DisplayMemberPath="text" SelectedValuePath="value"
|
||||
SelectedValues="{Binding UserIds}"
|
||||
ItemsSource="{x:Static flowchart:FlowchartService.Users}" ></controls:MultiSelectComboBox>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="RoleIdsStyle" TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Grid DataContext="{Binding Path=DataContext,RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}">
|
||||
<controls:MultiSelectComboBox BorderThickness="0" DisplayMemberPath="text" SelectedValuePath="value"
|
||||
SelectedValues="{Binding RoleIds}"
|
||||
ItemsSource="{x:Static flowchart:FlowchartService.Roles}"></controls:MultiSelectComboBox>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</controls:PropertiesView.Resources>
|
||||
</controls:PropertiesView>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="10" Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Grid Margin="5" Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Rectangle Name="Border"
|
||||
StrokeThickness="1"
|
||||
StrokeDashArray="2"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
@@ -25,19 +26,36 @@ namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public SelectableDesignerItemViewModelBase SelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return DiagramViewModel.SelectedItems?.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
ToolBoxViewModel = new ToolBoxViewModel();
|
||||
DiagramViewModel = new DiagramViewModel();
|
||||
DiagramViewModel.ShowGrid = true;
|
||||
DiagramViewModel.GridCellSize = new Size(100, 60);
|
||||
DiagramViewModel.GridMargin = 0d;
|
||||
DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
|
||||
DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
|
||||
DiagramViewModel.PageSizeType = PageSizeType.Custom;
|
||||
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
|
||||
|
||||
ConnectorViewModel.PathFinder = new OrthogonalPathFinder();
|
||||
_service.DrawModeViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
|
||||
DiagramViewModel.PropertyChanged += DiagramViewModel_PropertyChanged;
|
||||
}
|
||||
|
||||
private void DiagramViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "IsSelected")
|
||||
{
|
||||
RaisePropertyChanged(nameof(SelectedItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Test.ViewModels
|
||||
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.End, typeof(EndFlowNode), 80, 48));
|
||||
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.Middle, typeof(MiddleFlowNode), 80, 48));
|
||||
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.Decide, typeof(DecideFlowNode), 80, 48));
|
||||
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.COBegin, typeof(COBeginFlowNode), 48, 48));
|
||||
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.COBegin, typeof(COBeginFlowNode), 80, 48));
|
||||
toolBoxItems.Add(new FlowchartToolBoxData(NodeKinds.COEnd, typeof(COEndFlowNode), 80, 48));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user