mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-04 06:51:28 +08:00
分组,取消分组 ReDo UnDo 整理
This commit is contained in:
@@ -991,13 +991,13 @@
|
|||||||
<Fluent:Button Margin="5" Header="上移一层" Command="{Binding PageViewModel.DiagramViewModel.BringForwardCommand}" Size="Middle" Icon="/AIStudio.Wpf.DiagramApp;component/Images/BringForward.png"/>
|
<Fluent:Button Margin="5" Header="上移一层" Command="{Binding PageViewModel.DiagramViewModel.BringForwardCommand}" Size="Middle" Icon="/AIStudio.Wpf.DiagramApp;component/Images/BringForward.png"/>
|
||||||
<Fluent:Button Margin="5" Header="下移一层" Command="{Binding PageViewModel.DiagramViewModel.SendBackwardCommand}" Size="Middle" Icon="/AIStudio.Wpf.DiagramApp;component/Images/SendBackward.png"/>
|
<Fluent:Button Margin="5" Header="下移一层" Command="{Binding PageViewModel.DiagramViewModel.SendBackwardCommand}" Size="Middle" Icon="/AIStudio.Wpf.DiagramApp;component/Images/SendBackward.png"/>
|
||||||
</Fluent:DropDownButton>
|
</Fluent:DropDownButton>
|
||||||
<Fluent:DropDownButton Header="组合" Icon="{iconPacks:Material Kind=Group}" Width="50" VerticalAlignment="Top">
|
<Fluent:SplitButton Header="组合" Icon="{iconPacks:Material Kind=Group}" Width="50" VerticalAlignment="Top" Command="{Binding PageViewModel.DiagramViewModel.GroupCommand}">
|
||||||
<Fluent:DropDownButton.LargeIcon>
|
<Fluent:SplitButton.LargeIcon>
|
||||||
<iconPacks:PackIconMaterial Kind="Group" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<iconPacks:PackIconMaterial Kind="Group" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
</Fluent:DropDownButton.LargeIcon>
|
</Fluent:SplitButton.LargeIcon>
|
||||||
<Fluent:Button Margin="5" Header="组合" Command="{Binding PageViewModel.DiagramViewModel.GroupCommand}" Size="Middle" Icon="/AIStudio.Wpf.DiagramApp;component/Images/BringForward.png"/>
|
<Fluent:Button Margin="5" Header="组合" Command="{Binding PageViewModel.DiagramViewModel.GroupCommand}" Size="Middle" Icon="/AIStudio.Wpf.DiagramApp;component/Images/BringForward.png"/>
|
||||||
<Fluent:Button Margin="5" Header="取消组合" Command="{Binding PageViewModel.DiagramViewModel.UngroupCommand}" Size="Middle" Icon="/AIStudio.Wpf.DiagramApp;component/Images/SendBackward.png"/>
|
<Fluent:Button Margin="5" Header="取消组合" Command="{Binding PageViewModel.DiagramViewModel.UngroupCommand}" Size="Middle" Icon="/AIStudio.Wpf.DiagramApp;component/Images/SendBackward.png"/>
|
||||||
</Fluent:DropDownButton>
|
</Fluent:SplitButton>
|
||||||
<Fluent:DropDownButton Header="对齐" Icon="{iconPacks:Material Kind=AlignHorizontalLeft}" Width="50" VerticalAlignment="Top">
|
<Fluent:DropDownButton Header="对齐" Icon="{iconPacks:Material Kind=AlignHorizontalLeft}" Width="50" VerticalAlignment="Top">
|
||||||
<Fluent:DropDownButton.LargeIcon>
|
<Fluent:DropDownButton.LargeIcon>
|
||||||
<iconPacks:PackIconMaterial Kind="AlignHorizontalLeft" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<iconPacks:PackIconMaterial Kind="AlignHorizontalLeft" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
|||||||
@@ -540,7 +540,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
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.ClearSelectedItems();
|
||||||
Point position = e.GetPosition(this);
|
Point position = e.GetPosition(this);
|
||||||
if (dragObject.DesignerItem is SerializableObject serializableObject)
|
if (dragObject.DesignerItem is SerializableObject serializableObject)
|
||||||
{
|
{
|
||||||
@@ -587,7 +587,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
_viewModel.ClearSelectedItemsCommand.Execute(null);
|
_viewModel.ClearSelectedItems();
|
||||||
Point position = e.GetPosition(this);
|
Point position = e.GetPosition(this);
|
||||||
ImageItemViewModel itemBase = new ImageItemViewModel();
|
ImageItemViewModel itemBase = new ImageItemViewModel();
|
||||||
itemBase.Icon = file;
|
itemBase.Icon = file;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
@@ -59,7 +60,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
|
|
||||||
designerItems = designerItems.Distinct().ToList();
|
designerItems = designerItems.Distinct().ToList();
|
||||||
|
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = true;
|
Interlocked.Increment(ref DiagramViewModel.DoCommandManager.BeginDo);
|
||||||
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
||||||
{
|
{
|
||||||
item.SetOldValue(item.TopLeft, nameof(item.TopLeft));
|
item.SetOldValue(item.TopLeft, nameof(item.TopLeft));
|
||||||
@@ -76,8 +77,8 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
private void DragThumb_DragCompleted(object sender, DragCompletedEventArgs e)
|
private void DragThumb_DragCompleted(object sender, DragCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
if (drag == false)
|
if (drag == false)
|
||||||
{
|
{
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = false;
|
Interlocked.Decrement(ref DiagramViewModel.DoCommandManager.BeginDo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
Dictionary<DesignerItemViewModelBase, Tuple<PointBase, PointBase>> infos =
|
Dictionary<DesignerItemViewModelBase, Tuple<PointBase, PointBase>> infos =
|
||||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||||
p => new Tuple<PointBase, PointBase>(p.GetOldValue<PointBase>(nameof(p.TopLeft)), p.TopLeft));
|
p => new Tuple<PointBase, PointBase>(p.GetOldValue<PointBase>(nameof(p.TopLeft)), p.TopLeft));
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = false;
|
Interlocked.Decrement(ref DiagramViewModel.DoCommandManager.BeginDo);
|
||||||
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
() => {
|
() => {
|
||||||
foreach (var info in infos)
|
foreach (var info in infos)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
@@ -35,7 +36,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
{
|
{
|
||||||
designerItems = designerItem.Root.SelectedItems.ToList();
|
designerItems = designerItem.Root.SelectedItems.ToList();
|
||||||
|
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = true;
|
Interlocked.Increment(ref DiagramViewModel.DoCommandManager.BeginDo);
|
||||||
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
||||||
{
|
{
|
||||||
item.SetOldValue(item.Size, nameof(item.Size));
|
item.SetOldValue(item.Size, nameof(item.Size));
|
||||||
@@ -57,7 +58,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||||
p => new Tuple<SizeBase, SizeBase>(p.GetOldValue<SizeBase>(nameof(p.Size)), p.Size));
|
p => new Tuple<SizeBase, SizeBase>(p.GetOldValue<SizeBase>(nameof(p.Size)), p.Size));
|
||||||
|
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = false;
|
Interlocked.Decrement(ref DiagramViewModel.DoCommandManager.BeginDo);
|
||||||
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
() => {
|
() => {
|
||||||
foreach (var info in infos)
|
foreach (var info in infos)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
@@ -42,7 +43,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
{
|
{
|
||||||
designerItems = designerItem.Root.SelectedItems.ToList();
|
designerItems = designerItem.Root.SelectedItems.ToList();
|
||||||
|
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = true;
|
Interlocked.Increment(ref DiagramViewModel.DoCommandManager.BeginDo);
|
||||||
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
foreach (DesignerItemViewModelBase item in designerItems.OfType<DesignerItemViewModelBase>())
|
||||||
{
|
{
|
||||||
item.SetOldValue(this.designerItem.Angle, nameof(this.designerItem.Angle));
|
item.SetOldValue(this.designerItem.Angle, nameof(this.designerItem.Angle));
|
||||||
@@ -78,7 +79,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
|||||||
Dictionary<DesignerItemViewModelBase, Tuple<double, double>> infos =
|
Dictionary<DesignerItemViewModelBase, Tuple<double, double>> infos =
|
||||||
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
designerItems.OfType<DesignerItemViewModelBase>().ToDictionary(p => p,
|
||||||
p => new Tuple<double, double>(p.GetOldValue<double>(nameof(p.Angle)), p.Angle));
|
p => new Tuple<double, double>(p.GetOldValue<double>(nameof(p.Angle)), p.Angle));
|
||||||
DiagramViewModel.DoCommandManager.BeginDo = false;
|
Interlocked.Decrement(ref DiagramViewModel.DoCommandManager.BeginDo);
|
||||||
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
DiagramViewModel.DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
() => {
|
() => {
|
||||||
foreach (var info in infos)
|
foreach (var info in infos)
|
||||||
|
|||||||
@@ -66,23 +66,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
UnDoActionStack = new Stack<Command>();
|
UnDoActionStack = new Stack<Command>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _beginDo;
|
public int BeginDo;
|
||||||
public bool BeginDo
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _beginDo;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_beginDo = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _undoing;
|
private bool _undoing;
|
||||||
public void DoNewCommand(string name, Action action, Action unDoAction, Action clearAction = null, bool doit = true)
|
public void DoNewCommand(string name, Action action, Action unDoAction, Action clearAction = null, bool doit = true)
|
||||||
{
|
{
|
||||||
if (BeginDo == true)
|
if (BeginDo > 0)
|
||||||
return;
|
return;
|
||||||
if (_undoing == true)
|
if (_undoing == true)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid IsHitTestVisible="{Binding IsHitTestVisible}">
|
<Grid IsHitTestVisible="{Binding IsHitTestVisible}">
|
||||||
<TextBox x:Name="PART_TextBlock"
|
<TextBox x:Name="PART_TextBlock"
|
||||||
Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
|
||||||
Foreground="{Binding FontViewModel.FontColor,Converter={StaticResource ColorBrushConverter}}"
|
Foreground="{Binding FontViewModel.FontColor,Converter={StaticResource ColorBrushConverter}}"
|
||||||
FontSize="{Binding FontViewModel.FontSize}"
|
FontSize="{Binding FontViewModel.FontSize}"
|
||||||
FontFamily="{Binding FontViewModel.FontFamily}"
|
FontFamily="{Binding FontViewModel.FontFamily}"
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
</TextBox>
|
</TextBox>
|
||||||
<TextBox x:Name="PART_ShowText"
|
<TextBox x:Name="PART_ShowText"
|
||||||
Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
|
||||||
Foreground="{Binding FontViewModel.FontColor,Converter={StaticResource ColorBrushConverter}}"
|
Foreground="{Binding FontViewModel.FontColor,Converter={StaticResource ColorBrushConverter}}"
|
||||||
IsReadOnly="{Binding IsReadOnlyText}"
|
IsReadOnly="{Binding IsReadOnlyText}"
|
||||||
FontSize="{Binding FontViewModel.FontSize}"
|
FontSize="{Binding FontViewModel.FontSize}"
|
||||||
|
|||||||
@@ -75,8 +75,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
else if (selectable.IsSelected == false)
|
else if (selectable.IsSelected == false)
|
||||||
{
|
{
|
||||||
|
BindingExpression binding = PART_ShowText.GetBindingExpression(TextBox.TextProperty);
|
||||||
|
binding.UpdateSource();
|
||||||
|
|
||||||
PART_ShowText.Visibility = Visibility.Collapsed;
|
PART_ShowText.Visibility = Visibility.Collapsed;
|
||||||
PART_TextBlock.Visibility = Visibility.Visible;
|
PART_TextBlock.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
selectable.IsEditing = false;
|
selectable.IsEditing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DeleteLabel();
|
ClearLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -825,6 +825,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
UpdatePathGeneratorResult();
|
UpdatePathGeneratorResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RemoveVertex(ConnectorVertexModel vertice)
|
||||||
|
{
|
||||||
|
Vertices.Remove(vertice);
|
||||||
|
UpdatePathGeneratorResult();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void ExecuteEditCommand(object param)
|
protected override void ExecuteEditCommand(object param)
|
||||||
{
|
{
|
||||||
AddLabel();
|
AddLabel();
|
||||||
@@ -841,7 +847,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
label.UpdatePosition(paths);
|
label.UpdatePosition(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteLabel()
|
public void RemoveLabel(ConnectorLabelModel label)
|
||||||
|
{
|
||||||
|
Labels.Remove(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearLabel()
|
||||||
{
|
{
|
||||||
Labels?.Clear();
|
Labels?.Clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,14 +182,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
protected override void ClearText()
|
protected override void ClearText()
|
||||||
{
|
{
|
||||||
Connector.Labels.Remove(this);
|
Connector.RemoveLabel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteLabel(object parameter)
|
private void DeleteLabel(object parameter)
|
||||||
{
|
{
|
||||||
if (parameter is ConnectorLabelModel label)
|
if (parameter is ConnectorLabelModel label)
|
||||||
{
|
{
|
||||||
Connector.Labels.Remove(label);
|
Connector.RemoveLabel(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
if (parameter is ConnectorVertexModel vertice)
|
if (parameter is ConnectorVertexModel vertice)
|
||||||
{
|
{
|
||||||
Connector.Vertices.Remove(vertice);
|
Connector.RemoveVertex(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,11 +92,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
get; set;
|
get; set;
|
||||||
} = e => e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down;
|
} = e => e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down;
|
||||||
|
|
||||||
[Description("Group Keyboard shortcut (CTRL+Shift+G by default)")]
|
[Description("Group Keyboard shortcut (CTRL+G by default)")]
|
||||||
public Func<KeyEventArgs, bool> Group
|
public Func<KeyEventArgs, bool> Group
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
} = e => e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.G;
|
} = e => e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.G;
|
||||||
|
|
||||||
|
[Description("Ungroup Keyboard shortcut (Shift+G by default)")]
|
||||||
|
public Func<KeyEventArgs, bool> Ungroup
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
} = e => e.KeyboardDevice.Modifiers == ModifierKeys.Shift | e.Key == Key.G;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.ComponentModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||||
@@ -1195,7 +1196,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
if (attr != null && attr.Length != 0)
|
if (attr != null && attr.Length != 0)
|
||||||
{
|
{
|
||||||
//加入ReDo
|
//加入ReDo
|
||||||
DoCommandManager.DoNewCommand(sender.ToString() + e.PropertyName, () => Do(sender, e.PropertyName, valuePropertyChangedEventArgs.NewValue), () => UnDo(sender, e.PropertyName, valuePropertyChangedEventArgs.OldValue), null, false);
|
DoCommandManager.DoNewCommand(sender.ToString() + e.PropertyName,
|
||||||
|
() => {
|
||||||
|
Do(sender, e.PropertyName, valuePropertyChangedEventArgs.NewValue);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
UnDo(sender, e.PropertyName, valuePropertyChangedEventArgs.OldValue);
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
false);
|
||||||
|
|
||||||
Event?.Invoke(sender, new DiagramEventArgs(valuePropertyChangedEventArgs.PropertyName, valuePropertyChangedEventArgs.NewValue, valuePropertyChangedEventArgs.OldValue, selectable?.Id));
|
Event?.Invoke(sender, new DiagramEventArgs(valuePropertyChangedEventArgs.PropertyName, valuePropertyChangedEventArgs.NewValue, valuePropertyChangedEventArgs.OldValue, selectable?.Id));
|
||||||
}
|
}
|
||||||
@@ -2480,7 +2489,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
var oldcenter = BoundingRect.Center;
|
var oldcenter = BoundingRect.Center;
|
||||||
foreach (var item in selectedItems.OfType<DesignerItemViewModelBase>())
|
foreach (var item in selectedItems.OfType<DesignerItemViewModelBase>())
|
||||||
{
|
{
|
||||||
item.Left = item.Left - oldcenter.X + PageSize.Width / 2;
|
item.Left = item.Left - oldcenter.X + PageSize.Width / 2;
|
||||||
item.Top = item.Top - oldcenter.Y + PageSize.Height / 2;
|
item.Top = item.Top - oldcenter.Y + PageSize.Height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2541,7 +2550,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
foreach (var item in infos)
|
foreach (var item in infos)
|
||||||
{
|
{
|
||||||
item.Key.Size = item.Value;
|
item.Key.Size = item.Value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2695,15 +2704,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
items = SelectedItems?.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == Guid.Empty).ToList();
|
items = SelectedItems?.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == Guid.Empty).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
var groups = items.OfType<DesignerItemViewModelBase>().Where(p => p.IsGroup && p.ParentId == Guid.Empty).ToList();
|
|
||||||
|
|
||||||
//解除分组
|
|
||||||
if (groupItem == null && groups.Count > 0)
|
|
||||||
{
|
|
||||||
ExecuteUngroupCommand(groups);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RectangleBase rect = DiagramViewModelHelper.GetBoundingRectangle(items);
|
RectangleBase rect = DiagramViewModelHelper.GetBoundingRectangle(items);
|
||||||
|
|
||||||
if (groupItem == null)
|
if (groupItem == null)
|
||||||
@@ -2711,16 +2711,24 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
groupItem = new GroupDesignerItemViewModel();
|
groupItem = new GroupDesignerItemViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
Add(groupItem, true);
|
DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
|
() => {
|
||||||
|
Add(groupItem);
|
||||||
|
foreach (DesignerItemViewModelBase item in items)
|
||||||
|
item.ParentId = groupItem.Id;
|
||||||
|
groupItem.Resize();
|
||||||
|
ClearSelectedItems();
|
||||||
|
SelectionService.AddToSelection(groupItem);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
Remove(groupItem);
|
||||||
|
foreach (DesignerItemViewModelBase item in items)
|
||||||
|
{
|
||||||
|
item.IsSelected = true;
|
||||||
|
item.ParentId = Guid.Empty;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
foreach (DesignerItemViewModelBase item in items)
|
|
||||||
item.ParentId = groupItem.Id;
|
|
||||||
|
|
||||||
groupItem.Resize();
|
|
||||||
|
|
||||||
ClearSelectedItemsCommand.Execute(null);
|
|
||||||
//groupItem.IsSelected = true;
|
|
||||||
SelectionService.AddToSelection(groupItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteUngroupCommand(object parameter)
|
private void ExecuteUngroupCommand(object parameter)
|
||||||
@@ -2728,22 +2736,45 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
List<DesignerItemViewModelBase> groups;
|
List<DesignerItemViewModelBase> groups;
|
||||||
if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
if (parameter is IEnumerable<DesignerItemViewModelBase> para)
|
||||||
{
|
{
|
||||||
groups = para.ToList();
|
groups = para.Where(p => p.IsGroup && p.ParentId == Guid.Empty).ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
groups = SelectedItems?.OfType<DesignerItemViewModelBase>().Where(p => p.IsGroup && p.ParentId == Guid.Empty).ToList();
|
groups = SelectedItems?.OfType<DesignerItemViewModelBase>().Where(p => p.IsGroup && p.ParentId == Guid.Empty).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dictionary<DesignerItemViewModelBase, Tuple<Guid, int>> items = new Dictionary<DesignerItemViewModelBase, Tuple<Guid, int>>();
|
||||||
foreach (DesignerItemViewModelBase groupRoot in groups)
|
foreach (DesignerItemViewModelBase groupRoot in groups)
|
||||||
{
|
{
|
||||||
var children = SelectedItems.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == groupRoot.Id);
|
var children = SelectedItems.OfType<DesignerItemViewModelBase>().Where(p => p.ParentId == groupRoot.Id);
|
||||||
foreach (DesignerItemViewModelBase child in children)
|
foreach (DesignerItemViewModelBase child in children)
|
||||||
child.ParentId = Guid.Empty;
|
items.Add(child, new Tuple<Guid, int>(child.ParentId, child.ZIndex));
|
||||||
|
|
||||||
RemoveItemCommand.Execute(groupRoot);
|
|
||||||
UpdateZIndex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DoCommandManager.DoNewCommand(this.ToString(),
|
||||||
|
() => {
|
||||||
|
foreach (DesignerItemViewModelBase groupRoot in groups)
|
||||||
|
{
|
||||||
|
Remove(groupRoot);
|
||||||
|
}
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
item.Key.ParentId = Guid.Empty;
|
||||||
|
}
|
||||||
|
UpdateZIndex();
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
foreach (DesignerItemViewModelBase groupRoot in groups)
|
||||||
|
{
|
||||||
|
Add(groupRoot);
|
||||||
|
}
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
item.Key.ParentId = item.Value.Item1;
|
||||||
|
item.Key.ZIndex = item.Value.Item2;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool BelongToSameGroup(IGroupable item1, IGroupable item2)
|
private bool BelongToSameGroup(IGroupable item1, IGroupable item2)
|
||||||
@@ -2817,6 +2848,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
GroupCommand.Execute(null);
|
GroupCommand.Execute(null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (DiagramOption.ShortcutOption.Ungroup(e))
|
||||||
|
{
|
||||||
|
UngroupCommand.Execute(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
private bool _isSelected;
|
private bool _isSelected;
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
[CanDo]
|
//[CanDo]
|
||||||
public bool IsSelected
|
public bool IsSelected
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Linq;
|
|||||||
using System.Security.Policy;
|
using System.Security.Policy;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using AIStudio.Wpf.DiagramDesigner;
|
using AIStudio.Wpf.DiagramDesigner;
|
||||||
@@ -239,6 +240,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool _isExpanded = true;
|
private bool _isExpanded = true;
|
||||||
|
[CanDo]
|
||||||
public bool IsExpanded
|
public bool IsExpanded
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -322,6 +324,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
|
|
||||||
#region 附加信息属性
|
#region 附加信息属性
|
||||||
private LinkInfo _linkInfo;
|
private LinkInfo _linkInfo;
|
||||||
|
[CanDo]
|
||||||
public LinkInfo LinkInfo
|
public LinkInfo LinkInfo
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -335,6 +338,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ImageInfo _imageInfo;
|
private ImageInfo _imageInfo;
|
||||||
|
[CanDo]
|
||||||
public ImageInfo ImageInfo
|
public ImageInfo ImageInfo
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -348,6 +352,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string _remark;
|
private string _remark;
|
||||||
|
[CanDo]
|
||||||
[Browsable(true)]
|
[Browsable(true)]
|
||||||
public string Remark
|
public string Remark
|
||||||
{
|
{
|
||||||
@@ -362,6 +367,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double? _priority;
|
private double? _priority;
|
||||||
|
[CanDo]
|
||||||
public double? Priority
|
public double? Priority
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -375,6 +381,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double? _rate;
|
private double? _rate;
|
||||||
|
[CanDo]
|
||||||
public double? Rate
|
public double? Rate
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -388,6 +395,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ObservableCollection<string> _tags;
|
private ObservableCollection<string> _tags;
|
||||||
|
[CanDo]
|
||||||
public ObservableCollection<string> Tags
|
public ObservableCollection<string> Tags
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -568,6 +576,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
{
|
{
|
||||||
if (GetLevel0Node()?.LayoutUpdating == true) return;
|
if (GetLevel0Node()?.LayoutUpdating == true) return;
|
||||||
|
|
||||||
|
Interlocked.Increment(ref Root.DoCommandManager.BeginDo);
|
||||||
switch (e.PropertyName)
|
switch (e.PropertyName)
|
||||||
{
|
{
|
||||||
case nameof(Left):
|
case nameof(Left):
|
||||||
@@ -591,6 +600,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
case nameof(ItemWidth):
|
case nameof(ItemWidth):
|
||||||
case nameof(ItemHeight):
|
case nameof(ItemHeight):
|
||||||
{
|
{
|
||||||
|
|
||||||
UpdatedLayout();
|
UpdatedLayout();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -608,6 +618,7 @@ namespace AIStudio.Wpf.Mind.ViewModels
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Interlocked.Decrement(ref Root.DoCommandManager.BeginDo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void FontViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
protected override void FontViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user