Example #1
0
        /// <summary>
        /// Getting values of location and time from user interface
        /// In GCAL.Base there are used classes:
        ///  - GPGregorianTime - for storing calendar date and time
        ///  - GPLocationProvider - for storing location
        /// In user interface, there are usually strings, double and DateTime
        /// This function is specific for this test application, but you
        /// can see how the values are converted
        /// </summary>
        public void initVars()
        {
            GPLocation loca = new GPLocation();

            loca.setCity(textBox1.Text);
            double d;
            int    l;

            if (double.TryParse(textBox2.Text, out d))
            {
                loca.setLongitudeEastPositive(d);
            }
            else
            {
                loca.setLongitudeEastPositive(0);
                textBox2.Text = "0.0";
            }
            if (double.TryParse(textBox3.Text, out d))
            {
                loca.setLatitudeNorthPositive(d);
            }
            else
            {
                loca.setLatitudeNorthPositive(0.0);
                textBox3.Text = "0.0";
            }

            loc = new GPLocationProvider();
            loca.setTimeZoneName(comboBox1.Text);
            loc.setDefaultLocation(loca);

            if (!int.TryParse(textBox4.Text, out l))
            {
                l             = 1;
                textBox4.Text = "1";
            }

            if (l <= 0)
            {
                l             = 1;
                textBox4.Text = "1";
            }

            days = l;

            //
            // converting dates
            //
            DateTime dd = dateTimePicker1.Value;
            DateTime dt = dateTimePicker2.Value;

            startDate = new DateTime(dd.Year, dd.Month, dd.Day, dt.Hour, dt.Minute, dt.Second);
            endDate   = startDate.AddDays(days);
        }
Example #2
0
        public void ValidateInfo()
        {
            double d;

            if (LocationName.Length == 0)
            {
                labelMessage.Text      = GPStrings.getString(295);
                labelMessage.ForeColor = Color.Red;
                button1.Enabled        = false;
            }
            else if (Latitude.Length == 0)
            {
                labelMessage.Text      = GPStrings.getString(294);
                labelMessage.ForeColor = Color.Red;
                button1.Enabled        = false;
            }
            else if (Longitude.Length == 0)
            {
                labelMessage.Text      = GPStrings.getString(293);
                labelMessage.ForeColor = Color.Red;
                button1.Enabled        = false;
            }
            else if (Country == null)
            {
                labelMessage.Text      = GPStrings.getString(292);
                labelMessage.ForeColor = Color.Red;
                button1.Enabled        = false;
            }
            else if (TimeZone == null)
            {
                labelMessage.Text      = GPStrings.getString(291);
                labelMessage.ForeColor = Color.Red;
                button1.Enabled        = false;
            }
            else if (!GPLocation.ConvertStringToCoordinate(Latitude, out d))
            {
                labelMessage.Text      = GPStrings.getString(290);
                labelMessage.ForeColor = Color.Orange;
                button1.Enabled        = false;
            }
            else if (!GPLocation.ConvertStringToCoordinate(Longitude, out d))
            {
                labelMessage.Text      = GPStrings.getString(289);
                labelMessage.ForeColor = Color.Orange;
                button1.Enabled        = false;
            }
            else
            {
                labelMessage.Text      = GPStrings.getString(288);
                labelMessage.ForeColor = Color.Green;
                button1.Enabled        = true;
            }
        }
Example #3
0
        private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            // Cast the sender object back to ListBox type.
            ListBox theListBox = (ListBox)sender;

            // Get the string contained in each item.
            object item = theListBox.Items[e.Index];

            // If the item is the selected item, then draw the rectangle
            // filled in blue. The item is selected when a bitwise And
            // of the State property and the DrawItemState.Selected
            // property is true.
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds);
            }
            else
            {
                // Otherwise, draw the rectangle filled in beige.
                e.Graphics.FillRectangle(SystemBrushes.ControlLightLight, e.Bounds);
            }

            // Draw a rectangle in blue around each item.
            //e.Graphics.DrawRectangle(Pens.Blue, e.Bounds);

            if (item is GPLocation)
            {
                GPLocation loc = item as GPLocation;
                e.Graphics.DrawString(loc.getName(), labelCount.Font, Brushes.Black, e.Bounds.X + 4, e.Bounds.Y + 4);
                e.Graphics.DrawString("Timezone: " + loc.getTimeZone().getFullName(), label1.Font, Brushes.Black, e.Bounds.X + 4, e.Bounds.Y + 20);
            }
            else if (item is GPLocationChange)
            {
                GPLocationChange chan = item as GPLocationChange;
                GPGregorianTime  gt   = new GPGregorianTime(chan.LocationA);
                gt.setJulianGreenwichTime(new GPJulianTime(chan.julianStart, 0));
                string humanStart = string.Format("{0} {1}", gt.getLongTimeString(), chan.LocationA.getTimeZoneName());

                e.Graphics.DrawString(gt.getLongDateString() + " - travelling", labelCount.Font, Brushes.Black, e.Bounds.X + 48, e.Bounds.Y + 4);
                e.Graphics.DrawLine(Pens.Black, e.Bounds.X + 40, e.Bounds.Y + 4, e.Bounds.X + 40, e.Bounds.Bottom - 4);

                e.Graphics.DrawString("Start: " + chan.humanStart, label1.Font, Brushes.Black, e.Bounds.X + 48, e.Bounds.Y + 20);
                //e.Graphics.DrawString("End: " + chan.humanEnd, label1.Font, Brushes.Black, e.Bounds.X + 48, e.Bounds.Y + 36);
                e.Graphics.DrawString("Length: " + chan.humanLength, label1.Font, Brushes.Black, e.Bounds.X + 48, e.Bounds.Y + 36);
            }

            // Draw the focus rectangle around the selected item.
            e.DrawFocusRectangle();
        }
Example #4
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem lvi = listView1.SelectedItems[0];

            if ((lvi.Tag is GPLocation) == false)
            {
                return;
            }

            GPLocation loc = lvi.Tag as GPLocation;

            modifiedFlagAdded = true;
            int h1, m1;

            textBox2.Text = loc.getCity();
            GPAppHelper.hoursToParts(loc.GetLongitudeEastPositive(), out h1, out m1);
            comboBox2.SelectedIndex = h1;
            comboBox4.SelectedIndex = m1;
            comboBox3.SelectedIndex = (loc.GetLongitudeEastPositive() > 0.0 ? 0 : 1);
            GPAppHelper.hoursToParts(loc.GetLatitudeNorthPositive(), out h1, out m1);
            comboBox7.SelectedIndex = h1;
            comboBox6.SelectedIndex = (loc.GetLatitudeNorthPositive() > 0.0 ? 0 : 1);
            comboBox5.SelectedIndex = m1;
            comboBox8.SelectedItem  = loc.getTimeZoneName();
            comboBox1.SelectedItem  = loc.getCountryCode();
            modifiedFlagAdded       = false;

            if (listView1.Focused)
            {
                supressTextChange = true;
                textBox1.Text     = loc.getCity();
                supressTextChange = false;
            }

            modifiedFlagAdded = false;
        }
Example #5
0
        private GPTimeZone getTimeZone(int index)
        {
            LocationPickerControl lpic = (index == 0) ? LocationPicker : LocationPicker2;

            if (lpic != null)
            {
                GPLocationProvider lp = lpic.SelectedLocation;
                if (lp != null)
                {
                    return(lp.getTimeZone());
                }
            }

            GPLocation loc = (index == 0) ? LocationObj : LocationObj2;

            if (loc != null)
            {
                return(loc.getTimeZone());
            }

            return(null);
        }