Ejemplo n.º 1
0
        private void Listbox_Catalog_Down(object sender, SelectionChangedEventArgs e)
        {
            if (Listbox.SelectedIndex == -1)
            {
                return;
            }
            string st_path = Listbox_infos[Listbox.SelectedIndex]._path;

            if (!Listbox_infos[Listbox.SelectedIndex].IsRoot)
            {
                if (System.IO.File.Exists(st_path))
                {
                    BitmapSource icon_image; myicon micon = new myicon();
                    icon_image = (BitmapSource)micon.GetIcon(st_path, false, false);
                    FileInfo fInfor = new FileInfo(st_path);
                    this.FileBox_infos.Add((new my_class.File()
                    {
                        Pic = icon_image, _filetype = FileAttributes.ReadOnly, FileName = fInfor.Name
                    }));
                }
            }
            else
            {
                if (System.IO.Directory.Exists(st_path))
                {
                    AddFileBox(st_path);
                    s_path = st_path;
                }
                else
                {
                    Listbox_infos.RemoveAt(Listbox.SelectedIndex);
                }
            }
        }
Ejemplo n.º 2
0
        private void AddFileBox(string sc_path)
        {
            FileBox_infos.Clear();
            BitmapSource  icon_image; myicon micon = new myicon();
            DirectoryInfo TheFolder = new DirectoryInfo(sc_path);

            foreach (DirectoryInfo NextFolder in TheFolder.GetDirectories())
            {
                icon_image = (BitmapSource)micon.GetIcon(sc_path + "\\" + NextFolder.Name, false, true);
                this.FileBox_infos.Add((new my_class.File()
                {
                    Pic = icon_image, _filetype = FileAttributes.Directory, FileName = NextFolder.Name
                }));
            }
            foreach (FileInfo NextFile in TheFolder.GetFiles())
            {
                icon_image = (BitmapSource)micon.GetIcon(sc_path + "\\" + NextFile.Name, false, false);
                this.FileBox_infos.Add((new my_class.File()
                {
                    Pic = icon_image, _filetype = FileAttributes.ReadOnly, FileName = NextFile.Name
                }));
            }
        }
Ejemplo n.º 3
0
        private void MainWindow_drop(object sender, DragEventArgs e)
        {
            try
            {
                string   filePath = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
                FileInfo fInfor   = new FileInfo(filePath);
                if (fInfor.Extension == ".lnk")
                {
                    filePath = inktopath(filePath);
                    fInfor   = new FileInfo(filePath);
                }
                if (fInfor.Attributes == FileAttributes.Directory)//文件夹
                {
                    foreach (var item in Listbox_infos)
                    {
                        if (item.Name == fInfor.Name)
                        {
                            return;
                        }
                    }
                    Catalog tmp_catalog = new Catalog()
                    {
                        IsRoot = true, _path = filePath, Name = fInfor.Name
                    };
                    Listbox_infos.Add(tmp_catalog);
                    Listbox.SelectedIndex = Listbox_infos.Count - 1;
                    s_path = filePath;
                    //MessageBox.Show("是文件夹");
                }
                else//文件
                {
                    foreach (var item in FileBox_infos)
                    {
                        if (item.FileName == fInfor.Name)
                        {
                            return;
                        }
                    }

                    var t_window = new tool_window();
                    t_window.Top  = Top + Height / 2 - t_window.Height / 2;
                    t_window.Left = Left + Width / 2 - t_window.Width / 2;
                    foreach (var item in Listbox_infos)
                    {
                        if (!item.IsRoot)
                        {
                            t_window.tlist.Add(new tool_list()
                            {
                                Name = item.Name
                            });
                        }
                    }
                    t_window.ShowDialog();
                    //Console.WriteLine(t_window.result);
                    //  t_window.result;

                    bool bisName = false;
                    foreach (var item in Listbox_infos)
                    {
                        if (item.IsRoot)
                        {
                            continue;
                        }
                        if (item.Name == t_window.result)
                        {
                            bisName = true;
                            break;
                        }
                    }

                    if (bisName)
                    {
                        //存在这个目录
                        BitmapSource icon_image; myicon micon = new myicon();
                        icon_image = (BitmapSource)micon.GetIcon(filePath, false, false);

                        FileBox_infos.Add(new my_class.File()
                        {
                            Pic = icon_image, _filetype = FileAttributes.ReadOnly, FileName = fInfor.Name
                        });
                    }
                    else
                    {
                        Listbox_infos.Add(new Catalog()
                        {
                            IsRoot = false, _path = filePath, Name = t_window.result
                        });
                        Listbox.SelectedIndex = Listbox_infos.Count - 1;
                    }
                    //BitmapSource icon_image; myicon micon = new myicon();
                    //icon_image = (BitmapSource)micon.GetIcon(filePath, false, false);

                    //my_class.File Tmpfile = new my_class.File() { Pic = icon_image, _filetype = fInfor.Attributes, FileName = fInfor.Name };
                    //FileBox_infos.Add(Tmpfile);
                    // MessageBox.Show(fInfor.Name.Split('.')[0]);
                }
            }
            catch { }
            {
                return;
            }
        }