Exemplo n.º 1
0
        MyButtonItem(ToolStripMenuItem item, string name)
            : base()
        {
            if (name == "")
            {
                name = "AButtonItem_" + namect;
                namect++;
            }

            refitem = item;
            if (item != null)
            {
                this.Image   = item.Image;
                this.Visible = (item.Image != null);
                if (this.Image == null)
                {
                    this.Text = item.Text;
                }
                this.ToolTipText     = item.Text.Replace("&", "");
                this.Enabled         = item.Enabled;
                this.Click          += new EventHandler(MyButtonItem_Activate);
                item.CheckedChanged += new EventHandler(item_CheckedChanged);
                item.EnabledChanged += new EventHandler(item_EnabledChanged);

                this.ToolTipText = item.Text;
                this.Enabled     = item.Enabled;
                this.Checked     = item.Checked;

                havedock = false;
                ToolMenuItemExt tmie = item as ToolMenuItemExt;
                if (tmie != null)
                {
                    this.name = tmie.Name;
                }
                else
                {
                    Ambertation.Windows.Forms.DockPanel dw = item.Tag as Ambertation.Windows.Forms.DockPanel;

                    if (dw != null)
                    {
                        this.name = dw.Name;
                        havedock  = true;
                    }
                    else
                    {
                        this.name = "Button_" + (counter++);
                    }
                }
            }
            else
            {
                havedock  = false;
                this.name = name;
            }
        }
Exemplo n.º 2
0
        void LoadMenuItems(ToolStripMenuItem toolmenu, ToolStrip tootoolbar)
        {
            ToolMenuItemExt.ExternalToolNotify chghandler = new ToolMenuItemExt.ExternalToolNotify(ClosedToolPluginHandler);
            IToolExt[] toolsp = (IToolExt[])FileTable.ToolRegistry.ToolsPlus;
            foreach (IToolExt tool in toolsp)
            {
                string   name  = tool.ToString();
                string[] parts = name.Split("\\".ToCharArray());
                name = Localization.GetString(parts[parts.Length - 1]);
                Splash.Screen.SetMessage("Loading " + name);
                ToolMenuItemExt item = new ToolMenuItemExt(name, tool, chghandler);

                LoadFileWrappersExt.AddMenuItem(ref ChangedGuiResourceEvent, toolmenu.DropDownItems, item, parts);
            }

            ITool[] tools = FileTable.ToolRegistry.Tools;
            foreach (ITool tool in tools)
            {
                string name = tool.ToString().Trim();
                if (name == "")
                {
                    continue;
                }

                string[] parts = name.Split("\\".ToCharArray());
                name = Localization.GetString(parts[parts.Length - 1]);
                Splash.Screen.SetMessage("Loading " + name);
                ToolMenuItemExt item = new ToolMenuItemExt(name, tool, chghandler);

                LoadFileWrappersExt.AddMenuItem(ref ChangedGuiResourceEvent, toolmenu.DropDownItems, item, parts);
            }

            Splash.Screen.SetMessage("Creating Toolbar");
            LoadFileWrappersExt.BuildToolBar(tootoolbar, toolmenu.DropDownItems);
            //EnableMenuItems(null);
            Splash.Screen.SetMessage("Loaded Menu Items");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add one single MenuItem (and all needed Parents)
        /// </summary>
        /// <param name="item"></param>
        /// <param name="parts"></param>
        public static void AddMenuItem(ref SimPe.Events.ChangedResourceEvent ev, ToolStripItemCollection parent, ToolMenuItemExt item, string[] parts)
        {
            System.Reflection.Assembly a = typeof(LoadFileWrappersExt).Assembly;

            for (int i = 0; i < parts.Length - 1; i++)
            {
                string            name = SimPe.Localization.GetString(parts[i]);
                ToolStripMenuItem mi   = null;
                //find an existing Menu Item
                if (parent != null)
                {
                    foreach (ToolStripMenuItem oi in parent)
                    {
                        if (oi.Text.ToLower().Trim() == name.ToLower().Trim())
                        {
                            mi = oi;
                            break;
                        }
                    }
                }
                if (mi == null)
                {
                    mi = new ToolStripMenuItem(name);

                    if (parent != null)
                    {
                        System.IO.Stream imgstr = a.GetManifestResourceStream("SimPe." + parts[i] + ".png");
                        if (imgstr != null)
                        {
                            mi.Image = System.Drawing.Image.FromStream(imgstr);
                        }
                        parent.Insert(0, mi);
                    }
                }

                parent = mi.DropDownItems;
            }

            if (item.ToolExt != null)
            {
                LoadFileWrappersExt.SetShurtcutKey(item, item.ToolExt.Shortcut);
                item.Image = item.ToolExt.Icon;
                //item.ToolTipText = item.ToolExt.ToString();
            }

            parent.Add(item);
            ev += new SimPe.Events.ChangedResourceEvent(item.ChangeEnabledStateEventHandler);
            item.ChangeEnabledStateEventHandler(item, new SimPe.Events.ResourceEventArgs(null));
        }