private void Btn_ok_Click(object sender, EventArgs e) { String fileFilter = ""; String sdCardDirectories = ""; // Create the setting strings... foreach (ListViewItem filter in lV_fileFilters.Items) { fileFilter = String.Format("{0}:{1}", fileFilter, filter.Text); } foreach (ListViewItem directory in lV_directories.Items) { sdCardDirectories = String.Format("{0}:{1}", sdCardDirectories, directory.Text); } // Save the strings in the settings... Properties.Settings.Default.fileFilter = fileFilter.Remove(0, 1); Properties.Settings.Default.sdCardDirectories = sdCardDirectories.Remove(0, 1); Properties.Settings.Default.Save(); // Reread the settings in the main programm... Synchronisation.ReadUserSettings(); Close(); }
private List <FileInfo> Compare(bool compareWithTargetFolder) { List <FileInfo> sdCardFiles = Synchronisation.GetAllSdCardFiles(pathSdCard); List <FileInfo> allFilesToCopy = new List <FileInfo>(); if (!compareWithTargetFolder) { List <String> oldCopies = Synchronisation.GetAllOldCopyies(); foreach (FileInfo file in sdCardFiles) { String fileString = String.Format("{0}%{1}", file.GetFileName(), file.date); if (oldCopies.Contains(fileString)) { String date = oldCopies[oldCopies.IndexOf(fileString)].Split('%')[1]; if (date == file.date) { continue; } } Console.WriteLine("New file to Copy: " + file.path + " (" + file.date + ")"); allFilesToCopy.Add(file); } } else { List <FileInfo> compareFiles = Synchronisation.GetAllFiles(pathTargetFolder); List <String> compareFileNames = new List <String>(); foreach (FileInfo file in compareFiles) { compareFileNames.Add(file.GetFileName()); } foreach (FileInfo file in sdCardFiles) { if (compareFileNames.Contains(file.GetFileName())) { if (compareFiles[compareFileNames.IndexOf(file.GetFileName())].date == file.date) { continue; } } Console.WriteLine("New file to Copy: " + file.path + " (" + file.date + ")"); allFilesToCopy.Add(file); } } if (!day.Equals("all")) { for (int i = allFilesToCopy.Count - 1; i >= 0; i--) { FileInfo file = allFilesToCopy[i]; if (!file.date.Equals(day)) { allFilesToCopy.RemoveAt(i); } } } return(allFilesToCopy); }
private void CB_onlyOneDay_CheckedChanged(object sender, EventArgs e) { if (this.CB_onlyOneDay.Checked) { String pathSdCard = Path_SdCard.SelectedItem.ToString(); // Check if the given paths exsist... if (!Directory.Exists(pathSdCard)) { this.CB_onlyOneDay.Checked = false; string message = String.Format("Der angegebene Pfad \"{0}\" konnte nicht gefunden werden!", pathSdCard); string caption = "Pfad exsitiert nicht!"; MessageBox.Show(message, caption, MessageBoxButtons.OK); return; } new Thread( new ThreadStart(() => { List <FileInfo> files = Synchronisation.GetAllSdCardFiles(pathSdCard); List <String> addedDates = new List <String>(); foreach (FileInfo file in files) { if (!addedDates.Contains(file.date)) { addedDates.Add(file.date); CoB_selectDay.BeginInvoke(new Action(() => { CoB_selectDay.Items.Add(file.date); } )); } } CoB_selectDay.BeginInvoke(new Action(() => { CoB_selectDay.SelectedIndex = 0; } )); } )).Start(); } this.CoB_selectDay.Visible = this.CB_onlyOneDay.Checked; }
public LoadingWindow(string pathSdCard, string pathTargetFolder, bool compareWithTargetFolder, string day) { InitializeComponent(); Btn_ok.Enabled = false; Btn_cancle.Enabled = false; this.day = day; this.pathSdCard = pathSdCard; this.pathTargetFolder = pathTargetFolder; Logging.Debug("SD card: " + pathSdCard); Logging.Debug("Target folder: " + pathTargetFolder); Logging.Debug("Compare with target: " + (compareWithTargetFolder ? "true" : "false")); lbl_operation.Text = "Vergleiche..."; new Thread( new ThreadStart(() => { List <FileInfo> allFilesToCopy = Compare(compareWithTargetFolder); Logging.Info("Finished compairing"); lbl_operation.BeginInvoke(new Action(() => { lbl_operation.Text = "Kopiere..."; } )); Copy(allFilesToCopy); Logging.Info("Finished copying"); Synchronisation.StoreAllOldCopies(allFilesToCopy); lbl_operation.BeginInvoke(new Action(() => { lbl_operation.Text = "Fertig"; } )); Btn_ok.BeginInvoke(new Action(() => { Btn_ok.Enabled = true; } )); } )).Start(); }
public MainWindow() { InitializeComponent(); // Read user settings... Synchronisation.ReadUserSettings(); // Get the old paths... StringCollection lastSdCardPath = Properties.Settings.Default.lastSdCardPath; StringCollection lastAimFolderPath = Properties.Settings.Default.lastAimFolderPath; // Add all old paths to the combo boxes... if (lastSdCardPath != null) { foreach (string lastPath in lastSdCardPath) { this.Path_SdCard.Items.Add(lastPath); } if (this.Path_SdCard.Items.Count > 0) { this.Path_SdCard.SelectedIndex = 0; } } if (lastAimFolderPath != null) { foreach (string lastPath in lastAimFolderPath) { this.Path_aimFolder.Items.Add(lastPath); } if (this.Path_aimFolder.Items.Count > 0) { this.Path_aimFolder.SelectedIndex = 0; } } }