コード例 #1
0
ファイル: Form1.cs プロジェクト: avrhama/CopyManager
 public void copyItmesCtlClicked(object sender, CopyItems ci)
 {
     //seems silly[not efficient] that the function's resposability is to call to another function.
     //but i dont know yet if in the future i would like to excute displayCopiedFiles's procedure from another place.
     displayCopiedFiles(ci);
     selectedCopyItemsCtl = (CopyItemsCtl)sender;
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: avrhama/CopyManager
        public void copyItmesCtlRemoved(object sender, CopyItems ci)
        {
            CopyItemsCtl cic = (CopyItemsCtl)sender;

            copyItemsflwLytPnl.Controls.Remove(cic);
            copyItemsList.Remove(ci);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: avrhama/CopyManager
        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();
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: avrhama/CopyManager
        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;
            }
        }
コード例 #5
0
ファイル: CopyItems.cs プロジェクト: avrhama/CopyManager
        public override bool Equals(object obj)
        {
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }

            CopyItems cis = (CopyItems)obj;

            if (cis.count() != count())
            {
                return(false);
            }
            foreach (CopyItem ci in cis.items)
            {
                if (!items.Contains(ci))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #6
0
 public CopyItemsCtl(CopyItems ci)
 {
     InitializeComponent();
     this.copyItems = ci;
     config();
 }