Example #1
0
        public static void SelectPPT(string filepath)
        {
            if (f12 != null)
            {
                Log.Info("Form1.SelectPPT.addFile: " + filepath);
                f12.AddFile(filepath, false);
            }
            else
            {
                Log.Info("Form1.SelectPPT. new Form12()/addFile: " + filepath);
                MovingDisk    mdisk   = new MovingDisk();
                List <string> strList = new List <string>();
                try
                {
                    DriveInfo[] drives = mdisk.GetUSBDiskList();
                    foreach (DriveInfo drive in drives)
                    {
                        if ((drive.DriveType == DriveType.Removable) && !drive.Name.Substring(0, 1).Equals("A"))
                        {
                            try
                            {
                                if (!strList.Contains(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory))
                                {
                                    strList.Add(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory);
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                    f12 = new Form12(strList);
                    f12.AddFile(filepath, false);

                    f12.ShowInTaskbar = false;
                    f12.WindowState   = FormWindowState.Minimized;
                    f12.Hide();
                    f12.Visible = false;
                }
                catch (Exception ex)
                {
                    string ss = ex.Message;
                }
            }
        }
Example #2
0
        protected override void WndProc(ref Message m)
        {
            int mess = mdisk.MessageResult(m);

            if (mess == 1)
            {
                try
                {
                    DriveInfo[] drives = mdisk.GetUSBDiskList();
                    foreach (DriveInfo drive in drives)
                    {
                        if ((drive.DriveType == DriveType.Removable) && !drive.Name.Substring(0, 1).Equals("A"))
                        {
                            try
                            {
                                if (!strList.Contains(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory))
                                {
                                    strList.Add(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory);
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }

                    if (f12 == null)
                    {
                        f12 = new Form12(strList);
                    }
                    else
                    {
                        f12.UpdateForm(strList, f12.Visible);
                    }
                }
                catch (Exception ex)
                {
                    string ss = ex.Message;
                }
            }
            if (mess == 2)
            {
                if (f12 != null)
                {
                    List <string> removelist = new List <string>(strList.ToArray());
                    strList.Clear();
                    DriveInfo[] drives = mdisk.GetUSBDiskList();
                    int         i      = 0;
                    foreach (DriveInfo drive in drives)
                    {
                        if ((drive.DriveType == DriveType.Removable) && !drive.Name.Substring(0, 1).Equals("A"))
                        {
                            try
                            {
                                if (!strList.Contains(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory))
                                {
                                    strList.Add(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory);
                                }
                                DelStrList(drive.Name + "|" + drive.VolumeLabel + "|" + drive.RootDirectory, removelist);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                    f12.Hide();
                    f12.removeUSBFile(removelist);
                    f12.UpdateForm(strList, false);
                }
            }
            base.WndProc(ref m);
        }