void cPicker1_TextChanged2(object sender, EventArgs e) { Color c1 = ((LaMarvin.Windows.Forms.ColorPicker)sender).Color; AdobeColors.HSL hsl = AdobeColors.RGB_to_HSL(c1); selectedRow["h"] = hsl.H; selectedRow["s"] = hsl.S; selectedRow["v"] = hsl.L; }
public void updateChangedInfo(String propertyName, Object _changedValue) { String changedValue = _changedValue.ToString(); //Update DataRow and Graphics (only certain props require graphical updating). if (propertyName == "SectorID") { dr["sector_id"] = int.Parse(changedValue); } else if (propertyName == "NavType") { dr["nav_type"] = changedValue; } else if (propertyName == "Signature") { dr["signature"] = float.Parse(changedValue); float imageWidth = stargateImage.Width; float imageHeight = stargateImage.Height; float x = stargateImage.X; float y = stargateImage.Y; stargateImage.GetChild(0).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); stargateImage.GetChild(0).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); stargateImage.GetChild(0).Width = (float.Parse(changedValue) * 2) / 100; stargateImage.GetChild(0).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "IsHuge") { dr["is_huge"] = bool.Parse(changedValue); } else if (propertyName == "BaseXP") { dr["base_xp"] = int.Parse(changedValue); } else if (propertyName == "ExplorationRange") { dr["exploration_range"] = float.Parse(changedValue); float imageWidth = stargateImage.Width; float imageHeight = stargateImage.Height; float x = stargateImage.X; float y = stargateImage.Y; stargateImage.GetChild(2).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); stargateImage.GetChild(2).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); stargateImage.GetChild(2).Width = (float.Parse(changedValue) * 2) / 100; stargateImage.GetChild(2).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "BaseAssetID") { dr["base_asset_id"] = int.Parse(changedValue); foreach (DataGridViewRow row in _dgv.SelectedRows) { _dgv.Rows[row.Index].Cells["base_asset_id"].Value = int.Parse(changedValue); _dgv.Update(); _dgv.Refresh(); } } else if (propertyName == "Color") { Color color = (Color)_changedValue; AdobeColors.HSL hsv = AdobeColors.RGB_to_HSL(color); dr["h"] = hsv.H; dr["s"] = hsv.S; dr["v"] = hsv.L; } else if (propertyName == "Type") { _layer.RemoveChild(stargateImage); /* * if (changedValue == "Mobs") * { * dr["type"] = 0; * new MobSprite(_layer, dr, _pg); * } * else if (changedValue == "Planets") * { * dr["type"] = 3; * new PlanetSprite(_layer, dr, _pg); * } * else if (changedValue == "Starbases") * { * dr["type"] = 12; * new StarbaseSprite(_layer, dr, _pg); * } * else if (changedValue == "Decorations") * { * dr["type"] = 37; * new DecorationSprite(_layer, dr, _pg); * } * else if (changedValue == "Harvestables") * { * dr["type"] = 38; * new HarvestableSprite(_layer, dr, _pg); * }*/ _pg.SelectedObject = null; } else if (propertyName == "Scale") { dr["scale"] = float.Parse(changedValue); } else if (propertyName == "PositionX") { dr["position_x"] = float.Parse(changedValue); float dx = (float.Parse(changedValue) / 100) - stargateImage.X; stargateImage.TranslateBy(dx, 0); } else if (propertyName == "PositionY") { dr["position_y"] = float.Parse(changedValue); float dy = (float.Parse(changedValue) / 100) - stargateImage.Y; stargateImage.TranslateBy(0, dy); } else if (propertyName == "PositionZ") { dr["position_z"] = float.Parse(changedValue); } else if (propertyName == "Orientation_Yaw" || propertyName == "Orientation_Pitch" || propertyName == "Orientation_Roll") { QuaternionCalc qtmp = new QuaternionCalc(); double[] q1 = qtmp.AngleToQuat(dp.Orientation_Yaw, dp.Orientation_Pitch, dp.Orientation_Roll); dr["orientation_z"] = q1[0]; dr["orientation_u"] = q1[1]; dr["orientation_v"] = q1[2]; dr["orientation_w"] = q1[3]; } else if (propertyName == "Name") { dr["name"] = changedValue; float x = stargateImage.X; float y = stargateImage.Y; PText name = (PText)stargateImage.GetChild(3); name.Text = changedValue; name.TextAlignment = StringAlignment.Center; name.X = x - (name.Width / 2); name.Y = y - 20; foreach (DataGridViewRow row in _dgv.SelectedRows) { _dgv.Rows[row.Index].Cells["name"].Value = changedValue; _dgv.Update(); _dgv.Refresh(); } } else if (propertyName == "AppearsInRadar") { dr["appears_in_radar"] = bool.Parse(changedValue); if (bool.Parse(changedValue) == true) { changeImage(1); } else { changeImage(0); } } else if (propertyName == "RadarRange") { dr["radar_range"] = float.Parse(changedValue); float imageWidth = stargateImage.Width; float imageHeight = stargateImage.Height; float x = stargateImage.X; float y = stargateImage.Y; stargateImage.GetChild(1).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); stargateImage.GetChild(1).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); stargateImage.GetChild(1).Width = (float.Parse(changedValue) * 2) / 100; stargateImage.GetChild(1).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "Destination") { dr["gate_to"] = int.Parse(changedValue); } else if (propertyName == "IsClassSpecific") { dr["classSpecific"] = bool.Parse(changedValue); if (bool.Parse(changedValue) == true) { changeImage(2); } else { if (bool.Parse(dr["appears_in_radar"].ToString()) == true) { changeImage(1); } else { changeImage(0); } if (int.Parse(dr["faction_id"].ToString()) > 0) { changeImage(3); } } } else if (propertyName == "FactionID") { //get id from name; int id = mainFrm.factions.findIDbyName(changedValue); dr["faction_id"] = id; if (id > 0) { Console.Out.WriteLine("test2"); changeImage(3); } else { if (bool.Parse(dr["appears_in_radar"].ToString()) == true) { changeImage(1); } else { changeImage(0); } if (bool.Parse(dr["classSpecific"].ToString()) == true) { changeImage(2); } } } else if (propertyName == "SoundEffect") { dr["sound_effect_id"] = int.Parse(changedValue); } else if (propertyName == "SoundEffectRange") { dr["sound_effect_range"] = float.Parse(changedValue); } if (dr.RowState != DataRowState.Modified) { dr.SetModified(); } }
public void updateChangedInfo(String propertyName, Object _changedValue) { String changedValue = _changedValue.ToString(); //Update DataRow and Graphics (only certain props require graphical updating). if (propertyName == "SectorID") { dr["sector_id"] = int.Parse(changedValue); } else if (propertyName == "NavType") { dr["nav_type"] = changedValue; } else if (propertyName == "Signature") { dr["signature"] = float.Parse(changedValue); float imageWidth = harvestableImage.Width; float imageHeight = harvestableImage.Height; float x = harvestableImage.X; float y = harvestableImage.Y; harvestableImage.GetChild(0).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(0).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(0).Width = (float.Parse(changedValue) * 2) / 100; harvestableImage.GetChild(0).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "IsHuge") { dr["is_huge"] = bool.Parse(changedValue); } else if (propertyName == "BaseXP") { dr["base_xp"] = int.Parse(changedValue); } else if (propertyName == "ExplorationRange") { dr["exploration_range"] = float.Parse(changedValue); float imageWidth = harvestableImage.Width; float imageHeight = harvestableImage.Height; float x = harvestableImage.X; float y = harvestableImage.Y; harvestableImage.GetChild(2).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(2).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(2).Width = (float.Parse(changedValue) * 2) / 100; harvestableImage.GetChild(2).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "BaseAssetID") { dr["base_asset_id"] = int.Parse(changedValue); foreach (DataGridViewRow row in _dgv.SelectedRows) { _dgv.Rows[row.Index].Cells["base_asset_id"].Value = int.Parse(changedValue); _dgv.Update(); _dgv.Refresh(); } } else if (propertyName == "Color") { Color color = (Color)_changedValue; AdobeColors.HSL hsv = AdobeColors.RGB_to_HSL(color); dr["h"] = hsv.H; dr["s"] = hsv.S; dr["v"] = hsv.L; } else if (propertyName == "Type") { _layer.RemoveChild(harvestableImage); /* * if (changedValue == "Mobs") * { * dr["type"] = 0; * new MobSprite(_layer, dr, _pg); * } * else if (changedValue == "Planets") * { * dr["type"] = 3; * new PlanetSprite(_layer, dr, _pg); * } * else if (changedValue == "Stargates") * { * dr["type"] = 11; * new StargateSprite(_layer, dr, _pg); * } * else if (changedValue == "Starbases") * { * dr["type"] = 12; * new StarbaseSprite(_layer, dr, _pg); * } * else if (changedValue == "Decorations") * { * dr["type"] = 37; * new DecorationSprite(_layer, dr, _pg); * }*/ _pg.SelectedObject = null; } else if (propertyName == "Scale") { dr["scale"] = float.Parse(changedValue); } else if (propertyName == "PositionX") { dr["position_x"] = float.Parse(changedValue); float dx = (float.Parse(changedValue) / 100) - harvestableImage.X; harvestableImage.TranslateBy(dx, 0); } else if (propertyName == "PositionY") { dr["position_y"] = float.Parse(changedValue); float dy = (float.Parse(changedValue) / 100) - harvestableImage.Y; harvestableImage.TranslateBy(0, dy); } else if (propertyName == "PositionZ") { dr["position_z"] = float.Parse(changedValue); } else if (propertyName == "Orientation_Yaw" || propertyName == "Orientation_Pitch" || propertyName == "Orientation_Roll") { QuaternionCalc qtmp = new QuaternionCalc(); double[] q1 = qtmp.AngleToQuat(dp.Orientation_Yaw, dp.Orientation_Pitch, dp.Orientation_Roll); dr["orientation_z"] = q1[0]; dr["orientation_u"] = q1[1]; dr["orientation_v"] = q1[2]; dr["orientation_w"] = q1[3]; } else if (propertyName == "Name") { dr["name"] = changedValue; float x = harvestableImage.X; float y = harvestableImage.Y; PText name = (PText)harvestableImage.GetChild(3); name.Text = changedValue; name.TextAlignment = StringAlignment.Center; name.X = x - (name.Width / 2); name.Y = y - 20; foreach (DataGridViewRow row in _dgv.SelectedRows) { _dgv.Rows[row.Index].Cells["name"].Value = changedValue; _dgv.Update(); _dgv.Refresh(); } } else if (propertyName == "AppearsInRadar") { dr["appears_in_radar"] = bool.Parse(changedValue); if (bool.Parse(changedValue) == true) { changeImage(1); } else { changeImage(0); } } else if (propertyName == "RadarRange") { dr["radar_range"] = float.Parse(changedValue); float imageWidth = harvestableImage.Width; float imageHeight = harvestableImage.Height; float x = harvestableImage.X; float y = harvestableImage.Y; harvestableImage.GetChild(1).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(1).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(1).Width = (float.Parse(changedValue) * 2) / 100; harvestableImage.GetChild(1).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "Destination") { dr["gate_to"] = int.Parse(changedValue); } else if (propertyName == "Level") { dr["level"] = changedValue; } else if (propertyName == "Field") { if (changedValue == "Random") { dr["field"] = 0; } else if (changedValue == "Ring") { dr["field"] = 1; } else if (changedValue == "Donut") { dr["field"] = 2; } else if (changedValue == "Cylinder") { dr["field"] = 3; } else if (changedValue == "Sphere") { dr["field"] = 4; } else if (changedValue == "Gas Cloud Clump") { dr["field"] = 5; } } else if (propertyName == "ResCount") { dr["res_count"] = int.Parse(changedValue); } else if (propertyName == "MaxFieldRadius") { dr["max_field_radius"] = float.Parse(changedValue); int navType = int.Parse(dr["nav_type"].ToString()); int nodeCount = (3 + navType) + 2; float imageWidth = harvestableImage.Width; float imageHeight = harvestableImage.Height; float x = harvestableImage.X; float y = harvestableImage.Y; harvestableImage.GetChild(nodeCount).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(nodeCount).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(nodeCount).Width = (float.Parse(changedValue) * 2) / 100; harvestableImage.GetChild(nodeCount).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "MobSpawnRadius") { dr["spawn_radius"] = float.Parse(changedValue); int navType = int.Parse(dr["nav_type"].ToString()); int nodeCount = (3 + navType) + 1; float imageWidth = harvestableImage.Width; float imageHeight = harvestableImage.Height; float x = harvestableImage.X; float y = harvestableImage.Y; harvestableImage.GetChild(nodeCount).X = (x + (imageWidth / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(nodeCount).Y = (y + (imageHeight / 2)) - (float.Parse(changedValue) / 100); harvestableImage.GetChild(nodeCount).Width = (float.Parse(changedValue) * 2) / 100; harvestableImage.GetChild(nodeCount).Height = (float.Parse(changedValue) * 2) / 100; } else if (propertyName == "PopRockChance") { dr["pop_rock_chance"] = float.Parse(changedValue); } else if (propertyName == "SoundEffect") { dr["sound_effect_id"] = int.Parse(changedValue); } else if (propertyName == "SoundEffectRange") { dr["sound_effect_range"] = float.Parse(changedValue); } if (dr.RowState != DataRowState.Modified) { dr.SetModified(); } }