Ejemplo n.º 1
0
        public List<EDObject>GetAll(string system)
        {
            List<EDObject> listObjects = new List<EDObject>();
            string query = "api/v1/world_surveys";

            if (!String.IsNullOrEmpty(system))
                query = query + "/?q[system]="+HttpUtility.UrlEncode(system);

            string json = RequestGet(query);


            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)
            {
                EDObject obj = new EDObject();

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


            return listObjects;
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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");
            }
        }
Ejemplo n.º 4
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 EDPlanet)
            {
                EDPlanet planet = (EDPlanet)currentObj;

                textBoxName.Text = currentObj.objectName;

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

                textBoxGravity.Text = planet.gravity.ToString("0.00");
                textBoxRadius.Text = planet.radius.ToString("0");
                textBoxArrivalPoint.Text = planet.arrivalPoint.ToString("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");
            }
        }
Ejemplo n.º 5
0
        private void UpdateEDObject(EDObject obj)
        {
            if (obj is EDPlanet)
            {
                EDPlanet planet = (EDPlanet)obj;
                planet.objectName = textBoxName.Text;
                planet.ObjectType = obj.String2ObjectType(comboBoxType.Text);

                var culture = new CultureInfo("en-US");
                planet.gravity = float.Parse(textBoxGravity.Text.Replace(",", "."), culture);
                planet.radius = float.Parse(textBoxRadius.Text.Replace(",", "."), culture);
                planet.arrivalPoint = float.Parse(textBoxArrivalPoint.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 = new CultureInfo("en-US");
                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();
        }
Ejemplo n.º 6
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 EDPlanet)
            {
                EDPlanet planet = (EDPlanet)currentObj;

                textBoxName.Text = currentObj.objectName;


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

                textBoxGravity.Text = planet.gravity.ToString("0.00");
                textBoxRadius.Text = planet.radius.ToString("0");
                textBoxArrivalPoint.Text = planet.arrivalPoint.ToString("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");
            }
        }
Ejemplo n.º 7
0
        public ObjectTypesEnum ShortName2ObjectType(string v)
        {
            EDObject ed = new EDObject();

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

            }

            return ObjectTypesEnum.UnknownObject;
        }
Ejemplo n.º 8
0
        public ObjectTypesEnum String2ObjectType(string v)
        {
            EDObject ed = new EDObject();


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

            return ObjectTypesEnum.UnknownObject;
        }
Ejemplo n.º 9
0
        public bool Store(EDObject edobj)
        {
            


            dynamic jo = new JObject();

            jo.system = edobj.system;
            jo.commander = edobj.commander;
            jo.world = edobj.objectName;
            jo.world_type = edobj.Description;
            jo.terraformable = edobj.terraformable;
            if (edobj.gravity>0)
                jo.gravity = edobj.gravity;
            jo.terrain_difficulty = edobj.terrain_difficulty;
            jo.notes = edobj.notes;

            if (edobj.arrivalPoint>0)
                jo.arrival_point = edobj.arrivalPoint;

            jo.atmosphere_type = edobj.atmosphere;
            jo.vulcanism_type = edobj.vulcanism;

            if (edobj.radius>0)
                jo.radius = edobj.radius;

            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_survey", jo));

            string json;

            if (edobj.id == 0)
            {
                json = RequestPost(joPost.ToString(), "api/v1/world_surveys");

                JObject jo2 = (JObject)JObject.Parse(json);
                JObject obj = (JObject)jo2["world_survey"];
                edobj.id = obj["id"].Value<int>();
            }
            else
                json = RequestPatch(joPost.ToString(), "api/v1/world_surveys/" + edobj.id.ToString());
            return true;


        }
Ejemplo n.º 10
0
        public bool Delete(EDObject obj)
        {
            if (obj.id > 0)
                return DeleteID(obj.id);

            return true;
        }
Ejemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            //FormSagCarinaMission frm = new FormSagCarinaMission(this);
            //            frm.Show();

            //SystemViewForm frm = new SystemViewForm();
            //frm.Show();

            EdMaterializer mat = new EdMaterializer();

            mat.GetAll(null);


            EDObject obj = new EDObject();

            obj.commander = "Test";
            obj.system = "Fine Ring Sector JH-V C2-4";
            obj.objectName = "A 3";
            obj.ObjectType = ObjectTypesEnum.HighMetalContent;
            obj.arrivalPoint = 0;
            obj.gravity = 0.13f;

            obj.materials[MaterialEnum.Carbon] = true;
            obj.materials[MaterialEnum.Iron] = true;
            obj.materials[MaterialEnum.Nickel] = true;
            obj.materials[MaterialEnum.Phosphorus] = true;
            obj.materials[MaterialEnum.Sulphur] = true;
            obj.materials[MaterialEnum.Germanium] = true;
            obj.materials[MaterialEnum.Selenium] = true;
            obj.materials[MaterialEnum.Vanadium] = true;
            obj.materials[MaterialEnum.Cadmium] = true;
            obj.materials[MaterialEnum.Molybdenum] = true;
            obj.materials[MaterialEnum.Tin] = true;
            obj.materials[MaterialEnum.Polonium] = true;

            mat.DeleteID(5);
            mat.DeleteID(6);
            mat.DeleteID(7);

            mat.Store(obj);
        }
        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 EDObject();
            edobj.system = currentSystem;
            dataGridViewPlanet.Rows[nr].Tag = edobj;
           
        }
Ejemplo n.º 13
0
 private void SetMaterials(EDObject obj, CheckedListBox box)
 {
     for (int i = 0; i < box.Items.Count; i++)
     {
         string item = (string)box.Items[i];
         MaterialEnum mat = obj.MaterialFromString(item);
         box.SetItemChecked(i, obj.materials[mat]);
     }
 }