Esempio n. 1
0
        private void UpdateListViewLine()
        {
            ListViewItem lvi;

            if (listView1.SelectedItems.Count > 0)
            {
                lvi = listView1.SelectedItems[0];

                if (currentObj is EDWorld)
                {
                    EDWorld planet = (EDWorld)currentObj;
                    lvi.SubItems[0].Text = planet.objectName;
                    lvi.SubItems[1].Text = planet.Description;
                    lvi.SubItems[2].Text = planet.gravity.ToString("0.00");
                    lvi.SubItems[3].Text = planet.arrivalPoint.ToString("0");
                }
                if (currentObj is EDStar)
                {
                    EDStar star = (EDStar)currentObj;
                    lvi.SubItems[0].Text = star.objectName;
                    lvi.SubItems[1].Text = star.Description;
                    lvi.SubItems[2].Text = "";
                    lvi.SubItems[3].Text = star.arrivalPoint.ToString("0");
                }
            }
        }
Esempio n. 2
0
        public bool Delete(EDWorld obj)
        {
            if (obj.id > 0)
            {
                return(DeletePlanetID(obj.id));
            }

            return(true);
        }
Esempio n. 3
0
        private void toolStripButtonAdd_Click(object sender, EventArgs e)
        {
            EDWorld obj = new EDWorld();

            obj.system  = textBoxSystemName.Text;
            obj.updater = edForm.CommanderName;
            edObjects.Add(obj);
            CurrentItem = edObjects.Count - 1;
            UpDateListView();
        }
Esempio n. 4
0
        public ObjectTypesEnum ShortName2ObjectType(string v)
        {
            EDWorld ed = new EDWorld();

            foreach (ObjectTypesEnum mat in Enum.GetValues(typeof(ObjectTypesEnum)))
            {
                ed.ObjectType = mat;
                if (v.ToLower().Equals(ed.ShortName.ToLower()))
                    return mat;

            }

            return ObjectTypesEnum.UnknownObject;
        }
Esempio n. 5
0
        private void UpDateListView()
        {
            listView1.Items.Clear();

            foreach (var ob in edObjects)
            {
                if (ob is EDWorld)
                {
                    EDWorld      planet = (EDWorld)ob;
                    ListViewItem lvi;
                    lvi = listView1.Items.Add(planet.objectName);
                    lvi.SubItems.Add(planet.Description);

                    lvi.SubItems.Add(planet.gravity.ToString("0.00"));
                    lvi.SubItems.Add(planet.arrivalPoint.ToString("0"));

                    lvi.UseItemStyleForSubItems = false;


                    lvi.Tag = planet;
                }
                if (ob is EDStar)
                {
                    EDStar       planet = (EDStar)ob;
                    ListViewItem lvi;
                    lvi = listView1.Items.Add(planet.objectName);
                    lvi.SubItems.Add(planet.Description);

                    lvi.SubItems.Add("");  // Gravity
                    lvi.SubItems.Add(planet.arrivalPoint.ToString("0"));

                    lvi.UseItemStyleForSubItems = false;


                    for (int ii = 0; ii < mlist.Count; ii++)
                    {
                        ListViewItem.ListViewSubItem lvsi;
                        lvsi           = lvi.SubItems.Add("");
                        lvsi.BackColor = Color.Gray;
                    }

                    lvi.Tag = planet;
                }
            }
            if (edObjects.Count > 0)
            {
                listView1.Items[0].Selected = true;
            }
        }
Esempio n. 6
0
        public ObjectTypesEnum ShortName2ObjectType(string v)
        {
            EDWorld ed = new EDWorld();

            foreach (ObjectTypesEnum mat in Enum.GetValues(typeof(ObjectTypesEnum)))
            {
                ed.ObjectType = mat;
                if (v.ToLower().Equals(ed.ShortName.ToLower()))
                {
                    return(mat);
                }
            }

            return(ObjectTypesEnum.UnknownObject);
        }
