Exemple #1
0
        public void displayCopiedFiles(CopyItems cis)
        {
            listView1.Clear();
            imageList1.Images.Clear();

            ListViewItem item;

            listView1.BeginUpdate();
            string key;

            for (int i = 0; i < cis.count(); i++)
            {
                CopyItem ci   = cis.get(i);
                string   path = ci.Path;
                if (ci.isFile)
                {
                    System.IO.FileInfo file = new System.IO.FileInfo(path);
                    key = file.Extension;
                    if (key == ".lnk")
                    {
                        key = file.Name + key;
                    }
                }
                else
                {
                    key = path;
                }
                // Set a default icon for the file.
                Icon iconForFile = SystemIcons.WinLogo;

                //item = new ListViewItem(file.Name, 1);
                item = new ListViewItem(ci.Name, 1);
                // Check to see if the image collection contains an image
                // for this extension, using the extension as a key.
                if (!imageList1.Images.ContainsKey(key))
                {
                    // If not, add the image to the image list.
                    if (ci.isFile)
                    {
                        iconForFile = System.Drawing.Icon.ExtractAssociatedIcon(path);
                    }
                    else
                    {
                        iconForFile = ExtractFromPath(path);
                    }


                    imageList1.Images.Add(key, iconForFile);
                }
                item.ImageKey = key;
                item.Name     = path;
                listView1.Items.Add(item);
            }
            listView1.EndUpdate();
        }
Exemple #2
0
        public void getData()
        {
            if (Clipboard.ContainsFileDropList())
            {
                //copy items collection.
                CopyItems cis = new CopyItems();
                cis.CopiedDate = DateTime.Now;

                List <string> paths = Clipboard.GetFileDropList().Cast <string>().ToList();
                foreach (string path in paths)
                {
                    System.IO.FileAttributes attr = System.IO.File.GetAttributes(path);
                    CopyItem ci;
                    //detect whether its a directory or file
                    if ((attr & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory)
                    {
                        writeLog(path);
                        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
                        ci = new CopyItem(path, di.Name, false);
                    }
                    else
                    {
                        writeLog(path);
                        System.IO.FileInfo fi = new System.IO.FileInfo(path);

                        ci = new CopyItem(path, fi.Name);
                    }

                    cis.add(ci);
                }
                //fi.Attributes.
                //avoid duplicates copies.
                if (!copyItemsList.Contains(cis))
                {
                    copyItemsList.Add(cis);
                    //creating copyItems control and add it to the copyItems panel control.
                    CopyItemsCtl cic = new CopyItemsCtl(cis);
                    //register to copyItemsCtl click event.
                    cic.ClickEventHandler += copyItmesCtlClicked;
                    //register to copyItemsCtl remove event.
                    cic.RemoveEventHandler += copyItmesCtlRemoved;
                    copyItemsflwLytPnl.Controls.Add(cic);
                }
                tabControl1.SelectedIndex = 0;
            }
            else if (Clipboard.ContainsText())
            {
                CopyText ct = new CopyText(Clipboard.GetText());
                if (!copiedTextsListBox.Items.Contains(ct))
                {
                    copiedTextsListBox.Items.Add(ct);
                }
                tabControl1.SelectedIndex = 1;
            }
        }
Exemple #3
0
        public void remove(string path)
        {
            CopyItem ci = null;

            foreach (CopyItem c in items)
            {
                if (path == c.Path)
                {
                    ci = c;
                }
            }
            items.Remove(ci);
        }
Exemple #4
0
 public void remove(CopyItem ci)
 {
     items.Remove(ci);
 }
Exemple #5
0
 public void add(CopyItem ci)
 {
     items.Add(ci);
 }