mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-04 06:51:28 +08:00
最近精简代码,有些bug,修复
This commit is contained in:
@@ -2383,9 +2383,10 @@
|
|||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid>
|
<Grid>
|
||||||
<ScrollViewer x:Name="designerScrollViewer"
|
<ScrollViewer x:Name="designerScrollViewer"
|
||||||
Background="{DynamicResource GrayBrush8}"
|
Background="{DynamicResource GrayBrush8}"
|
||||||
HorizontalScrollBarVisibility="Auto"
|
HorizontalScrollBarVisibility="Auto"
|
||||||
VerticalScrollBarVisibility="Auto">
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
Focusable="False">
|
||||||
<DockPanel x:Name="panel">
|
<DockPanel x:Name="panel">
|
||||||
<controls:Ruler x:Name="hruler"
|
<controls:Ruler x:Name="hruler"
|
||||||
Unit="{Binding PageUnit,Converter={StaticResource RulerUnitConverter}}"
|
Unit="{Binding PageUnit,Converter={StaticResource RulerUnitConverter}}"
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace AIStudio.Wpf.DiagramApp
|
|||||||
|
|
||||||
private void HookEvents()
|
private void HookEvents()
|
||||||
{
|
{
|
||||||
this.PreviewMouseWheel += this.OnPreviewMouseWheel;
|
//this.PreviewMouseWheel += this.OnPreviewMouseWheel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ZoomSlider_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
private void ZoomSlider_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||||
@@ -55,20 +55,20 @@ namespace AIStudio.Wpf.DiagramApp
|
|||||||
TextOptions.SetTextFormattingMode(this, textFormattingMode);
|
TextOptions.SetTextFormattingMode(this, textFormattingMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
//private void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||||
{
|
//{
|
||||||
if (Keyboard.IsKeyDown(Key.LeftCtrl) == false
|
// if (Keyboard.IsKeyDown(Key.LeftCtrl) == false
|
||||||
&& Keyboard.IsKeyDown(Key.RightCtrl) == false)
|
// && Keyboard.IsKeyDown(Key.RightCtrl) == false)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var newZoomValue = this.zoomSlider.Value + (e.Delta > 0 ? 0.1 : -0.1);
|
// var newZoomValue = this.zoomSlider.Value + (e.Delta > 0 ? 0.1 : -0.1);
|
||||||
|
|
||||||
this.zoomSlider.Value = Math.Max(Math.Min(newZoomValue, this.zoomSlider.Maximum), this.zoomSlider.Minimum);
|
// this.zoomSlider.Value = Math.Max(Math.Min(newZoomValue, this.zoomSlider.Maximum), this.zoomSlider.Minimum);
|
||||||
|
|
||||||
e.Handled = true;
|
// e.Handled = true;
|
||||||
}
|
//}
|
||||||
|
|
||||||
private void btnPrint_Click(object sender, RoutedEventArgs e)
|
private void btnPrint_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AIStudio.Wpf.DiagramDesigner.ViewModels;
|
using AIStudio.Wpf.DiagramDesigner.ViewModels;
|
||||||
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
|
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner
|
namespace AIStudio.Wpf.DiagramDesigner
|
||||||
{
|
{
|
||||||
@@ -15,19 +16,31 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
private Point? startPoint;
|
private Point? startPoint;
|
||||||
private Point? endPoint;
|
private Point? endPoint;
|
||||||
private List<Point> pointList = new List<Point>();
|
private List<Point> pointList = new List<Point>();
|
||||||
private List<PointDesignerItemViewModel> pointDesignerItemViewModelList = new List<PointDesignerItemViewModel>();
|
|
||||||
private Pen rubberbandPen;
|
private Pen rubberbandPen;
|
||||||
|
|
||||||
private DesignerCanvas _designerCanvas;
|
private DesignerCanvas _designerCanvas;
|
||||||
|
|
||||||
private IDiagramViewModel _viewModel { get { return _designerCanvas.DataContext as IDiagramViewModel; } }
|
private IDiagramViewModel _viewModel
|
||||||
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _designerCanvas.DataContext as IDiagramViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private IDiagramServiceProvider _service
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DiagramServicesProvider.Instance.Provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public RubberbandAdorner(DesignerCanvas designerCanvas, Point? dragStartPoint)
|
public RubberbandAdorner(DesignerCanvas designerCanvas, Point? dragStartPoint)
|
||||||
: base(designerCanvas)
|
: base(designerCanvas)
|
||||||
{
|
{
|
||||||
this._designerCanvas = designerCanvas;
|
this._designerCanvas = designerCanvas;
|
||||||
|
this._designerCanvas.Focus();
|
||||||
this.startPoint = dragStartPoint;
|
this.startPoint = dragStartPoint;
|
||||||
rubberbandPen = new Pen(Brushes.LightSlateGray, 1);
|
rubberbandPen = new Pen(Brushes.LightSlateGray, 1);
|
||||||
rubberbandPen.DashStyle = new DashStyle(new double[] { 2 }, 1);
|
rubberbandPen.DashStyle = new DashStyle(new double[] { 2 }, 1);
|
||||||
@@ -55,14 +68,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
else if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
|
else if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
|
||||||
{
|
{
|
||||||
|
if (!this.IsMouseCaptured)
|
||||||
|
this.CaptureMouse();
|
||||||
|
|
||||||
|
endPoint = e.GetPosition(this);
|
||||||
|
|
||||||
if (pointList.Count == 0 && this.startPoint.HasValue)
|
if (pointList.Count == 0 && this.startPoint.HasValue)
|
||||||
{
|
{
|
||||||
pointList.Add(this.startPoint.Value);
|
pointList.Add(this.startPoint.Value);
|
||||||
var item = new PointDesignerItemViewModel(startPoint.Value);
|
|
||||||
item.ShowConnectors = true;
|
|
||||||
_viewModel.Add(item);
|
|
||||||
pointDesignerItemViewModelList.Add(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateSelection();
|
||||||
|
this.InvalidateVisual();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -74,38 +91,23 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e)
|
protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine && e.ChangedButton == MouseButton.Left )
|
if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine && e.ChangedButton == MouseButton.Left)
|
||||||
{
|
{
|
||||||
endPoint = e.GetPosition(this);
|
//按着ctrl自动封闭曲线
|
||||||
|
if (Keyboard.IsKeyDown(Key.LeftCtrl) == true || Keyboard.IsKeyDown(Key.RightCtrl) == true)
|
||||||
bool isend = false;
|
{
|
||||||
var connector = ControlExtession.TryFindFromPoint<PointConnector>(this._designerCanvas, endPoint.Value);
|
pointList.Add(this.startPoint.Value);
|
||||||
if (connector != null)
|
}
|
||||||
{
|
else
|
||||||
if (object.Equals(connector.DataContext, pointDesignerItemViewModelList[0].TopConnector))
|
|
||||||
{
|
|
||||||
isend = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isend == false)
|
|
||||||
{
|
{
|
||||||
|
endPoint = e.GetPosition(this);
|
||||||
pointList.Add(endPoint.Value);
|
pointList.Add(endPoint.Value);
|
||||||
var item = new PointDesignerItemViewModel(endPoint.Value);
|
|
||||||
item.ShowConnectors = true;
|
|
||||||
_viewModel.Add(item);
|
|
||||||
pointDesignerItemViewModelList.Add(item);
|
|
||||||
|
|
||||||
UpdateSelection();
|
UpdateSelection();
|
||||||
this.InvalidateVisual();
|
this.InvalidateVisual();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
this._service.DrawModeViewModel.SetDrawMode(DrawMode.Polygon);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// release mouse capture
|
// release mouse capture
|
||||||
@@ -136,25 +138,27 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
itemBase.ItemHeight = Math.Abs(this.endPoint.Value.Y - this.startPoint.Value.Y);
|
itemBase.ItemHeight = Math.Abs(this.endPoint.Value.Y - this.startPoint.Value.Y);
|
||||||
|
|
||||||
_viewModel.AddItemCommand.Execute(itemBase);
|
_viewModel.AddItemCommand.Execute(itemBase);
|
||||||
|
|
||||||
|
this.Dispatcher.BeginInvoke((System.Action)(() => {
|
||||||
|
itemBase.ShowText = true;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
else if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Polyline
|
else if (this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Polyline
|
||||||
|| this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Polygon
|
|| this._service.DrawModeViewModel.GetDrawMode() == DrawMode.Polygon
|
||||||
|| this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
|
|| this._service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
|
||||||
{
|
{
|
||||||
ShapeDesignerItemViewModel itemBase = new ShapeDesignerItemViewModel(this._service.DrawModeViewModel.GetDrawMode(), pointList);
|
ShapeDesignerItemViewModel itemBase = new ShapeDesignerItemViewModel(this._service.DrawModeViewModel.GetDrawMode(), pointList);
|
||||||
_viewModel.AddItemCommand.Execute(itemBase);
|
_viewModel.AddItemCommand.Execute(itemBase);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShapeDesignerItemViewModel itemBase = new ShapeDesignerItemViewModel(this._service.DrawModeViewModel.GetDrawMode(), new List<Point> { this.startPoint.Value, this.endPoint.Value });
|
ShapeDesignerItemViewModel itemBase = new ShapeDesignerItemViewModel(this._service.DrawModeViewModel.GetDrawMode(), new List<Point> { this.startPoint.Value, this.endPoint.Value });
|
||||||
_viewModel.AddItemCommand.Execute(itemBase);
|
_viewModel.AddItemCommand.Execute(itemBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._service.DrawModeViewModel.ResetDrawMode();
|
this._service.DrawModeViewModel.ResetDrawMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
pointDesignerItemViewModelList.ForEach(p => _viewModel.Remove(p));
|
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +193,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
else if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
|
else if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
|
||||||
{
|
{
|
||||||
var disList = pointList.ToList();
|
var disList = pointList.ToList();
|
||||||
for (int i = 1; i < pointList.Count; i++)
|
//按着ctrl自动封闭曲线
|
||||||
|
if (Keyboard.IsKeyDown(Key.LeftCtrl) == true || Keyboard.IsKeyDown(Key.RightCtrl) == true)
|
||||||
|
{
|
||||||
|
disList.Add(this.startPoint.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disList.Add(this.endPoint.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i < disList.Count; i++)
|
||||||
{
|
{
|
||||||
dc.DrawLine(rubberbandPen, disList[i - 1], disList[i]);
|
dc.DrawLine(rubberbandPen, disList[i - 1], disList[i]);
|
||||||
}
|
}
|
||||||
@@ -211,8 +225,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
return GetParent<T>(parentType, parent);
|
return GetParent<T>(parentType, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void UpdateSelection()
|
private void UpdateSelection()
|
||||||
{
|
{
|
||||||
IDiagramViewModel vm = (_designerCanvas.DataContext as IDiagramViewModel);
|
IDiagramViewModel vm = (_designerCanvas.DataContext as IDiagramViewModel);
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ using Newtonsoft.Json;
|
|||||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||||
using AIStudio.Wpf.DiagramDesigner.ViewModels;
|
using AIStudio.Wpf.DiagramDesigner.ViewModels;
|
||||||
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
|
using AIStudio.Wpf.DiagramDesigner.ViewModels.BaseViewModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner
|
namespace AIStudio.Wpf.DiagramDesigner
|
||||||
{
|
{
|
||||||
public class DesignerCanvas : Canvas
|
public class DesignerCanvas : Canvas
|
||||||
{
|
{
|
||||||
|
#region 属性
|
||||||
private IDiagramViewModel _viewModel
|
private IDiagramViewModel _viewModel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -35,7 +37,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
return DiagramServicesProvider.Instance.Provider;
|
return DiagramServicesProvider.Instance.Provider;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConnectionViewModel partialConnection;
|
private ConnectionViewModel partialConnection;
|
||||||
private List<Connector> connectorsHit = new List<Connector>();
|
private List<Connector> connectorsHit = new List<Connector>();
|
||||||
|
|
||||||
@@ -188,6 +189,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 初始化
|
||||||
public DesignerCanvas()
|
public DesignerCanvas()
|
||||||
{
|
{
|
||||||
this.Focusable = true;
|
this.Focusable = true;
|
||||||
@@ -200,7 +204,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
private void DesignerCanvas_Loaded(object sender, RoutedEventArgs e)
|
private void DesignerCanvas_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.Focus();
|
this.Focus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnRender(DrawingContext dc)
|
protected override void OnRender(DrawingContext dc)
|
||||||
@@ -222,7 +225,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
dc.DrawLine(new Pen(new SolidColorBrush(GridColor), 1), new Point(i, GridMarginSize.Height), new Point(i, rect.Height - GridMarginSize.Height));
|
dc.DrawLine(new Pen(new SolidColorBrush(GridColor), 1), new Point(i, GridMarginSize.Height), new Point(i, rect.Height - GridMarginSize.Height));
|
||||||
dc.DrawLine(new Pen(new SolidColorBrush(GridColor), 1), new Point(rect.Width - GridMarginSize.Width, GridMarginSize.Height), new Point(rect.Width - GridMarginSize.Width, rect.Height - GridMarginSize.Height));
|
dc.DrawLine(new Pen(new SolidColorBrush(GridColor), 1), new Point(rect.Width - GridMarginSize.Width, GridMarginSize.Height), new Point(rect.Width - GridMarginSize.Width, rect.Height - GridMarginSize.Height));
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Format/Move
|
||||||
private void _service_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void _service_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is IDrawModeViewModel)
|
if (sender is IDrawModeViewModel)
|
||||||
@@ -241,7 +246,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Format/Move
|
|
||||||
private void EnterFormat()
|
private void EnterFormat()
|
||||||
{
|
{
|
||||||
StreamResourceInfo sri = Application.GetResourceStream(new Uri("pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Images/FormatPainter.cur", UriKind.RelativeOrAbsolute));
|
StreamResourceInfo sri = Application.GetResourceStream(new Uri("pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Images/FormatPainter.cur", UriKind.RelativeOrAbsolute));
|
||||||
@@ -270,13 +274,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
_service.DrawModeViewModel.CursorMode = CursorMode.Normal;
|
_service.DrawModeViewModel.CursorMode = CursorMode.Normal;
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
private void Format(SelectableDesignerItemViewModelBase source, SelectableDesignerItemViewModelBase target)
|
private void Format(SelectableDesignerItemViewModelBase source, SelectableDesignerItemViewModelBase target)
|
||||||
{
|
{
|
||||||
CopyHelper.CopyPropertyValue(source.ColorViewModel, target.ColorViewModel);
|
CopyHelper.CopyPropertyValue(source.ColorViewModel, target.ColorViewModel);
|
||||||
CopyHelper.CopyPropertyValue(source.FontViewModel, target.FontViewModel);
|
CopyHelper.CopyPropertyValue(source.FontViewModel, target.FontViewModel);
|
||||||
|
CopyHelper.CopyPropertyValue(source.ShapeViewModel, target.ShapeViewModel);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private Connector sourceConnector;
|
private Connector sourceConnector;
|
||||||
public Connector SourceConnector
|
public Connector SourceConnector
|
||||||
@@ -294,7 +299,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
FullyCreatedConnectorInfo sourceDataItem = sourceConnector.Info;
|
FullyCreatedConnectorInfo sourceDataItem = sourceConnector.Info;
|
||||||
|
|
||||||
|
|
||||||
Rect rectangleBounds = sourceConnector.TransformToVisual(this).TransformBounds(new Rect(sourceConnector.RenderSize));
|
Rect rectangleBounds = sourceConnector.TransformToVisual(this).TransformBounds(new Rect(sourceConnector.RenderSize));
|
||||||
Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
|
Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
|
||||||
rectangleBounds.Bottom + (rectangleBounds.Height / 2));
|
rectangleBounds.Bottom + (rectangleBounds.Height / 2));
|
||||||
@@ -305,38 +309,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FullyCreatedConnectorInfo sourceConnectorInfo;
|
|
||||||
public FullyCreatedConnectorInfo SourceConnectorInfo
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return sourceConnectorInfo;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (sourceConnectorInfo != value)
|
|
||||||
{
|
|
||||||
sourceConnectorInfo = value;
|
|
||||||
sourceConnector = new Connector() { Name = "占位" };//占位使用
|
|
||||||
connectorsHit.Add(sourceConnector);
|
|
||||||
|
|
||||||
Rect rectangleBounds = new Rect(sourceConnectorInfo.DataItem.Left, sourceConnectorInfo.DataItem.Top, 3, 3);
|
|
||||||
Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
|
|
||||||
rectangleBounds.Bottom + (rectangleBounds.Height / 2));
|
|
||||||
partialConnection = new ConnectionViewModel(_viewModel, sourceConnectorInfo, new PartCreatedConnectorInfo(point.X, point.Y), DrawMode, RouterMode);
|
|
||||||
_viewModel.Add(partialConnection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnMouseDown(e);
|
base.OnMouseDown(e);
|
||||||
|
|
||||||
if (_viewModel.IsReadOnly) return;
|
if (_viewModel.IsReadOnly) return;
|
||||||
|
|
||||||
this.Focus();
|
|
||||||
|
|
||||||
if (_service.DrawModeViewModel.CursorMode == CursorMode.Format)
|
if (_service.DrawModeViewModel.CursorMode == CursorMode.Format)
|
||||||
{
|
{
|
||||||
var element = (e.OriginalSource as FrameworkElement);
|
var element = (e.OriginalSource as FrameworkElement);
|
||||||
@@ -365,20 +343,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
|
if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
|
||||||
{
|
{
|
||||||
_viewModel.ClearSelectedItemsCommand.Execute(null);
|
_viewModel.ClearSelectedItems();
|
||||||
|
|
||||||
}
|
}
|
||||||
//e.Handled = true;
|
e.Handled = true;
|
||||||
|
|
||||||
if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.ConnectingLineSmooth)
|
|
||||||
{
|
|
||||||
if (connectorsHit.Count == 0)
|
|
||||||
{
|
|
||||||
LinkPointDesignerItemViewModel pointItemView = new LinkPointDesignerItemViewModel(rubberbandSelectionStartPoint.Value);
|
|
||||||
_viewModel.Add(pointItemView);
|
|
||||||
SourceConnectorInfo = pointItemView.Connectors.FirstOrDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,12 +354,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
protected override void OnMouseMove(MouseEventArgs e)
|
protected override void OnMouseMove(MouseEventArgs e)
|
||||||
{
|
{
|
||||||
|
var focusedElement = Keyboard.FocusedElement;
|
||||||
|
Debug.WriteLine("focusedElement:" + focusedElement?.ToString());
|
||||||
|
|
||||||
base.OnMouseMove(e);
|
base.OnMouseMove(e);
|
||||||
|
|
||||||
if (_viewModel.IsReadOnly) return;
|
if (_viewModel.IsReadOnly) return;
|
||||||
|
|
||||||
this.Focus();
|
|
||||||
|
|
||||||
Point currentPoint = e.GetPosition(this);
|
Point currentPoint = e.GetPosition(this);
|
||||||
_viewModel.CurrentPoint = new Point(ScreenHelper.WidthToMm(currentPoint.X), ScreenHelper.WidthToMm(currentPoint.Y));
|
_viewModel.CurrentPoint = new Point(ScreenHelper.WidthToMm(currentPoint.X), ScreenHelper.WidthToMm(currentPoint.Y));
|
||||||
var point = CursorPointManager.GetCursorPosition();
|
var point = CursorPointManager.GetCursorPosition();
|
||||||
@@ -418,10 +387,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
var nearPort = FindNearPortToAttachTo();
|
var nearPort = FindNearPortToAttachTo();
|
||||||
if (nearPort != null || partialConnection.SinkConnectorInfoFully != null)
|
if (nearPort != null || partialConnection.SinkConnectorInfoFully != null)
|
||||||
{
|
{
|
||||||
//var oldPort = _ongoingLink.TargetPort;
|
|
||||||
//_ongoingLink.SetTargetPort(nearPort);
|
|
||||||
//oldPort?.Refresh();
|
|
||||||
//nearPort?.Refresh();
|
|
||||||
partialConnection.SinkConnectorInfo = nearPort;
|
partialConnection.SinkConnectorInfo = nearPort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -447,10 +412,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
adornerLayer.Add(adorner);
|
adornerLayer.Add(adorner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnMouseUp(MouseButtonEventArgs e)
|
protected override void OnMouseUp(MouseButtonEventArgs e)
|
||||||
@@ -459,18 +424,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
if (_viewModel.IsReadOnly) return;
|
if (_viewModel.IsReadOnly) return;
|
||||||
|
|
||||||
this.Focus();
|
|
||||||
|
|
||||||
if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mediator.Instance.NotifyColleagues<bool>("DoneDrawingMessage", true);
|
Mediator.Instance.NotifyColleagues<bool>("DoneDrawingMessage", true);
|
||||||
|
|
||||||
if (sourceConnector != null)
|
if (sourceConnector != null)
|
||||||
{
|
{
|
||||||
FullyCreatedConnectorInfo sourceDataItem = sourceConnectorInfo ?? (sourceConnector.Info);
|
FullyCreatedConnectorInfo sourceDataItem = sourceConnector.Info;
|
||||||
if (connectorsHit.Count() == 2)
|
if (connectorsHit.Count() == 2)
|
||||||
{
|
{
|
||||||
Connector sinkConnector = connectorsHit.Last();
|
Connector sinkConnector = connectorsHit.Last();
|
||||||
@@ -481,25 +439,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
sinkDataItem.DataItem.Root.Items[indexOfLastTempConnection]);
|
sinkDataItem.DataItem.Root.Items[indexOfLastTempConnection]);
|
||||||
sinkDataItem.DataItem.Root.AddItemCommand.Execute(new ConnectionViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode));
|
sinkDataItem.DataItem.Root.AddItemCommand.Execute(new ConnectionViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode));
|
||||||
}
|
}
|
||||||
else if (partialConnection.IsFullConnection)
|
else if (partialConnection.IsFullConnection)//自动连接模式
|
||||||
{
|
{
|
||||||
partialConnection.RaiseFullConnection();
|
partialConnection.RaiseFullConnection();
|
||||||
}
|
}
|
||||||
else if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine && connectorsHit.Count() == 1)
|
|
||||||
{
|
|
||||||
LinkPointDesignerItemViewModel pointItemView = new LinkPointDesignerItemViewModel(e.GetPosition(this));
|
|
||||||
FullyCreatedConnectorInfo sinkDataItem = pointItemView.TopConnector;
|
|
||||||
|
|
||||||
int indexOfLastTempConnection = _viewModel.Items.Count - 1;
|
|
||||||
_viewModel.Remove(_viewModel.Items[indexOfLastTempConnection]);
|
|
||||||
_viewModel.Add(pointItemView);
|
|
||||||
|
|
||||||
var connector = new ConnectionViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode);
|
|
||||||
_viewModel.AddItemCommand.Execute(connector);
|
|
||||||
|
|
||||||
sourceDataItem.DataItem.ZIndex++;
|
|
||||||
connector.ZIndex--;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Need to remove last item as we did not finish drawing the path
|
//Need to remove last item as we did not finish drawing the path
|
||||||
@@ -513,9 +456,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
connectorsHit = new List<Connector>();
|
connectorsHit = new List<Connector>();
|
||||||
sourceConnector = null;
|
sourceConnector = null;
|
||||||
sourceConnectorInfo = null;
|
|
||||||
|
|
||||||
_service.DrawModeViewModel.ResetDrawMode();
|
if (_service.DrawModeViewModel.GetDrawMode() != DrawMode.DirectLine)
|
||||||
|
{
|
||||||
|
_service.DrawModeViewModel.ResetDrawMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||||
@@ -577,34 +522,26 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
while (hitObject != null &&
|
while (hitObject != null &&
|
||||||
hitObject.GetType() != typeof(DesignerCanvas))
|
hitObject.GetType() != typeof(DesignerCanvas))
|
||||||
{
|
{
|
||||||
if (hitObject is Connector connector && connector.Info != null)
|
if (hitObject is Connector connector)
|
||||||
{
|
{
|
||||||
if (SourceConnector == null || connector.Info.CanAttachTo(SourceConnector.Info))
|
if (!connectorsHit.Contains(hitObject as Connector))
|
||||||
{
|
connectorsHit.Add(hitObject as Connector);
|
||||||
if (connectorsHit.Any(p => p.Name == "占位"))
|
|
||||||
{
|
|
||||||
connectorsHit.Remove(connectorsHit.FirstOrDefault(p => p.Name == "占位"));
|
|
||||||
}
|
|
||||||
if (!connectorsHit.Contains(hitObject as Connector))
|
|
||||||
connectorsHit.Add(hitObject as Connector);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
hitObject = VisualTreeHelper.GetParent(hitObject);
|
hitObject = VisualTreeHelper.GetParent(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDrop(DragEventArgs e)
|
protected override void OnDrop(DragEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnDrop(e);
|
base.OnDrop(e);
|
||||||
|
|
||||||
if (_viewModel.IsReadOnly) return;
|
if (_viewModel.IsReadOnly) return;
|
||||||
|
|
||||||
DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
|
DragObject dragObject = e.Data.GetData(typeof(DragObject)) as DragObject;
|
||||||
if (dragObject != null)
|
if (dragObject != null)
|
||||||
{
|
{
|
||||||
_viewModel.ClearSelectedItemsCommand.Execute(null);
|
_viewModel.ClearSelectedItemsCommand.Execute(null);
|
||||||
Point position = e.GetPosition(this);
|
Point position = e.GetPosition(this);
|
||||||
if (dragObject.DesignerItem is SerializableObject serializableObject)
|
if (dragObject.DesignerItem is SerializableObject serializableObject)
|
||||||
{
|
{
|
||||||
var designerItems = serializableObject.ToObject();
|
var designerItems = serializableObject.ToObject();
|
||||||
@@ -618,7 +555,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
foreach (var item in designerItems.OfType<DesignerItemViewModelBase>())
|
foreach (var item in designerItems.OfType<DesignerItemViewModelBase>())
|
||||||
{
|
{
|
||||||
item.Left += position.X - itemswidth / 2;
|
item.Left += position.X - itemswidth / 2;
|
||||||
item.Top += position.Y - itemsheight / 2;
|
item.Top += position.Y - itemsheight / 2;
|
||||||
}
|
}
|
||||||
_viewModel.AddItemCommand.Execute(designerItems);
|
_viewModel.AddItemCommand.Execute(designerItems);
|
||||||
}
|
}
|
||||||
@@ -668,7 +605,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
this.Focus();
|
this.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FullyCreatedConnectorInfo FindNearPortToAttachTo()
|
#region 自动依附节点
|
||||||
|
private FullyCreatedConnectorInfo FindNearPortToAttachTo()
|
||||||
{
|
{
|
||||||
foreach (var port in _viewModel.Items.OfType<DesignerItemViewModelBase>().ToList().SelectMany(n => n.Connectors))
|
foreach (var port in _viewModel.Items.OfType<DesignerItemViewModelBase>().ToList().SelectMany(n => n.Connectors))
|
||||||
{
|
{
|
||||||
@@ -679,5 +617,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
<Setter Property="ContentTemplate">
|
<Setter Property="ContentTemplate">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid x:Name="selectedGrid" IsHitTestVisible="{Binding IsHitTestVisible}" >
|
<Grid x:Name="selectedGrid" IsHitTestVisible="{Binding IsHitTestVisible}" >
|
||||||
<Grid.ContextMenu>
|
<Grid.ContextMenu>
|
||||||
<ContextMenu ItemsSource="{Binding MenuOptions}" Visibility="{Binding ShowMenuOptions,Converter={StaticResource BooleanToVisibilityConverter}}">
|
<ContextMenu ItemsSource="{Binding MenuOptions}" Visibility="{Binding ShowMenuOptions,Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||||
<ContextMenu.ItemContainerStyle>
|
<ContextMenu.ItemContainerStyle>
|
||||||
@@ -462,8 +462,8 @@
|
|||||||
Value="{Binding Area.Left}" />
|
Value="{Binding Area.Left}" />
|
||||||
<Setter Property="Canvas.ZIndex"
|
<Setter Property="Canvas.ZIndex"
|
||||||
Value="{Binding ZIndex}" />
|
Value="{Binding ZIndex}" />
|
||||||
<!--<Setter Property="dd:SelectionProps.EnabledForSelection"
|
<Setter Property="dd:SelectionProps.EnabledForSelection"
|
||||||
Value="{Binding EnabledForSelection}" />-->
|
Value="{Binding EnabledForSelection}" />
|
||||||
<Setter Property="Visibility"
|
<Setter Property="Visibility"
|
||||||
Value="{Binding Visible,Converter={StaticResource BooleanToVisibilityConverter}}"/>
|
Value="{Binding Visible,Converter={StaticResource BooleanToVisibilityConverter}}"/>
|
||||||
<Setter Property="ContentTemplate">
|
<Setter Property="ContentTemplate">
|
||||||
@@ -860,7 +860,8 @@
|
|||||||
<ScrollViewer Name="DesignerScrollViewer"
|
<ScrollViewer Name="DesignerScrollViewer"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
HorizontalScrollBarVisibility="Auto"
|
HorizontalScrollBarVisibility="Auto"
|
||||||
VerticalScrollBarVisibility="Auto">
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
Focusable="False">
|
||||||
<ItemsControl x:Name="diagram" ItemsSource="{Binding Items}"
|
<ItemsControl x:Name="diagram" ItemsSource="{Binding Items}"
|
||||||
ItemContainerStyleSelector="{x:Static dd:DesignerItemsControlItemStyleSelector.Instance}">
|
ItemContainerStyleSelector="{x:Static dd:DesignerItemsControlItemStyleSelector.Instance}">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
|
|||||||
28
AIStudio.Wpf.DiagramDesigner/UserControls/GridControl.cs
Normal file
28
AIStudio.Wpf.DiagramDesigner/UserControls/GridControl.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace AIStudio.Wpf.DiagramDesigner
|
||||||
|
{
|
||||||
|
public class GridControl : Grid
|
||||||
|
{
|
||||||
|
public IDiagramViewModel DiagramViewModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (this.DataContext as SelectableDesignerItemViewModelBase)?.Root;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||||
|
//{
|
||||||
|
// base.OnPreviewKeyDown(e);
|
||||||
|
|
||||||
|
// e.Handled = DiagramViewModel?.ExecuteShortcut(e) ?? false;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,9 +59,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
private void TextControl_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void TextControl_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName == "IsSelected")
|
if (sender is ISelectable selectable)
|
||||||
{
|
{
|
||||||
if (sender is ISelectable selectable)
|
if (e.PropertyName == "IsSelected")
|
||||||
{
|
{
|
||||||
if (selectable.IsSelected == false)
|
if (selectable.IsSelected == false)
|
||||||
{
|
{
|
||||||
@@ -70,16 +70,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
selectable.IsEditing = false;
|
selectable.IsEditing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (e.PropertyName == "ShowText")
|
||||||
else if (e.PropertyName == "ShowText")
|
|
||||||
{
|
|
||||||
PART_ShowText.Visibility = Visibility.Visible;
|
|
||||||
PART_TextBlock.Visibility = Visibility.Collapsed;
|
|
||||||
PART_ShowText.Focus();
|
|
||||||
if (!string.IsNullOrEmpty(PART_ShowText.Text))
|
|
||||||
{
|
{
|
||||||
PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
|
PART_ShowText.Visibility = Visibility.Visible;
|
||||||
}
|
PART_TextBlock.Visibility = Visibility.Collapsed;
|
||||||
|
PART_ShowText.Focus();
|
||||||
|
if (!string.IsNullOrEmpty(PART_ShowText.Text))
|
||||||
|
{
|
||||||
|
PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,19 +356,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool enabledForSelection = true;
|
|
||||||
public bool EnabledForSelection
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return enabledForSelection;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetProperty(ref enabledForSelection, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private double _left;
|
private double _left;
|
||||||
[CanDo]
|
[CanDo]
|
||||||
public double Left
|
public double Left
|
||||||
|
|||||||
@@ -1251,7 +1251,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
DoCommandManager.DoNewCommand(this.ToString(),
|
DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
() => {
|
() => {
|
||||||
ClearSelectedItems();
|
ClearSelectedItems();
|
||||||
Add(newitems);
|
Add(newitems, true);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
foreach (var item in newitems)
|
foreach (var item in newitems)
|
||||||
|
|||||||
@@ -78,6 +78,20 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool enabledForSelection = true;
|
||||||
|
public bool EnabledForSelection
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return enabledForSelection;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref enabledForSelection, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private bool _isReadOnlyText = false;
|
private bool _isReadOnlyText = false;
|
||||||
public bool IsReadOnlyText
|
public bool IsReadOnlyText
|
||||||
{
|
{
|
||||||
@@ -105,27 +119,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
SetProperty(ref _customText, value);
|
SetProperty(ref _customText, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _showText;
|
|
||||||
public bool ShowText
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _showText;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (!SetProperty(ref _showText, value))
|
|
||||||
{
|
|
||||||
RaisePropertyChanged(nameof(ShowText));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ClearText()
|
protected override void ClearText()
|
||||||
{
|
{
|
||||||
ShowText = false;
|
ShowText = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteSelectItemCommand(object param)
|
private void ExecuteSelectItemCommand(object param)
|
||||||
@@ -163,8 +162,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
if (IsReadOnly == true) return;
|
if (IsReadOnly == true) return;
|
||||||
|
|
||||||
ShowText = true;
|
ShowText = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,22 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _showText;
|
||||||
|
public bool ShowText
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _showText;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (!SetProperty(ref _showText, value))
|
||||||
|
{
|
||||||
|
RaisePropertyChanged(nameof(ShowText));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool _visible = true;
|
private bool _visible = true;
|
||||||
public bool Visible
|
public bool Visible
|
||||||
{
|
{
|
||||||
@@ -343,7 +359,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected virtual void ClearText()
|
protected virtual void ClearText()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -39,13 +39,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
base.Init(root, initNew);
|
base.Init(root, initNew);
|
||||||
|
|
||||||
CustomText = true;
|
CustomText = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void InitNew()
|
protected override void InitNew()
|
||||||
{
|
{
|
||||||
this.ItemWidth = 150;
|
this.ItemWidth = 150;
|
||||||
this.ClearConnectors();
|
this.ClearConnectors();
|
||||||
|
ShowText = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _watermark = "请输入文本";
|
private string _watermark = "请输入文本";
|
||||||
@@ -60,5 +61,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
SetProperty(ref _watermark, value);
|
SetProperty(ref _watermark, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void ClearText()
|
||||||
|
{
|
||||||
|
Root.RemoveItemCommand.Execute(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,6 +339,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
void Remove(object parameter);
|
void Remove(object parameter);
|
||||||
|
|
||||||
|
void ClearSelectedItems();
|
||||||
|
|
||||||
bool ExecuteShortcut(KeyEventArgs e);
|
bool ExecuteShortcut(KeyEventArgs e);
|
||||||
|
|
||||||
event PropertyChangedEventHandler PropertyChanged;
|
event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShowText
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
void AddToSelection(bool selected);
|
void AddToSelection(bool selected);
|
||||||
|
|
||||||
event PropertyChangedEventHandler PropertyChanged;
|
event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ namespace AIStudio.Wpf.Mind.Helpers
|
|||||||
{
|
{
|
||||||
connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineStraight.ToString(), RouterMode.RouterOrthogonal.ToString());
|
connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineStraight.ToString(), RouterMode.RouterOrthogonal.ToString());
|
||||||
}
|
}
|
||||||
|
connector.EnabledForSelection = false;
|
||||||
connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor;
|
connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor;
|
||||||
connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle;
|
connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle;
|
||||||
connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle;
|
connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle;
|
||||||
|
|||||||
Reference in New Issue
Block a user