public static void writeFileAndFolderSettings(FileAndFolderSettings settings) { string path = null; if (File.Exists(SETTINGS_LOCAL_FILENAME)) { path = SETTINGS_LOCAL_FILENAME; } else { path = SETTINGS_APPDATA_FILENAME; } //if we select portable mode delete the other settings file if (settings.PortableMode) { path = SETTINGS_LOCAL_FILENAME; if (File.Exists(SETTINGS_APPDATA_FILENAME)) { File.Delete(SETTINGS_APPDATA_FILENAME); } } else //if we select app data for the settings delete the local settings file { path = SETTINGS_APPDATA_FILENAME; if (File.Exists(SETTINGS_LOCAL_FILENAME)) { File.Delete(SETTINGS_LOCAL_FILENAME); } } xmlWriter <FileAndFolderSettings>(path, settings); }
private string getFullPath(FileAndFolderSettings settings, string part1, string part2) { var applicationDirectory = settings.OpenChordsApplicationDirectory; string path = Path.GetFullPath(Path.Combine(applicationDirectory, part1 + part2)); return(path); }
public void TestPathRelativeFolders() { var settings = new FileAndFolderSettings(); settings.ApplicationDataFolder = @"../Data"; settings.OpenSongSetsAndSongs = "c:/OpenSong"; Settings.setup(settings); string expectedSongPath = getFullPath(settings, "", "../Data/Songs/"); string expectedSetsPath = getFullPath(settings, "", "../Data/Sets/"); string expectedMediaPath = getFullPath(settings, "", "../Data/Media/"); string expectedPrintPath = getFullPath(settings, "", "../Data/Export/Print/"); string expectedTabletPath = getFullPath(settings, "", "../Data/Export/Tablet/"); string expectedOpenSong_BackgroundsPath = getFullPath(settings, settings.OpenSongSetsAndSongs, "/Backgrounds/"); string expectedOpenSong_Sets = getFullPath(settings, settings.OpenSongSetsAndSongs, "/Sets/"); string expectedOpenSong_SongPath = getFullPath(settings, settings.OpenSongSetsAndSongs, "/Songs/OpenChords/"); Assert.AreEqual(Settings.GlobalApplicationSettings.SongsFolder, expectedSongPath); Assert.AreEqual(Settings.GlobalApplicationSettings.SetsFolder, expectedSetsPath); Assert.AreEqual(Settings.GlobalApplicationSettings.MediaFolder, expectedMediaPath); Assert.AreEqual(Settings.GlobalApplicationSettings.PrintFolder, expectedPrintPath); Assert.AreEqual(Settings.GlobalApplicationSettings.TabletFolder, expectedTabletPath); Assert.AreEqual(Settings.GlobalApplicationSettings.OpensongSongsFolder, expectedOpenSong_SongPath); Assert.AreEqual(Settings.GlobalApplicationSettings.OpenSongSetFolder, expectedOpenSong_Sets); Assert.AreEqual(Settings.GlobalApplicationSettings.OpensongBackgroundsFolder, expectedOpenSong_BackgroundsPath); }
public void TestPathsWithRelativeandAbsoluteFolders() { var settings = new FileAndFolderSettings(); settings.ApplicationDataFolder = @"c:\OpenChords"; settings.OpenSongSetsAndSongs = "../OpenSong"; Settings.setup(settings); Assert.AreEqual(Settings.GlobalApplicationSettings.SongsFolder, @"c:\OpenChords\Songs\"); Assert.AreEqual(Settings.GlobalApplicationSettings.SetsFolder, @"c:\OpenChords\Sets\"); Assert.AreEqual(Settings.GlobalApplicationSettings.MediaFolder, @"c:\OpenChords\Media\"); Assert.AreEqual(Settings.GlobalApplicationSettings.PrintFolder, @"c:\OpenChords\Export\Print\"); Assert.AreEqual(Settings.GlobalApplicationSettings.TabletFolder, @"c:\OpenChords\Export\Tablet\"); var applicationDirectory = settings.OpenChordsApplicationDirectory; string expectedOpenSong_SongPath = Path.GetFullPath(Path.Combine(applicationDirectory, settings.OpenSongSetsAndSongs + "/Songs/OpenChords/")); string expectedOpenSong_BackgroundsPath = Path.GetFullPath(Path.Combine(applicationDirectory, settings.OpenSongSetsAndSongs + "/Backgrounds/")); string expectedOpenSong_Sets = Path.GetFullPath(Path.Combine(applicationDirectory, settings.OpenSongSetsAndSongs + "/Sets/")); Assert.AreEqual(Settings.GlobalApplicationSettings.OpensongSongsFolder, expectedOpenSong_SongPath); Assert.AreEqual(Settings.GlobalApplicationSettings.OpenSongSetFolder, expectedOpenSong_Sets); Assert.AreEqual(Settings.GlobalApplicationSettings.OpensongBackgroundsFolder, expectedOpenSong_BackgroundsPath); }
private void loadSelectedTab(TabControl tabControl) { var selectedTabPage = tabControl.SelectedPage; var selectedTabControl = tabControl.SelectedPage.Content; //if the control is already loaded we have nothing that we need to do if (selectedTabControl != null) { return; } //load the tab switch (selectedTabPage.Text) { case "General Settings": selectedTabPage.Content = new Preferences.GeneralSettingsPreferences(FileAndFolderSettings.loadSettings()); break; case "Display Settings": selectedTabPage.Content = new Preferences.DisplayAndPrintPreferences(DisplayAndPrintSettings.loadSettings(DisplayAndPrintSettingsType.DisplaySettings), _songToPreview); break; case "Print Settings": selectedTabPage.Content = new Preferences.DisplayAndPrintPreferences(DisplayAndPrintSettings.loadSettings(DisplayAndPrintSettingsType.PrintSettings), _songToPreview); break; case "Tablet Settings": selectedTabPage.Content = new Preferences.DisplayAndPrintPreferences(DisplayAndPrintSettings.loadSettings(DisplayAndPrintSettingsType.TabletSettings), _songToPreview); break; case "Shortcut Settings": selectedTabPage.Content = new ShortcutSettingsPreferences(Entities.ShortcutSettings.LoadSettings()); break; case "User Interface Settings": selectedTabPage.Content = new UserInterfacePreferences(); break; } }