/// <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; } }
public void SetData(GPLocationProvider loa, GPLocationProvider lob, GPGregorianTime sd, double travelDurationHours) { GPLocationProvider lp = new GPLocationProvider(); lp.setDefaultLocation(loa.getDefaultLocation()); GPLocationChange locChange = new GPLocationChange(); locChange.LocationA = loa.getDefaultLocation(); locChange.LocationB = lob.getDefaultLocation(); locChange.TimezoneStart = true; locChange.julianStart = sd.getJulianGreenwichTime(); locChange.julianEnd = locChange.julianStart + travelDurationHours / 24.0; lp.addChange(locChange); provider = lp; startDateA = new GPGregorianTime(sd); startDateA.setLocationProvider(lp); startDateA.AddDays(-6); nCount = 15; }
// 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; } }