示例#1
0
        public int loadXML()
        {
            string filePath = AppDomain.CurrentDomain.BaseDirectory + "config.xml";

            if (!File.Exists(filePath))
            {
                FileStream fs     = new FileStream(filePath, FileMode.CreateNew, FileAccess.Write);
                byte[]     buffer = System.Text.Encoding.UTF8.GetBytes(Kindle_Quick.Properties.Resources.config);
                fs.Write(buffer, 0, buffer.Length);
                fs.Close();
            }
            int         countPrograms = 0;
            XmlDocument xml           = new XmlDocument();

            xml.Load(filePath);
            autoCompletionList.Clear();
            XmlNode     allpeople = xml.SelectSingleNode("programs");
            XmlNodeList xpeople   = allpeople.ChildNodes;

            foreach (XmlNode xnf in xpeople)
            {
                XmlElement  xe   = (XmlElement)xnf;
                XmlNodeList xnf1 = xe.ChildNodes;
                if (File.Exists(xnf1[2].InnerText))
                {
                    autoCompletionList.Add(new Program {
                        Name = xnf1[0].InnerText.ToString(), PingYing = xnf1[1].InnerText, Link = xnf1[2].InnerText, Icon = IconToBitmap.ToBitmapSource(System.Drawing.Icon.ExtractAssociatedIcon(xnf1[2].InnerText).ToBitmap())
                    });
                    countPrograms++;
                }
            }
            return(countPrograms);
        }
示例#2
0
 private void WindowMain_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop, false))
     {
         String[] files = (String[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop);
         foreach (string s in files)
         {
             if (System.IO.File.Exists(s))
             {
                 string fileName = s.Substring(s.LastIndexOf(@"\") + 1, s.LastIndexOf(".") - s.LastIndexOf(@"\") - 1);
                 add(fileName, s);
                 autoCompletionList.Add(new Program {
                     Name = fileName, PingYing = PinYing.LineStr(fileName), Link = s, Icon = IconToBitmap.ToBitmapSource(System.Drawing.Icon.ExtractAssociatedIcon(s).ToBitmap())
                 });
             }
         }
     }
 }