示例#1
0
        private static WebView GetWebView(JourneyViewModel journeyViewModel)
        {
            WebView webView = new WebView();

            webView.Url  = MapHelper.GoogleMapUrl();
            webView.Size = new Size(500, 300);
            return(webView);
        }
示例#2
0
        public void Add(DateTime fromDateTime, DateTime toDateTime)
        {
            Journey          journey          = new Journey(fromDateTime.Date.AddHours(12).ToUniversalTime(), toDateTime.Date.AddHours(12).ToUniversalTime());
            JourneyViewModel journeyViewModel = new JourneyViewModel(journey);

            Journeys.Insert(0, journeyViewModel);
            journey.Save();
            UpdateApplicationBadge();
            SelectedJourney = journeyViewModel;
        }
示例#3
0
        static ContextMenu CreateContextMenu(JourneyViewModel journeyViewModel)
        {
            var menu = new ContextMenu();

            var deleteItem = new ButtonMenuItem {
                Text = "Delete"
            };

            deleteItem.Click      += (s, e) => { journeyViewModel.DeleteSpending(); };
            deleteItem.DataContext = journeyViewModel;
            deleteItem.BindDataContext(c => c.Enabled, (JourneyViewModel m) => m.HasSelectedSpending);

            var addItem = new ButtonMenuItem {
                Text = "Add"
            };

            addItem.Click += (s, e) => { journeyViewModel.AddSpending(); };

            menu.Items.Add(deleteItem);
            menu.Items.Add(addItem);

            return(menu);
        }
示例#4
0
        public static Control GetView(JourneyViewModel journeyViewModel)
        {
            var grid = new GridView {
                DataStore = journeyViewModel.Journey.Spendings
            };

            grid.DataContext           = journeyViewModel;
            grid.AllowColumnReordering = true;
            grid.CanDeleteItem         = s => true;
            grid.ContextMenu           = CreateContextMenu(journeyViewModel);
            grid.SelectedItemBinding.BindDataContext((JourneyViewModel m) => m.SelectedSpending);

            grid.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <Spending, int>(r => r.Order).Convert(r => r.ToString(), v => Converters.FromStringToInt(v))
                },
                HeaderText = "Order",
                Editable   = true,
                Resizable  = true,
                Sortable   = true
            });

            grid.Columns.Add(new GridColumn
            {
                DataCell = new ComboBoxCell {
                    Binding = Binding.Property <Spending, object>(r => r.Type), DataStore = ConstantManager.Instance.SpendingTypes
                },
                HeaderText = "Type",
                Editable   = true,
                Resizable  = true,
                Sortable   = true
            });

            grid.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <Spending, double>(r => r.Price).Convert(r => r.ToString(), v => Converters.FromStringToDouble(v))
                },
                HeaderText = "Price",
                Editable   = true,
                Resizable  = true,
                Sortable   = true
            });

            grid.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <Spending, double>(r => r.Euro).Convert(r => r.ToString(), v => Converters.FromStringToDouble(v))
                },
                HeaderText = "Euro",
                Editable   = true,
                Resizable  = true,
                Sortable   = true
            });

            grid.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <Spending, double>(r => r.UnitaryPrice).Convert(r => r.ToString(), v => Converters.FromStringToDouble(v))
                },
                HeaderText = "UnitaryPrice",
                Editable   = true,
                Resizable  = true,
                Sortable   = true
            });

            grid.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <Spending, double>(r => r.Quantity).Convert(r => r.ToString(), v => Converters.FromStringToDouble(v))
                },
                HeaderText = "Quantity",
                Editable   = true,
                Resizable  = true,
                Sortable   = true
            });

            grid.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <Spending, string>(r => r.Coordinates)
                },
                HeaderText = "Lat, Long",
                Editable   = true,
                Resizable  = true,
                Sortable   = true,
                Width      = 200,
                AutoSize   = false
            });

            grid.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <Event, string>(r => r.Comments)
                },
                HeaderText = "Comments",
                Editable   = true,
                Resizable  = true,
                Sortable   = true
            });

            return(grid);
        }
示例#5
0
        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);
        }