Esempio n. 7
0
        private void UpdateEDObject(EDObject obj)
        {
            if (obj is EDWorld)
            {
                EDWorld planet = (EDWorld)obj;
                planet.objectName = textBoxName.Text;
                planet.ObjectType = obj.String2ObjectType(comboBoxType.Text);

                var culture = CultureInfo.InvariantCulture;
                planet.mass            = float.Parse(textBoxMass.Text.Replace(",", "."), culture);
                planet.gravity         = float.Parse(textBoxGravity.Text.Replace(",", "."), culture);
                planet.radius          = float.Parse(textBoxRadius.Text.Replace(",", "."), culture);
                planet.surfaceTemp     = Int16.Parse(textBoxSurfaceTemp.Text, culture);
                planet.arrivalPoint    = float.Parse(textBoxArrivalPoint.Text.Replace(",", "."), culture);
                planet.surfacePressure = float.Parse(textBoxSurfaceTemp.Text.Replace(",", "."), culture);

                planet.atmosphere = planet.AtmosphereStr2Enum(comboBoxAtmosphere.Text);
                planet.vulcanism  = planet.VulcanismStr2Enum(comboBoxVulcanism.Text);

                //GetMaterials(ref planet, checkedListBox1);
                //GetMaterials(ref planet, checkedListBox2);
                //GetMaterials(ref planet, checkedListBox3);
                //GetMaterials(ref planet, checkedListBox4);
            }

            if (obj is EDStar)
            {
                EDStar star = (EDStar)obj;
                star.objectName = textBoxStarName.Text;
                star.ObjectType = obj.String2ObjectType(comboBoxStarType.Text);
                star.subclass   = textBoxStarSubClass.Text;

                var culture = CultureInfo.InvariantCulture;
                star.mass         = float.Parse(textBoxStarMass.Text.Replace(",", "."), culture);
                star.radius       = float.Parse(textBoxS_Radius.Text.Replace(",", "."), culture);
                star.arrivalPoint = float.Parse(textBoxS_ArrivalPoint.Text.Replace(",", "."), culture);

                star.star_age    = float.Parse(textBox_StarAge.Text.Replace(",", "."), culture);
                star.surfaceTemp = int.Parse(textBoxStarTemp.Text, culture);
                star.orbitPeriod = float.Parse(textBoxStarOrbitPeriod.Text.Replace(",", "."), culture);
                star.luminosity  = textBoxStarLuminosity.Text;
                star.notes       = textBoxStarNote.Text;
            }



            UpdateListViewLine();
        }
Esempio n. 8
0
        public ObjectTypesEnum String2ObjectType(string v)
        {
            EDWorld ed = new EDWorld();

            if (v == null)
            {
                return(ObjectTypesEnum.UnknownObject);
            }

            if (objectAliases.ContainsKey(v.ToLower()))
            {
                return(objectAliases[v.ToLower()]);
            }


            return(ObjectTypesEnum.UnknownObject);
        }
Esempio n. 9
0
        public List <EDWorld> GetWorldSurveys(string system)
        {
            List <EDWorld> listObjects = new List <EDWorld>();
            string         query       = "api/v2/world_surveys";

            if (!String.IsNullOrEmpty(system))
            {
                query = query + "?system=" + HttpUtility.UrlEncode(system);
            }

            var response = RequestGet(query);
            var json     = response.Body;

            JArray  jArray  = null;
            JObject jObject = null;

            if (json != null && json.Length > 5)
            {
                jObject = (JObject)JObject.Parse(json);
            }

            if (jObject == null)
            {
                return(listObjects);
            }


            jArray = (JArray)jObject["world_surveys"];


            foreach (JObject jo in jArray)
            {
                EDWorld obj = new EDWorld();

                if (obj.ParseJson(jo))
                {
                    listObjects.Add(obj);
                }
            }


            return(listObjects);
        }
        private void toolStripButtonAddPlanet_Click(object sender, EventArgs e)
        {
            int nr = dataGridViewPlanet.Rows.Add();

            DataGridViewRow newRow = (DataGridViewRow)dataGridViewPlanet.Rows[nr];

            DataGridViewComboBoxCell cmbCell = (DataGridViewComboBoxCell)newRow.Cells[1];
            cmbCell.Value = dictComboShortNames[0];
            cmbCell = (DataGridViewComboBoxCell)newRow.Cells[3];
            cmbCell.Value = "Unknown";

            var edobj = new EDWorld();
            edobj.system = currentSystem;
            dataGridViewPlanet.Rows[nr].Tag = edobj;
        }
