Esempio n. 1
0
        private void iconPack_OperationCompleted(object sender, IconLoadedEventArgs e)
        {
            int j = 0;

            for (int i = 0; i < this.mainToolStrip.Items.Count; i++)
            {
                if (this.mainToolStrip.Items[i] is ToolStripSeparator)
                {
                    continue;
                }

                this.mainToolStrip.Items[i].Image = e.Image[j++];
            }
        }
Esempio n. 2
0
        public IconPack LoadFromFile(String filename)
        {
            try
            {
                string preview = Directory.GetFiles(filename + "\\Preview")[0];
                this.Image = new Bitmap(preview);
            }
            catch
            {
                return(null);
            }

            this.Filename = filename;

            string xmlFile = filename + "\\" + filename.Substring(filename.LastIndexOf('\\')) + ".xml";

            if (File.Exists(xmlFile))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(xmlFile);

                XmlReaderSettings settings = new XmlReaderSettings();

                this.Name = doc.DocumentElement.Name;

                this.Version = doc.DocumentElement.Attributes["Version"].Value;
                this.Author  = doc.DocumentElement.Attributes["Author"].Value;

                this.Description = doc.SelectSingleNode(this.Name + "/Description").InnerText;
                XmlNode tagNode = doc.SelectSingleNode(this.Name + "/Tags");

                String authorLink = tagNode.SelectSingleNode("AuthorLink").InnerText;
                String credits    = tagNode.SelectSingleNode("Credits").InnerText;

                this.Tag = new Tag()
                {
                    AuthorLink = authorLink, Credits = credits
                };

                foreach (XmlNode node in doc.SelectNodes(this.Name + "/Icon"))  //XPath
                {
                    string Key      = node.SelectSingleNode("Key").InnerText.ToLower();
                    string FullName = node.SelectSingleNode("FullName").InnerText;

                    if (File.Exists(string.Concat(Filename, "\\", FullName)))
                    {
                        Image image = new Bitmap(string.Concat(Filename, "\\", FullName));
                        icons.Add(image);
                    }
                }

                IconLoadedEventArgs ile = new IconLoadedEventArgs(icons);

                if (OperationCompleted != null)
                {
                    OperationCompleted(this, ile);
                }
            }

            return(this);
        }