private void btnFileDetailDelete_Click(object sender, RoutedEventArgs e) { if (dgridFileDetail.SelectedItems == null || dgridFileDetail.SelectedItems.Count <= 0) return; var selFiles = dgridFileDetail.SelectedItems; if (selFiles.Count > 1) { MessageBox.Show("選択可能ファイルは1つだけです", "警告"); return; } common.FileContents selFile = (common.FileContents)dgridFileDetail.SelectedItem; detail.FileCopyDetail fileCopy = new detail.FileCopyDetail(ColViewFileDetail, dispinfoSelectContents); fileCopy.DeleteExecute(selFile); OnRefreshFileDetailInfo(null, null); }
private void btnFileDetailAdd_Click(object sender, RoutedEventArgs e) { if (txtFileDetailPasteFilename.Text.Length <= 0) return; MessageBoxResult result; detail.FileCopyDetail fileCopy = new detail.FileCopyDetail(ColViewFileDetail, dispinfoSelectContents); if (dgridFileDetail.SelectedItems == null || dgridFileDetail.SelectedItems.Count <= 0) fileCopy.SetAdd(txtFileDetailPasteFilename.Text); else { var selFiles = dgridFileDetail.SelectedItems; if (selFiles.Count > 1) { MessageBox.Show("選択可能ファイルは1つだけです", "警告"); return; } common.FileContents selFile = (common.FileContents)dgridFileDetail.SelectedItem; Regex regexMov = new Regex(MovieContents.REGEX_MOVIE_EXTENTION, RegexOptions.IgnoreCase); if (!regexMov.IsMatch(selFile.FileInfo.Name)) { MessageBox.Show("動画のみが選択可能です", "警告"); return; } fileCopy.SetReplace(selFile, txtFileDetailPasteFilename.Text); } string message = ""; if (fileCopy.IsOverride) message = "拡張子が同じファイルが存在するので上書きします"; else { if (fileCopy.Status == detail.FileCopyDetail.STATUS_ADD) message = "ファイルを追加します"; else message = "拡張子が" + dispinfoSelectContents.Extension + "のファイルは削除してコピーします"; } result = MessageBox.Show(message, "確認", MessageBoxButton.OKCancel); if (result == MessageBoxResult.Cancel) return; bgworkerFileDetailCopy.DoWork += new DoWorkEventHandler(bgworkerFileDetailCopy_DoWork); bgworkerFileDetailCopy.ProgressChanged += new ProgressChangedEventHandler(bgworkerFileDetailCopy_ProgressChanged); bgworkerFileDetailCopy.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgworkerFileDetailCopy_RunWorkerCompleted); lgridProgressBar.Visibility = Visibility.Visible; txtFileDetailPasteFilename.Visibility = Visibility.Collapsed; if (bgworkerFileDetailCopy.IsBusy != true) { var param = Tuple.Create(fileCopy); stopwatchFileDetailCopy.Start(); bgworkerFileDetailCopy.RunWorkerAsync(param); } }