From bc3d5ddf42f4702855f42ad543324b6d6015f16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AB=E5=9F=8Evia?= Date: Tue, 3 Jan 2023 12:21:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8F=9C=E5=8D=95=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/ToolBar.xaml | 3 ++- VPet-Simulator.Core/Display/ToolBar.xaml.cs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/VPet-Simulator.Core/Display/ToolBar.xaml b/VPet-Simulator.Core/Display/ToolBar.xaml index e4e29a5..35d9e5f 100644 --- a/VPet-Simulator.Core/Display/ToolBar.xaml +++ b/VPet-Simulator.Core/Display/ToolBar.xaml @@ -16,7 +16,8 @@ - + diff --git a/VPet-Simulator.Core/Display/ToolBar.xaml.cs b/VPet-Simulator.Core/Display/ToolBar.xaml.cs index fc11715..fde07c9 100644 --- a/VPet-Simulator.Core/Display/ToolBar.xaml.cs +++ b/VPet-Simulator.Core/Display/ToolBar.xaml.cs @@ -72,5 +72,25 @@ namespace VPet_Simulator.Core { m.Core.Controller.ShowSetting(); } + + public void AddMenuButton(string parentMenu, + string displayName, + Action clickCallback) + { + var menuItem = new MenuItem() + { + Header = displayName, + }; + menuItem.Click += delegate + { + clickCallback?.Invoke(); + }; + switch (parentMenu) + { + case "投喂": + MenuFeed.Items.Add(menuItem); + break; + } + } } }