public void LoadIcons() { Type ourType = this.GetType(); FieldInfo[] fields = ourType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (FieldInfo fi in fields) { if (fi.FieldType.IsSubclassOf(typeof(PdnMenuItem)) || fi.FieldType == typeof(PdnMenuItem)) { string iconFileName = "Icons." + fi.Name[0].ToString().ToUpper() + fi.Name.Substring(1) + "Icon.png"; PdnMenuItem mi = (PdnMenuItem)fi.GetValue(this); Stream iconStream = PdnResources.GetResourceStream(iconFileName); if (iconStream != null) { iconStream.Dispose(); mi.SetIcon(iconFileName); } else { Tracing.Ping(iconFileName + " not found"); } } } this.iconsLoaded = true; }
protected virtual void OnAppWorkspaceChanged() { foreach (ToolStripItem item in this.DropDownItems) { PdnMenuItem asPMI = item as PdnMenuItem; if (asPMI != null) { asPMI.AppWorkspace = AppWorkspace; } } }
public void LoadNames(string baseName) { foreach (ToolStripItem item in this.DropDownItems) { string itemNameBase = baseName + "." + item.Name; string itemNameText = itemNameBase + ".Text"; string text = PdnResources.GetString(itemNameText); if (text != null) { item.Text = text; } PdnMenuItem pmi = item as PdnMenuItem; if (pmi != null) { pmi.textResourceName = itemNameText; pmi.LoadNames(itemNameBase); } } this.namesLoaded = true; }