protected override void OnDropDownOpening(EventArgs e) { if (!this.toolsListInit) { this.DropDownItems.Clear(); this.DropDownItems.Add(this.menuToolsAntialiasing); this.DropDownItems.Add(this.menuToolsAlphaBlending); this.DropDownItems.Add(this.menuToolsSeperator); foreach (ToolInfo toolInfo in DocumentWorkspace.ToolInfos) { PdnMenuItem mi = new PdnMenuItem(toolInfo.Name, null, this.menuTools_ClickHandler); mi.SetIcon(toolInfo.Image); mi.Tag = toolInfo; this.DropDownItems.Add(mi); } this.toolsListInit = true; } Type currentToolType; if (AppWorkspace.ActiveDocumentWorkspace != null) { currentToolType = AppWorkspace.ActiveDocumentWorkspace.GetToolType(); } else { currentToolType = null; } foreach (ToolStripItem tsi in this.DropDownItems) { PdnMenuItem mi = tsi as PdnMenuItem; if (mi != null) { ToolInfo toolInfo = mi.Tag as ToolInfo; if (toolInfo != null) { if (toolInfo.ToolType == currentToolType) { mi.Checked = true; } else { mi.Checked = false; } } } } this.menuToolsAntialiasing.Checked = AppWorkspace.AppEnvironment.AntiAliasing; this.menuToolsAlphaBlending.Checked = AppWorkspace.AppEnvironment.AlphaBlending; base.OnDropDownOpening(e); }
public void LoadIcons() { foreach (FieldInfo info in base.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { if (info.FieldType.IsSubclassOf(typeof(PdnMenuItem)) || (info.FieldType == typeof(PdnMenuItem))) { char ch = info.Name[0]; string fileName = "Icons." + ch.ToString().ToUpper() + info.Name.Substring(1) + "Icon.png"; PdnMenuItem item = (PdnMenuItem)info.GetValue(this); Stream stream = PdnResources.CreateResourceStream(fileName); if (stream != null) { stream.Dispose(); item.SetIcon(fileName); } } } this.iconsLoaded = true; }