コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }