Beispiel #1
0
        /// <summary>
        /// Add new travelling
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            WizardDlg wizard = new WizardDlg();

            LocationPickerControl lpc = new LocationPickerControl();

            lpc.TravellerVisible = false;
            wizard.AddPage(lpc, "Start Location", "Select location, where you start your travelling");

            LocationPickerControl lpc2 = new LocationPickerControl();

            lpc2.TravellerVisible = false;
            wizard.AddPage(lpc2, "Target Location", "Select location, where you finish your traveling");

            TravellingEditControl tec = new TravellingEditControl();

            tec.LocationPicker          = lpc;
            tec.LocationPicker2         = lpc2;
            tec.TransitionTimezoneIndex = 0;
            wizard.AddPage(tec, "Travelling time", "Specify travelling time");

            wizard.ResetPages();

            if (wizard.ShowDialog() == DialogResult.OK)
            {
                GPLocationChange newChange = new GPLocationChange();

                newChange.LocationA = lpc.SelectedLocation.getLocation(0);
                newChange.LocationB = lpc2.SelectedLocation.getLocation(0);

                GPGregorianTime start = new GPGregorianTime(newChange.LocationA);
                start.setDateTime(tec.getUTCDateTime(0).AddHours(newChange.LocationA.getTimeZoneOffsetHours()));
                newChange.julianStart = start.getJulianGreenwichTime();

                GPGregorianTime end = new GPGregorianTime(newChange.LocationB);
                end.setDateTime(tec.getUTCDateTime(1).AddHours(newChange.LocationB.getTimeZoneOffsetHours()));
                newChange.julianEnd = end.getJulianGreenwichTime();

                newChange.TimezoneStart = (tec.TransitionTimezoneIndex == 0);

                GPLocationProvider lp = GPAppHelper.getMyLocation();

                lp.addChange(newChange);

                RefreshList();
                travellingChanged = true;
            }
        }
Beispiel #2
0
        private void EditTravellingInListbox(ListBox lbox, int index)
        {
            GPLocationChange newChange = (GPLocationChange)lbox.SelectedItem;

            if (newChange != null)
            {
                WizardDlg             wizard = new WizardDlg();
                GPGregorianTime       start, end;
                TravellingEditControl tec = new TravellingEditControl();
                tec.LocationObj  = newChange.LocationA;
                tec.LocationObj2 = newChange.LocationB;
                wizard.AddPage(tec, "Travelling time", "Specify travelling time");

                tec.TransitionTimezoneIndex = (newChange.TimezoneStart ? 0 : 1);

                start = new GPGregorianTime(newChange.TimezoneStart ? newChange.LocationA : newChange.LocationB);
                start.setJulianGreenwichTime(new GPJulianTime(newChange.julianStart, 0));
                tec.setUTCDateTime(start.getLocalTime(), 0);

                start.setJulianGreenwichTime(new GPJulianTime(newChange.julianEnd, 0));
                tec.setUTCDateTime(start.getLocalTime(), 1);

                wizard.ResetPages();

                if (wizard.ShowDialog() == DialogResult.OK)
                {
                    start = new GPGregorianTime(newChange.LocationA);
                    start.setDateTime(tec.getUTCDateTime(0).AddHours(newChange.LocationA.getTimeZoneOffsetHours()));
                    newChange.julianStart = start.getJulianGreenwichTime();

                    end = new GPGregorianTime(newChange.LocationB);
                    end.setDateTime(tec.getUTCDateTime(1).AddHours(newChange.LocationB.getTimeZoneOffsetHours()));
                    newChange.julianEnd = end.getJulianGreenwichTime();

                    newChange.TimezoneStart = (tec.TransitionTimezoneIndex == 0);

                    listBox1.Invalidate();
                    listBox1.Update();
                }
            }
        }
Beispiel #3
0
        // insert after
        private void button7_Click(object sender, EventArgs e)
        {
            ListBox lbox        = listBox1;
            int     index       = lbox.SelectedIndex;
            int     changeIndex = getChangeIndexFromListBoxIndex(index);

            GPLocationChange   chng     = null;
            GPLocationProvider provider = GPAppHelper.getMyLocation();

            // ask for travelling time
            // ask for starting location
            WizardDlg wizard = new WizardDlg();

            LocationPickerControl lpc = new LocationPickerControl();

            lpc.TravellerVisible = false;
            wizard.AddPage(lpc, "Target Location", "Select location, where you end your travelling");

            //LocationPickerControl lpc2 = new LocationPickerControl();
            //lpc2.TravellerVisible = false;
            //wizard.AddPage(lpc2, "Target Location", "Select location, where you finish your traveling");

            TravellingEditControl tec = new TravellingEditControl();

            if (IsSelectedLocation)
            {
                tec.LocationObj = listBox1.SelectedItem as GPLocation;
                if ((listBox1.SelectedIndex - 1) > 0)
                {
                    chng = (listBox1.Items[listBox1.SelectedIndex - 1] as GPLocationChange);
                }
            }
            if (IsSelectedTravelling)
            {
                chng            = (listBox1.SelectedItem as GPLocationChange);
                tec.LocationObj = chng.LocationB;
            }
            tec.LocationPicker2         = lpc;
            tec.TransitionTimezoneIndex = 0;
            if (chng != null)
            {
                GPGregorianTime start = new GPGregorianTime(tec.LocationObj);
                start.setJulianGreenwichTime(new GPJulianTime(chng.julianStart, 0));
                tec.SetBottomEndDateLimit(start.getLocalTime());
            }
            wizard.AddPage(tec, "Travelling time", "Specify travelling time");

            wizard.ResetPages();

            if (wizard.ShowDialog() == DialogResult.OK)
            {
                GPLocationChange newChange = new GPLocationChange();

                newChange.LocationA = tec.LocationObj;
                newChange.LocationB = lpc.SelectedLocation.getLocation(0);

                GPGregorianTime start = new GPGregorianTime(newChange.LocationA);
                start.setDateTime(tec.getUTCDateTime(0).AddHours(newChange.LocationA.getTimeZoneOffsetHours()));
                newChange.julianStart = start.getJulianGreenwichTime();

                GPGregorianTime end = new GPGregorianTime(newChange.LocationB);
                end.setDateTime(tec.getUTCDateTime(1).AddHours(newChange.LocationB.getTimeZoneOffsetHours()));
                newChange.julianEnd = end.getJulianGreenwichTime();

                newChange.TimezoneStart = (tec.TransitionTimezoneIndex == 0);

                // remove travellings before changeIndex
                // insert new travelling at index 0
                provider.removeChangesAfterIndex(changeIndex);
                provider.addChange(newChange);

                RefreshList();
                travellingChanged = true;
            }
        }