Exemple #1
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())
                 });
             }
         }
     }
 }
Exemple #2
0
        private void add(string namep, string linkp)
        {
            XmlDocument xml = new XmlDocument();

            xml.Load(AppDomain.CurrentDomain.BaseDirectory + "config.xml");
            XmlNode    root     = xml.SelectSingleNode("programs");
            XmlElement program  = xml.CreateElement("program");
            XmlElement name     = xml.CreateElement("name");
            XmlElement link     = xml.CreateElement("link");
            XmlElement pingying = xml.CreateElement("pinying");

            name.InnerText     = namep;
            link.InnerText     = linkp;
            pingying.InnerText = PinYing.LineStr(namep);
            program.AppendChild(name);
            program.AppendChild(pingying);
            program.AppendChild(link);
            root.AppendChild(program);
            xml.Save(AppDomain.CurrentDomain.BaseDirectory + "config.xml");
        }