private void CreateButton_Click(object sender, EventArgs e)
        {
            if (ManualSSR.Checked)
            {
                int fieldCheck = FieldCheck();
                if (fieldCheck == 0)
                {
                    GroundEvent current = new GroundEvent();
                    current.Id = IDText.Text;
                    current.Country = CountryText.Text;
                    current.Latitude = Latitude.Text;
                    current.Longitude = Longitude.Text;
                    string start = ReadWrite.CheckTimeCell(StartTimeText.Text);
                    if (start == "Unspecified")
                    {
                        current.StartTime = "Unspecified";
                        current.MilStartTime = "Unspecified";
                    }
                    else
                    {
                        current.MilStartTime = StartTimeText.Text;
                        current.StartTime = StartTimeText.Text;
                    }

                    string stop = ReadWrite.CheckTimeCell(StopTimeText.Text);
                    if (stop == "Unspecified")
                    {
                        current.StopTime = "Unspecified";
                        current.MilStopTime = "Unspecified";
                    }
                    else
                    {
                        current.MilStopTime = StopTimeText.Text;
                        current.StopTime = StopTimeText.Text;
                    }
                    current.Description = DesciptionText.Text;
                    current.SsrType = TypeSelect.Text;

                    CommonData.CurrentEvents.Add(current);
                    GroundEventFunctions.CreateGroundEvent(current);
                    ReadWrite.WriteEventFile(CommonData.EventFileStr);
                }
                CommonData.NewSsrCreated = true;
            }
            else if(SSRFromFile.Checked)
            {
                int importOption = 0;
                if (ImportAll.Checked)
                {
                    importOption = 1;
                }
                ReadWrite.ImportEventSheet(FileText.Text, importOption);
                CommonData.NewSsrCreated = true;
            }
            this.Close();
        }
        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);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            if (ManualSSR.Checked)
            {
                int fieldCheck = FieldCheck();
                if (fieldCheck == 0)
                {
                    GroundEvent current = new GroundEvent();
                    current.Id        = Regex.Replace(IDText.Text, @"[^0-9a-zA-Z_]+", "");
                    current.Country   = CountryText.Text;
                    current.Latitude  = Latitude.Text;
                    current.Longitude = Longitude.Text;
                    string start = ReadWrite.CheckTimeCell(StartTimeText.Text);
                    if (start == "Unspecified")
                    {
                        current.StartTime    = "Unspecified";
                        current.MilStartTime = "Unspecified";
                    }
                    else
                    {
                        current.MilStartTime = StartTimeText.Text;
                        current.StartTime    = StartTimeText.Text;
                    }

                    string stop = ReadWrite.CheckTimeCell(StopTimeText.Text);
                    if (stop == "Unspecified")
                    {
                        current.StopTime    = "Unspecified";
                        current.MilStopTime = "Unspecified";
                    }
                    else
                    {
                        current.MilStopTime = StopTimeText.Text;
                        current.StopTime    = StopTimeText.Text;
                    }
                    current.Description = DesciptionText.Text;
                    current.SsrType     = TypeSelect.Text;

                    if (!String.IsNullOrEmpty(_contactEvent.Poc))
                    {
                        current.Poc = _contactEvent.Poc;
                    }
                    if (!String.IsNullOrEmpty(_contactEvent.PocPhone))
                    {
                        current.PocPhone = _contactEvent.PocPhone;
                    }
                    if (!String.IsNullOrEmpty(_contactEvent.PocEmail))
                    {
                        current.PocEmail = _contactEvent.PocEmail;
                    }

                    current.ColorOption = ColorSelection.Text;
                    CommonData.CurrentEvents.Add(current);

                    GroundEventFunctions.CreateGroundEvent(current);
                    CreatorFunctions.ChangeObjectColor("Place/" + current.Id, (CustomUserInterface.ColorOptions)Enum.Parse(typeof(CustomUserInterface.ColorOptions), ColorSelection.Text));

                    ReadWrite.WriteEventFile(CommonData.EventFileStr);
                }
                CommonData.NewSsrCreated = true;
            }
            else if (SSRFromFile.Checked)
            {
                int importOption = 0;
                if (ImportAll.Checked)
                {
                    importOption = 1;
                }
                ReadWrite.ImportEventSheet(FileText.Text, importOption, SheetColor.Text);
                CommonData.NewSsrCreated = true;
            }
            this.Close();
        }