mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-12 04:06:36 +08:00
快捷键支持
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
xmlns:ac="https://gitee.com/akwkevin/AI-wpf-controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<ac:OptionsPanel HeaderText="{Binding Title}" HorizontalAlignment="Right" VerticalAlignment="Top" BorderBrush="#b8daff" BorderThickness="1" Background="#cce5ff" ac:ControlAttach.CornerRadius="3">
|
||||
<ac:OptionsPanel HeaderText="{Binding Title}" HorizontalAlignment="Right" VerticalAlignment="Bottom" BorderBrush="#b8daff" BorderThickness="1" Background="#cce5ff" ac:ControlAttach.CornerRadius="3">
|
||||
<TextBlock MaxWidth="350" Grid.Row="1" Text="{Binding Info}" Margin="10" TextWrapping="WrapWithOverflow" Foreground="#004085" />
|
||||
</ac:OptionsPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -81,8 +81,9 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo
|
||||
new MenuItemViewModel(){Title = "Groups",
|
||||
Children=new List<MenuItemViewModel>
|
||||
{
|
||||
new MenuItemViewModel(){Title = "Grouping"},
|
||||
new MenuItemViewModel(){Title = "Group"},
|
||||
new MenuItemViewModel(){Title = "CustomDefinedGroup"},
|
||||
new MenuItemViewModel(){Title = "CustomShortcutGroup"},
|
||||
}
|
||||
},
|
||||
new MenuItemViewModel(){Title = "Customization",
|
||||
@@ -106,7 +107,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo
|
||||
new MenuItemViewModel(){Title = "PathAnimation"},
|
||||
new MenuItemViewModel(){Title = "LineAnimation"},
|
||||
}
|
||||
},
|
||||
},
|
||||
new MenuItemViewModel(){Title = "Editor",
|
||||
Children=new List<MenuItemViewModel>
|
||||
{
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
{
|
||||
class CustomShortcutGroupViewModel : BaseViewModel
|
||||
{
|
||||
public CustomShortcutGroupViewModel()
|
||||
{
|
||||
Title = "Custom Shortcut";
|
||||
Info = "You can customize what needs to be pressed to group selected nodes. CTRL+SHIFT+K in this example.";
|
||||
|
||||
DiagramViewModel = new DiagramViewModel();
|
||||
DiagramViewModel.PageSizeType = PageSizeType.Custom;
|
||||
DiagramViewModel.PageSize = new Size(double.NaN, double.NaN);
|
||||
DiagramViewModel.ColorViewModel = new ColorViewModel();
|
||||
DiagramViewModel.ColorViewModel.FillColor.Color = System.Windows.Media.Colors.Orange;
|
||||
DiagramViewModel.DiagramOption.ShortcutOption.Group = e => e.KeyboardDevice.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift) && e.Key == Key.K;
|
||||
|
||||
DefaultDesignerItemViewModel node1 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 50, Top = 50, Text = "1" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node1);
|
||||
|
||||
DefaultDesignerItemViewModel node2 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 300, Top = 300, Text = "2" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node2);
|
||||
|
||||
DefaultDesignerItemViewModel node3 = new DefaultDesignerItemViewModel(DiagramViewModel) { Left = 300, Top = 50, Text = "3" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(node3);
|
||||
|
||||
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.RightConnector, node2.LeftConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
ConnectionViewModel connector2 = new ConnectionViewModel(DiagramViewModel, node2.RightConnector, node3.RightConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
DiagramViewModel.GroupCommand.Execute(new List<DesignerItemViewModelBase> { node1, node2 });
|
||||
|
||||
DiagramViewModel.ClearSelectedItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ using System.Windows;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
||||
{
|
||||
class GroupingViewModel : BaseViewModel
|
||||
class GroupViewModel : BaseViewModel
|
||||
{
|
||||
public GroupingViewModel()
|
||||
public GroupViewModel()
|
||||
{
|
||||
Title = "Grouping";
|
||||
Info = "You can (un)group nodes using CTRL+ALT+G.<br>" +
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.CustomShortcutGroupView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dd="https://gitee.com/akwkevin/aistudio.-wpf.-diagram"
|
||||
xmlns:controls="clr-namespace:AIStudio.Wpf.DiagramDesigner.Demo.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<!-- Diagram Control -->
|
||||
<dd:DiagramControl x:Name="diagram" DataContext="{Binding DiagramViewModel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
|
||||
<controls:TitleControl/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner.Demo.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// CustomShortcutGroupView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CustomShortcutGroupView : UserControl
|
||||
{
|
||||
public CustomShortcutGroupView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.GroupingView"
|
||||
<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.Demo.Views.GroupView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
@@ -16,9 +16,9 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.Views
|
||||
/// <summary>
|
||||
/// GroupingView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class GroupingView : UserControl
|
||||
public partial class GroupView : UserControl
|
||||
{
|
||||
public GroupingView()
|
||||
public GroupView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
Reference in New Issue
Block a user