private void CommandBinding_DeleteFileDB(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(VM_DuplicateFile)) { VM_DuplicateFile df = obj as VM_DuplicateFile; MessageBoxResult res = MessageBox.Show(string.Format(Shoko.Commons.Properties.Resources.DuplicateFiles_DeleteEntry), Shoko.Commons.Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == MessageBoxResult.Yes) { Cursor = Cursors.Wait; string result = VM_ShokoServer.Instance.ShokoServices.DeleteDuplicateFile(df.DuplicateFileID, 0); if (result.Length > 0) { MessageBox.Show(result, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } else { DuplicateFilesCollection.Remove(df); FileCount = DuplicateFilesCollection.Count; //RefreshDuplicateFiles(); } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { Cursor = Cursors.Arrow; } }
private void CommandBinding_DeleteFile2(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(DuplicateFileVM)) { DuplicateFileVM df = obj as DuplicateFileVM; MessageBoxResult res = MessageBox.Show(string.Format(Properties.Resources.DuplicateFiles_ConfirmDelete), Properties.Resources.Confirm, MessageBoxButton.YesNo, MessageBoxImage.Warning); if (res == MessageBoxResult.Yes) { this.Cursor = Cursors.Wait; string result = JMMServerVM.Instance.clientBinaryHTTP.DeleteDuplicateFile(df.DuplicateFileID, 2); if (result.Length > 0) { MessageBox.Show(result, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } else { DuplicateFilesCollection.Remove(df); FileCount = DuplicateFilesCollection.Count; //RefreshDuplicateFiles(); } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; } }
private void CommandBinding_DeleteFile1(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(DuplicateFileVM)) { DuplicateFileVM df = obj as DuplicateFileVM; MessageBoxResult res = MessageBox.Show(string.Format("Are you sure you want to delete this file, the physical video file will also be deleted"), "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (res == MessageBoxResult.Yes) { this.Cursor = Cursors.Wait; string result = JMMServerVM.Instance.clientBinaryHTTP.DeleteDuplicateFile(df.DuplicateFileID, 1); if (result.Length > 0) { MessageBox.Show(result, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { DuplicateFilesCollection.Remove(df); FileCount = DuplicateFilesCollection.Count; //RefreshDuplicateFiles(); } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; } }
public void RefreshDuplicateFiles() { try { Cursor = Cursors.Wait; DuplicateFilesCollection.Clear(); List <VM_DuplicateFile> dfs = VM_ShokoServer.Instance.ShokoServices.GetAllDuplicateFiles().CastList <VM_DuplicateFile>(); FileCount = dfs.Count; foreach (VM_DuplicateFile df in dfs) { DuplicateFilesCollection.Add(df); } // move to the next item if (lastSelIndex <= lbDuplicateFiles.Items.Count) { lbDuplicateFiles.SelectedIndex = lastSelIndex; lbDuplicateFiles.Focus(); lbDuplicateFiles.ScrollIntoView(lbDuplicateFiles.SelectedItem); } else { // move to the previous item if (lastSelIndex - 1 <= lbDuplicateFiles.Items.Count) { lbDuplicateFiles.SelectedIndex = lastSelIndex - 1; lbDuplicateFiles.Focus(); lbDuplicateFiles.ScrollIntoView(lbDuplicateFiles.SelectedItem); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { Cursor = Cursors.Arrow; } }
public void RefreshDuplicateFiles() { try { this.Cursor = Cursors.Wait; DuplicateFilesCollection.Clear(); List <JMMServerBinary.Contract_DuplicateFile> dfs = JMMServerVM.Instance.clientBinaryHTTP.GetAllDuplicateFiles(); FileCount = dfs.Count; foreach (JMMServerBinary.Contract_DuplicateFile df in dfs) { DuplicateFilesCollection.Add(new DuplicateFileVM(df)); } // move to the next item if (lastSelIndex <= lbDuplicateFiles.Items.Count) { lbDuplicateFiles.SelectedIndex = lastSelIndex; lbDuplicateFiles.Focus(); lbDuplicateFiles.ScrollIntoView(lbDuplicateFiles.SelectedItem); } else { // move to the previous item if (lastSelIndex - 1 <= lbDuplicateFiles.Items.Count) { lbDuplicateFiles.SelectedIndex = lastSelIndex - 1; lbDuplicateFiles.Focus(); lbDuplicateFiles.ScrollIntoView(lbDuplicateFiles.SelectedItem); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; } }