Esempio n. 1
0
        public ConfigurationWindow(MissionTrackerViewModel viewModel)
        {
            Data        = viewModel;
            DataContext = Data;

            InitializeComponent();
            MissionTrackerConfiguration config = MissionTrackerConfiguration.FromFile();

            MaxStarDistanceBox.Text = config.maxDistanceFromCurrent;
            MinStationDistance.Text = config.problemDistanceFromStar;
        }
Esempio n. 2
0
        public ProblematicDestinationCalculator(MissionTrackerViewModel viewModel)
        {
            mViewModel     = viewModel;
            mRepository    = SystemInfoSqlLiteRepository.Instance;
            mStarMapConfig = StarMapConfiguration.FromFile();
            mBaseUrl       = "http://www.edsm.net/";
            var config = MissionTrackerConfiguration.FromFile();

            maxDistanceFromCurrent = int.Parse(config.maxDistanceFromCurrent);
            minStationDistance     = int.Parse(config.problemDistanceFromStar);
        }
Esempio n. 3
0
        private void configChanged(object sender, TextChangedEventArgs e)
        {
            MissionTrackerConfiguration config = MissionTrackerConfiguration.FromFile();

            if (!string.IsNullOrEmpty(MaxStarDistanceBox.Text))
            {
                config.maxDistanceFromCurrent = MaxStarDistanceBox.Text;
            }
            if (!string.IsNullOrEmpty(MinStationDistance.Text))
            {
                config.problemDistanceFromStar = MinStationDistance.Text;
            }
            config.ToFile();
        }
Esempio n. 4
0
        /// <summary>
        /// Obtain credentials from a file.  If the file name is not supplied the the default
        /// path of Constants.Data_DIR\edsm.json is used
        /// </summary>
        public static MissionTrackerConfiguration FromFile(string filename = null)
        {
            if (filename == null)
            {
                filename = Constants.DATA_DIR + @"\missionTracker.json";
            }

            MissionTrackerConfiguration credentials = new MissionTrackerConfiguration();

            try
            {
                string credentialsData = File.ReadAllText(filename);
                credentials = JsonConvert.DeserializeObject <MissionTrackerConfiguration>(credentialsData);
            }
            catch (Exception ex)
            {
                Logging.Debug("Failed to read mission tracker information", ex);
            }

            credentials.dataPath = filename;
            return(credentials);
        }