Ejemplo n.º 1
0
        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent;
            ItemsTree   itemsTree  = (ItemsTree)ParentForm.Controls.Find("itemsTree1", true).GetValue(0);

            if (e.Button == MouseButtons.Left)
            {
                ListView lv = (ListView)sender;

                int idx = lv.SelectedIndices[0];
                if (idx < 0 || idx > lv.Items.Count - 1)
                {
                    return;
                }

                if (lv.Items[0].Text == "[...]")
                {
                    if (idx == 0)
                    {
                        LoadDirectory((string)lv.Items[0].Name);
                    }
                    else
                    {
                        idx -= 1;
                        items[idx].OnClick(lv, LoadDirectory);
                    }
                }
                else
                {
                    items[idx].OnClick(lv, LoadDirectory);
                }
            }
        }
Ejemplo n.º 2
0
        private void RightHoldEvent()
        {
            List <Item> temp = new List <Item>();

            temp = selectedItems.Values.ToList();

            ShellContextMenu shellcontextmenu = new ShellContextMenu();

            List <DirectoryInfo> dir = new List <DirectoryInfo>();
            List <FileInfo>      fi  = new List <FileInfo>();


            List <Item> items = selectedItems.Values.ToList();

            try
            {
                if (items.Count == 0)
                {
                    if (GetCurrentSelectedItem() != null)
                    {
                        if (listView1.SelectedItems.GetType() == typeof(MyFile))
                        {
                            fi.Add(new FileInfo(GetCurrentSelectedItem().strParentPath + GetCurrentSelectedItem().StrName + GetCurrentSelectedItem().StrExt));
                        }
                        else
                        {
                            dir.Add(new DirectoryInfo((GetCurrentSelectedItem().strParentPath + (GetCurrentSelectedItem().StrName + "\\"))));
                        }
                    }
                    else
                    {
                        ItemsViewer     ParentForm = (ItemsViewer)this.Parent.Parent.Parent;
                        DirectoryInfo[] temp1      = new DirectoryInfo[1];
                        temp1[0] = new DirectoryInfo(ParentForm.StrCurrentPath);
                        shellcontextmenu.ShowContextMenu(temp1, MousePosition);
                    }
                }
                else
                {
                    foreach (Item i in items)
                    {
                        if (i.GetType() == typeof(MyFile))
                        {
                            fi.Add(new FileInfo(i.strParentPath + i.StrName + i.StrExt));
                        }
                        else
                        {
                            dir.Add(new DirectoryInfo(i.strParentPath + i.StrName + "\\"));
                        }
                    }
                }
                shellcontextmenu.ShowContextMenu(fi.ToArray(), dir.ToArray(), MousePosition);
            }
            catch { }
        }
Ejemplo n.º 3
0
 public string Next(ItemsViewer us)
 {
     if (listFoward.Count != 0)
     {
         string res = listFoward[listFoward.Count() - 1];
         listBack.Add(us.StrCurrentPath);
         listFoward.RemoveAt(listFoward.Count() - 1);
         return(res);
     }
     return(null);
 }
Ejemplo n.º 4
0
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(Tuple <List <Item>, string>)))
            {
                Tuple <List <Item>, string> temp = (Tuple <List <Item>, string>)e.Data.GetData(typeof(Tuple <List <Item>, string>));

                ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent;

                frmCopy cpy = new frmCopy(temp.Item1, ParentForm.StrCurrentPath);
                cpy.ShowDialog();
            }
        }
Ejemplo n.º 5
0
        public frmSearch(string strPath, ItemsViewer List)
        {
            InitializeComponent();

            LanguageChange();

            Init();
            listView1.DoubleBuffered(true);
            tbPath.Text = strPath;
            parenList   = List;

            HideBottomPanel();
        }
