diff --git a/src/Views/Launcher.xaml.cs b/src/Views/Launcher.xaml.cs index a5617934..acaba972 100644 --- a/src/Views/Launcher.xaml.cs +++ b/src/Views/Launcher.xaml.cs @@ -96,6 +96,7 @@ namespace SourceGit.Views { #region TAB_OPERATION private void OnTabAdding(object sender, Widgets.PageTabBar.TabEventArgs e) { var page = new Widgets.Welcome(); + page.OnNodeEdited += node => tabs.Update(node.Id, node.Bookmark, node.Name); container.Add(e.TabId, page); Controls.PopupWidget.RegisterContainer(e.TabId, page); } diff --git a/src/Views/Widgets/Welcome.xaml.cs b/src/Views/Widgets/Welcome.xaml.cs index bd5977aa..7426d52f 100644 --- a/src/Views/Widgets/Welcome.xaml.cs +++ b/src/Views/Widgets/Welcome.xaml.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -12,6 +13,7 @@ namespace SourceGit.Views.Widgets { /// 新标签页 /// public partial class Welcome : UserControl, Controls.IPopupContainer { + /// /// 树节点数据 /// @@ -44,6 +46,11 @@ namespace SourceGit.Views.Widgets { public List Children { get; set; } } + /// + /// 仓库节点编辑事件参数 + /// + public event Action OnNodeEdited; + public Welcome() { InitializeComponent(); UpdateTree(); @@ -144,7 +151,7 @@ namespace SourceGit.Views.Widgets { if (repo != null) { repo.Bookmark = refIdx; node.Bookmark = refIdx; - (Application.Current.MainWindow as Launcher)?.tabs.Update(node.Id, refIdx, node.Name); + OnNodeEdited?.Invoke(node); } ev.Handled = true; }; @@ -400,7 +407,7 @@ namespace SourceGit.Views.Widgets { Models.Preference.Instance.RenameGroup(node.Id, edit.Text); } else { Models.Preference.Instance.RenameRepository(node.Id, node.Name); - (Application.Current.MainWindow as Launcher)?.tabs.Update(node.Id, node.Bookmark, edit.Text); + OnNodeEdited?.Invoke(node); } e.Handled = false; }