Exemple #1
0
        /// <summary>
        /// Save the current configuration.
        /// </summary>
        internal bool SaveConfiguration()
        {
            var configuration = Configuration;

            if (configuration == null)
            {
                return(true);
            }

            if (string.IsNullOrEmpty(configuration.Path))
            {
                return(SaveConfigurationAs());
            }
            try
            {
                configuration.Save(configuration.Path);
                UserPreferences.Preferences.LocoNetConfigurationPath = configuration.Path;
                UserPreferences.SaveNow();
                PathChanged.Fire(this);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// Open a configuration from the given path.
        /// </summary>
        internal void OpenConfiguration(string path)
        {
            try
            {
                // Open
                var tmp = LocoNetConfiguration.Load(path);

                // Can we close?
                if (SaveConfigurationIfDirty())
                {
                    Setup(null, tmp);
                    UserPreferences.Preferences.LocoNetConfigurationPath = path;
                    UserPreferences.SaveNow();
                    PathChanged.Fire(this);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }