public MainView() { ProcessStartInfo mongoDbProcessInfo = new ProcessStartInfo(); mongoDbProcessInfo.FileName = "/usr/local/Cellar/mongodb-community/4.2.1/bin/mongod"; mongoDbProcessInfo.Arguments = "--config /usr/local/etc/mongod.conf"; //mongoDbProcessInfo.FileName = "/opt/local/bin/mongod"; //mongoDbProcessInfo.Arguments = "--config /usr/local/etc/mongod.conf"; mongoDbProcessInfo.UseShellExecute = false; mongoDbProcessInfo.CreateNoWindow = true; mongoDbProcess = Process.Start(mongoDbProcessInfo); //p.WaitForExit(); MainViewModel = new MainViewModel(); this.DataContext = MainViewModel; Title = "iTrip"; ClientSize = new Size(1200, 600); var gridView = new GridView(); JourneyList = new SelectableFilterCollection <JourneyViewModel>(gridView, MainViewModel.Journeys); gridView.ShowHeader = false; gridView.DataStore = JourneyList; gridView.SelectedItemBinding.BindDataContext((MainViewModel m) => m.SelectedJourney); gridView.ContextMenu = CreateContextMenu(); gridView.AllowMultipleSelection = true; gridView.Style = "journeyList"; gridView.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = Binding.Property <JourneyViewModel, string>(r => r.Text) }, HeaderText = "Name", Editable = false, Resizable = false, Sortable = false, }); var searchBox = CreateSearchBox(JourneyList); var addButton = new Label(); addButton.Text = "+"; addButton.Font = new Font(FontFamilies.SansFamilyName, 30); addButton.TextColor = Colors.DarkGray; addButton.MouseUp += (sender, e) => { AddNewJourney(); ((Label)sender).TextColor = Colors.DarkGray; }; addButton.MouseDown += (sender, e) => ((Label)sender).TextColor = Colors.Black; var deleteButton = new Label(); deleteButton.Text = "–"; deleteButton.Font = new Font(FontFamilies.SansFamilyName, 32); deleteButton.TextColor = Colors.DarkGray; deleteButton.MouseUp += (sender, e) => { DeleteSelectedJourney(); ((Label)sender).TextColor = Colors.DarkGray; }; deleteButton.MouseDown += (sender, e) => ((Label)sender).TextColor = Colors.Black; TableLayout bottomBar = ViewHelper.AppendH(addButton, deleteButton) as TableLayout; bottomBar.Padding = new Padding(5, 0); var layout = new TableLayout { Rows = { new TableRow(searchBox) { ScaleHeight = false }, new TableRow(gridView) { ScaleHeight = true }, new TableRow(bottomBar) { ScaleHeight = false }, //new TableRow(new TableLayout { Rows = { new TableRow(addButton, deleteButton, null) } } ) { ScaleHeight = false } }, Padding = new Padding(0, 20, 0, 0) }; var splitter = new Splitter { Orientation = Orientation.Horizontal, Position = 200, FixedPanel = SplitterFixedPanel.Panel1, Panel1 = layout, }; splitter.BindDataContext(c => c.Panel2, (MainViewModel m) => m.SelectedJourneyControl); var mainLayout = new TableLayout { Rows = { new TableRow(splitter) { ScaleHeight = true }, //new TableRow(GetStatusBar()) { ScaleHeight = false } }, Padding = new Padding(0, 0, 0, 0), }; Content = mainLayout; Style = "main"; var addJourneyCommand = new Command { MenuText = "New Journey", Image = Icon.FromResource("iTrip.Images.AddIcon.png"), ToolBarText = "New Journey", Shortcut = Keys.Application | Keys.N }; addJourneyCommand.Executed += (sender, e) => AddNewJourney(); var saveJourneyCommand = new Command { MenuText = "Save Journey", ToolBarText = "Save Journey", Shortcut = Keys.Application | Keys.S }; saveJourneyCommand.Executed += (sender, e) => MainViewModel.Save(); var addEventCommand = new Command { MenuText = "Add Event", ToolBarText = "Add Event" }; addEventCommand.Executed += (sender, e) => MainViewModel.SelectedJourney?.AddEvent(); var addExpenseCommand = new Command { MenuText = "Add Expense", Image = Icon.FromResource("iTrip.Images.AddExpenseIcon.png"), ToolBarText = "Add Event" }; addExpenseCommand.Executed += (sender, e) => MainViewModel.SelectedJourney?.AddSpending(); var displayMapCommand = new Command { MenuText = "Map", ToolBarText = "Map" }; displayMapCommand.Executed += (sender, e) => DisplayMap(); var displayReporting = new Command { MenuText = "Reporting", ToolBarText = "Reporting" }; displayReporting.Executed += (sender, e) => DisplaySummary(); //var quitCommand = new Command { MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q }; //quitCommand.Executed += (sender, e) => Quit(); var aboutCommand = new Command { MenuText = "About..." }; aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "iTrip v1.5"); // create menu Menu = new MenuBar { Items = { // File submenu new ButtonMenuItem { Text = "&File", Items ={ addJourneyCommand, saveJourneyCommand, addEventCommand, addExpenseCommand } }, new ButtonMenuItem { Text = "&View", Items ={ displayMapCommand, displayReporting } } // new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } }, // new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } }, }, ApplicationItems = { // application (OS X) or file menu (others) new ButtonMenuItem { Text = "&Preferences..." }, }, //QuitItem = quitCommand, AboutItem = aboutCommand }; // create toolbar //ToolBar = new ToolBar { Items = { addJourneyCommand, new SeparatorToolItem() { Type = SeparatorToolItemType.FlexibleSpace }, saveJourneyCommand, addEventCommand, addExpenseCommand } }; }
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" }); }