diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/MainWindowViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/MainWindowViewModel.cs index 2ecb996..092b17f 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/MainWindowViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/MainWindowViewModel.cs @@ -84,7 +84,10 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels } set { - SetProperty(ref _pageViewModel, value); + if (SetProperty(ref _pageViewModel, value)) + { + + } } } diff --git a/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs b/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs index 0260ba3..6cb67d8 100644 --- a/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs +++ b/AIStudio.Wpf.DiagramApp/ViewModels/PageViewModel.cs @@ -160,7 +160,7 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels if (_diagramViewModel != value) { if (_diagramViewModel != null) - { + { _diagramViewModel.PropertyChanged -= DiagramViewModel_PropertyChanged; } SetProperty(ref _diagramViewModel, value); diff --git a/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml b/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml index 68548c1..1406b73 100644 --- a/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml +++ b/AIStudio.Wpf.DiagramApp/Views/MainWindow.xaml @@ -34,7 +34,7 @@ - + @@ -827,7 +827,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AIStudio.Wpf.DiagramDesigner/Controls/DesignerCanvas.cs b/AIStudio.Wpf.DiagramDesigner/Controls/DesignerCanvas.cs index 319c723..768e33e 100644 --- a/AIStudio.Wpf.DiagramDesigner/Controls/DesignerCanvas.cs +++ b/AIStudio.Wpf.DiagramDesigner/Controls/DesignerCanvas.cs @@ -199,6 +199,15 @@ namespace AIStudio.Wpf.DiagramDesigner _service.PropertyChanged += _service_PropertyChanged; this.Loaded += DesignerCanvas_Loaded; + this.IsVisibleChanged += DesignerCanvas_IsVisibleChanged; + } + + private void DesignerCanvas_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if (IsVisible) + { + this.Focus(); + } } private void DesignerCanvas_Loaded(object sender, RoutedEventArgs e) @@ -354,8 +363,8 @@ namespace AIStudio.Wpf.DiagramDesigner protected override void OnMouseMove(MouseEventArgs e) { - //var focusedElement = Keyboard.FocusedElement; - //Debug.WriteLine("focusedElement:" + focusedElement?.ToString()); + var focusedElement = Keyboard.FocusedElement; + Debug.WriteLine("focusedElement:" + focusedElement?.ToString()); base.OnMouseMove(e); diff --git a/AIStudio.Wpf.DiagramDesigner/Controls/MyTabControl.cs b/AIStudio.Wpf.DiagramDesigner/Controls/MyTabControl.cs new file mode 100644 index 0000000..e50a061 --- /dev/null +++ b/AIStudio.Wpf.DiagramDesigner/Controls/MyTabControl.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace AIStudio.Wpf.DiagramDesigner.Controls +{ + public class DiagramTabControl : TabControl + { + public DiagramTabControl() + { + // Attach event handler to TabControl.SelectionChanged event + this.SelectionChanged += DiagramTabControl_SelectionChanged; + this.IsVisibleChanged += DiagramTabControl_IsVisibleChanged; + } + + private void DiagramTabControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + foreach (var item in this.Items) + { + if (item is DiagramViewModel viewModel) + { + viewModel.ShowSearch = false; + } + } + } + + private void DiagramTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + // Iterate through all TabItems and manually set the Visibility property + foreach (var item in this.Items) + { + if (item is DiagramViewModel viewModel) + { + if (item != this.SelectedItem) + { + viewModel.ShowSearch = false; + } + } + } + } + } +} \ No newline at end of file diff --git a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml index 56e937e..0929ad9 100644 --- a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml +++ b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml @@ -315,7 +315,7 @@ - + @@ -819,7 +819,7 @@ - + - + diff --git a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml.cs b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml.cs index dd1f55c..4649e50 100644 --- a/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml.cs +++ b/AIStudio.Wpf.DiagramDesigner/UserControls/DiagramControl.xaml.cs @@ -27,6 +27,13 @@ namespace AIStudio.Wpf.DiagramDesigner { this.Resources.MergedDictionaries.Add(ResourceDictionary); } + + this.IsVisibleChanged += DiagramControl_IsVisibleChanged; + } + + private void DiagramControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + } public static readonly DependencyProperty ResourceDictionaryProperty = DependencyProperty.Register(nameof(ResourceDictionary), typeof(ResourceDictionary), typeof(DiagramControl), new UIPropertyMetadata(null, OnResourceDictionaryChanged)); diff --git a/AIStudio.Wpf.DiagramDesigner/UserControls/LineControl.xaml b/AIStudio.Wpf.DiagramDesigner/UserControls/LineControl.xaml index 69b4469..f5557bc 100644 --- a/AIStudio.Wpf.DiagramDesigner/UserControls/LineControl.xaml +++ b/AIStudio.Wpf.DiagramDesigner/UserControls/LineControl.xaml @@ -12,6 +12,8 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs index b528a0d..0202159 100644 --- a/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs +++ b/AIStudio.Wpf.Mind/Controls/MindEditor.xaml.cs @@ -20,12 +20,15 @@ namespace AIStudio.Wpf.Mind.Controls /// [TemplatePart(Name = PART_DiagramControl, Type = typeof(DiagramControl))] [TemplatePart(Name = PART_ContentControl, Type = typeof(ContentControl))] + [TemplatePart(Name = PART_SearchControl, Type = typeof(Border))] public partial class MindEditor : UserControl { public const string PART_DiagramControl = "PART_DiagramControl"; public const string PART_ContentControl = "PART_ContentControl"; + public const string PART_SearchControl = "PART_SearchControl"; private DiagramControl _diagramControl; private ContentControl _contentControl; + private Border _searchborder; private MindDiagramViewModel _diagramViewModel; @@ -56,7 +59,16 @@ namespace AIStudio.Wpf.Mind.Controls _diagramControl.DataContext = _diagramViewModel; _contentControl = GetTemplateChild(PART_ContentControl) as ContentControl; - _contentControl.DataContext = _diagramViewModel; + if (_contentControl != null) + { + _contentControl.DataContext = _diagramViewModel; + } + + _searchborder = GetTemplateChild(PART_SearchControl) as Border; + if (_searchborder != null) + { + _searchborder.DataContext = _diagramViewModel; + } GetDataFunc = GetData; } diff --git a/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml b/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml index c892d1d..c9106d7 100644 --- a/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml +++ b/AIStudio.Wpf.Mind/Controls/ToolBoxControl.xaml @@ -627,39 +627,7 @@ 搜索 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +