示例#1
0
        private void cB_Start_TextChanged(object sender, EventArgs e)
        {
            if (((ComboBox)sender).SelectedItem != null)
            {
                Start = (Data.System)((ComboBox)sender).SelectedItem;
            }

            CheckButtonOk();
        }
示例#2
0
        private void cB_End_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (((ComboBox)sender).SelectedItem != null)
            {
                End = (Data.System)((ComboBox)sender).SelectedItem;
            }

            CheckButtonOk();
        }
示例#3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (Closing)
            {
                return;
            }
            var dgvSender = (DataGridView)sender;

            if (dgvSender.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0)
            {
                var tTrade = (Data.Trade)dgvSender.Rows[e.RowIndex].DataBoundItem;
                if (tTrade == null)
                {
                    return;
                }

                if (e.ColumnIndex == 0)
                {
                    new RouteViewer(tTrade.Route).Show();
                    return;
                }

                Data.System tSystem = null;
                if (dgvSender.Columns[e.ColumnIndex].HeaderText == "Start")
                {
                    tSystem = tTrade.Steps[0].System;
                }
                else // End
                {
                    tSystem = tTrade.Steps[tTrade.Steps.Count - 1].System;
                }

                if (tSystem != null)
                {
                    new Systems.Main(tSystem).Show();
                }
            }
        }
示例#4
0
        private static void LoadSystems()
        {
            Systems = new List <Data.System>();

            var FactionsFile = new System.IO.FileInfo("Data/factions.json");

            DownloadDB(FactionsFile, AppSettings.Default.FactionsDbUrl);

            var SystemsFile = new System.IO.FileInfo("Data/systems.json");

            DownloadDB(SystemsFile, AppSettings.Default.SystemsDbUrl);

            var StationsFile = new System.IO.FileInfo("Data/stations_lite.json");

            DownloadDB(StationsFile, AppSettings.Default.StationsDbUrl);


            var FactionsArray = new Data.Faction[0];

            using (var reader = new StreamReader(FactionsFile.FullName))
            {
                string json = reader.ReadToEnd();
                json            = json.Replace("null", "0");
                ProgressMessage = "Reading Factions";

                var FactionsList = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Data.Faction> >(json);
                Progress = 10;

                ProgressMessage = "Processing Factions";

                int LargestID = 0;
                foreach (var faction in FactionsList)
                {
                    if (faction.id > LargestID)
                    {
                        LargestID = faction.id;
                    }
                }

                FactionsArray = new Data.Faction[LargestID + 1];

                foreach (var faction in FactionsList)
                {
                    FactionsArray[faction.id] = faction;
                }
            }

            using (var reader = new StreamReader(SystemsFile.FullName))
            {
                string json = reader.ReadToEnd();
                json            = json.Replace("null", "0");
                ProgressMessage = "Reading Systems";
                var SystemList = new List <Data.System>();
                SystemList = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Data.System> >(json);
                Progress   = 20;

                ProgressMessage = "Processing Systems";
                int LargestID = 0;
                foreach (var system in SystemList)
                {
                    if (system.id > LargestID)
                    {
                        LargestID = system.id;
                    }
                }

                var SysArray = new Data.System[LargestID + 1];

                foreach (var system in SystemList)
                {
                    if (system.power == "0")
                    {
                        system.power = "";
                    }
                    if (system.primary_economy == "0")
                    {
                        system.primary_economy = "";
                    }
                    if (system.security == "0")
                    {
                        system.security = "";
                    }
                    if (system.state == "0")
                    {
                        system.state = "";
                    }
                    if (system.government == "0")
                    {
                        system.government = "";
                    }
                    if (system.allegiance == "0")
                    {
                        system.allegiance = "";
                    }

                    system.faction      = FactionsArray[system.controlling_minor_faction_id];
                    SysArray[system.id] = system;
                }
                SystemList.Clear();
                SystemList = null;

                foreach (var faction in FactionsArray)
                {
                    if (faction != null)
                    {
                        faction.home_system = SysArray[faction.home_system_id];
                    }
                }


                Progress = 40;

                ProgressMessage = "Reading Stations";
                var Stations = new List <Data.Station>();
                using (var sreader = new StreamReader(StationsFile.FullName))
                {
                    string sjson = sreader.ReadToEnd();
                    sjson    = sjson.Replace("null", "0");
                    Stations = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Data.Station> >(sjson);
                }
                Progress        = 80;
                ProgressMessage = "Processing Stations";

                foreach (var station in Stations)
                {
                    station.Faction = FactionsArray[station.FactionID];

                    SysArray[station.System_ID].Stations.Add(station);
                }
                Stations.Clear();


                Systems = SysArray.Where(x => x != null).ToList();

                foreach (var system in Systems)
                {
                    system.ParseNote();
                }
                Progress = 95;
            }
        }
示例#5
0
 /// <summary>
 /// Gets the distance from this system to the target system.
 /// </summary>
 /// <param name="Target">The target system.</param>
 /// <returns>The distance in Ls</returns>
 public double GetDistanceTo(System Target)
 {
     return((this.Coordinates - Target.Coordinates).Length);
 }