Exemple #1
0
        /// <summary>
        /// Obtain cargo configuration from a file.  If the file name is not supplied the the default
        /// path of Constants.Data_DIR\cargomonitor.json is used
        /// </summary>
        public static MissionMonitorConfiguration FromFile(string filename = null)
        {
            if (filename == null)
            {
                filename = Constants.DATA_DIR + @"\missionmonitor.json";
            }

            MissionMonitorConfiguration configuration = new MissionMonitorConfiguration();

            if (File.Exists(filename))
            {
                string json = Files.Read(filename);
                if (json != null)
                {
                    try
                    {
                        configuration = FromJsonString(json);
                    }
                    catch (Exception ex)
                    {
                        Logging.Debug("Failed to read missions configuration", ex);
                    }
                }
            }
            if (configuration == null)
            {
                configuration = new MissionMonitorConfiguration();
            }

            configuration.dataPath = filename;
            return(configuration);
        }
        public ConfigurationWindow()
        {
            InitializeComponent();

            missionsData.ItemsSource = missionMonitor()?.missions;

            MissionMonitorConfiguration configuration = MissionMonitorConfiguration.FromFile();

            missionWarningInt.Text = configuration.missionWarning?.ToString(CultureInfo.InvariantCulture);
        }
Exemple #3
0
        public ConfigurationWindow()
        {
            InitializeComponent();

            monitor = ((MissionMonitor)EDDI.Instance.ObtainMonitor("Mission monitor"));
            missionsData.ItemsSource = monitor.missions;

            MissionMonitorConfiguration configuration = MissionMonitorConfiguration.FromFile();

            missionWarningInt.Text = configuration.missionWarning?.ToString(CultureInfo.InvariantCulture);
        }
Exemple #4
0
        private void warningChanged(object sender, TextChangedEventArgs e)
        {
            MissionMonitorConfiguration configuration = MissionMonitorConfiguration.FromFile();

            try
            {
                int?warning = string.IsNullOrWhiteSpace(missionWarningInt.Text) ? 60 : Convert.ToInt32(missionWarningInt.Text, CultureInfo.InvariantCulture);
                ((MissionMonitor)EDDI.Instance.ObtainMonitor("Mission monitor")).missionWarning = warning;
                configuration.missionWarning = warning;
                configuration.ToFile();
            }
            catch
            {
                // Bad user input; ignore it
            }
        }
Exemple #5
0
        /// <summary>
        /// Obtain cargo configuration from a json.
        /// </summary>
        public static MissionMonitorConfiguration FromJson(dynamic json)
        {
            MissionMonitorConfiguration configuration = new MissionMonitorConfiguration();

            if (json != null)
            {
                try
                {
                    configuration = JsonConvert.DeserializeObject <MissionMonitorConfiguration>(json);
                }
                catch (Exception ex)
                {
                    Logging.Debug("Failed to obtain missions configuration", ex);
                }
            }
            return(configuration);
        }