private void PopulateSsRs()
        {
            CommonData.EventFileStr = CommonData.DirectoryStr + "\\" + "CurrentSSRs.txt";
            List <GroundEvent> fileSections = new List <GroundEvent>();

            if (File.Exists(CommonData.DirectoryStr + "\\" + "CurrentSSRs.txt"))
            {
                fileSections = ReadWrite.ReadEventFile(CommonData.EventFileStr);
            }
            imageList1.Images.Clear();
            foreach (var item in CommonData.Preferences.EventImageLocations)
            {
                try
                {
                    imageList1.Images.Add(Image.FromFile(item));
                }
                catch (Exception)
                {
                }
            }
            ListSSR.SmallImageList = imageList1;
            foreach (var item in fileSections)
            {
                if (item != null)
                {
                    CommonData.CurrentEvents.Add(item);
                    try
                    {
                        GroundEventFunctions.CreateGroundEvent(item);
                        //SSRList.Items.Add(item.ID);
                        var listItem = new ListViewItem();
                        int index    = GroundEventFunctions.GetImageIndex(item);
                        if (index != -1)
                        {
                            listItem.ImageIndex = index;
                        }
                        listItem.SubItems[0].Text = item.Id;
                        ListSSR.Items.Add(listItem);

                        if (item.SubObjects.Count > 0)
                        {
                            foreach (var subObject in item.SubObjects)
                            {
                                GroundEventFunctions.CreateSubObject(item, subObject);
                            }
                        }
                    }
                    catch (Exception)
                    {
                        string mes = "Could not load SSR: " + item.Id;
                        MessageBox.Show(mes);
                    }
                }
            }
        }
        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));
        }
Beispiel #3
0
        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);
        }