ui/wpf/UIcore/MainToolBar.cs

changeset 108
77254bd6dccb
parent 107
b34bd1557c6c
child 109
c3dfcb8f0be7
--- a/ui/wpf/UIcore/MainToolBar.cs	Sat Apr 05 17:57:04 2025 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media;
-
-namespace UI
-{
-    public class MainToolBar
-    {
-        Dictionary<string, IToolItem> Items = new Dictionary<string, IToolItem>();
-        List<string> Defaults = new List<string>();
-
-        public MainToolBar()
-        {
-
-        }
-
-        public bool HasItems()
-        {
-            return Defaults.Count > 0 ? true : false;
-        }
-
-        public void AddDefault(string itemName)
-        {
-            Defaults.Add(itemName);
-        }
-
-        public void AddToolItem(string name, string label, Action<IntPtr> action)
-        {
-            ToolItem item = new ToolItem();
-            item.Label = label;
-            item.Action = action;
-            Items.Add(name, item);
-        }
-
-        public ToolBarTray CreateToolBarTray(IntPtr objptr)
-        {
-            ToolBarTray tray = new ToolBarTray();
-            ToolBar toolbar = new ToolBar();
-            tray.ToolBars.Add(toolbar);
-            foreach(string s in Defaults)
-            {
-                IToolItem item = Items[s];
-                item.AddTo(toolbar, objptr);
-            }
-
-            return tray;
-        }
-    }
-
-    public interface IToolItem
-    {
-        void AddTo(System.Windows.Controls.ToolBar toolbar, IntPtr uiobj);
-    }
-
-    public class ToolItem : IToolItem
-    {
-        public string Label { get; set; }
-        // TODO: icon
-        public Action<IntPtr> Action { get; set; }
-
-        public void AddTo(System.Windows.Controls.ToolBar toolbar, IntPtr uiobj)
-        {
-            Button button = new Button();
-            button.Content = Label;
-
-            EventCallback e = new EventCallback(uiobj, Action);
-            button.Click += e.Callback;
-
-            toolbar.Items.Add(button);
-        }
-    }
-}

mercurial