/// <summary> /// method for insert files /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MenuInsert_Click(object sender, RoutedEventArgs e) { ListViewItem item = (ListViewItem)this.LVInfo.SelectedItem; if (item != null) { try { DirectoryInfo dir = (DirectoryInfo)item.Tag; this.copyContent.In = dir.Parent; } catch (Exception ex) { FileInfo file = (FileInfo)item.Tag; this.copyContent.In = file.Directory; } } else { this.copyContent.In = this.saveRott; } var answer = MessageBox.Show("Are you sure you want to copy this content?", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Question); if (answer == MessageBoxResult.Yes) { WInProgressBar pb = new WInProgressBar(); MediatorProgressBar.ActCopy(this.copyContent); MediatorProgressBar.Root(this.saveRott); pb.Show(); } }
/// <summary> /// method for delete files /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MenuDelete_Click(object sender, RoutedEventArgs e) { if (this.LVInfo.SelectedIndex == -1) { return; } List <DirectoryInfo> content = new List <DirectoryInfo>(); foreach (ListViewItem item in this.LVInfo.SelectedItems) { try { DirectoryInfo dir = (DirectoryInfo)item.Tag; content.Add(dir); } catch (Exception ex) { FileInfo file = (FileInfo)item.Tag; content.Add(new DirectoryInfo(file.FullName)); } } MessageBoxResult answer = new MessageBoxResult(); answer = MessageBox.Show("Are you sure you want to delete this content?", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Question); if (answer == MessageBoxResult.Yes) { WInProgressBar pb = new WInProgressBar(); MediatorProgressBar.Items(content, true); MediatorProgressBar.Root(this.saveRott); this.element.DeletePath(content); pb.ShowDialog(); this.view[this.indexView](this.saveRott, null); } }
/// <summary> /// method for change file /// </summary> /// <param name="files"></param> /// <param name="newPath"></param> /// <param name="parent"></param> /// <param name="flag"></param> /// <param name="cp"></param> public void ChangeFiles(List <string> files, string newPath, List <string> parent, bool flag, Copy cp) { bool flagchange = false; int index = 0; int count = 1; string path = string.Empty; int value = 0; foreach (var file in files) { if (!file.Contains(parent[index])) { index++; } MediatorProgressBar.Name(file.Remove(0, file.LastIndexOf('\\') + 1)); if (!flag) { path = string.Format("{0}{1}", newPath, file.Remove(0, parent[index].Length + 1)); Copy.CopyFile(file, path, ref flagchange, cp); } else { Delete.DeleteFile(file); } value = count * 100 / files.Count; MediatorProgressBar.Count(value); count++; } }
/// <summary> /// method for delete content /// </summary> private void DeleteContend() { this.thread = new Thread((object y) => { try { this.delcont.AddContent(); this.delcont.StartDelete(); this.delcont.Reset(); MediatorProgressBar.GetRoot(this.root); MediatorProgressBar.Count(100); MediatorProgressBar.Close(); } catch (Exception e) { try { MessageBox.Show(string.Format("Access is denied {0}", e.Message.Remove(0, e.Message.IndexOf('"'))), "Delete", MessageBoxButton.OK, MessageBoxImage.Error); } catch (Exception ex) { } MediatorProgressBar.Count(100); MediatorProgressBar.Close(); } }); thread.Start(); }
/// <summary> /// method for copy files /// </summary> /// <param name="copy"></param> /// <param name="newPath"></param> public static void CopyFile(string copy, string newPath, ref bool flag, Copy cp) { if (cp.flagEx) { while (true) { } } using (FileStream FileTo = new FileStream(copy, FileMode.Open)) { try { using (FileStream FileIn = new FileStream(newPath, FileMode.CreateNew)) { CopyByte(FileIn, FileTo); cp.copyFiles.Add(newPath); } } catch (Exception ex) { if (!flag) { flag = MediatorProgressBar.Ask(); } if (flag == true) { using (FileStream FileIn = new FileStream(newPath, FileMode.Create)) { CopyByte(FileIn, FileTo); cp.copyFiles.Add(newPath); } } } } }
/// <summary> /// method for copy content /// </summary> private void CopyContent() { this.thread = new Thread((object y) => { try { this.copyCont.AddContent(); this.copyCont.StartCopy(); MediatorProgressBar.GetRoot(this.root); MediatorProgressBar.Count(100); MediatorProgressBar.Close(); } catch (Exception e) { this.copyCont.ErrorDelete(); MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); MediatorProgressBar.GetRoot(this.root); MediatorProgressBar.Count(100); MediatorProgressBar.Close(); } }); thread.Start(); }