/// <summary> /// Deletion of the selected save /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteSave_Click(object sender, RoutedEventArgs e) { ISaveWork selectedItem = (ISaveWork)SaveList.SelectedItem; VM.DeleteSaveProcedure(selectedItem.Index); ChangeUIElementEnableState(SelectionButtonList, false); SaveList.Items.Refresh(); IsAnItemSelected = false; }
/// <summary> /// Confirm changes and save them to the existing object. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ConfirmModifyClick(object sender, RoutedEventArgs e) { if (!Regex.IsMatch(SaveNameForm.Text, @"^[a-zA-Z0-9 '_]{3,50}$") || !Regex.IsMatch(SaveSourcePathForm.Text, @"^[a-zA-Z]:(?:[\/\\][a-zA-Z0-9 _#]+)*$") || !Regex.IsMatch(SaveDestinationPathForm.Text, @"^[a-zA-Z]:(?:[\/\\][a-zA-Z0-9 _#]+)*$") || SaveTypeForm.SelectedItem == null) { MessageBox.Show(Properties.Langs.Lang.ConfirmBoxFormError, Properties.Langs.Lang.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); } else { ChangeUIElementVisibilityState(confirmButtonList, Visibility.Hidden); ISaveWork selectedItem = (ISaveWork)SaveList.SelectedItem; List <Extension> extensionList = new List <Extension>(); if (ALL.IsChecked == false) { foreach (CheckBox _checkBox in CheckBoxList) { if (_checkBox.IsChecked == true) { Enum.TryParse(_checkBox.Name.ToLower(), out Extension _extension); extensionList.Add(_extension); } } } else { extensionList.Add(Extension.ALL); } SaveWorkType saveType = SaveWorkType.complete; if (SaveTypeForm.SelectedIndex != 0) { saveType = SaveWorkType.differencial; } VM.ModifySaveProcedure(selectedItem.Index, SaveNameForm.Text, SaveSourcePathForm.Text.Replace("\\", "/"), SaveDestinationPathForm.Text.Replace("\\", "/"), saveType, extensionList); ClearForm(); ChangeUIElementEnableState(FormElementList, false); ChangeUIElementEnableState(OptionButtonList, true); ChangeUIElementEnableState(SelectionButtonList, true); ALL.IsEnabled = false; ChangeUIElementEnableState(CheckBoxList, false); ChangeUIElementEnableState(SelectionButtonList, false); SaveList.Items.Refresh(); SaveList.SelectedItem = null; IsAnItemSelected = false; } }
/// <summary> /// Informs the Model of the cancel request, and closes the save status frame. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CancelSaveStatus_Click(object sender, RoutedEventArgs e) { SaveStatus.Visibility = Visibility.Collapsed; if (!AllSaves) { ISaveWork selectedItem = (ISaveWork)SaveList.SelectedItem; VM.CancelSaveProcedure(selectedItem.Index); } else { VM.CancelAllSaveProcedures(); } }
/// <summary> /// Informs the Model of the resume request, and change UIElements accordingly. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ResumeSaveStatus_Click(object sender, RoutedEventArgs e) { PauseSaveStatus.IsEnabled = true; ResumeSaveStatus.IsEnabled = false; ChangeSaveStatusLabel(SaveStatusEnum.running); if (!AllSaves) { ISaveWork selectedItem = (ISaveWork)SaveList.SelectedItem; VM.PauseSaveProcedure(selectedItem.Index, false); } else { VM.PauseAllSaveProcedures(false); } }
/// <summary> /// Fill in the form with Save object info. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ModifySave_Click(object sender, RoutedEventArgs e) { ISaveWork selectedItem = (ISaveWork)SaveList.SelectedItem; SaveNameForm.Text = selectedItem.Name; SaveSourcePathForm.Text = selectedItem.SourcePath; SaveDestinationPathForm.Text = selectedItem.DestinationPath; if (selectedItem.Type == SaveWorkType.complete) { SaveTypeForm.SelectedIndex = 0; } else { SaveTypeForm.SelectedIndex = 1; } if (selectedItem.ExtentionToEncryptList != null) { foreach (Extension _extension in selectedItem.ExtentionToEncryptList) { CheckBox _checkBox = FindName(_extension.ToString().First().ToString().ToUpper() + _extension.ToString().Substring(1)) as CheckBox; _checkBox.IsChecked = true; } if (ALL.IsChecked == true) { ChangeUIElementEnableState(CheckBoxList, false); } else { ChangeUIElementEnableState(CheckBoxList, true); } } ChangeUIElementEnableState(FormElementList, true); ChangeUIElementEnableState(OptionButtonList, false); ChangeUIElementEnableState(SelectionButtonList, false); ALL.IsEnabled = true; ChangeUIElementVisibilityState(ConfirmButtonList, Visibility.Visible); Confirm.Click -= ConfirmModifyClick; Confirm.Click -= ConfirmCreateClick; Confirm.Click += ConfirmModifyClick; }
/// <summary> /// Launch the selected save /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LaunchSave_Click(object sender, RoutedEventArgs e) { ISaveWork selectedItem = (ISaveWork)SaveList.SelectedItem; AllSaves = false; SaveStatus.Visibility = Visibility.Visible; PauseSaveStatus.IsEnabled = true; ResumeSaveStatus.IsEnabled = false; ChangeCurrentSaveLabel(selectedItem.Name); ChangeSaveStatusLabel(SaveStatusEnum.running); ChangeSaveProgressLabel(0); VM.LaunchSaveProcedure(selectedItem.Index); while (!VM.Model.WorkList[selectedItem.Index].IsActive) { } VM.Model.WorkList[selectedItem.Index].Progress.PropertyChanged += Progress_PropertyChanged; }
/// <summary> /// Create a Log Line about: Start copy a file /// </summary> /// <param name="fi">FileInfo of the file</param> public static void StartCopyFileLogLine(ISaveWork _work, FileInfo _fi) { CreateLogLine(_work.Index, "Start copy" + _fi.Name); }
/// <summary> /// Create a Log Line about: the modification of a save. /// </summary> /// <param name="_nb">ID of the save</param> /// <param name="WorkList">WorkList of the save</param> public static void ChangeWorkLogLine(ISaveWork _work) { CreateLogLine(_work.Index, "Modification of a existing save work in position " + _work.Index + ", current parameters : name : " + _work.Name + ", source path : " + _work.SourcePath + ", destination path : " + _work.DestinationPath + ", type : " + _work.Type); }
/// <summary> /// Create a Log Line about: The current save /// </summary> /// <param name="_nb">ID of the save</param> /// <param name="WorkList">WorkList of the save</param> /// <param name="fi">FileInfo of the file</param> public static void SavingInfoLogLine(ISaveWork _work, FileInfo _fi) { CreateLogLine(_work.Index, "Saving " + _fi.FullName + " in " + _work.Progress.CurrentDestinationFilePath + ", size : " + _fi.Length + " Bytes"); }
public static void EncryptedFile(ISaveWork _work, string _fi, string _time) { CreateLogLine(_work.Index, "Index : " + _work.Index + " ,File Enctyption of " + _fi + " Done ! elapsed time : " + _time); }
/// <summary> /// Create a Log Line about: the creation of a new save. /// </summary> /// <param name="_nb">ID of the save</param> /// <param name="_work">WorkList of the save</param> public static void CreateWorkLogLine(ISaveWork _work) { CreateLogLine(_work.Index, "Creation of a new save work, name : " + _work.Name + ", source path : " + _work.SourcePath + ", destination path : " + _work.DestinationPath + ", type : " + _work.Type); }
/// <summary> /// Create a Log Line about: Exiting a subdirectory /// </summary> /// <param name="subDir">DirectoryInfo of the subdirectory</param> public static void ExitSubdirectoryLogLine(ISaveWork _work, DirectoryInfo _subDir) { CreateLogLine(_work.Index, "Exiting subdirectory : " + _subDir.Name); }
/// <summary> /// Create a Log Line about: Starting the copy of a specific file /// </summary> /// <param name="_work">Save Work Object</param> public static void StartCopy(ISaveWork _work) { CreateLogLine(_work.Index, "Saving file from " + _work.SourcePath + " to " + _work.DestinationPath + " ..."); }
/// <summary> /// Create a Log Line about: End copy a file /// </summary> /// <param name="fi">FileInfo of the file</param> /// <param name="timeSpend"></param> public static void FinishCopyFileLogLine(ISaveWork _work, FileInfo _fi, string _timeSpend) { CreateLogLine(_work.Index, _fi.Name + " succesfully copy ! Time spend : " + _timeSpend + " second(s)"); }
/// <summary> /// Create a Log Line about: The start of a saving action /// </summary> /// <param name="_nb">ID of the save</param> /// <param name="WorkList">WorkList of the save</param> public static void StartSaveLogLine(ISaveWork _work) { CreateLogLine(_work.Index, "Launching save work from work : " + _work.Name + ", type : " + _work.Type); }
/// <summary> /// Create a Log Line about: Files found to save /// </summary> /// <param name="nbFiles">Number of files found</param> /// <param name="sourceDirectory">DirectoryInfo of the source directory</param> /// <param name="directorySize">Total size of the directory</param> public static void FileToSaveFound(ISaveWork _work, int _nbFiles, DirectoryInfo _sourceDirectory, long _directorySize) { CreateLogLine(_work.Index, _nbFiles + " files to save found from " + _sourceDirectory.Name + ",Total size of the directory: " + _directorySize + " Bytes"); }
/// <summary> /// Create a Log Line about: The creation of a new directory /// </summary> /// <param name="filePath">DirectoryInfo of the file</param> public static void CreateDirectoryLogLine(ISaveWork _work, DirectoryInfo _filePath) { CreateLogLine(_work.Index, "Creating target directory in : " + _filePath.FullName); }
/// <summary> /// Create a Log Line about: The end of a saving action /// </summary> /// <param name="_nb">ID of the save</param> /// <param name="WorkList">WorkList of the save</param> /// <param name="timeSpend">time spend between the start and the end of the save</param> public static void FinishSaveLogLine(ISaveWork _work, string _timeSpend) { CreateLogLine(_work.Index, _work.Name + " succesfully saved ! Time spend : " + _timeSpend); }