Beispiel #1
0
        public SettingsViewModel()
        {
            SaveCommand   = new DelegateCommand(OnSaveCommand);
            BrowseCommand = new DelegateCommand(OnBrowseCommand);

            userSettings = new UserSettingsModel();
            xmlCreator   = new XmlCreator();

            filePath = Environment.ExpandEnvironmentVariables(ConfigurationManager.AppSettings["UserSettingsFilePath"]);
            int directoryIndex = filePath.LastIndexOf(@"\");

            if (!File.Exists(filePath))
            {
                Directory.CreateDirectory(filePath.Substring(0, directoryIndex));
                xmlCreator.CreateDefaultUserSettingsXmlFile(filePath);
            }

            xmlReader = new XmlReader();

            xmlReader.ObtainUserDetailsFromXmlFile(filePath, userSettings);

            DefaultSettings = new SettingsBindableModel
            {
                DefaultServerAddress             = userSettings.DefaultServerAddress,
                DefaultServerPort                = userSettings.DefaultServerPort,
                DefaultOutputDirectory           = userSettings.DefaultOutputDirectory,
                DefaultFileName                  = userSettings.DefaultFileName,
                AutomaticallySaveToFile          = userSettings.AutomaticallySaveToFile,
                AutomaticallyExpandQuickCommands = userSettings.AutomaticallyExpandQuickCommands,
            };

            LastSaved = "Never.";
        }