Ejemplo n.º 6
0
        public void LoadDirectory(string Path)
        {
            //Kiem tra su thay doi ve cac item trong duong dan



            ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent;

            if (Path != "")
            {
                fileSystemWatcher1.Path = Path.Substring(0, 3);

                if (new DirectoryInfo(Path).Exists == false)
                {
                    //LoadDirectory( Path.Substring(0, 3));

                    ParentForm.history.CancelNextAdd();
                    ParentForm.history.CancelFowardClear();

                    string tempPath = Path.Split(new string[] { "\\" }, StringSplitOptions.None)[0] + "\\";
                    for (int i = 1; i < Path.Split(new string[] { "\\" }, StringSplitOptions.None).Length - 2; i++)
                    {
                        tempPath += ParentForm.StrCurrentPath.Split(new string[] { "\\" }, StringSplitOptions.None)[i] + "\\";
                    }
                    LoadDirectory(tempPath);

                    return;
                }
            }

            ItemsTree itemsTree = (ItemsTree)ParentForm.Controls.Find("itemsTree1", true).GetValue(0);


            listView1.Items.Clear();
            PopulateItems(listView1, Path);

            ParentForm.history.InsertDirectoryToListBack(ParentForm.StrCurrentPath);

            ParentForm.SelectDriveFromDirectory(Path);
            itemsTree.SelectNodeFormDirectory(Path);

            ParentForm.StrCurrentPath = Path;
            ParentForm.SetAddressLabel(Path);



            selectedItems.Clear();
            UpdateItemsCount();
        }
        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeView tv = (TreeView)sender;

            ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent;
            ItemsList   itemslist  = (ItemsList)ParentForm.Controls.Find("itemsList1", true).GetValue(0);

            if (new DirectoryInfo(tv.SelectedNode.Tag.ToString()).Exists == false)
            {
                tv.SelectedNode.Remove();
                return;
            }

            itemslist.LoadDirectory(tv.SelectedNode.Tag.ToString());
        }
Ejemplo n.º 8
0
        internal void ReloadItems()
        {
            ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent;

            listView1.Items.Clear();


            ParentForm.history.CancelNextAdd();
            ParentForm.history.CancelFowardClear();

            Dictionary <int, Item> tempSelectedItems = new Dictionary <int, Item>(selectedItems);

            LoadDirectory(ParentForm.StrCurrentPath);

            selectedItems = tempSelectedItems;

            ReselectItems();
        }
