private bool SaveConfigurationFile <T>(AppData <T> appData, bool askForConfirmation = true) where T : INamed, new() { bool configurationSaved = false; var fileName = appData.Status[ApplicationStatusBackup.StatusItem.ConfigurationFileName]; var dbLocation = appData.Status[ApplicationStatusBackup.StatusItem.ConfigurationFileLocation]; string fullPath = string.Empty; if (appData.IsNewConfiguration) { fullPath = CommonDialogs.SaveToFileDialogBox(fileName, dbLocation); } else { fullPath = Path.Combine(dbLocation, fileName); if (askForConfirmation && CommonDialogs.AreYouSure($"Save file?\n{fullPath}") == DialogResult.No) { fullPath = string.Empty; } } if (!string.IsNullOrEmpty(fullPath)) { appData.SaveItems(Path.GetDirectoryName(fullPath), Path.GetFileName(fullPath)); configurationSaved = true; } return(configurationSaved); }
private void btnSelectFile_Click(object sender, EventArgs e) { var fullPath = CommonDialogs.SelectFileDialogBox(""); if (!string.IsNullOrEmpty(fullPath)) { this.txtName.Text = fullPath; } }
private void RemoveFileFromLastOpenedFiles <T>(string fullFileName, AppData <T> appData) where T : INamed, new() { if (DialogResult.No == CommonDialogs.AreYouSure($"Remove file from the list?\n{fullFileName}")) { return; } appData.RemoveFileNameFromLastOpenedFiles(fullFileName); UpdateListOfLastOpenedFiles(); }
private void SelectConfigurationFileToOpen <T>(AppData <T> appData, ListView listViewToPopulate) where T : INamed, new() { var folderToOpen = appData.Status[ApplicationStatusBackup.StatusItem.ConfigurationFileLocation]; var fullPath = CommonDialogs.SelectFileDialogBox("", folderToOpen); if (!string.IsNullOrEmpty(fullPath)) { OpenConfigurationFile(appData, listViewToPopulate, fullPath); } }
private bool OpenConfigurationFile <T>(AppData <T> appData, ListView listViewToPopulate, string fullPath) where T : INamed, new() { var fileOpened = true; try { appData.Load(fullPath); PopulateListView(appData.Instances, listViewToPopulate); UpdateListOfLastOpenedFiles(); UpdateConfigFileListHeader(appData); } catch (FileNotFoundException ex) { Trace.WriteLine(ex); CommonDialogs.TellUserFileCouldNotBeOpened(fullPath); fileOpened = false; } return(fileOpened); }
private void MoveItemsUp() { ListView focusedListView = GetFocusedListBetweenDatabasesOrScripts(); if (focusedListView == null) { return; } if (!IsThereAnyItemSelected(focusedListView)) { CommonDialogs.TellUserToSelectItemsInOrderToMove(); return; } var selectedIndices = focusedListView.SelectedIndices.Cast <int>().ToList(); var datasource = (ArrangeableList <INamed>)focusedListView.Tag; var indicesToSelect = datasource.MoveItemsUpOnePosition(selectedIndices); PopulateListView(datasource, focusedListView, indicesToSelect); }
private void EditSelectedItem() { ListView focusedListView = GetFocusedListBetweenDatabasesOrScripts(); if (focusedListView == null) { return; } if (focusedListView.SelectedIndices.Count != 1) { CommonDialogs.TellUserToSelectJustOneItem(); return; } if (focusedListView == lvDatabases) { EditSelectedDatabaseItem(focusedListView); } else { EditSelectedScriptItem(focusedListView); } }