Esempio n. 11
0
        private void UpdateObject(int v)
        {
            if (v < 0)
            {
                return;
            }

            currentObj = edObjects[v];
            if (currentObj.IsPlanet)
            {
                panelPlanets.Visible = true;
                panelStar.Visible    = false;
            }
            else
            {
                panelPlanets.Visible = false;
                panelStar.Visible    = true;
            }


            if (currentObj is EDWorld)
            {
                EDWorld planet = (EDWorld)currentObj;

                textBoxName.Text = currentObj.objectName;


                var nr = (from str in dictComboPlanetDesc where str.Value == planet.Description select str.Key).FirstOrDefault <int>();
                comboBoxType.SelectedIndex = nr;

                textBoxMass.Text   = planet.mass.ToString("0.0000");
                textBoxRadius.Text = planet.radius.ToString("0");

                if (planet.gravity == 0)
                {
                    planet.gravity = (float)CalcG(planet.mass, planet.radius);
                }

                textBoxGravity.Text     = planet.gravity.ToString("0.00");
                textBoxSurfaceTemp.Text = planet.surfaceTemp.ToString("0");
                textBoxPreasure.Text    = planet.surfacePressure.ToString("0.00");

                textBoxArrivalPoint.Text   = planet.arrivalPoint.ToString("0");
                textBoxOrbitPeriod.Text    = planet.orbitPeriod.ToString("0.0");
                textBoxRotationPeriod.Text = planet.rotationPeriod.ToString("0.0");
                textBoxSemiMajorAxis.Text  = planet.semiMajorAxis.ToString("0.00");
                textBoxArrivalPoint.Text   = planet.arrivalPoint.ToString("0.0");
                textBoxRock.Text           = planet.rockPct.ToString("0.0");
                textBoxMetal.Text          = planet.metalPct.ToString("0.0");
                textBoxIce.Text            = planet.icePct.ToString("0.0");


                try
                {
                    comboBoxAtmosphere.SelectedIndex = (int)planet.atmosphere;
                    comboBoxVulcanism.SelectedIndex  = (int)planet.vulcanism;
                }
                catch (Exception)
                {
                }
                //SetMaterials(planet, checkedListBox1);
                //SetMaterials(planet, checkedListBox2);
                //SetMaterials(planet, checkedListBox3);
                //SetMaterials(planet, checkedListBox4);
            }
            if (currentObj is EDStar)
            {
                EDStar star = (EDStar)currentObj;

                textBoxStarName.Text = star.objectName;

                var nr = (from str in dictComboStarDesc where str.Value == star.Description select str.Key).FirstOrDefault <int>();
                comboBoxStarType.SelectedIndex = nr;
                textBoxStarSubClass.Text       = star.subclass;
                textBoxStarMass.Text           = star.mass.ToString();
                textBoxS_Radius.Text           = star.radius.ToString();
                textBox_StarAge.Text           = star.star_age.ToString("0");
                textBoxStarOrbitPeriod.Text    = star.orbitPeriod.ToString();
                textBoxS_ArrivalPoint.Text     = star.arrivalPoint.ToString("0");
                textBoxStarNote.Text           = star.notes;
                textBoxStarLuminosity.Text     = star.luminosity;
                textBoxStarTemp.Text           = star.surfaceTemp.ToString("0");
            }
        }
