private void CreateWorkingPaths() { /* * FolderBrowserDialog folderDialog = new FolderBrowserDialog(); * DialogResult result = folderDialog.ShowDialog(); * if (result == System.Windows.Forms.DialogResult.OK) * { * DialogResult pathResult = Dialogs.ChangeWorkingFilePathsPrompt(this); * if (pathResult == System.Windows.Forms.DialogResult.Yes) * { * List<SyncItem> syncItems = ListviewHelper.GetListviewSyncItems(listView1); * syncProject.CreateWorkingPaths(syncItems, folderDialog.SelectedPath); * ListviewHelper.UpdateListviewItems(listView1); * } * } * */ WorkingPaths workingPaths = new WorkingPaths(); workingPaths.SetInitialDirectory(Environment.CurrentDirectory); workingPaths.SetExistingFolders(syncProject.GetWorkingFolderPaths()); DialogResult result = workingPaths.ShowDialog(this); if (result == DialogResult.OK) { List <SyncItem> syncItems = ListviewHelper.GetListviewSyncItems(listView1); syncProject.CreateWorkingPaths(syncItems, workingPaths.FolderPath); ListviewHelper.UpdateListviewItems(listView1); } }
private void listView1_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { try { SyncItem newItem = null; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { if (syncProject.PathIsDirectory(file)) { Dialogs.DirectoryTargetDroppedPathPrompt(this, file); } else if (syncProject.TargetFileExists(file)) { Dialogs.DuplicateTargetDroppedPathPrompt(this, file); } else { newItem = syncProject.AddSyncItem(file, string.Empty); ListviewHelper.CreateListviewItem(listView1, imageList, newItem, true); } } this.itemSyncBox1.CurrentSyncItem = newItem; EnableControls(); } catch (Exception ex) { Dialogs.FileDropError(this, ex); } } }
private void itemSyncBox1_TargetFileChanged(object sender, EventArgs e) { if (syncProject.SingleSelection) { ListviewHelper.UpdateSelectedListviewItem(listView1, imageList, this.itemSyncBox1.CurrentSyncItem); EnableControls(); } }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { // here is where the syncItem list is synced. List <SyncItem> items = ListviewHelper.GetListviewSyncItems(listView1); syncProject.SelectItems(items.Select(r => r.Id).ToArray()); this.itemSyncBox1.CurrentSyncItem = syncProject.SelectedItem; // e.Item.Tag as SyncItem; EnableControls(); }
public static void ReloadListview(ListView listView, ImageList imageList, List <SyncItem> syncItems) { listView.Items.Clear(); foreach (SyncItem item in syncItems) { ListviewHelper.CreateListviewItem(listView, imageList, item); } }
private void AddItem() { listView1.SelectedItems.Clear(); SyncItem newItem = syncProject.AddSyncItem(string.Empty, string.Empty); ListviewHelper.CreateListviewItem(listView1, imageList, newItem, true); this.itemSyncBox1.CurrentSyncItem = newItem; EnableControls(); }
private void CreateProject() { string filePath; DialogResult result = Dialogs.CreateProjectDialog(this, out filePath); if (result == System.Windows.Forms.DialogResult.OK) { syncProject.Create(filePath); ListviewHelper.ReloadListview(listView1, imageList, syncProject.SyncItems); recentProjectMenu.Notify(filePath); recentProjectMenu.CurrentlyOpenedFile = filePath; this.Text = WindowCaption(); EnableControls(); } }
private void recentProjectMenu_RecentProjectOpened(object sender, RecentProjectEventArgs e) { if (File.Exists(e.RecentFile.FullPath)) { syncProject.Load(e.RecentFile.FullPath); ListviewHelper.ReloadListview(listView1, imageList, syncProject.SyncItems); recentProjectMenu.Notify(e.RecentFile.FullPath); recentProjectMenu.CurrentlyOpenedFile = e.RecentFile.FullPath; ConfigSettings.LastProject = e.RecentFile.FullPath; this.Text = WindowCaption(); EnableControls(); } else { DialogResult result = Dialogs.MissingRecentFileError(this); if (result == System.Windows.Forms.DialogResult.Yes) { recentProjectMenu.Remove(e.RecentFile.FullPath); } } }
private bool LoadLastProject() { try { string lastProject = ConfigSettings.LastProject; if (!string.IsNullOrEmpty(lastProject)) { syncProject.Load(lastProject); ListviewHelper.ReloadListview(listView1, imageList, syncProject.SyncItems); recentProjectMenu.Notify(lastProject); recentProjectMenu.CurrentlyOpenedFile = lastProject; this.Text = WindowCaption(); EnableControls(); return(true); } } catch (Exception exception) { MessageBox.Show(this, exception.Message, ConfigSettings.ApplicationTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(false); }
private void listView1_ColumnClick(object sender, ColumnClickEventArgs e) { ListviewHelper.SortColumn(listView1, e.Column); }