/// <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; } }
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); }
// 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; } }