public static int GetSubObjectImageIndex(SubObject currentSsr) { int index = -1; for (int i = 0; i < CommonData.Preferences.EventTypeList.Count; i++) { if (currentSsr.Type.Contains(CommonData.Preferences.EventTypeList[i])) { index = i; } } return(index); }
private void Add_Click(object sender, EventArgs e) { SubObjectList.SmallImageList = imageList1; SubObject newSub = new SubObject(); newSub.Type = "Unknown"; if (CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects.Count != 0) { newSub.Name = "SubObject" + CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects.Count.ToString(); } else { newSub.Name = "SubObject"; } //Assign default values to class newSub.Latitude = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Latitude; newSub.Longitude = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Longitude; newSub.ZoomLevel = "1000"; CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects.Add(newSub); int index = GroundEventFunctions.GetSubObjectImageIndex(newSub); var listItem = new ListViewItem(); listItem.ImageIndex = index; listItem.SubItems[0].Text = newSub.Name; SubObjectList.Items.Add(listItem); SubObjectList.FocusedItem = listItem; CommonData.SubObjectIndex = SubObjectList.Items.Count - 1; SubObjectType.Enabled = true; ZoomLevel.Enabled = true; LatitudeValue.Enabled = true; LongitudeValue.Enabled = true; NameValue.Enabled = true; //Assign GUI values SubObjectType.SelectedIndex = 0; ZoomLevel.SelectedIndex = 1; LongitudeValue.Text = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Longitude.ToString(); LatitudeValue.Text = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Latitude.ToString(); NameValue.Text = newSub.Name; //Create sub-object and change color to match higher level object GroundEventFunctions.CreateSubObject(CommonData.CurrentEvents[CommonData.EventSelectedIndex], newSub); CreatorFunctions.ChangeObjectColor("Place/" + CommonData.CurrentEvents[CommonData.EventSelectedIndex].Id + "-" + newSub.Name, (CustomUserInterface.ColorOptions)Enum.Parse(typeof(CustomUserInterface.ColorOptions), CommonData.CurrentEvents[CommonData.EventSelectedIndex].ColorOption)); }
private void Add_Click(object sender, EventArgs e) { SubObjectList.SmallImageList = imageList1; SubObject newSub = new SubObject(); newSub.Type = "Unknown"; if (CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects.Count != 0) { newSub.Name = "SubObject" + CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects.Count.ToString(); } else { newSub.Name = "SubObject"; } //Assign default values to class newSub.Latitude = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Latitude; newSub.Longitude = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Longitude; newSub.ZoomLevel = "1000"; CommonData.CurrentEvents[CommonData.EventSelectedIndex].SubObjects.Add(newSub); int index = GroundEventFunctions.GetSubObjectImageIndex(newSub); var listItem = new ListViewItem(); listItem.ImageIndex = index; listItem.SubItems[0].Text = newSub.Name; SubObjectList.Items.Add(listItem); SubObjectList.FocusedItem = listItem; CommonData.SubObjectIndex = SubObjectList.Items.Count - 1; SubObjectType.Enabled = true; ZoomLevel.Enabled = true; LatitudeValue.Enabled = true; LongitudeValue.Enabled = true; NameValue.Enabled = true; //Assign GUI values SubObjectType.SelectedIndex = 0; ZoomLevel.SelectedIndex = 1; LongitudeValue.Text = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Longitude.ToString(); LatitudeValue.Text = CommonData.CurrentEvents[CommonData.EventSelectedIndex].Latitude.ToString(); NameValue.Text = newSub.Name; //Create sub-object GroundEventFunctions.CreateSubObject(CommonData.CurrentEvents[CommonData.EventSelectedIndex], newSub); }
public static void CreateSubObject(GroundEvent currentGroundEvent, SubObject currentSub) { string placeName = currentGroundEvent.Id + "-" + currentSub.Name; IAgPlace place; IAgExecCmdResult result = CommonData.StkRoot.ExecuteCommand("DoesObjExist / */Place/" + placeName); if (result[0] == "0") { place = CommonData.StkRoot.CurrentScenario.Children.New(AgESTKObjectType.ePlace, placeName) as IAgPlace; } else { place = CommonData.StkRoot.GetObjectFromPath("Place/" + placeName) as IAgPlace; } place.Position.AssignGeodetic(Double.Parse(currentSub.Latitude), Double.Parse(currentSub.Longitude), 0); string filePath = GetImagePath(currentSub.Type); string cmd = "VO */Place/" + placeName + " marker show on markertype imagefile imagefile \"" + filePath + "\" Transparent Off Size 32"; if (filePath != null) { try { CommonData.StkRoot.ExecuteCommand(cmd); } catch (Exception) { MessageBox.Show("Could not update image. Check image file path in settings"); } } string zoom = currentSub.ZoomLevel + "000"; try { cmd = "VO */Place/" + placeName + " ModelDetail Set ModelLabel " + zoom + " MarkerLabel " + zoom + " Marker " + zoom + " Point " + zoom; CommonData.StkRoot.ExecuteCommand(cmd); } catch (Exception) { string mes = "Could not Modify Zoom for SubObject"; MessageBox.Show(mes); } }