Ejemplo n.º 9
0
        internal void NewFolderInCurrentPath()
        {
            var a = Microsoft.VisualBasic.Interaction.InputBox(MultiLanguage.GetText("new_folder_text"), MultiLanguage.GetText("folder_name_text"), MultiLanguage.GetText("name_text"));

            if (a != "")
            {
                ItemsViewer   ParentForm = (ItemsViewer)this.Parent.Parent.Parent;
                DirectoryInfo temp       = new DirectoryInfo(ParentForm.StrCurrentPath + a + "\\");
                if (temp.Exists == true)
                {
                    MessageBox.Show(MultiLanguage.GetText("folder_exist"), MultiLanguage.GetText("error_text"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    temp.Create();
                    ReloadItems();
                }
            }
        }
Ejemplo n.º 10
0
        internal void RenameFocusItem()
        {
            Demo4.Item temp = this.GetCurrentSelectedItem();
            if (temp != null) //Rename item dang duoc focus
            {
                var a = Microsoft.VisualBasic.Interaction.InputBox(MultiLanguage.GetText("btnRename_text"), MultiLanguage.GetText("NewName_text"), temp.StrName + temp.StrExt);

                if (a != "")
                {
                    ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent;

                    if (temp.GetType() == typeof(MyFile))
                    {
                        if (new FileInfo(ParentForm.StrCurrentPath + a).Exists == true)
                        {
                            MessageBox.Show(MultiLanguage.GetText("file_exist"), MultiLanguage.GetText("error_text"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            new FileInfo(ParentForm.StrCurrentPath + temp.StrName + temp.StrExt).MoveTo(ParentForm.StrCurrentPath + a);
                        }
                    }
                    else
                    {
                        if (new DirectoryInfo(ParentForm.StrCurrentPath + a + "\\").Exists == true)
                        {
                            MessageBox.Show(MultiLanguage.GetText("folder_exist"), MultiLanguage.GetText("error_text"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            new DirectoryInfo(ParentForm.StrCurrentPath + temp.StrName + "\\").MoveTo(ParentForm.StrCurrentPath + a + "\\");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show(MultiLanguage.GetText("no_item_selected"), MultiLanguage.GetText("error_text"), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 11
0
        public void UpdateItemsCount()
        {
            int  nFiles = 0, nDirectory = 0;
            long nSize = 0;
            int  iFiles = 0, iDirectory = 0;
            long selectedSize = 0;

            foreach (Item i in items)
            {
                if (i.GetType() == typeof(MyFile))
                {
                    nFiles++;
                    nSize += long.Parse(i.StrSize);
                }
                else
                {
                    nDirectory++;
                }
            }

            foreach (Item i in selectedItems.Values.ToList())
            {
                if (i.GetType() == typeof(MyFile))
                {
                    selectedSize += long.Parse(i.StrSize);
                    iFiles++;
                }
                else
                {
                    iDirectory++;
                }
            }

            ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent;

            ParentForm.SetFileCount(iFiles, nFiles, iDirectory, nDirectory, selectedSize, nSize);
        }
Ejemplo n.º 12
0
        private void listView1_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            ItemsViewer ParentForm = (ItemsViewer)this.Parent.Parent.Parent;

            switch (e.Column)
            {
            case 0:
            {
                if (listView1.Columns[e.Column].ImageKey == "ASCIcon")
                {
                    ClearAllHeaderImg(listView1);
                    listView1.Columns[e.Column].ImageKey = "DESCIcon";
                    SortIdx = (int)SortBy.NameDESC;
                    listView1.Items.Clear();
                    PopulateItems(listView1, ParentForm.StrCurrentPath);
                }
                else
                {
                    ClearAllHeaderImg(listView1);
                    listView1.Columns[e.Column].ImageKey = "ASCIcon";
                    SortIdx = (int)SortBy.NameASC;
                    listView1.Items.Clear();
                    PopulateItems(listView1, ParentForm.StrCurrentPath);
                }
                ReselectItems();
                break;
            }

            case 1:
            {
                if (listView1.Columns[e.Column].ImageKey == "ASCIcon")
                {
                    ClearAllHeaderImg(listView1);
                    listView1.Columns[e.Column].ImageKey = "DESCIcon";
                    SortIdx = (int)SortBy.ExtDESC;
                    listView1.Items.Clear();
                    PopulateItems(listView1, ParentForm.StrCurrentPath);
                }
                else
                {
                    ClearAllHeaderImg(listView1);
                    listView1.Columns[e.Column].ImageKey = "ASCIcon";
                    SortIdx = (int)SortBy.ExtASC;
                    listView1.Items.Clear();
                    PopulateItems(listView1, ParentForm.StrCurrentPath);
                }
                ReselectItems();
                break;
            }

            case 2:
            {
                if (listView1.Columns[e.Column].ImageKey == "ASCIcon")
                {
                    ClearAllHeaderImg(listView1);
                    listView1.Columns[e.Column].ImageKey = "DESCIcon";
                    SortIdx = (int)SortBy.SizeDESC;
                    listView1.Items.Clear();
                    PopulateItems(listView1, ParentForm.StrCurrentPath);
                }
                else
                {
                    ClearAllHeaderImg(listView1);
                    listView1.Columns[e.Column].ImageKey = "ASCIcon";
                    SortIdx = (int)SortBy.SizeASC;
                    listView1.Items.Clear();
                    PopulateItems(listView1, ParentForm.StrCurrentPath);
                }
                ReselectItems();
                break;
            }

            case 3:
            {
                if (listView1.Columns[e.Column].ImageKey == "ASCIcon")
                {
                    ClearAllHeaderImg(listView1);
                    listView1.Columns[e.Column].ImageKey = "DESCIcon";
                    SortIdx = (int)SortBy.DateDESC;
                    listView1.Items.Clear();
                    PopulateItems(listView1, ParentForm.StrCurrentPath);
                }
                else
                {
                    ClearAllHeaderImg(listView1);
                    listView1.Columns[e.Column].ImageKey = "ASCIcon";
                    SortIdx = (int)SortBy.DateASC;
                    listView1.Items.Clear();
                    PopulateItems(listView1, ParentForm.StrCurrentPath);
                }
                ReselectItems();
                break;
            }
            }
        }