diff --git a/AIStudio.Wpf.ADiagram/AIStudio.Wpf.ADiagram.csproj b/AIStudio.Wpf.ADiagram/AIStudio.Wpf.ADiagram.csproj index 93b0d93..4b1bde2 100644 --- a/AIStudio.Wpf.ADiagram/AIStudio.Wpf.ADiagram.csproj +++ b/AIStudio.Wpf.ADiagram/AIStudio.Wpf.ADiagram.csproj @@ -13,16 +13,6 @@ - - - - - - - - - - @@ -115,8 +105,6 @@ - - @@ -128,13 +116,13 @@ - - - + + + @@ -239,32 +227,6 @@ - - $(DefaultXamlRuntime) - - - $(DefaultXamlRuntime) - Designer - - - $(DefaultXamlRuntime) - Designer - - - $(DefaultXamlRuntime) - Designer - - - $(DefaultXamlRuntime) - Designer - - - $(DefaultXamlRuntime) - Designer - - - $(DefaultXamlRuntime) - $(DefaultXamlRuntime) diff --git a/AIStudio.Wpf.ADiagram/App.xaml b/AIStudio.Wpf.ADiagram/App.xaml index f237e9f..967845d 100644 --- a/AIStudio.Wpf.ADiagram/App.xaml +++ b/AIStudio.Wpf.ADiagram/App.xaml @@ -9,6 +9,8 @@ + + diff --git a/AIStudio.Wpf.ADiagram/AssemblyInfo.cs b/AIStudio.Wpf.ADiagram/AssemblyInfo.cs deleted file mode 100644 index 8b5504e..0000000 --- a/AIStudio.Wpf.ADiagram/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Windows; - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/AIStudio.Wpf.ADiagram/Controls/CancelRoutedEventArgs.cs b/AIStudio.Wpf.ADiagram/Controls/CancelRoutedEventArgs.cs deleted file mode 100644 index 43fe5be..0000000 --- a/AIStudio.Wpf.ADiagram/Controls/CancelRoutedEventArgs.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; - -namespace AIStudio.Wpf.ADiagram.Controls -{ - public class CancelRoutedEventArgs : RoutedEventArgs - { - public CancelRoutedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source) - { - } - - public bool Cancel { get; set; } - } -} diff --git a/AIStudio.Wpf.ADiagram/Controls/ContextMenuToggleButton.cs b/AIStudio.Wpf.ADiagram/Controls/ContextMenuToggleButton.cs deleted file mode 100644 index 608c174..0000000 --- a/AIStudio.Wpf.ADiagram/Controls/ContextMenuToggleButton.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; - -namespace AIStudio.Wpf.ADiagram.Controls -{ - /// - /// 带上下文菜单的切换按钮 - /// - public class ContextMenuToggleButton : ToggleButton - { - public ContextMenu Menu { get; set; } - - protected override void OnClick() - { - base.OnClick(); - if (Menu != null) - { - if (IsChecked == true) - { - Menu.PlacementTarget = this; - Menu.IsOpen = true; - } - else - { - Menu.IsOpen = false; - } - } - } - } -} diff --git a/AIStudio.Wpf.ADiagram/Controls/ScrollViewer.xaml b/AIStudio.Wpf.ADiagram/Controls/ScrollViewer.xaml deleted file mode 100644 index 85e0556..0000000 --- a/AIStudio.Wpf.ADiagram/Controls/ScrollViewer.xaml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/AIStudio.Wpf.ADiagram/Controls/ScrollViewer.xaml.cs b/AIStudio.Wpf.ADiagram/Controls/ScrollViewer.xaml.cs deleted file mode 100644 index c0bc7b9..0000000 --- a/AIStudio.Wpf.ADiagram/Controls/ScrollViewer.xaml.cs +++ /dev/null @@ -1,237 +0,0 @@ -using System; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; - -namespace AIStudio.Wpf.ADiagram.Controls -{ - public class ScrollViewer : System.Windows.Controls.ScrollViewer - { - private double _totalVerticalOffset; - - private double _totalHorizontalOffset; - - private bool _isRunning; - - /// - /// 滚动方向 - /// - public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register( - "Orientation", typeof(Orientation), typeof(ScrollViewer), new PropertyMetadata(Orientation.Vertical)); - - /// - /// 滚动方向 - /// - public Orientation Orientation - { - get => (Orientation)GetValue(OrientationProperty); - set => SetValue(OrientationProperty, value); - } - - /// - /// 是否响应鼠标滚轮操作 - /// - public static readonly DependencyProperty CanMouseWheelProperty = DependencyProperty.Register( - "CanMouseWheel", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(true)); - - /// - /// 是否响应鼠标滚轮操作 - /// - public bool CanMouseWheel - { - get => (bool)GetValue(CanMouseWheelProperty); - set => SetValue(CanMouseWheelProperty, value); - } - - protected override void OnMouseWheel(MouseWheelEventArgs e) - { - if (!CanMouseWheel) return; - - if (!IsInertiaEnabled) - { - if (Orientation == Orientation.Vertical) - { - base.OnMouseWheel(e); - } - else - { - _totalHorizontalOffset = HorizontalOffset; - CurrentHorizontalOffset = HorizontalOffset; - _totalHorizontalOffset = Math.Min(Math.Max(0, _totalHorizontalOffset - e.Delta), ScrollableWidth); - CurrentHorizontalOffset = _totalHorizontalOffset; - } - return; - } - e.Handled = true; - - if (Orientation == Orientation.Vertical) - { - if (!_isRunning) - { - _totalVerticalOffset = VerticalOffset; - CurrentVerticalOffset = VerticalOffset; - } - _totalVerticalOffset = Math.Min(Math.Max(0, _totalVerticalOffset - e.Delta), ScrollableHeight); - ScrollToVerticalOffsetInternal(_totalVerticalOffset); - } - else - { - if (!_isRunning) - { - _totalHorizontalOffset = HorizontalOffset; - CurrentHorizontalOffset = HorizontalOffset; - } - _totalHorizontalOffset = Math.Min(Math.Max(0, _totalHorizontalOffset - e.Delta), ScrollableWidth); - ScrollToHorizontalOffsetInternal(_totalHorizontalOffset); - } - } - - internal void ScrollToTopInternal(double milliseconds = 500) - { - if (!_isRunning) - { - _totalVerticalOffset = VerticalOffset; - CurrentVerticalOffset = VerticalOffset; - } - ScrollToVerticalOffsetInternal(0, milliseconds); - } - - internal void ScrollToVerticalOffsetInternal(double offset, double milliseconds = 500) - { - var animation = AnimationHelper.CreateAnimation(offset, milliseconds); - animation.EasingFunction = new CubicEase - { - EasingMode = EasingMode.EaseOut - }; - animation.FillBehavior = FillBehavior.Stop; - animation.Completed += (s, e1) => - { - CurrentVerticalOffset = offset; - _isRunning = false; - }; - _isRunning = true; - - BeginAnimation(CurrentVerticalOffsetProperty, animation, HandoffBehavior.Compose); - } - - internal void ScrollToHorizontalOffsetInternal(double offset, double milliseconds = 500) - { - var animation = AnimationHelper.CreateAnimation(offset, milliseconds); - animation.EasingFunction = new CubicEase - { - EasingMode = EasingMode.EaseOut - }; - animation.FillBehavior = FillBehavior.Stop; - animation.Completed += (s, e1) => - { - CurrentHorizontalOffset = offset; - _isRunning = false; - }; - _isRunning = true; - - BeginAnimation(CurrentHorizontalOffsetProperty, animation, HandoffBehavior.Compose); - } - - protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters) => - IsPenetrating ? null : base.HitTestCore(hitTestParameters); - - /// - /// 是否支持惯性 - /// - public static readonly DependencyProperty IsInertiaEnabledProperty = DependencyProperty.RegisterAttached( - "IsInertiaEnabled", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(false)); - - public static void SetIsInertiaEnabled(DependencyObject element, bool value) - { - element.SetValue(IsInertiaEnabledProperty, value); - } - - public static bool GetIsInertiaEnabled(DependencyObject element) - { - return (bool)element.GetValue(IsInertiaEnabledProperty); - } - - /// - /// 是否支持惯性 - /// - public bool IsInertiaEnabled - { - get => (bool)GetValue(IsInertiaEnabledProperty); - set => SetValue(IsInertiaEnabledProperty, value); - } - - /// - /// 控件是否可以穿透点击 - /// - public static readonly DependencyProperty IsPenetratingProperty = DependencyProperty.RegisterAttached( - "IsPenetrating", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(false)); - - /// - /// 控件是否可以穿透点击 - /// - public bool IsPenetrating - { - get => (bool)GetValue(IsPenetratingProperty); - set => SetValue(IsPenetratingProperty, value); - } - - public static void SetIsPenetrating(DependencyObject element, bool value) - { - element.SetValue(IsPenetratingProperty, value); - } - - public static bool GetIsPenetrating(DependencyObject element) - { - return (bool)element.GetValue(IsPenetratingProperty); - } - - /// - /// 当前垂直滚动偏移 - /// - internal static readonly DependencyProperty CurrentVerticalOffsetProperty = DependencyProperty.Register( - "CurrentVerticalOffset", typeof(double), typeof(ScrollViewer), new PropertyMetadata(0d, OnCurrentVerticalOffsetChanged)); - - private static void OnCurrentVerticalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if (d is ScrollViewer ctl && e.NewValue is double v) - { - ctl.ScrollToVerticalOffset(v); - } - } - - /// - /// 当前垂直滚动偏移 - /// - internal double CurrentVerticalOffset - { - // ReSharper disable once UnusedMember.Local - get => (double)GetValue(CurrentVerticalOffsetProperty); - set => SetValue(CurrentVerticalOffsetProperty, value); - } - - /// - /// 当前水平滚动偏移 - /// - internal static readonly DependencyProperty CurrentHorizontalOffsetProperty = DependencyProperty.Register( - "CurrentHorizontalOffset", typeof(double), typeof(ScrollViewer), new PropertyMetadata(0d, OnCurrentHorizontalOffsetChanged)); - - private static void OnCurrentHorizontalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if (d is ScrollViewer ctl && e.NewValue is double v) - { - ctl.ScrollToHorizontalOffset(v); - } - } - - /// - /// 当前水平滚动偏移 - /// - internal double CurrentHorizontalOffset - { - get => (double)GetValue(CurrentHorizontalOffsetProperty); - set => SetValue(CurrentHorizontalOffsetProperty, value); - } - } -} \ No newline at end of file diff --git a/AIStudio.Wpf.ADiagram/Controls/TabControl.xaml b/AIStudio.Wpf.ADiagram/Controls/TabControl.xaml deleted file mode 100644 index 4c34286..0000000 --- a/AIStudio.Wpf.ADiagram/Controls/TabControl.xaml +++ /dev/null @@ -1,181 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/AIStudio.Wpf.ADiagram/Controls/TabControl.xaml.cs b/AIStudio.Wpf.ADiagram/Controls/TabControl.xaml.cs deleted file mode 100644 index 8ba83c6..0000000 --- a/AIStudio.Wpf.ADiagram/Controls/TabControl.xaml.cs +++ /dev/null @@ -1,443 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Input; - -namespace AIStudio.Wpf.ADiagram.Controls -{ - [TemplatePart(Name = OverflowButtonKey, Type = typeof(ContextMenuToggleButton))] - [TemplatePart(Name = HeaderPanelKey, Type = typeof(TabPanel))] - [TemplatePart(Name = OverflowScrollviewer, Type = typeof(ScrollViewer))] - [TemplatePart(Name = ScrollButtonLeft, Type = typeof(ButtonBase))] - [TemplatePart(Name = ScrollButtonRight, Type = typeof(ButtonBase))] - [TemplatePart(Name = HeaderBorder, Type = typeof(System.Windows.Controls.Border))] - public class TabControl : System.Windows.Controls.TabControl - { - private const string OverflowButtonKey = "PART_OverflowButton"; - - private const string HeaderPanelKey = "PART_HeaderPanel"; - - private const string OverflowScrollviewer = "PART_OverflowScrollviewer"; - - private const string ScrollButtonLeft = "PART_ScrollButtonLeft"; - - private const string ScrollButtonRight = "PART_ScrollButtonRight"; - - private const string HeaderBorder = "PART_HeaderBorder"; - - private ContextMenuToggleButton _buttonOverflow; - - internal TabPanel HeaderPanel { get; private set; } - - private ScrollViewer _scrollViewerOverflow; - - private ButtonBase _buttonScrollLeft; - - private ButtonBase _buttonScrollRight; - - private System.Windows.Controls.Border _headerBorder; - - /// - /// 是否为内部操作 - /// - internal bool IsInternalAction; - - /// - /// 是否启用动画 - /// - public static readonly DependencyProperty IsAnimationEnabledProperty = DependencyProperty.Register( - "IsAnimationEnabled", typeof(bool), typeof(TabControl), new PropertyMetadata(false)); - - /// - /// 是否启用动画 - /// - public bool IsAnimationEnabled - { - get => (bool)GetValue(IsAnimationEnabledProperty); - set => SetValue(IsAnimationEnabledProperty, value); - } - - /// - /// 是否可以拖动 - /// - public static readonly DependencyProperty IsDraggableProperty = DependencyProperty.Register( - "IsDraggable", typeof(bool), typeof(TabControl), new PropertyMetadata(false)); - - /// - /// 是否可以拖动 - /// - public bool IsDraggable - { - get => (bool)GetValue(IsDraggableProperty); - set => SetValue(IsDraggableProperty, value); - } - - /// - /// 是否显示关闭按钮 - /// - public static readonly DependencyProperty ShowCloseButtonProperty = DependencyProperty.RegisterAttached( - "ShowCloseButton", typeof(bool), typeof(TabControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits)); - - public static void SetShowCloseButton(DependencyObject element, bool value) - => element.SetValue(ShowCloseButtonProperty, value); - - public static bool GetShowCloseButton(DependencyObject element) - => (bool) element.GetValue(ShowCloseButtonProperty); - - /// - /// 是否显示关闭按钮 - /// - public bool ShowCloseButton - { - get => (bool)GetValue(ShowCloseButtonProperty); - set => SetValue(ShowCloseButtonProperty, value); - } - - /// - /// 是否显示上下文菜单 - /// - public static readonly DependencyProperty ShowContextMenuProperty = DependencyProperty.RegisterAttached( - "ShowContextMenu", typeof(bool), typeof(TabControl), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.Inherits)); - - public static void SetShowContextMenu(DependencyObject element, bool value) - => element.SetValue(ShowContextMenuProperty, value); - - public static bool GetShowContextMenu(DependencyObject element) - => (bool) element.GetValue(ShowContextMenuProperty); - - /// - /// 是否显示上下文菜单 - /// - public bool ShowContextMenu - { - get => (bool)GetValue(ShowContextMenuProperty); - set => SetValue(ShowContextMenuProperty, value); - } - - /// - /// 是否将标签填充 - /// - public static readonly DependencyProperty IsTabFillEnabledProperty = DependencyProperty.Register( - "IsTabFillEnabled", typeof(bool), typeof(TabControl), new PropertyMetadata(false)); - - /// - /// 是否将标签填充 - /// - public bool IsTabFillEnabled - { - get => (bool)GetValue(IsTabFillEnabledProperty); - set => SetValue(IsTabFillEnabledProperty, value); - } - - /// - /// 标签宽度 - /// - public static readonly DependencyProperty TabItemWidthProperty = DependencyProperty.Register( - "TabItemWidth", typeof(double), typeof(TabControl), new PropertyMetadata(200.0)); - - /// - /// 标签宽度 - /// - public double TabItemWidth - { - get => (double)GetValue(TabItemWidthProperty); - set => SetValue(TabItemWidthProperty, value); - } - - /// - /// 标签高度 - /// - public static readonly DependencyProperty TabItemHeightProperty = DependencyProperty.Register( - "TabItemHeight", typeof(double), typeof(TabControl), new PropertyMetadata(30.0)); - - /// - /// 标签高度 - /// - public double TabItemHeight - { - get => (double)GetValue(TabItemHeightProperty); - set => SetValue(TabItemHeightProperty, value); - } - - /// - /// 是否可以滚动 - /// - public static readonly DependencyProperty IsScrollableProperty = DependencyProperty.Register( - "IsScrollable", typeof(bool), typeof(TabControl), new PropertyMetadata(false)); - - /// - /// 是否可以滚动 - /// - public bool IsScrollable - { - get => (bool) GetValue(IsScrollableProperty); - set => SetValue(IsScrollableProperty, value); - } - - /// - /// 是否显示溢出按钮 - /// - public static readonly DependencyProperty ShowOverflowButtonProperty = DependencyProperty.Register( - "ShowOverflowButton", typeof(bool), typeof(TabControl), new PropertyMetadata(true)); - - /// - /// 是否显示溢出按钮 - /// - public bool ShowOverflowButton - { - get => (bool) GetValue(ShowOverflowButtonProperty); - set => SetValue(ShowOverflowButtonProperty, value); - } - - /// - /// 是否显示滚动按钮 - /// - public static readonly DependencyProperty ShowScrollButtonProperty = DependencyProperty.Register( - "ShowScrollButton", typeof(bool), typeof(TabControl), new PropertyMetadata(false)); - - /// - /// 是否显示滚动按钮 - /// - public bool ShowScrollButton - { - get => (bool) GetValue(ShowScrollButtonProperty); - set => SetValue(ShowScrollButtonProperty, value); - } - - /// - /// 可见的标签数量 - /// - private int _itemShowCount; - - protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e) - { - base.OnItemsChanged(e); - - if (HeaderPanel == null) - { - IsInternalAction = false; - return; - } - - UpdateOverflowButton(); - - if (IsInternalAction) - { - IsInternalAction = false; - return; - } - - if (IsAnimationEnabled) - { - HeaderPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, new Duration(TimeSpan.FromMilliseconds(200))); - } - else - { - HeaderPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0)); - } - - if (e.Action == NotifyCollectionChangedAction.Add) - { - for (var i = 0; i < Items.Count; i++) - { - if (!(ItemContainerGenerator.ContainerFromIndex(i) is TabItem item)) return; - item.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); - item.TabPanel = HeaderPanel; - } - } - - _headerBorder?.InvalidateMeasure(); - - IsInternalAction = false; - } - - public override void OnApplyTemplate() - { - if (_buttonOverflow != null) - { - if (_buttonOverflow.Menu != null) - { - _buttonOverflow.Menu.Closed -= Menu_Closed; - _buttonOverflow.Menu = null; - } - - _buttonOverflow.Click -= ButtonOverflow_Click; - } - - if (_buttonScrollLeft != null) _buttonScrollLeft.Click -= ButtonScrollLeft_Click; - if (_buttonScrollRight != null) _buttonScrollRight.Click -= ButtonScrollRight_Click; - - base.OnApplyTemplate(); - HeaderPanel = GetTemplateChild(HeaderPanelKey) as TabPanel; - - if (IsTabFillEnabled) return; - - _buttonOverflow = GetTemplateChild(OverflowButtonKey) as ContextMenuToggleButton; - _scrollViewerOverflow = GetTemplateChild(OverflowScrollviewer) as ScrollViewer; - _buttonScrollLeft = GetTemplateChild(ScrollButtonLeft) as ButtonBase; - _buttonScrollRight = GetTemplateChild(ScrollButtonRight) as ButtonBase; - _headerBorder = GetTemplateChild(HeaderBorder) as System.Windows.Controls.Border; - - if (_buttonScrollLeft != null) _buttonScrollLeft.Click += ButtonScrollLeft_Click; - if (_buttonScrollRight != null) _buttonScrollRight.Click += ButtonScrollRight_Click; - - if (_buttonOverflow != null) - { - var menu = new System.Windows.Controls.ContextMenu - { - Placement = PlacementMode.Bottom, - PlacementTarget = _buttonOverflow - }; - menu.Closed += Menu_Closed; - _buttonOverflow.Menu = menu; - _buttonOverflow.Click += ButtonOverflow_Click; - } - } - - protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) - { - base.OnRenderSizeChanged(sizeInfo); - UpdateOverflowButton(); - } - - private void UpdateOverflowButton() - { - if (!IsTabFillEnabled) - { - _itemShowCount = (int)(ActualWidth / TabItemWidth); - if (_buttonOverflow != null) - { - _buttonOverflow.Visibility = (ShowOverflowButton && Items.Count > 0 && Items.Count >= _itemShowCount) ? Visibility.Visible : Visibility.Collapsed; - } - } - } - - private void Menu_Closed(object sender, RoutedEventArgs e) => _buttonOverflow.IsChecked = false; - - private void ButtonScrollRight_Click(object sender, RoutedEventArgs e) => - _scrollViewerOverflow.ScrollToHorizontalOffsetInternal(Math.Min( - _scrollViewerOverflow.CurrentHorizontalOffset + TabItemWidth, _scrollViewerOverflow.ScrollableWidth)); - - private void ButtonScrollLeft_Click(object sender, RoutedEventArgs e) => - _scrollViewerOverflow.ScrollToHorizontalOffsetInternal(Math.Max( - _scrollViewerOverflow.CurrentHorizontalOffset - TabItemWidth, 0)); - - private void ButtonOverflow_Click(object sender, RoutedEventArgs e) - { - if (_buttonOverflow.IsChecked == true) - { - _buttonOverflow.Menu.Items.Clear(); - for (var i = 0; i < Items.Count; i++) - { - if(!(ItemContainerGenerator.ContainerFromIndex(i) is TabItem item)) continue; - - var menuItem = new System.Windows.Controls.MenuItem - { - HeaderStringFormat = ItemStringFormat, - HeaderTemplate = ItemTemplate, - HeaderTemplateSelector = ItemTemplateSelector, - Header = item.Header, - Width = TabItemWidth, - IsChecked = item.IsSelected, - IsCheckable = true - }; - - menuItem.Click += delegate - { - _buttonOverflow.IsChecked = false; - - var list = GetActualList(); - if (list == null) return; - - var actualItem = ItemContainerGenerator.ItemFromContainer(item); - if (actualItem == null) return; - - var index = list.IndexOf(actualItem); - if (index >= _itemShowCount) - { - list.Remove(actualItem); - list.Insert(0, actualItem); - if (IsAnimationEnabled) - { - HeaderPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, new Duration(TimeSpan.FromMilliseconds(200))); - } - else - { - HeaderPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0)); - } - HeaderPanel.ForceUpdate = true; - HeaderPanel.Measure(new Size(HeaderPanel.DesiredSize.Width, ActualHeight)); - HeaderPanel.ForceUpdate = false; - SetCurrentValue(SelectedIndexProperty, 0); - } - - item.IsSelected = true; - }; - _buttonOverflow.Menu.Items.Add(menuItem); - } - } - } - - internal double GetHorizontalOffset() => _scrollViewerOverflow?.CurrentHorizontalOffset ?? 0; - - internal void UpdateScroll() => _scrollViewerOverflow?.RaiseEvent(new MouseWheelEventArgs(Mouse.PrimaryDevice, Environment.TickCount, 0) - { - RoutedEvent = MouseWheelEvent - }); - - internal void CloseAllItems() => CloseOtherItems(null); - - internal void CloseOtherItems(TabItem currentItem) - { - var actualItem = currentItem != null ? ItemContainerGenerator.ItemFromContainer(currentItem) : null; - - var list = GetActualList(); - if (list == null) return; - - IsInternalAction = true; - - for (var i = 0; i < Items.Count; i++) - { - var item = list[i]; - if (!Equals(item, actualItem) && item != null) - { - var argsClosing = new CancelRoutedEventArgs(TabItem.ClosingEvent, item); - - if (!(ItemContainerGenerator.ContainerFromItem(item) is TabItem tabItem)) continue; - - tabItem.RaiseEvent(argsClosing); - if (argsClosing.Cancel) return; - - tabItem.RaiseEvent(new RoutedEventArgs(TabItem.ClosedEvent, item)); - list.Remove(item); - - i--; - } - } - - SetCurrentValue(SelectedIndexProperty, Items.Count == 0 ? -1 : 0); - } - - internal IList GetActualList() - { - IList list; - if (ItemsSource != null) - { - list = ItemsSource as IList; - } - else - { - list = Items; - } - - return list; - } - - protected override bool IsItemItsOwnContainerOverride(object item) => item is TabItem; - - protected override DependencyObject GetContainerForItemOverride() => new TabItem(); - } -} \ No newline at end of file diff --git a/AIStudio.Wpf.ADiagram/Controls/TabItem.cs b/AIStudio.Wpf.ADiagram/Controls/TabItem.cs deleted file mode 100644 index 8a1563d..0000000 --- a/AIStudio.Wpf.ADiagram/Controls/TabItem.cs +++ /dev/null @@ -1,467 +0,0 @@ -using System; -using System.Windows; -using System.Windows.Controls.Primitives; -using System.Windows.Data; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; - -namespace AIStudio.Wpf.ADiagram.Controls -{ - public class TabItem : System.Windows.Controls.TabItem - { - /// - /// 动画速度 - /// - private const int AnimationSpeed = 150; - - /// - /// 选项卡是否处于拖动状态 - /// - private static bool ItemIsDragging; - - /// - /// 选项卡是否等待被拖动 - /// - private bool _isWaiting; - - /// - /// 拖动中的选项卡坐标 - /// - private Point _dragPoint; - - /// - /// 鼠标按下时选项卡位置 - /// - private int _mouseDownIndex; - - /// - /// 鼠标按下时选项卡横向偏移 - /// - private double _mouseDownOffsetX; - - /// - /// 鼠标按下时的坐标 - /// - private Point _mouseDownPoint; - - /// - /// 右侧可移动的最大值 - /// - private double _maxMoveRight; - - /// - /// 左侧可移动的最大值 - /// - private double _maxMoveLeft; - - /// - /// 选项卡宽度 - /// - public double ItemWidth { get; internal set; } - - /// - /// 选项卡拖动等待距离(在鼠标移动了超过20个像素无关单位后,选项卡才开始被拖动) - /// - private const double WaitLength = 20; - - /// - /// 选项卡是否处于拖动状态 - /// - private bool _isDragging; - - /// - /// 选项卡是否已经被拖动 - /// - private bool _isDragged; - - /// - /// 目标横向位移 - /// - internal double TargetOffsetX { get; set; } - - /// - /// 当前编号 - /// - private int _currentIndex; - - /// - /// 标签容器横向滚动距离 - /// - private double _scrollHorizontalOffset; - - private TabPanel _tabPanel; - - /// - /// 标签容器 - /// - internal TabPanel TabPanel - { - get - { - if (_tabPanel == null && TabControlParent != null) - { - _tabPanel = TabControlParent.HeaderPanel; - } - - return _tabPanel; - } - set => _tabPanel = value; - } - - /// - /// 当前编号 - /// - internal int CurrentIndex - { - get => _currentIndex; - set - { - if (_currentIndex == value || value < 0) return; - var oldIndex = _currentIndex; - _currentIndex = value; - UpdateItemOffsetX(oldIndex); - } - } - - /// - /// 是否显示关闭按钮 - /// - public static readonly DependencyProperty ShowCloseButtonProperty = - TabControl.ShowCloseButtonProperty.AddOwner(typeof(TabItem)); - - /// - /// 是否显示关闭按钮 - /// - public bool ShowCloseButton - { - get => (bool)GetValue(ShowCloseButtonProperty); - set => SetValue(ShowCloseButtonProperty, value); - } - - public static void SetShowCloseButton(DependencyObject element, bool value) - => element.SetValue(ShowCloseButtonProperty, value); - - public static bool GetShowCloseButton(DependencyObject element) - => (bool)element.GetValue(ShowCloseButtonProperty); - - /// - /// 是否显示上下文菜单 - /// - public static readonly DependencyProperty ShowContextMenuProperty = - TabControl.ShowContextMenuProperty.AddOwner(typeof(TabItem), new FrameworkPropertyMetadata(OnShowContextMenuChanged)); - - private static void OnShowContextMenuChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var ctl = (TabItem) d; - if (ctl.Menu != null) - { - var show = (bool)e.NewValue; - ctl.Menu.IsEnabled = show; - ctl.Menu.Show(show); - } - } - - /// - /// 是否显示上下文菜单 - /// - public bool ShowContextMenu - { - get => (bool) GetValue(ShowContextMenuProperty); - set => SetValue(ShowContextMenuProperty, value); - } - - public static void SetShowContextMenu(DependencyObject element, bool value) - => element.SetValue(ShowContextMenuProperty, value); - - public static bool GetShowContextMenu(DependencyObject element) - => (bool)element.GetValue(ShowContextMenuProperty); - - public static readonly DependencyProperty MenuProperty = DependencyProperty.Register( - "Menu", typeof(System.Windows.Controls.ContextMenu), typeof(TabItem), new PropertyMetadata(default(System.Windows.Controls.ContextMenu), OnMenuChanged)); - - private static void OnMenuChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - var ctl = (TabItem) d; - ctl.OnMenuChanged(e.NewValue as System.Windows.Controls.ContextMenu); - } - - private void OnMenuChanged(System.Windows.Controls.ContextMenu menu) - { - if (IsLoaded && menu != null) - { - var parent = TabControlParent; - if (parent == null) return; - - var item = parent.ItemContainerGenerator.ItemFromContainer(this); - - menu.DataContext = item; - menu.SetBinding(IsEnabledProperty, new Binding(ShowContextMenuProperty.Name) - { - Source = this - }); - menu.SetBinding(VisibilityProperty, new Binding(ShowContextMenuProperty.Name) - { - Source = this, - Converter = ResourceHelper.GetResource("Boolean2VisibilityConverter") - }); - } - } - - public System.Windows.Controls.ContextMenu Menu - { - get => (System.Windows.Controls.ContextMenu) GetValue(MenuProperty); - set => SetValue(MenuProperty, value); - } - - /// - /// 更新选项卡横向偏移 - /// - /// - private void UpdateItemOffsetX(int oldIndex) - { - if (!_isDragging) return; - var moveItem = TabPanel.ItemDic[CurrentIndex]; - moveItem.CurrentIndex -= CurrentIndex - oldIndex; - var offsetX = moveItem.TargetOffsetX; - var resultX = offsetX + (oldIndex - CurrentIndex) * ItemWidth; - TabPanel.ItemDic[CurrentIndex] = this; - TabPanel.ItemDic[moveItem.CurrentIndex] = moveItem; - moveItem.CreateAnimation(offsetX, resultX); - } - - public TabItem() - { - CommandBindings.Add(new CommandBinding(ControlCommands.Close, (s, e) => Close())); - CommandBindings.Add(new CommandBinding(ControlCommands.CloseAll, - (s, e) => { TabControlParent.CloseAllItems(); })); - CommandBindings.Add(new CommandBinding(ControlCommands.CloseOther, - (s, e) => { TabControlParent.CloseOtherItems(this); })); - - Loaded += (s, e) => OnMenuChanged(Menu); - } - - private Util.Controls.Handy.TabControls.TabControl TabControlParent => System.Windows.Controls.ItemsControl.ItemsControlFromItemContainer(this) as TabControl; - - protected override void OnMouseRightButtonDown(MouseButtonEventArgs e) - { - base.OnMouseRightButtonDown(e); - IsSelected = true; - Focus(); - } - - protected override void OnHeaderChanged(object oldHeader, object newHeader) - { - base.OnHeaderChanged(oldHeader, newHeader); - - if (TabPanel != null) - { - TabPanel.ForceUpdate = true; - InvalidateMeasure(); - TabPanel.ForceUpdate = true; - } - } - - internal void Close() - { - var parent = TabControlParent; - if (parent == null) return; - - var item = parent.ItemContainerGenerator.ItemFromContainer(this); - - var argsClosing = new CancelRoutedEventArgs(ClosingEvent, item); - RaiseEvent(argsClosing); - if (argsClosing.Cancel) return; - - TabPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, parent.IsAnimationEnabled - ? new Duration(TimeSpan.FromMilliseconds(200)) - : new Duration(TimeSpan.FromMilliseconds(1))); - - parent.IsInternalAction = true; - RaiseEvent(new RoutedEventArgs(ClosedEvent, item)); - - var list = parent.GetActualList(); - list?.Remove(item); - } - - protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) - { - base.OnMouseLeftButtonDown(e); - - var parent = TabControlParent; - if (parent == null) return; - - if (parent.IsDraggable && !ItemIsDragging && !_isDragging) - { - parent.UpdateScroll(); - TabPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0)); - _mouseDownOffsetX = RenderTransform.Value.OffsetX; - _scrollHorizontalOffset = parent.GetHorizontalOffset(); - var mx = TranslatePoint(new Point(), parent).X + _scrollHorizontalOffset; - _mouseDownIndex = CalLocationIndex(mx); - var subIndex = _mouseDownIndex - CalLocationIndex(_scrollHorizontalOffset); - _maxMoveLeft = -subIndex * ItemWidth; - _maxMoveRight = parent.ActualWidth - ActualWidth + _maxMoveLeft; - - _isDragging = true; - ItemIsDragging = true; - _isWaiting = true; - _dragPoint = e.GetPosition(parent); - _dragPoint = new Point(_dragPoint.X + _scrollHorizontalOffset, _dragPoint.Y); - _mouseDownPoint = _dragPoint; - CaptureMouse(); - } - } - - protected override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - - if (ItemIsDragging && _isDragging) - { - var parent = TabControlParent; - if (parent == null) return; - - var subX = TranslatePoint(new Point(), parent).X + _scrollHorizontalOffset; - CurrentIndex = CalLocationIndex(subX); - - var p = e.GetPosition(parent); - p = new Point(p.X + _scrollHorizontalOffset, p.Y); - - var subLeft = p.X - _dragPoint.X; - var totalLeft = p.X - _mouseDownPoint.X; - - if (Math.Abs(subLeft) <= WaitLength && _isWaiting) return; - - _isWaiting = false; - _isDragged = true; - - var left = subLeft + RenderTransform.Value.OffsetX; - if (totalLeft < _maxMoveLeft) - { - left = _maxMoveLeft + _mouseDownOffsetX; - } - else if (totalLeft > _maxMoveRight) - { - left = _maxMoveRight + _mouseDownOffsetX; - } - - var t = new TranslateTransform(left, 0); - RenderTransform = t; - _dragPoint = p; - } - } - - protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) - { - base.OnMouseLeftButtonUp(e); - - ReleaseMouseCapture(); - - if (_isDragged) - { - var parent = TabControlParent; - if (parent == null) return; - - var subX = TranslatePoint(new Point(), parent).X + _scrollHorizontalOffset; - var index = CalLocationIndex(subX); - var left = index * ItemWidth; - var offsetX = RenderTransform.Value.OffsetX; - CreateAnimation(offsetX, offsetX - subX + left, index); - } - - _isDragging = false; - ItemIsDragging = false; - _isDragged = false; - } - - /// - /// 创建动画 - /// - internal void CreateAnimation(double offsetX, double resultX, int index = -1) - { - var parent = TabControlParent; - - void AnimationCompleted() - { - RenderTransform = new TranslateTransform(resultX, 0); - if (index == -1) return; - - var list = parent.GetActualList(); - if (list == null) return; - - var item = parent.ItemContainerGenerator.ItemFromContainer(this); - if (item == null) return; - - TabPanel.CanUpdate = false; - parent.IsInternalAction = true; - - list.Remove(item); - parent.IsInternalAction = true; - list.Insert(index, item); - TabPanel.CanUpdate = true; - TabPanel.ForceUpdate = true; - TabPanel.Measure(new Size(TabPanel.DesiredSize.Width, ActualHeight)); - TabPanel.ForceUpdate = false; - - Focus(); - IsSelected = true; - - if (!IsMouseCaptured) - { - parent.SetCurrentValue(Selector.SelectedIndexProperty, _currentIndex); - } - } - - TargetOffsetX = resultX; - if (!parent.IsAnimationEnabled) - { - AnimationCompleted(); - return; - } - - var animation = AnimationHelper.CreateAnimation(resultX, AnimationSpeed); - animation.FillBehavior = FillBehavior.Stop; - animation.Completed += (s1, e1) => AnimationCompleted(); - var f = new TranslateTransform(offsetX, 0); - RenderTransform = f; - f.BeginAnimation(TranslateTransform.XProperty, animation, HandoffBehavior.Compose); - } - - /// - /// 计算选项卡当前合适的位置编号 - /// - /// - /// - private int CalLocationIndex(double left) - { - if (_isWaiting) - { - return CurrentIndex; - } - - var maxIndex = TabControlParent.Items.Count - 1; - var div = (int)(left / ItemWidth); - var rest = left % ItemWidth; - var result = rest / ItemWidth > .5 ? div + 1 : div; - - return result > maxIndex ? maxIndex : result; - } - - public static readonly RoutedEvent ClosingEvent = EventManager.RegisterRoutedEvent("Closing", RoutingStrategy.Bubble, typeof(EventHandler), typeof(TabItem)); - - public event EventHandler Closing - { - add => AddHandler(ClosingEvent, value); - remove => RemoveHandler(ClosingEvent, value); - } - - public static readonly RoutedEvent ClosedEvent = EventManager.RegisterRoutedEvent("Closed", RoutingStrategy.Bubble, typeof(EventHandler), typeof(TabItem)); - - public event EventHandler Closed - { - add => AddHandler(ClosedEvent, value); - remove => RemoveHandler(ClosedEvent, value); - } - } -} \ No newline at end of file diff --git a/AIStudio.Wpf.ADiagram/Controls/TabPanel.cs b/AIStudio.Wpf.ADiagram/Controls/TabPanel.cs deleted file mode 100644 index 06e39ba..0000000 --- a/AIStudio.Wpf.ADiagram/Controls/TabPanel.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Windows; -using System.Windows.Media; - -namespace AIStudio.Wpf.ADiagram.Controls -{ - public class TabPanel : System.Windows.Controls.Panel - { - private int _itemCount; - - /// - /// 是否可以更新 - /// - internal bool CanUpdate = true; - - /// - /// 选项卡字典 - /// - internal Dictionary ItemDic = new Dictionary(); - - /// - /// 流式行为持续时间 - /// - public static readonly DependencyProperty FluidMoveDurationProperty = DependencyProperty.Register( - "FluidMoveDuration", typeof(Duration), typeof(TabPanel), new PropertyMetadata(new Duration(TimeSpan.FromMilliseconds(200)))); - - /// - /// 流式行为持续时间 - /// - public Duration FluidMoveDuration - { - get => (Duration)GetValue(FluidMoveDurationProperty); - set => SetValue(FluidMoveDurationProperty, value); - } - - /// - /// 是否将标签填充 - /// - public static readonly DependencyProperty IsTabFillEnabledProperty = DependencyProperty.Register( - "IsTabFillEnabled", typeof(bool), typeof(TabPanel), new PropertyMetadata(ValueBoxes.FalseBox)); - - /// - /// 是否将标签填充 - /// - public bool IsTabFillEnabled - { - get => (bool)GetValue(IsTabFillEnabledProperty); - set => SetValue(IsTabFillEnabledProperty, value); - } - - /// - /// 标签宽度 - /// - public static readonly DependencyProperty TabItemWidthProperty = DependencyProperty.Register( - "TabItemWidth", typeof(double), typeof(TabPanel), new PropertyMetadata(200.0)); - - /// - /// 标签宽度 - /// - public double TabItemWidth - { - get => (double)GetValue(TabItemWidthProperty); - set => SetValue(TabItemWidthProperty, value); - } - - /// - /// 标签高度 - /// - public static readonly DependencyProperty TabItemHeightProperty = DependencyProperty.Register( - "TabItemHeight", typeof(double), typeof(TabPanel), new PropertyMetadata(30.0)); - - /// - /// 标签高度 - /// - public double TabItemHeight - { - get => (double)GetValue(TabItemHeightProperty); - set => SetValue(TabItemHeightProperty, value); - } - - /// - /// 是否可以强制更新 - /// - internal bool ForceUpdate; - - private Size _oldSize; - - /// - /// 是否已经加载 - /// - private bool _isLoaded; - - protected override Size MeasureOverride(Size constraint) - { - if ((_itemCount == InternalChildren.Count || !CanUpdate) && !ForceUpdate) return _oldSize; - constraint.Height = TabItemHeight; - _itemCount = InternalChildren.Count; - - var size = new Size(); - - ItemDic.Clear(); - - var count = InternalChildren.Count; - if (count == 0) - { - _oldSize = new Size(); - return _oldSize; - } - constraint.Width += InternalChildren.Count; - - var itemWidth = .0; - var arr = new int[count]; - - if (!IsTabFillEnabled) - { - itemWidth = TabItemWidth; - } - else - { - if (TemplatedParent is TabControl tabControl) - { - arr = ArithmeticHelper.DivideInt2Arr((int)tabControl.ActualWidth + InternalChildren.Count, count); - } - } - - for (var index = 0; index < count; index++) - { - if (IsTabFillEnabled) - { - itemWidth = arr[index]; - } - if (InternalChildren[index] is TabItem tabItem) - { - tabItem.RenderTransform = new TranslateTransform(); - tabItem.MaxWidth = itemWidth; - var rect = new Rect - { - X = size.Width - tabItem.BorderThickness.Left, - Width = itemWidth, - Height = TabItemHeight - }; - tabItem.Arrange(rect); - tabItem.ItemWidth = itemWidth - tabItem.BorderThickness.Left; - tabItem.CurrentIndex = index; - tabItem.TargetOffsetX = 0; - ItemDic[index] = tabItem; - size.Width += tabItem.ItemWidth; - } - } - size.Height = constraint.Height; - _oldSize = size; - return _oldSize; - } - - public TabPanel() - { - Loaded += (s, e) => - { - if (_isLoaded) return; - ForceUpdate = true; - Measure(new Size(DesiredSize.Width, ActualHeight)); - ForceUpdate = false; - foreach (var item in ItemDic.Values) - { - item.TabPanel = this; - } - _isLoaded = true; - }; - } - } -} \ No newline at end of file diff --git a/AIStudio.Wpf.ADiagram/DesignItems/Customs/1.json b/AIStudio.Wpf.ADiagram/DesignItems/Customs/1.json index 44d50f5..73a0c04 100644 --- a/AIStudio.Wpf.ADiagram/DesignItems/Customs/1.json +++ b/AIStudio.Wpf.ADiagram/DesignItems/Customs/1.json @@ -21,7 +21,7 @@ "ItemWidth": 65.0, "ItemHeight": 65.0, "Icon": "M 0,0 H 60 V 40 C 30,30 30,50 0,40 Z", - "ItemTypeName": "AIStudio.Wpf.ADiagram.Demos.Others.PathItemViewModel", + "ItemTypeName": "AIStudio.Wpf.BaseDiagram.Extensions.ViewModels.PathItemViewModel", "Id": "da395032-ad9e-4dab-a035-f59bed5cb4c4", "ZIndex": 0, "IsGroup": false, @@ -93,76 +93,6 @@ ], "FlowNodeDesignerItems": [ ], - "AllDesignerItems": [ - { - "Left": 132.80000000000007, - "Top": 101.26000022888184, - "Margin": 0.0, - "ItemWidth": 65.0, - "ItemHeight": 65.0, - "Icon": "M 0,0 H 60 V 40 C 30,30 30,50 0,40 Z", - "ItemTypeName": "AIStudio.Wpf.ADiagram.Demos.Others.PathItemViewModel", - "Id": "da395032-ad9e-4dab-a035-f59bed5cb4c4", - "ZIndex": 0, - "IsGroup": false, - "ParentId": "00000000-0000-0000-0000-000000000000", - "Text": "欢迎来到AIStudio画板", - "ColorItem": { - "LineColor": { - "BrushType": 1, - "Color": "#FF808080", - "GradientStop": null, - "Offset": null, - "Image": null, - "SubType": 0, - "StartPoint": "0,0", - "EndPoint": "0,0", - "Opacity": 1.0, - "LinearOrientation": 0, - "RadialOrientation": 0, - "Angle": 0 - }, - "FillColor": { - "BrushType": 1, - "Color": "#FFFFA500", - "GradientStop": null, - "Offset": null, - "Image": null, - "SubType": 0, - "StartPoint": "0,0", - "EndPoint": "0,0", - "Opacity": 1.0, - "LinearOrientation": 0, - "RadialOrientation": 0, - "Angle": 0 - }, - "ShadowColor": "#00FFFFFF", - "LineWidth": 1.0, - "LeftArrowPathStyle": 0, - "RightArrowPathStyle": 1, - "LeftArrowSizeStyle": 10, - "RightArrowSizeStyle": 10 - }, - "FontItem": { - "FontWeight": "Normal", - "FontStyle": "Normal", - "FontStretch": "Normal", - "Underline": false, - "Strikethrough": false, - "OverLine": false, - "FontColor": "#FF000000", - "FontFamily": "Arial", - "FontSize": 11.0, - "FontObject": "Arial, 11pt", - "TextEffectColor": "#00FFFFFF", - "HighlightColor": "#00FFFFFF", - "FontCase": 0, - "HorizontalAlignment": 1, - "VerticalAlignment": 1, - "LineHeight": 0.0 - } - } - ], "ConnectionIds": [ ], "Connections": [ diff --git a/AIStudio.Wpf.ADiagram/Enums/ColorType.cs b/AIStudio.Wpf.ADiagram/Models/ColorType.cs similarity index 83% rename from AIStudio.Wpf.ADiagram/Enums/ColorType.cs rename to AIStudio.Wpf.ADiagram/Models/ColorType.cs index 1e49561..7aa6d24 100644 --- a/AIStudio.Wpf.ADiagram/Enums/ColorType.cs +++ b/AIStudio.Wpf.ADiagram/Models/ColorType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace AIStudio.Wpf.ADiagram.Enums +namespace AIStudio.Wpf.ADiagram.Models { public enum ColorType { diff --git a/AIStudio.Wpf.ADiagram/Models/DiagramItem.cs b/AIStudio.Wpf.ADiagram/Models/DiagramItem.cs index 8f4fd1e..43500a8 100644 --- a/AIStudio.Wpf.ADiagram/Models/DiagramItem.cs +++ b/AIStudio.Wpf.ADiagram/Models/DiagramItem.cs @@ -7,9 +7,12 @@ using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; -using AIStudio.Wpf.ADiagram.Demos.Flowchart; -using AIStudio.Wpf.ADiagram.Demos.Others; +using AIStudio.Wpf.Flowchart; +using AIStudio.Wpf.BaseDiagram.Extensions.ViewModels; +using AIStudio.Wpf.BaseDiagram.Extensions.Models; using Newtonsoft.Json; +using AIStudio.Wpf.Flowchart.Models; +using AIStudio.Wpf.Flowchart.ViewModels; namespace AIStudio.Wpf.ADiagram.Models { diff --git a/AIStudio.Wpf.ADiagram/Models/PathToolBoxData.cs b/AIStudio.Wpf.ADiagram/Models/PathToolBoxData.cs index c408fae..1016c6a 100644 --- a/AIStudio.Wpf.ADiagram/Models/PathToolBoxData.cs +++ b/AIStudio.Wpf.ADiagram/Models/PathToolBoxData.cs @@ -1,14 +1,8 @@ -using Util.DiagramDesigner.Helpers; +using AIStudio.Wpf.Flowchart; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Media; -using System.Windows.Shapes; using Util.DiagramDesigner; -using AIStudio.Wpf.ADiagram.Demos.Flowchart; -using AIStudio.Wpf.ADiagram.Helpers; +using Util.DiagramDesigner.Helpers; namespace AIStudio.Wpf.ADiagram.Models { diff --git a/AIStudio.Wpf.ADiagram/Themes/Generic.xaml b/AIStudio.Wpf.ADiagram/Themes/Generic.xaml index 374cd75..b9c18c3 100644 --- a/AIStudio.Wpf.ADiagram/Themes/Generic.xaml +++ b/AIStudio.Wpf.ADiagram/Themes/Generic.xaml @@ -16,14 +16,12 @@ - - - - - - - - + + + + + + diff --git a/AIStudio.Wpf.ADiagram/Themes/Styles/Expander.xaml b/AIStudio.Wpf.ADiagram/Themes/Styles/Expander.xaml index 47117b0..79b649f 100644 --- a/AIStudio.Wpf.ADiagram/Themes/Styles/Expander.xaml +++ b/AIStudio.Wpf.ADiagram/Themes/Styles/Expander.xaml @@ -1,6 +1,6 @@  + xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters;assembly=AIStudio.Wpf.BaseDiagram"> - + diff --git a/AIStudio.Wpf.ADiagram/Demos/Others/ViewModels/PersistDesignerItemData.cs b/AIStudio.Wpf.BaseDiagram/Extensions/ViewModels/PersistDesignerItemData.cs similarity index 79% rename from AIStudio.Wpf.ADiagram/Demos/Others/ViewModels/PersistDesignerItemData.cs rename to AIStudio.Wpf.BaseDiagram/Extensions/ViewModels/PersistDesignerItemData.cs index 7b3c9a9..b86dc26 100644 --- a/AIStudio.Wpf.ADiagram/Demos/Others/ViewModels/PersistDesignerItemData.cs +++ b/AIStudio.Wpf.BaseDiagram/Extensions/ViewModels/PersistDesignerItemData.cs @@ -1,12 +1,6 @@ -using Util.DiagramDesigner; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using AIStudio.Wpf.ADiagram.Models; +using AIStudio.Wpf.BaseDiagram.Models; -namespace AIStudio.Wpf.ADiagram.Demos.Others +namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels { /// /// This is passed to the PopupWindow.xaml window, where a DataTemplate is used to provide the diff --git a/AIStudio.Wpf.ADiagram/Demos/Others/ViewModels/PersistDesignerItemViewModel.cs b/AIStudio.Wpf.BaseDiagram/Extensions/ViewModels/PersistDesignerItemViewModel.cs similarity index 83% rename from AIStudio.Wpf.ADiagram/Demos/Others/ViewModels/PersistDesignerItemViewModel.cs rename to AIStudio.Wpf.BaseDiagram/Extensions/ViewModels/PersistDesignerItemViewModel.cs index 6710df4..54f50a4 100644 --- a/AIStudio.Wpf.ADiagram/Demos/Others/ViewModels/PersistDesignerItemViewModel.cs +++ b/AIStudio.Wpf.BaseDiagram/Extensions/ViewModels/PersistDesignerItemViewModel.cs @@ -1,14 +1,8 @@ -using AIStudio.Wpf.ADiagram.Services; +using AIStudio.Wpf.BaseDiagram.Services; using Util.DiagramDesigner; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Input; -using System.Windows.Media; +using AIStudio.Wpf.BaseDiagram.Extensions.Models; -namespace AIStudio.Wpf.ADiagram.Demos.Others +namespace AIStudio.Wpf.BaseDiagram.Extensions.ViewModels { public class PersistDesignerItemViewModel : DesignerItemViewModelBase { diff --git a/AIStudio.Wpf.ADiagram/Demos/Others/ViewModels/PersistDesignerItemViewModel.xaml b/AIStudio.Wpf.BaseDiagram/Extensions/ViewModels/PersistDesignerItemViewModel.xaml similarity index 87% rename from AIStudio.Wpf.ADiagram/Demos/Others/ViewModels/PersistDesignerItemViewModel.xaml rename to AIStudio.Wpf.BaseDiagram/Extensions/ViewModels/PersistDesignerItemViewModel.xaml index 11f2ac2..c66ade0 100644 --- a/AIStudio.Wpf.ADiagram/Demos/Others/ViewModels/PersistDesignerItemViewModel.xaml +++ b/AIStudio.Wpf.BaseDiagram/Extensions/ViewModels/PersistDesignerItemViewModel.xaml @@ -1,9 +1,9 @@  - +