Exemple #1
0
        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;
        }
Exemple #2
0
        protected virtual void OnAppWorkspaceChanged()
        {
            foreach (ToolStripItem item in this.DropDownItems)
            {
                PdnMenuItem asPMI = item as PdnMenuItem;

                if (asPMI != null)
                {
                    asPMI.AppWorkspace = AppWorkspace;
                }
            }
        }
Exemple #3
0
        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;
        }