Esempio n. 12
0
        public bool StorePlanet(EDWorld edobj)
        {
            dynamic jo = new JObject();

            jo.system     = edobj.system;
            jo.updater    = edobj.updater;
            jo.world      = edobj.objectName;
            jo.world_type = edobj.Description;

            jo.mass               = edobj.mass;
            jo.radius             = edobj.radius;
            jo.gravity            = edobj.gravity;
            jo.surface_temp       = edobj.surfaceTemp;
            jo.surface_pressure   = edobj.surfacePressure;
            jo.orbit_period       = edobj.orbitPeriod;
            jo.rotation_period    = edobj.rotationPeriod;
            jo.semi_major_axis    = edobj.semiMajorAxis;
            jo.terrain_difficulty = edobj.terrain_difficulty;

            jo.vulcanism_type  = edobj.vulcanism.ToString();
            jo.rock_pct        = edobj.rockPct;
            jo.metal_pct       = edobj.metalPct;
            jo.ice_pct         = edobj.metalPct;
            jo.reserve         = edobj.Reserve;
            jo.arrival_point   = edobj.arrivalPoint;
            jo.terraformable   = edobj.terraformable;
            jo.atmosphere_type = edobj.atmosphere.ToString();

            jo.notes      = edobj.notes;
            jo.images_url = edobj.image_url;



            //jo.carbon = edobj.materials[MaterialEnum.Carbon];
            //jo.iron = edobj.materials[MaterialEnum.Iron];
            //jo.nickel = edobj.materials[MaterialEnum.Nickel];
            //jo.phosphorus = edobj.materials[MaterialEnum.Phosphorus];
            //jo.sulphur = edobj.materials[MaterialEnum.Sulphur];
            //jo.arsenic = edobj.materials[MaterialEnum.Arsenic];
            //jo.chromium = edobj.materials[MaterialEnum.Chromium];
            //jo.germanium = edobj.materials[MaterialEnum.Germanium];
            //jo.manganese = edobj.materials[MaterialEnum.Manganese];
            //jo.selenium = edobj.materials[MaterialEnum.Selenium];
            //jo.vanadium = edobj.materials[MaterialEnum.Vanadium];
            //jo.zinc = edobj.materials[MaterialEnum.Zinc];
            //jo.zirconium = edobj.materials[MaterialEnum.Zirconium];
            //jo.cadmium = edobj.materials[MaterialEnum.Cadmium];
            //jo.mercury = edobj.materials[MaterialEnum.Mercury];
            //jo.molybdenum = edobj.materials[MaterialEnum.Molybdenum];
            //jo.niobium = edobj.materials[MaterialEnum.Niobium];
            //jo.tin = edobj.materials[MaterialEnum.Tin];
            //jo.tungsten = edobj.materials[MaterialEnum.Tungsten];
            //jo.antimony = edobj.materials[MaterialEnum.Antimony];
            //jo.polonium = edobj.materials[MaterialEnum.Polonium];
            //jo.ruthenium = edobj.materials[MaterialEnum.Ruthenium];
            //jo.technetium = edobj.materials[MaterialEnum.Technetium];
            //jo.tellurium = edobj.materials[MaterialEnum.Tellurium];
            //jo.yttrium = edobj.materials[MaterialEnum.Yttrium];

            JObject joPost = new JObject(new JProperty("world", jo));

            if (edobj.id == 0)
            {
                var response = RequestSecurePost(joPost.ToString(), "api/v2/worlds");
                if (response.StatusCode == HttpStatusCode.Created)
                {
                    JObject jo2 = (JObject)JObject.Parse(response.Body);
                    JObject obj = (JObject)jo2["world"];
                    edobj.id = obj["id"].Value <int>();
                }
                else if ((int)response.StatusCode == 422)
                {
                    // Surprise, record is already there for some reason!
                    // I may create an api method on the server that negates the need to check for
                    // this at some point
                    // - Greg

                    var queryParam = $"system={jo.system}&world={jo.world}";
                    response = RequestGet($"api/v2/worlds?{queryParam}");
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        JObject jo2 = (JObject)JObject.Parse(response.Body);
                        JObject obj = (JObject)jo2["world"][0];
                        edobj.id = obj["id"].Value <int>();

                        response = RequestSecurePatch(joPost.ToString(), "api/v2/worlds/" + edobj.id.ToString());
                    }
                }
            }
            else
            {
                var response = RequestSecurePatch(joPost.ToString(), "api/v2/worlds/" + edobj.id.ToString());
            }
            return(true);
        }
Esempio n. 13
0
 private void toolStripButtonAdd_Click(object sender, EventArgs e)
 {
     EDWorld obj = new EDWorld();
     obj.system = textBoxSystemName.Text;
     obj.updater = edForm.CommanderName;
     edObjects.Add(obj);
     CurrentItem = edObjects.Count - 1;
     UpDateListView();
 }
Esempio n. 14
0
        public ObjectTypesEnum String2ObjectType(string v)
        {
            EDWorld ed = new EDWorld();
            if (v == null)
                return ObjectTypesEnum.UnknownObject;

            if (objectAliases.ContainsKey(v.ToLower()))
                return objectAliases[v.ToLower()];

            return ObjectTypesEnum.UnknownObject;
        }