public void copyItmesCtlRemoved(object sender, CopyItems ci) { CopyItemsCtl cic = (CopyItemsCtl)sender; copyItemsflwLytPnl.Controls.Remove(cic); copyItemsList.Remove(ci); }
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; }
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; } }