Example #1
0
        public void AddItem(ShowItem newItem)
        {
            //add items to list from other screens
            theList.Add(newItem);

            //checking to see if the item being added is to turn
            //navigation on
            if ((newItem.Title).Equals("Navigation On"))
            {
                isNavigationOn = true;
            }

            //checking to see if the item being added is to turn
            //stars on
            if ((newItem.Title).Equals("Turn on Stars"))
            {
                isStarOn = true;
            }


            UpdateList();
        }
        private void btnSubmitEarth_Click(object sender, EventArgs e)
        {
            String cartCode        = "";
            String cartDescription = "";
            String outputLbl       = popularLocationsCombo.Text;

            if (!(String.IsNullOrEmpty(outputLbl)))
            {
                //confirmation message
                String            sub = "Submit?";
                String            con = "Confirm";
                DialogResult      results;
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;

                //display messgae
                results = MessageBox.Show(sub, con, buttons);
                //if result is 'yes' then show submited
                if (results == DialogResult.Yes)
                {
                    Boolean isNavigationOn = HomeScreen.Current.GetIsNavOn();

                    //if navigation has not been turned on yet, turn it on to
                    //flyTo galaxy
                    if (!isNavigationOn)
                    {
                        ShowItem naviItem = new ShowItem("Navigation On", "turn navigation on for flyTo commands", "navigation on;");
                        HomeScreen.Current.AddItem(naviItem);
                    }


                    //if user does not enter manual lat and long values

                    cartDescription = "move to " + popularLocationsCombo.Text.Trim();
                    cartCode        = "\tnavigation landUseHeightAboveGround on\n" +
                                      "\tnavigation landHeightAboveGround 200\n" +
                                      "\tnavigation landLatitude " + landLatitude + "\n" +
                                      "\tnavigation landLongitude " + landLongitude + "\n ";

                    if (landDuration_Valid == true)
                    {
                        landDuration_Valid = false;
                        cartDescription    = cartDescription +
                                             "\nLand duration = " + landDuration + " seconds\n";
                        cartCode = cartCode +
                                   "\tnavigation landDuration " + landDuration + "\n";
                    }
                    //add land command to end of every string
                    cartCode = cartCode +
                               "\tnavigation land\n";

                    //create Earth item
                    ShowItem earthItem = new ShowItem("Earth Move", cartDescription, cartCode);

                    //add show item to list
                    HomeScreen.Current.AddItem(earthItem);


                    //update the show list after submit
                    HomeScreen.Current.UpdateList();
                }
            }

            else
            {
                //confirmation message
                String            sub = "Submit?";
                String            con = "Confirm";
                DialogResult      results;
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;

                //display messgae
                results = MessageBox.Show(sub, con, buttons);
                //if result is 'yes' then show submited
                if (results == DialogResult.Yes)
                {
                    Boolean isNavigationOn = HomeScreen.Current.GetIsNavOn();

                    //if navigation has not been turned on yet, turn it on to
                    //flyTo galaxy
                    if (!isNavigationOn)
                    {
                        ShowItem naviItem = new ShowItem("Navigation On", "turn navigation on for flyTo commands", "navigation on;");
                        HomeScreen.Current.AddItem(naviItem);
                    }


                    //if user enters manual lat and long values
                    if (Latitude_Valid && Longitude_Valid == true)
                    {
                        if (southRadio.Checked)
                        {
                            latitude = latitude * -1;
                        }
                        if (westRadioButton.Checked)
                        {
                            longitude = longitude * -1;
                        }


                        Latitude_Valid  = false;
                        Longitude_Valid = false;
                        cartDescription = "move to custom coordinates: " + latitude + ", " + longitude;
                        cartCode        = "\tnavigation landUseHeightAboveGround on\n" +
                                          "\tnavigation landHeightAboveGround 200\n" +
                                          "\tnavigation landLatitude " + latitude + "\n" +
                                          "\tnavigation landLongitude " + longitude + "\n ";

                        if (landDuration_Valid == true)
                        {
                            landDuration_Valid = false;
                            cartDescription    = cartDescription +
                                                 "\nLand duration = " + landDuration + " seconds\n";
                            cartCode = cartCode +
                                       "\tnavigation landDuration " + landDuration + "\n";
                        }
                    }
                    //add land command to end of every string
                    cartCode = cartCode +
                               "\tnavigation land\n";

                    //create Earth item
                    ShowItem earthItem = new ShowItem("Earth Move", cartDescription, cartCode);

                    //add show item to list
                    HomeScreen.Current.AddItem(earthItem);


                    //update the show list after submit
                    HomeScreen.Current.UpdateList();
                }
            }
        }
        private void SubBtn_Click(object sender, EventArgs e)
        {
            //check Right Ascention is correct
            if (rAsHrTxt_Valid == false || rAsMinTxt_Valid == false || rAsSecTxt_Valid == false)
            {
                //reort error in Right ascention
                if (MessageBox.Show("Right Ascention is not correct. Please validate data.") ==
                    DialogResult.OK)
                {
                    rAsHrTxt.Select();
                }

                return;
            }

            //check that Declination is correct
            if (decDTxt_Valid == false || decMinTxt_Valid == false || decSecTxt_Valid == false)
            {
                //report an error in declination
                if (MessageBox.Show("Declination is not correct. Please validate data.") ==
                    DialogResult.OK)
                {
                    decDTxt.Select();
                }
                return;
            }

            //check if duration is correct
            if (durTxt_Valid == false)
            {
                //report an error in declination
                if (MessageBox.Show("Duration is not correct. Please validate data.") ==
                    DialogResult.OK)
                {
                    durationTxt.Select();
                }
                return;
            }


            //check if distance is correct
            if (distanceTxt_Valid == false)
            {
                if (StarFavorites.Text != "")
                {
                    //if a star is selected then ignore distance
                }//report an error in declination
                else if (MessageBox.Show("Distance is not correct. Please validate data.") ==
                         DialogResult.OK)
                {
                    distanceTxt.Select();
                    return;
                }
            }



            //confirmation message
            String            sub = "Submit?";
            String            con = "Confirm";
            DialogResult      results;
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;

            //display messgae
            results = MessageBox.Show(sub, con, buttons);
            //if result is 'yes' then show submited
            if (results == DialogResult.Yes)
            {
                String description = String.Empty;

                //see if star is selected
                if (selectedName != String.Empty)
                {
                    description += "Name: " + selectedName + "\n";
                }


                //create desrciption
                description += "Right Ascention: " + RAHr + "h " + RAMin + "m " + RASec + "s \n" +
                               "Declination: " + DecD + "° " + DecMin + "\' " + DecSec + "\"";


                //see if stars are on
                Boolean starsOn = HomeScreen.Current.getIsStarsOn();

                //see if stars are needed for commands to come
                if (!starsOn)
                {
                    ShowItem turnOnStars = new ShowItem("Turn on Stars", "Turn on stars for any command using stars", "\tstars on");
                    HomeScreen.Current.AddItem(turnOnStars);
                }


                //create star item
                ShowItem Staritem = new ShowItem("Star Move", description, codeMaker());

                //add show item to list
                HomeScreen.Current.AddItem(Staritem);

                //update the show list after submit
                HomeScreen.Current.UpdateList();
            }
            else
            {
                //what to do if no is selected
            }
        }
        private void btnSubmitGalaxy_Click(object sender, EventArgs e)
        {
            String outputLbl = lblGalaxiesOutput.Text;

            if (!(String.IsNullOrEmpty(outputLbl)) && durationValid)
            {
                //confirmation message
                String            sub = "Submit?";
                String            con = "Confirm";
                DialogResult      results;
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;

                //display messgae
                results = MessageBox.Show(sub, con, buttons);
                //if result is 'yes' then show submited
                if (results == DialogResult.Yes)
                {
                    Boolean isNavigationOn = HomeScreen.Current.GetIsNavOn();
                    String  galaxyOutput   = "";

                    //if navigation has not been turned on yet, turn it on to
                    //flyTo galaxy
                    if (!isNavigationOn)
                    {
                        ShowItem naviItem = new ShowItem("Navigation On", "turn navigation on", "\tnavigation on");
                        HomeScreen.Current.AddItem(naviItem);
                    }


                    connect.Open();
                    SqlCommand cmd = connect.CreateCommand();
                    cmd.CommandType = CommandType.Text;
                    //cmd.CommandText = "select CommonName from GalaxiesScreenList WHERE (CommonName LIKE '%' + @searchValue + '%')";
                    //cmd.Parameters.AddWithValue("@searchValue", lblGalaxiesOutput.Text);
                    cmd.CommandText = "select CommonName, DigistarName from GalaxiesScreenList";
                    cmd.ExecuteNonQuery();

                    //Get the digistar name based on common name selected
                    DataTable      dt = new DataTable();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.Fill(dt);
                    foreach (DataRow dr in dt.Rows)
                    {
                        if ((dr["CommonName"].ToString().Trim()).Contains(lblGalaxiesOutput.Text))
                        {
                            try
                            {
                                galaxyOutput = dr["DigistarName"].ToString().Trim();
                            } catch
                            {
                            }
                        }
                    }

                    connect.Close();

                    //the description shown in the Current Script
                    String cartDescription = "Move to " + lblGalaxiesOutput.Text + " Galaxy.\nDuration: " + durationValue + " seconds\n";

                    //lines of code for going to a galaxy
                    String cartCode = "\tscene attitude 0 -45 0\n";
                    cartCode += "\tstars on\n";
                    cartCode += "\t" + galaxyOutput + " on\n" + "\t" + galaxyOutput + " intensity 90 duration 4\n";
                    //cartCode += "\tnavigation on\n";
                    cartCode += "\tnavigation defaultOrbitRate 0\n";

                    if (durationValid)
                    {
                        cartCode += "\tnavigation flyto " + galaxyOutput + " duration " + durationValue + "\n";

                        //create star item
                        ShowItem galaxyItem = new ShowItem("Galaxy Move", cartDescription, cartCode);
                        //add show item to list
                        HomeScreen.Current.AddItem(galaxyItem);
                    }


                    //update the show list after submit
                    HomeScreen.Current.UpdateList();


                    //NO CONFIRMATIONS NEEDED

                    /*/for after submited is 'ok'
                     * if (MessageBox.Show("Submitted") == DialogResult.OK)
                     * {
                     *  //do something after submitted message
                     * }
                     */
                }
            }
        }
        }//end combo box period

        //submit button
        private void button_Submit_Click(object sender, EventArgs e)
        {
            //confirmation message
            String            sub = "Submit?";
            String            con = "Confirm";
            DialogResult      results;
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;

            //if date is not selected, display error msg
            if (DateSelected == false)
            {
                MessageBox.Show("Error: Date not selected.");
            }

            //if hour not selected, display error msg
            else if (HourSelected == false)
            {
                MessageBox.Show("Error: Hours not selected.");
            }

            //if minutes not selected, display error msg
            else if (MinSelected == false)
            {
                MessageBox.Show("Error: Minutes not selected.");
            }

            //if period not selected, display error msg
            else if (PeriodSelected == false)
            {
                MessageBox.Show("Error: Period not selected.");
            }

            //no error message, successfully submitted
            else
            {
                //build selection submission output string
                sub = "Selected: \nDate: " + monthCalendar1.SelectionRange.Start.ToString("dd MMM yyyy")
                      + "\nTime: " + comboBox_Hours.SelectedItem.ToString() + ":" +
                      comboBox_Min.SelectedItem.ToString() + " " +
                      comboBox_Periods.SelectedItem.ToString() + "\n";

                //checkbox options
                //if more stars is selected
                if (checkBox_MoreStars.Checked == true)
                {
                    sub += "\nMore Stars";
                }

                //if constellation art is selected
                if (checkBox_ConstArt.Checked == true)
                {
                    sub += "\nConstellation Art";
                }

                //is constellation lines is selected
                if (checkBox_ConstLines.Checked == true)
                {
                    sub += "\nConstellation Lines";
                }

                //if label constellations are selected
                if (checkBox_LabelConst.Checked == true)
                {
                    sub += "\nLabel Constellations";
                }


                //display message
                results = MessageBox.Show(sub, con, buttons);
                //if result is 'yes' then show submitted
                if (results == DialogResult.Yes)
                {
                    //create star item
                    ShowItem nightitem = new ShowItem("Night Sky Move", sub, createCode());

                    //add show item to list
                    HomeScreen.Current.AddItem(nightitem);



                    //update the show list after submit
                    HomeScreen.Current.UpdateList();
                }
                else
                {
                    //what to do if no is selected - nothing will show in current Show box
                }
            }
        }//end submit btn