Пример #1
0
        private void newFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListView    lv  = currentListView;
            ListViewTag lvt = (ListViewTag)lv.Tag;

            PopupTextEntry popup = new PopupTextEntry();

            popup.Text = "Enter Folder Name";
            popup.setTextBoxText("New Folder");
            if (popup.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            DockedItem folder = new DockedItem(popup.getTextBoxText());

            Image di = Properties.Resources.defaultIcon;

            setDockedItemImage(di, folder);

            folder.folder = true;

            lvt.item.docklist.Add(folder);

            Save(lv);
        }
Пример #2
0
        private void ListView_DragDrop(object sender, DragEventArgs e)
        {
            ListView    lv  = (ListView)sender;
            ListViewTag lvt = (ListViewTag)lv.Tag;

            string[] file = {};

            DockedItem item = new DockedItem();
            FileInfo   fi;

            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                file = (string[])e.Data.GetData(DataFormats.FileDrop);
            }

            foreach (string str in file)
            {
                item.path = str;
                Image img = Icon.ExtractAssociatedIcon(str).ToBitmap();
                setDockedItemImage(img, item);

                fi        = new FileInfo(str);
                item.name = fi.Name;

                if (lv == lvRoot)
                {
                    dockTree.Insert(dockTree.Count, item);
                }
                else
                {
                    lvt.item.Add(item);
                }
            }
            Save(lv);
        }
Пример #3
0
        private void ListView_ItemActivate(object sender, EventArgs e)
        {
            ListView     lv   = (ListView)sender;
            ListViewTag  lvt  = (ListViewTag)lv.Tag;
            ListViewItem lvi  = lv.SelectedItems[0];
            ListViewTag  lvit = (ListViewTag)lvi.Tag;

            if (lvit.item.folder == false)
            {
                try
                {
                    // Attempt to run the file
                    Console.Write("\nrunning " + lvit.item.path);
                    System.Diagnostics.Process.Start(lvit.item.path);
                }
                catch
                {
                    Console.Write("\ncould not open file\n");
                    return;
                }
            }
            else             // Make a new listview and display it
            // Might write a method for this?
            {
                if ((ListView)((ListViewTag)lv.Tag).subListView != null)
                {
                    cleanTree((ListView)((ListViewTag)lv.Tag).subListView);
                }

                // Create the new list view
                ListView subListView = new ListView();

                subListView.Size             = lv.Size;
                subListView.View             = lv.View;
                subListView.SmallImageList   = lv.SmallImageList;
                subListView.LargeImageList   = lv.LargeImageList;
                subListView.Activation       = lv.Activation;
                subListView.AllowDrop        = lv.AllowDrop;
                subListView.ContextMenuStrip = lv.ContextMenuStrip;

                subListView.OwnerDraw = true; // Allows custom drawing of items

                subListView.Tag = new ListViewTag(lvit.item);

                // Appearance
                subListView.BackColor   = lv.BackColor;
                subListView.Font        = lv.Font;
                subListView.ForeColor   = lv.ForeColor;
                subListView.BorderStyle = lv.BorderStyle;

                // Add necessary events
                subListView.ItemActivate += new System.EventHandler(this.ListView_ItemActivate);
                subListView.DragDrop     += new System.Windows.Forms.DragEventHandler(this.ListView_DragDrop);
                subListView.DragEnter    += new System.Windows.Forms.DragEventHandler(this.ListView_DragEnter);
                subListView.MouseClick   += new System.Windows.Forms.MouseEventHandler(this.ListView_MouseClick);
                subListView.MouseUp      += new System.Windows.Forms.MouseEventHandler(this.ListView_MouseClick);
                subListView.DrawItem     += new DrawListViewItemEventHandler(ListView_DrawItem);

                lvt.subListView = subListView;
                this.Controls.Add(subListView);

                PaintListView(subListView);
                PositionWindow();
            }
        }