private void DisplayMap() { List <string> wayPoints = JourneyList.SelectedItems.ToList().OrderBy(x => x.Journey.FromDateTime).SelectMany(x => x.GetWayPoints()).ToList(); List <DirectionRequest> directionRequests = MapHelper.GetDirectionRequests(wayPoints); var jsonDirectionRequests = JsonConvert.SerializeObject(directionRequests); string script = "calculateAndDisplayRoute(" + jsonDirectionRequests + ");"; Dialog mapWindow = new Dialog(); WebView webView = new WebView(); webView.Url = MapHelper.GoogleMapUrl(); webView.Size = new Size(800, 500); //webView.LoadComplete += (sender, e) => ((WebView)sender).ExecuteScript(script); Button closeButton = new Button(); closeButton.Text = "Close"; closeButton.Click += (sender, e) => mapWindow.Close(); TextArea textArea = new TextArea(); textArea.Text = jsonDirectionRequests; textArea.Size = new Size(800, 500); mapWindow.Content = ViewHelper.AppendV(textArea, closeButton); mapWindow.DisplayMode = DialogDisplayMode.Attached; mapWindow.ShowModal(this); }
private void DisplaySummary() { Dialog summaryWindow = new Dialog(); summaryWindow.Height = 500; summaryWindow.Width = 600; Control reporting = ReportingView.GetView(JourneyList.SelectedItems.ToList().OrderBy(x => x.Journey.FromDateTime).ToList()); Button closeButton = new Button(); closeButton.Text = "Close"; closeButton.Click += (sender, e) => summaryWindow.Close(); summaryWindow.Content = ViewHelper.AppendV(reporting, ViewHelper.AppendV(null, ViewHelper.AppendH(null, closeButton, null), null)); summaryWindow.DisplayMode = DialogDisplayMode.Attached; summaryWindow.ShowModal(this); }
public static Control GetView(JourneyViewModel journeyViewModel) { var webView = GetWebView(journeyViewModel); TabControl tabControl = new TabControl(); tabControl.Pages.Add(new TabPage(EventListView.GetView(journeyViewModel)) { Text = "Events" }); tabControl.Pages.Add(new TabPage(SpendingListView.GetView(journeyViewModel)) { Text = "Expenses" }); tabControl.Pages.Add(new TabPage(webView) { Text = "Map" }); var borderCrossingPage = new TabPage(); borderCrossingPage.Text = "Border Crossing"; borderCrossingPage.DataContext = journeyViewModel.Journey; borderCrossingPage.BindDataContext(c => c.Enabled, (Journey m) => m.IncludeBorderCrossing); borderCrossingPage.EnabledChanged += (sender, e) => { if (tabControl.SelectedIndex == 3) { tabControl.SelectedIndex = 0; } }; borderCrossingPage.Content = BorderCrossingView.GetView(journeyViewModel.Journey.BorderCrossing); tabControl.Pages.Add(borderCrossingPage); tabControl.SelectedIndexChanged += (sender, e) => { if ((sender as TabControl).SelectedPage.Text == "Map") { List <string> wayPoints = journeyViewModel.GetWayPoints(); List <DirectionRequest> directionRequests = MapHelper.GetDirectionRequests(wayPoints); var jsonDirectionRequests = JsonConvert.SerializeObject(directionRequests); string script = "calculateAndDisplayRoute(" + jsonDirectionRequests + ");"; Console.WriteLine(script); webView.ExecuteScript(script); } }; //TableLayout layoutGrids = new TableLayout(); //layoutGrids.Rows.Add(new TableRow(EventListView.GetView(journeyViewModel)) { ScaleHeight = true }); //layoutGrids.Rows.Add(new TableRow(SpendingListView.GetView(journeyViewModel)) { ScaleHeight = true }); //var button = new Button(); //button.Text = "Update map"; //button.Click += (sender, e) => { webView.ExecuteScript(journeyViewModel.GoogleMapParameters); }; TableLayout layout = ViewHelper.AppendV( GetTitleBar(journeyViewModel.Journey), ViewHelper.AppendH( ViewHelper.AppendV( ViewHelper.AppendH( GetWeatherDropDown(journeyViewModel.Journey), GetNoteSlider(journeyViewModel.Journey), GetIncludeBorderCrossing(journeyViewModel.Journey), null ), BivouacView.GetView(journeyViewModel.Journey.Bivouac) ) ), tabControl ) as TableLayout; layout.Padding = new Padding(10, 0, 10, 10); //layout.BackgroundColor = Colors.White; return(layout); }
public static Control GetView(BorderCrossing borderCrossing) { NumericUpDown visaDuration = new NumericUpDown(); visaDuration.DataContext = borderCrossing; visaDuration.BindDataContext(c => c.Value, (BorderCrossing m) => m.VisaDuration); visaDuration.Tag = "Visa Duration"; visaDuration.Width = 50; NumericUpDown visaPrice = new NumericUpDown(); visaPrice.DataContext = borderCrossing; visaPrice.BindDataContext(c => c.Value, (BorderCrossing m) => m.VisaPrice); visaPrice.Tag = "Visa Price"; visaPrice.Width = 50; NumericUpDown visaVehicleDuration = new NumericUpDown(); visaVehicleDuration.DataContext = borderCrossing; visaVehicleDuration.BindDataContext(c => c.Value, (BorderCrossing m) => m.VisaVehicleDuration); visaVehicleDuration.Tag = "Visa Vehicle Duration"; visaVehicleDuration.Width = 50; NumericUpDown visaVehiclePrice = new NumericUpDown(); visaVehiclePrice.DataContext = borderCrossing; visaVehiclePrice.BindDataContext(c => c.Value, (BorderCrossing m) => m.VisaVehiclePrice); visaVehiclePrice.Tag = "Visa Vehicle Price"; visaVehiclePrice.Width = 50; CheckBox fumigation = new CheckBox(); fumigation.DataContext = borderCrossing; fumigation.BindDataContext(c => c.Checked, (BorderCrossing m) => m.Fumigation); fumigation.Tag = "Fumigation"; fumigation.Width = 50; NumericUpDown fumigationPrice = new NumericUpDown(); fumigationPrice.DataContext = borderCrossing; fumigationPrice.BindDataContext(c => c.Value, (BorderCrossing m) => m.FumigationPrice); fumigationPrice.Tag = "Fumigation Price"; fumigationPrice.Width = 50; CheckBox vehicleInspection = new CheckBox(); vehicleInspection.DataContext = borderCrossing; vehicleInspection.BindDataContext(c => c.Checked, (BorderCrossing m) => m.VehicleInspection); vehicleInspection.Tag = "Vehicle Inspection"; vehicleInspection.Width = 50; CheckBox tramidores = new CheckBox(); tramidores.DataContext = borderCrossing; tramidores.BindDataContext(c => c.Checked, (BorderCrossing m) => m.Tramidores); tramidores.Tag = "Tramidores"; tramidores.Width = 50; NumericUpDown tramidoresPrice = new NumericUpDown(); tramidoresPrice.DataContext = borderCrossing; tramidoresPrice.BindDataContext(c => c.Value, (BorderCrossing m) => m.TramidoresPrice); tramidoresPrice.Tag = "Tramidores Price"; tramidoresPrice.Width = 50; TextArea comments = new TextArea(); comments.DataContext = borderCrossing; comments.BindDataContext(c => c.Text, (Bivouac m) => m.Comments); var font = new Font("Helvetica", 13, FontStyle.Italic); var info = new Label() { Text = "Prices expressed in euros and duration expressed in days.", }; info.Font = font; var row1 = ViewHelper.AppendH(ViewHelper.Labelize(visaDuration, 130), ViewHelper.Labelize(visaVehicleDuration, 130), ViewHelper.Labelize(fumigation, 130), ViewHelper.Labelize(tramidores, 130)); var row2 = ViewHelper.AppendH(ViewHelper.Labelize(visaPrice, 130), ViewHelper.Labelize(visaVehiclePrice, 130), ViewHelper.Labelize(fumigationPrice, 130), ViewHelper.Labelize(tramidoresPrice, 130)); var row3 = ViewHelper.AppendH(ViewHelper.Labelize(vehicleInspection, 130), null); var layout = ViewHelper.AppendV(new Panel() { Content = info, Padding = new Padding(0, 10) }, row1, row2, row3, new Panel() { Content = comments, Padding = new Padding(0, 10) }); return(new Panel() { Content = layout, Padding = new Padding(10, 0) }); }
public static Control GetView(Bivouac bivouac) { ComboBox typeDropDown = new ComboBox(); typeDropDown.DataContext = bivouac; typeDropDown.DataStore = ConstantManager.Instance.BivouacTypes; typeDropDown.BindDataContext(c => c.SelectedKey, (Bivouac m) => m.Type); typeDropDown.Tag = "Type"; ComboBox noteDropDown = new ComboBox(); noteDropDown.DataContext = bivouac; noteDropDown.DataStore = ConstantManager.Instance.Notes; noteDropDown.BindDataContext(c => c.SelectedKey, (Bivouac m) => m.Note); noteDropDown.TextColor = Colors.Gold; noteDropDown.Tag = "Note"; TextBox addressTextBox = new TextBox(); addressTextBox.DataContext = bivouac; addressTextBox.BindDataContext(c => c.Text, (Bivouac m) => m.Address); addressTextBox.Tag = "Address"; TextBox cityTextBox = new TextBox(); cityTextBox.DataContext = bivouac; cityTextBox.BindDataContext(c => c.Text, (Bivouac m) => m.City); cityTextBox.Tag = "City"; ComboBox countryDropDown = new ComboBox(); countryDropDown.DataContext = bivouac; countryDropDown.DataStore = ConstantManager.Instance.Countries; countryDropDown.BindDataContext(c => c.SelectedKey, (Bivouac m) => m.Country); countryDropDown.Tag = "Country"; TextBox coordinatesTextBox = new TextBox(); coordinatesTextBox.DataContext = bivouac; coordinatesTextBox.BindDataContext(c => c.Text, (Bivouac m) => m.Coordinates); coordinatesTextBox.Tag = "Lat, Long"; NumericStepper elevationNumericUpDown = new NumericStepper(); elevationNumericUpDown.DataContext = bivouac; elevationNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.Elevation); elevationNumericUpDown.Tag = "Height (m)"; NumericStepper distanceNumericUpDown = new NumericStepper(); distanceNumericUpDown.DataContext = bivouac; distanceNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.Distance); distanceNumericUpDown.Tag = "Total (km)"; NumericStepper distanceTrackNumericUpDown = new NumericStepper(); distanceTrackNumericUpDown.DataContext = bivouac; distanceTrackNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.DistanceTrack); distanceTrackNumericUpDown.Tag = "Track (km)"; NumericStepper walkNumericUpDown = new NumericStepper(); walkNumericUpDown.DataContext = bivouac; walkNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.Walk); walkNumericUpDown.Tag = "Walk (m)"; NumericStepper wakeUpTemperatureNumericUpDown = new NumericStepper(); wakeUpTemperatureNumericUpDown.DataContext = bivouac; wakeUpTemperatureNumericUpDown.BindDataContext(c => c.Value, (Bivouac m) => m.WakeUpTemperature); wakeUpTemperatureNumericUpDown.Tag = "Wake T (C°)"; CheckBox photoCheckBox = new CheckBox(); photoCheckBox.DataContext = bivouac; photoCheckBox.BindDataContext(c => c.Checked, (Bivouac m) => m.Photo); photoCheckBox.Tag = "Photo"; photoCheckBox.Width = 14; CheckBox fromiOverLanderCheckBox = new CheckBox(); fromiOverLanderCheckBox.DataContext = bivouac; fromiOverLanderCheckBox.BindDataContext(c => c.Checked, (Bivouac m) => m.FromIOverLander); fromiOverLanderCheckBox.Tag = "iOverLander"; fromiOverLanderCheckBox.Width = 14; CheckBox toiOverLanderCheckBox = new CheckBox(); toiOverLanderCheckBox.DataContext = bivouac; toiOverLanderCheckBox.BindDataContext(c => c.Checked, (Bivouac m) => m.ToIOverLander); toiOverLanderCheckBox.Tag = "Shared"; toiOverLanderCheckBox.Width = 14; TextArea commentTextArea = new TextArea(); commentTextArea.DataContext = bivouac; commentTextArea.BindDataContext(c => c.Text, (Bivouac m) => m.Comments); GridView tagsGrid = new GridView(); tagsGrid.DataStore = bivouac.GetBivouacTags(); tagsGrid.ShowHeader = false; tagsGrid.Width = 170; tagsGrid.Columns.Add(new GridColumn { DataCell = new CheckBoxCell { Binding = Binding.Property <Tag, bool?>(r => r.IsChecked) }, Editable = true }); tagsGrid.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property <Tag, string>(r => r.Name) }, Editable = false }); var infoColumn = ViewHelper.AppendV( ViewHelper.AppendH(ViewHelper.Labelize(typeDropDown), ViewHelper.Labelize(addressTextBox)), ViewHelper.AppendH(ViewHelper.Labelize(noteDropDown), ViewHelper.Labelize(cityTextBox), ViewHelper.Labelize(elevationNumericUpDown)), ViewHelper.AppendH(ViewHelper.Labelize(wakeUpTemperatureNumericUpDown), ViewHelper.Labelize(countryDropDown)), ViewHelper.AppendH(ViewHelper.Labelize(distanceNumericUpDown), ViewHelper.Labelize(coordinatesTextBox)), ViewHelper.AppendH(ViewHelper.Labelize(distanceTrackNumericUpDown), ViewHelper.Labelize(elevationNumericUpDown)), ViewHelper.AppendH(ViewHelper.Labelize(walkNumericUpDown), ViewHelper.Labelize(photoCheckBox, 42), ViewHelper.Labelize(fromiOverLanderCheckBox, 79), ViewHelper.Labelize(toiOverLanderCheckBox, 49)) ); return(new GroupBox() { Padding = 5, Content = ViewHelper.AppendH(infoColumn, tagsGrid, new Label() { Width = 20 }, commentTextArea), Text = "Bivouac" }); }