mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
适应窗口大小完成
This commit is contained in:
@@ -198,6 +198,7 @@ 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)
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
new FrameworkPropertyMetadata(null,
|
new FrameworkPropertyMetadata(null,
|
||||||
new PropertyChangedCallback(OnDesignerCanvasChanged)));
|
new PropertyChangedCallback(OnDesignerCanvasChanged)));
|
||||||
|
|
||||||
|
|
||||||
public FrameworkElement DesignerCanvas
|
public FrameworkElement DesignerCanvas
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -63,7 +62,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
target.OnDesignerCanvasChanged(oldDesignerCanvas, newDesignerCanvas);
|
target.OnDesignerCanvasChanged(oldDesignerCanvas, newDesignerCanvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected virtual void OnDesignerCanvasChanged(FrameworkElement oldDesignerCanvas, FrameworkElement newDesignerCanvas)
|
protected virtual void OnDesignerCanvasChanged(FrameworkElement oldDesignerCanvas, FrameworkElement newDesignerCanvas)
|
||||||
{
|
{
|
||||||
if (oldDesignerCanvas != null)
|
if (oldDesignerCanvas != null)
|
||||||
@@ -139,8 +137,77 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
SetValue(MinimumZoomValueProperty, value);
|
SetValue(MinimumZoomValueProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty FitViewModelProperty =
|
||||||
|
DependencyProperty.Register(nameof(FitViewModel), typeof(FitViewModel), typeof(ZoomBox),
|
||||||
|
new FrameworkPropertyMetadata(null,
|
||||||
|
new PropertyChangedCallback(OnFitViewModelChanged)));
|
||||||
|
|
||||||
|
public FitViewModel FitViewModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (FitViewModel)GetValue(FitViewModelProperty);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(FitViewModelProperty, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnFitViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
ZoomBox target = (ZoomBox)d;
|
||||||
|
var fitviewmodel = e.NewValue as FitViewModel;
|
||||||
|
if (fitviewmodel != null)
|
||||||
|
{
|
||||||
|
target.OnFitViewModelChanged(fitviewmodel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFitViewModelChanged(FitViewModel fitViewModel)
|
||||||
|
{
|
||||||
|
if (IsLoaded && fitViewModel != null)
|
||||||
|
{
|
||||||
|
if (fitViewModel.FitMode == FitMode.None)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (fitViewModel.FitMode == FitMode.FitWidth)
|
||||||
|
{
|
||||||
|
ZoomValue = (this.ScrollViewer.ViewportWidth * fitViewModel.PaddingRate) / fitViewModel.BoundingRect.Width;
|
||||||
|
}
|
||||||
|
else if (fitViewModel.FitMode == FitMode.FitHeight)
|
||||||
|
{
|
||||||
|
ZoomValue = (this.ScrollViewer.ViewportHeight * fitViewModel.PaddingRate) / fitViewModel.BoundingRect.Height;
|
||||||
|
}
|
||||||
|
else if (fitViewModel.FitMode == FitMode.FitAuto)
|
||||||
|
{
|
||||||
|
ZoomValue = Math.Min(
|
||||||
|
(this.ScrollViewer.ViewportWidth * fitViewModel.PaddingRate) / fitViewModel.BoundingRect.Width,
|
||||||
|
(this.ScrollViewer.ViewportHeight * fitViewModel.PaddingRate) / fitViewModel.BoundingRect.Height
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
double xOffset, yOffset;
|
||||||
|
xOffset = fitViewModel.BoundingRect.Left * ZoomValue - (this.ScrollViewer.ViewportWidth - fitViewModel.BoundingRect.Width * ZoomValue) / 2;
|
||||||
|
yOffset = fitViewModel.BoundingRect.Top * ZoomValue - (this.ScrollViewer.ViewportHeight - fitViewModel.BoundingRect.Height * ZoomValue) / 2;
|
||||||
|
this.ScrollViewer.ScrollToHorizontalOffset(xOffset);
|
||||||
|
this.ScrollViewer.ScrollToVerticalOffset(yOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public ZoomBox()
|
||||||
|
{
|
||||||
|
this.Loaded += ZoomBox_Loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ZoomBox_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
OnFitViewModelChanged(FitViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnApplyTemplate()
|
public override void OnApplyTemplate()
|
||||||
{
|
{
|
||||||
base.OnApplyTemplate();
|
base.OnApplyTemplate();
|
||||||
@@ -163,6 +230,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
this.zoomThumb.DragDelta += new DragDeltaEventHandler(this.Thumb_DragDelta);
|
this.zoomThumb.DragDelta += new DragDeltaEventHandler(this.Thumb_DragDelta);
|
||||||
this.zoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(this.ZoomSlider_ValueChanged);
|
this.zoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(this.ZoomSlider_ValueChanged);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ZoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
private void ZoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||||
@@ -197,7 +266,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
Canvas.SetTop(this.zoomThumb, yOffset + this.ScrollViewer.VerticalOffset * scale);
|
Canvas.SetTop(this.zoomThumb, yOffset + this.ScrollViewer.VerticalOffset * scale);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用于记录鼠标按下的点
|
/// 用于记录鼠标按下的点
|
||||||
@@ -207,7 +276,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
private void DesignerCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
private void DesignerCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
_clickPoint = e.GetPosition((FrameworkElement)sender);
|
_clickPoint = e.GetPosition((FrameworkElement)sender);
|
||||||
Debug.WriteLine($"({_clickPoint.X},{_clickPoint.Y})");
|
|
||||||
DesignerCanvas.Cursor = Cursors.Hand;
|
DesignerCanvas.Cursor = Cursors.Hand;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +289,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
if (e.RightButton == MouseButtonState.Pressed)
|
if (e.RightButton == MouseButtonState.Pressed)
|
||||||
{
|
{
|
||||||
FrameworkElement cabSender = (FrameworkElement)sender;
|
FrameworkElement cabSender = (FrameworkElement)sender;
|
||||||
//_clickPoint=new Point(scroll.ActualWidth/2,scroll.ActualHeight/2);
|
|
||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
Point p = e.MouseDevice.GetPosition(cabSender);
|
Point p = e.MouseDevice.GetPosition(cabSender);
|
||||||
@@ -265,8 +332,34 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
xOffset = (x - scale * w) / 2;
|
xOffset = (x - scale * w) / 2;
|
||||||
yOffset = (y - scale * h) / 2;
|
yOffset = (y - scale * h) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FitViewModel
|
||||||
|
{
|
||||||
|
public Rect BoundingRect
|
||||||
|
{
|
||||||
|
get;set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FitMode FitMode
|
||||||
|
{
|
||||||
|
get;set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double PaddingRate
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
} = 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum FitMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
FitAuto,
|
||||||
|
FitWidth,
|
||||||
|
FitHeight,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner.Geometrys
|
namespace AIStudio.Wpf.DiagramDesigner.Geometrys
|
||||||
{
|
{
|
||||||
@@ -1069,6 +1070,16 @@ namespace AIStudio.Wpf.DiagramDesigner.Geometrys
|
|||||||
// return value;
|
// return value;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
public static implicit operator RectangleBase(Rect rect)
|
||||||
|
{
|
||||||
|
return new RectangleBase(rect.Left, rect.Top, rect.Width, rect.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator Rect(RectangleBase rect)
|
||||||
|
{
|
||||||
|
return new Rect(rect.Left, rect.Top, rect.Width, rect.Height);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -856,7 +856,7 @@
|
|||||||
AllowDrop="{Binding AllowDrop}">
|
AllowDrop="{Binding AllowDrop}">
|
||||||
<dd:DesignerCanvas.LayoutTransform>
|
<dd:DesignerCanvas.LayoutTransform>
|
||||||
<ScaleTransform ScaleX="{Binding ZoomValue}" ScaleY="{Binding ZoomValue}" />
|
<ScaleTransform ScaleX="{Binding ZoomValue}" ScaleY="{Binding ZoomValue}" />
|
||||||
</dd:DesignerCanvas.LayoutTransform>
|
</dd:DesignerCanvas.LayoutTransform>
|
||||||
</dd:DesignerCanvas>
|
</dd:DesignerCanvas>
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
@@ -887,7 +887,7 @@
|
|||||||
GridMarginSize="{Binding GridMarginSize}"
|
GridMarginSize="{Binding GridMarginSize}"
|
||||||
GridColor="{Binding GridColor}"
|
GridColor="{Binding GridColor}"
|
||||||
Background="{Binding PageBackground,Converter={StaticResource ColorBrushConverter}}"
|
Background="{Binding PageBackground,Converter={StaticResource ColorBrushConverter}}"
|
||||||
AllowDrop="{Binding AllowDrop}">
|
AllowDrop="{Binding AllowDrop}">
|
||||||
<dd:DesignerCanvas.LayoutTransform>
|
<dd:DesignerCanvas.LayoutTransform>
|
||||||
<ScaleTransform ScaleX="{Binding ZoomValue}" ScaleY="{Binding ZoomValue}" />
|
<ScaleTransform ScaleX="{Binding ZoomValue}" ScaleY="{Binding ZoomValue}" />
|
||||||
</dd:DesignerCanvas.LayoutTransform>
|
</dd:DesignerCanvas.LayoutTransform>
|
||||||
@@ -905,8 +905,8 @@
|
|||||||
MaximumZoomValue="{Binding MaximumZoomValue,Mode=TwoWay}"
|
MaximumZoomValue="{Binding MaximumZoomValue,Mode=TwoWay}"
|
||||||
MinimumZoomValue="{Binding MinimumZoomValue,Mode=TwoWay}"
|
MinimumZoomValue="{Binding MinimumZoomValue,Mode=TwoWay}"
|
||||||
ZoomValue="{Binding ZoomValue,Mode=TwoWay}"
|
ZoomValue="{Binding ZoomValue,Mode=TwoWay}"
|
||||||
Margin="5,0,0,5" />
|
FitViewModel="{Binding FitViewModel}"
|
||||||
|
Margin="5,0,0,5" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double _maximumZoomValue = 3;
|
private double _maximumZoomValue = 100;
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public double MaximumZoomValue
|
public double MaximumZoomValue
|
||||||
{
|
{
|
||||||
@@ -422,7 +422,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double _minimumZoomValue = 0.5;
|
private double _minimumZoomValue = 0.01;
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public double MinimumZoomValue
|
public double MinimumZoomValue
|
||||||
{
|
{
|
||||||
@@ -463,6 +463,19 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FitViewModel _fitViewModel;
|
||||||
|
public FitViewModel FitViewModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _fitViewModel;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _fitViewModel, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string _name;
|
private string _name;
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public string Name
|
public string Name
|
||||||
@@ -561,6 +574,26 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ObservableCollection<CinchMenuItem> menuOptions;
|
||||||
|
public IEnumerable<CinchMenuItem> MenuOptions
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return menuOptions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShowMenuOptions
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (MenuOptions == null || MenuOptions.Count() == 0)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DiagramOption DiagramOption
|
public DiagramOption DiagramOption
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
@@ -739,7 +772,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SimpleCommand _selectAllCommand;
|
private SimpleCommand _selectAllCommand;
|
||||||
public virtual SimpleCommand SelectAllCommand
|
public SimpleCommand SelectAllCommand
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -748,7 +781,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SimpleCommand _selectInverseCommand;
|
private SimpleCommand _selectInverseCommand;
|
||||||
public virtual SimpleCommand SelectInverseCommand
|
public SimpleCommand SelectInverseCommand
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -882,6 +915,33 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SimpleCommand _fitAutoCommand;
|
||||||
|
public SimpleCommand FitAutoCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._fitAutoCommand ?? (this._fitAutoCommand = new SimpleCommand(ExecuteEnable, ExecuteFitAutoCommand));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private SimpleCommand _fitWidthCommand;
|
||||||
|
public SimpleCommand FitWidthCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._fitWidthCommand ?? (this._fitWidthCommand = new SimpleCommand(ExecuteEnable, ExecuteFitWidthCommand));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private SimpleCommand _fitHeightCommand;
|
||||||
|
public SimpleCommand FitHeightCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._fitHeightCommand ?? (this._fitHeightCommand = new SimpleCommand(ExecuteEnable, ExecuteFitHeightCommand));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private SimpleCommand _groupCommand;
|
private SimpleCommand _groupCommand;
|
||||||
public SimpleCommand GroupCommand
|
public SimpleCommand GroupCommand
|
||||||
{
|
{
|
||||||
@@ -991,6 +1051,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
AllowDrop = diagramItem.AllowDrop;
|
AllowDrop = diagramItem.AllowDrop;
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
BuildMenuOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Init()
|
public virtual void Init()
|
||||||
@@ -1003,6 +1064,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
return IsReadOnly == false;
|
return IsReadOnly == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 菜单
|
||||||
|
private void BuildMenuOptions()
|
||||||
|
{
|
||||||
|
menuOptions = new ObservableCollection<CinchMenuItem>();
|
||||||
|
CinchMenuItem menuItem = new CinchMenuItem();
|
||||||
|
menuItem.Text = "居中";
|
||||||
|
menuItem.Command = CenterMoveCommand;
|
||||||
|
menuItem.CommandParameter = this;
|
||||||
|
menuOptions.Add(menuItem);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region UnDo ReDo
|
#region UnDo ReDo
|
||||||
|
|
||||||
private void Do(object sender, string propertyName, object newvalue)
|
private void Do(object sender, string propertyName, object newvalue)
|
||||||
@@ -2250,7 +2323,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteCenterMoveCommand(object parameter)
|
protected virtual void ExecuteCenterMoveCommand(object parameter)
|
||||||
{
|
{
|
||||||
IEnumerable<DesignerItemViewModelBase> selectedItems;
|
IEnumerable<DesignerItemViewModelBase> selectedItems;
|
||||||
if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
||||||
@@ -2267,6 +2340,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
item.Left = (PageSize.Width - item.ItemWidth) / 2;
|
item.Left = (PageSize.Width - item.ItemWidth) / 2;
|
||||||
item.Top = (PageSize.Height - item.ItemHeight) / 2;
|
item.Top = (PageSize.Height - item.ItemHeight) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(selectedItems) };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateZIndex()
|
public void UpdateZIndex()
|
||||||
@@ -2329,6 +2404,23 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 适应大小
|
||||||
|
private void ExecuteFitAutoCommand(object parameter)
|
||||||
|
{
|
||||||
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(Items.OfType<DesignerItemViewModelBase>()), FitMode = FitMode.FitAuto };
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteFitWidthCommand(object parameter)
|
||||||
|
{
|
||||||
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(Items.OfType<DesignerItemViewModelBase>()), FitMode = FitMode.FitWidth };
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteFitHeightCommand(object parameter)
|
||||||
|
{
|
||||||
|
FitViewModel = new FitViewModel() { BoundingRect = DiagramViewModelHelper.GetBoundingRectangle(Items.OfType<DesignerItemViewModelBase>()), FitMode = FitMode.FitHeight };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 分组
|
#region 分组
|
||||||
private void ExecuteGroupCommand(object parameter)
|
private void ExecuteGroupCommand(object parameter)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<ContentControl x:Name="PART_ContentControl" Template="{Binding ToolBox,RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
<ContentControl x:Name="PART_ContentControl" Template="{Binding ToolBox,RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
|
||||||
|
|
||||||
<!-- Diagram Control -->
|
<!-- Diagram Control -->
|
||||||
<dd:DiagramControl Grid.Row="1" x:Name="PART_DiagramControl" MinWidth="1000" MinHeight="1000" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
<dd:DiagramControl Grid.Row="1" x:Name="PART_DiagramControl" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|||||||
@@ -514,7 +514,7 @@
|
|||||||
<controls:DropDownButton Grid.Column="0">
|
<controls:DropDownButton Grid.Column="0">
|
||||||
<controls:DropDownButton.Content>
|
<controls:DropDownButton.Content>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M290.816 774.144h167.936c12.288 0 20.48 8.192 20.48 20.48s-8.192 20.48-20.48 20.48h-219.136c-12.288 0-20.48-8.192-20.48-20.48v-2.048-206.848c0-12.288 8.192-20.48 20.48-20.48s20.48 8.192 20.48 20.48v163.84l210.944-198.656c8.192-8.192 20.48-8.192 28.672 0s8.192 20.48 0 28.672l-208.896 194.56z m462.848-524.288h-167.936c-12.288 0-20.48-8.192-20.48-20.48s8.192-20.48 20.48-20.48h219.136c12.288 0 20.48 8.192 20.48 20.48v208.896c0 12.288-8.192 20.48-20.48 20.48s-20.48-8.192-20.48-20.48v-163.84l-210.944 198.656c-8.192 8.192-20.48 8.192-28.672 0s-8.192-20.48 0-28.672l208.896-194.56z m188.416 323.584c0 12.288-8.192 20.48-20.48 20.48s-20.48-8.192-20.48-20.48v-389.12c0-34.816-26.624-61.44-61.44-61.44h-655.36c-34.816 0-61.44 26.624-61.44 61.44v655.36c0 34.816 26.624 61.44 61.44 61.44h655.36c34.816 0 61.44-26.624 61.44-61.44v-94.208c0-12.288 8.192-20.48 20.48-20.48s20.48 8.192 20.48 20.48v94.208c0 57.344-45.056 102.4-102.4 102.4h-655.36c-57.344 0-102.4-45.056-102.4-102.4v-655.36c0-57.344 45.056-102.4 102.4-102.4h655.36c57.344 0 102.4 45.056 102.4 102.4v389.12z"></Path>
|
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M877.714286 768c0 21.942857-14.628571 36.571429-36.571429 36.571429h-585.142857c-21.942857 0-36.571429-14.628571-36.571429-36.571429v-585.142857c0-21.942857 14.628571-36.571429 36.571429-36.571429h585.142857c21.942857 0 36.571429 14.628571 36.571429 36.571429v585.142857zM841.142857 73.142857h-585.142857C197.485714 73.142857 146.285714 124.342857 146.285714 182.857143v585.142857c0 58.514286 51.2 109.714286 109.714286 109.714286h585.142857c58.514286 0 109.714286-51.2 109.714286-109.714286v-585.142857c0-58.514286-51.2-109.714286-109.714286-109.714286z m-146.285714 365.714286H585.142857V329.142857c0-21.942857-14.628571-36.571429-36.571428-36.571428s-36.571429 14.628571-36.571429 36.571428V438.857143H402.285714c-21.942857 0-36.571429 14.628571-36.571428 36.571428s14.628571 36.571429 36.571428 36.571429H512v109.714286c0 21.942857 14.628571 36.571429 36.571429 36.571428s36.571429-14.628571 36.571428-36.571428V512h109.714286c21.942857 0 36.571429-14.628571 36.571428-36.571429S716.8 438.857143 694.857143 438.857143z"></Path>
|
||||||
<TextBlock>展开</TextBlock>
|
<TextBlock>展开</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</controls:DropDownButton.Content>
|
</controls:DropDownButton.Content>
|
||||||
@@ -543,7 +543,40 @@
|
|||||||
<MenuItem Header="选择子树" IsCheckable="True" Command="{Binding SelectChildCommand}" />
|
<MenuItem Header="选择子树" IsCheckable="True" Command="{Binding SelectChildCommand}" />
|
||||||
</controls:DropDownButton.Items>
|
</controls:DropDownButton.Items>
|
||||||
</controls:DropDownButton>
|
</controls:DropDownButton>
|
||||||
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="3" Command="{Binding AddChildCommand}">
|
<Line Grid.Column="2" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
|
||||||
|
<StackPanel Orientation="Horizontal" Grid.Column="3" >
|
||||||
|
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="4" Command="{Binding CenterMoveCommand}">
|
||||||
|
<StackPanel>
|
||||||
|
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M256 320c35 0 64 -29 64 -64s-29 -64 -64 -64s-64 29 -64 64s29 64 64 64zM405 107v85h43v-85c0 -23 -20 -43 -43 -43h-85v43h85zM405 448c23 0 43 -20 43 -43v-85h-43v85h-85v43h85zM107 405v-85h-43v85c0 23 20 43 43 43h85v-43h-85zM107 192v-85h85v-43h-85 c-23 0 -43 20 -43 43v85h43z"></Path>
|
||||||
|
<TextBlock>居中</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="4" Command="{Binding FitAutoCommand}">
|
||||||
|
<StackPanel>
|
||||||
|
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" RenderTransformOrigin="0.5,0.5" Data="M1023.216289 841.246459v9.61262a268.243293 268.243293 0 0 1-1.9339 51.191468 145.725046 145.725046 0 0 1-48.0631 85.66039 153.233128 153.233128 0 0 1-65.126924 31.681831 126.897961 126.897961 0 0 1-40.441259 2.218297H175.769975a293.611509 293.611509 0 0 1-66.776427-3.640282 142.198522 142.198522 0 0 1-100.221518-91.348331A239.291674 239.291674 0 0 1 0.524516 846.081209V193.560629 132.472144a164.950286 164.950286 0 0 1 16.551908-56.253736A147.886463 147.886463 0 0 1 93.806746 8.930067a155.735822 155.735822 0 0 1 26.505805-6.768649L134.077368 0.739432h734.654446a108.070877 108.070877 0 0 1 34.127646 1.421986 152.607454 152.607454 0 0 1 65.980114 29.122257 146.180081 146.180081 0 0 1 51.191468 84.522802 254.819752 254.819752 0 0 1 2.787091 55.116147V841.417097zM942.618167 129.457535a65.126923 65.126923 0 0 0-22.751764-35.322113 53.011609 53.011609 0 0 0-50.395156-13.025385H138.798359l-5.687941 0.568794-13.821696 3.697162a64.956285 64.956285 0 0 0-31.169917 26.847081 120.29995 120.29995 0 0 0-8.816308 61.657279v661.735044a245.548409 245.548409 0 0 0 1.9339 57.391324 63.648059 63.648059 0 0 0 41.920124 44.934733 172.060212 172.060212 0 0 0 45.844804 2.843971h702.858857a54.149197 54.149197 0 0 0 23.661834-1.421986 73.033161 73.033161 0 0 0 29.520413-16.096872 98.515136 98.515136 0 0 0 19.623396-81.166917V174.16475a199.077931 199.077931 0 0 0-2.047658-44.707215z m-116.090874 694.781981a37.085375 37.085375 0 0 1-19.850914 20.362828h-0.511915a36.232184 36.232184 0 0 1-13.366661 2.730212H597.75831a36.516581 36.516581 0 0 1-31.681831-18.713326 38.052325 38.052325 0 0 1 0-37.369772 36.516581 36.516581 0 0 1 31.681831-18.713325h106.762651l-120.413709-123.030162a37.881686 37.881686 0 0 1-9.953897-36.345942 36.914736 36.914736 0 0 1 26.107649-26.676443 35.890907 35.890907 0 0 1 35.549631 10.181414l120.413708 123.030162v-109.151586a37.54041 37.54041 0 0 1 18.258291-32.364384 36.004666 36.004666 0 0 1 36.57346 0 37.54041 37.54041 0 0 1 18.25829 32.364384v199.419208a37.199133 37.199133 0 0 1-2.559573 13.594179zM402.775696 249.359329H296.297442l120.35683 123.087041a37.938566 37.938566 0 0 1 9.498861 36.118425 36.971616 36.971616 0 0 1-25.880131 26.448925 36.004666 36.004666 0 0 1-35.322113-9.6695L244.59406 302.2003v109.151586a37.654169 37.654169 0 0 1-18.31517 32.421263 36.004666 36.004666 0 0 1-36.57346 0 37.711048 37.711048 0 0 1-18.25829-32.421263V211.989557a36.857857 36.857857 0 0 1 2.616452-13.594178v-0.625674a36.914736 36.914736 0 0 1 19.907794-20.305949h0.568794a34.525801 34.525801 0 0 1 13.309781-2.673332h195.039494a36.459701 36.459701 0 0 1 31.681831 18.656446 38.166083 38.166083 0 0 1 0 37.426651 36.459701 36.459701 0 0 1-31.79559 18.485808z">
|
||||||
|
<Path.RenderTransform>
|
||||||
|
<ScaleTransform ScaleY="-1"/>
|
||||||
|
</Path.RenderTransform>
|
||||||
|
</Path>
|
||||||
|
<TextBlock>适应窗口大小</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="4" Command="{Binding FitWidthCommand}">
|
||||||
|
<StackPanel>
|
||||||
|
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M113.777 819.198 113.777 204.8c0-50.267 40.75-91.022 91.02-91.022l614.376 0c50.29 0 91.045 40.755 91.045 91.022l0 614.398c0 50.27-40.755 91.02-91.045 91.02L204.797 910.218C154.527 910.218 113.777 869.468 113.777 819.198zM796.438 841.953c25.125 0 45.51-20.385 45.51-45.51L841.948 227.554c0-25.122-20.385-45.51-45.505-45.51L227.552 182.044c-25.125 0-45.535 20.387-45.535 45.51l0 568.889c0 25.125 20.39 45.51 45.535 45.51L796.438 841.953zM623.043 603.269l57.115-57.14L344.357 546.129l55.5 55.505c13.31 13.335 13.335 34.93 0 48.265-13.335 13.33-34.95 13.33-48.29 0l-105.765-105.77c-3.415-1.615-6.78-3.525-9.625-6.37-7.08-7.1-10.1-16.475-9.67-25.76-0.46-9.262 2.59-18.66 9.69-25.76 2.85-2.842 6.15-4.8 9.58-6.348l105.79-105.79c13.34-13.335 34.955-13.335 48.29 0 13.31 13.332 13.335 34.927 0 48.262l-55.5 55.502 335.802 0-57.115-57.117c-13.355-13.335-13.335-34.952 0-48.287s34.93-13.335 48.265 0l115.37 115.395c13.335 13.332 13.36 34.927 0 48.262l-115.37 115.395c-13.335 13.335-34.95 13.335-48.265 0C609.708 638.198 609.708 616.583 623.043 603.269z"></Path>
|
||||||
|
<TextBlock>适应窗口宽度</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="4" Command="{Binding FitHeightCommand}">
|
||||||
|
<StackPanel>
|
||||||
|
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M819.198 910.218 204.799 910.218c-50.267 0-91.022-40.75-91.022-91.02L113.777 204.822c0-50.29 40.755-91.045 91.022-91.045l614.398 0c50.27 0 91.02 40.755 91.02 91.045l0 614.376C910.218 869.468 869.468 910.218 819.198 910.218zM841.953 227.554c0-25.122-20.385-45.51-45.51-45.51L227.554 182.044c-25.122 0-45.51 20.387-45.51 45.51l0 568.889c0 25.125 20.387 45.535 45.51 45.535l568.889 0c25.125 0 45.51-20.39 45.51-45.535L841.953 227.554zM603.268 400.952l-57.14-57.115 0 335.802 55.505-55.5c13.335-13.31 34.93-13.335 48.265 0 13.33 13.335 13.33 34.95 0 48.29l-105.77 105.765c-1.615 3.415-3.525 6.78-6.37 9.625-7.1 7.08-16.475 10.1-25.76 9.67-9.262 0.46-18.66-2.59-25.76-9.69-2.842-2.85-4.8-6.15-6.347-9.58l-105.79-105.79c-13.335-13.34-13.335-34.955 0-48.29 13.332-13.31 34.927-13.335 48.262 0l55.502 55.5L477.865 343.837l-57.117 57.115c-13.335 13.357-34.952 13.335-48.287 0s-13.335-34.93 0-48.265l115.395-115.37c13.332-13.335 34.927-13.357 48.262 0l115.395 115.37c13.335 13.335 13.335 34.952 0 48.265C638.198 414.286 616.583 414.286 603.268 400.952z"></Path>
|
||||||
|
<TextBlock>适应窗口高度</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</StackPanel>
|
||||||
|
<Line Grid.Column="4" X1="0" Y1="0" X2="0" Y2="100" StrokeDashArray="1" Stroke="Gray" StrokeThickness="1"></Line>
|
||||||
|
<Button Style="{StaticResource FlatButtonStyle}" Grid.Column="5" Command="{Binding AddChildCommand}">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M911.958045 890.721335l-241.415018-246.54112a336.369964 336.369964 0 1 0-58.095828 45.158522l247.029321 252.643623a36.859118 36.859118 0 0 0 51.749225 0 37.103218 37.103218 0 0 0 0.7323-51.261025zM176.240286 404.473897a261.431228 261.431228 0 1 1 261.431228 261.431228A261.675328 261.675328 0 0 1 176.240286 404.473897z"></Path>
|
<Path Width="18" Height="18" Stretch="Uniform" Fill="Black" Data="M911.958045 890.721335l-241.415018-246.54112a336.369964 336.369964 0 1 0-58.095828 45.158522l247.029321 252.643623a36.859118 36.859118 0 0 0 51.749225 0 37.103218 37.103218 0 0 0 0.7323-51.261025zM176.240286 404.473897a261.431228 261.431228 0 1 1 261.431228 261.431228A261.675328 261.675328 0 0 1 176.240286 404.473897z"></Path>
|
||||||
<TextBlock>搜索</TextBlock>
|
<TextBlock>搜索</TextBlock>
|
||||||
|
|||||||
@@ -589,7 +589,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes = nodes.Except(new List<MindNode>{ RootItem }).ToList();
|
nodes = nodes.Except(new List<MindNode> { RootItem }).ToList();
|
||||||
|
|
||||||
if (nodes.Any())
|
if (nodes.Any())
|
||||||
{
|
{
|
||||||
@@ -597,14 +597,14 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
DoCommandManager.DoNewCommand(this.ToString(),
|
DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
() => {
|
() => {
|
||||||
foreach (var node in nodes)
|
foreach (var node in nodes)
|
||||||
{
|
{
|
||||||
node.ParentNode.RemoveChild(node, true);
|
node.ParentNode.RemoveChild(node, true);
|
||||||
}
|
}
|
||||||
RootItem.LayoutUpdated();
|
RootItem.LayoutUpdated();
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
foreach (var node in nodes)
|
foreach (var node in nodes)
|
||||||
{
|
{
|
||||||
node.ParentNode.AddChild(node, indexs[node]);
|
node.ParentNode.AddChild(node, indexs[node]);
|
||||||
}
|
}
|
||||||
RootItem.LayoutUpdated();
|
RootItem.LayoutUpdated();
|
||||||
@@ -615,54 +615,62 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void ExecuteCenterMoveCommand(object parameter)
|
||||||
|
{
|
||||||
|
RootItem.Left = (PageSize.Width - RootItem.ItemWidth) / 2;
|
||||||
|
RootItem.Top = (PageSize.Height - RootItem.ItemHeight) / 2;
|
||||||
|
RootItem?.LayoutUpdated();
|
||||||
|
FitViewModel = new FitViewModel() { BoundingRect = RootItem.GetBounds() };
|
||||||
|
}
|
||||||
|
|
||||||
private void ExecuteAddLinkCommand(object obj)
|
private void ExecuteAddLinkCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteRemoveLinkCommand(object obj)
|
private void ExecuteRemoveLinkCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteAddImageCommand(object obj)
|
private void ExecuteAddImageCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteRemoveImageCommand(object obj)
|
private void ExecuteRemoveImageCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteAddRemarkCommand(object obj)
|
private void ExecuteAddRemarkCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteRemoveRemarkCommand(object obj)
|
private void ExecuteRemoveRemarkCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteAddPriorityCommand(object obj)
|
private void ExecuteAddPriorityCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteAddRatioCommand(object obj)
|
private void ExecuteAddRatioCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteAddTagCommand(object obj)
|
private void ExecuteAddTagCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteRemoveTagCommand(object obj)
|
private void ExecuteRemoveTagCommand(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecutedChangeMindTypeCommand(object obj)
|
private void ExecutedChangeMindTypeCommand(object obj)
|
||||||
@@ -720,7 +728,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
RootItem.LayoutUpdated();
|
RootItem.LayoutUpdated();
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
//ToDo
|
//ToDo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -729,7 +737,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
{
|
{
|
||||||
if (parameter is MindNode node)
|
if (parameter is MindNode node)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -738,43 +746,43 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
|
|
||||||
if (node != null)
|
if (node != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecutedPasteThemeCommand(object parameter)
|
private void ExecutedPasteThemeCommand(object parameter)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecutedExpand2Level1Command(object obj)
|
private void ExecutedExpand2Level1Command(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecutedExpand2Level2Command(object obj)
|
private void ExecutedExpand2Level2Command(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecutedExpand2Level3Command(object obj)
|
private void ExecutedExpand2Level3Command(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecutedExpand2Level4Command(object obj)
|
private void ExecutedExpand2Level4Command(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecutedExpand2Level5Command(object obj)
|
private void ExecutedExpand2Level5Command(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecutedExpand2Level6Command(object obj)
|
private void ExecutedExpand2Level6Command(object obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
protected override void ExecutedResetLayoutCommand(object obj)
|
protected override void ExecutedResetLayoutCommand(object obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user