Esempio n. 1
0
        public override void Run(Window window)
        {
            Rect square = window.GetInnerSquare();

            Background bg = new Background(window);

            bg.Color = Color.Olive;
            bg.Move(0, 0);
            bg.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
            bg.Show();

            ContextPopup ctxPopup = new ContextPopup(bg)
            {
                IsHorizontal = false,
                AutoHide     = false,
            };

            for (int i = 0; i < 5; i++)
            {
                ctxPopup.Append(string.Format("{0} item", _count++));
            }

            ctxPopup.Dismissed += (e, o) => {
                Console.WriteLine("Dismissed");
            };
            ctxPopup.Geometry = new Rect(square.X, square.Y, square.Width / 4, square.Height);
            ctxPopup.Show();

            bool   ctxPopupVisible = true;
            string dismissCaption  = "Dismiss ContextPopup!";
            string showCaption     = "Show ContextPopup!";

            Button button = new Button(window)
            {
                Text = dismissCaption
            };

            button.Clicked += (E, o) =>
            {
                if (ctxPopupVisible)
                {
                    ctxPopup.Dismiss();
                }
                else
                {
                    ctxPopup.Show();
                }
                ctxPopupVisible = !ctxPopupVisible;
                button.Text     = ctxPopupVisible ? dismissCaption : showCaption;
            };

            button.Geometry = new Rect(square.X + square.Width / 2, square.Y, square.Width / 2, square.Height);
            button.Show();
        }
        /// <summary>
        /// Handle the event of the view selection in the ContextPopup.
        /// </summary>
        /// <param name="sender">Specifies the sender object</param>
        /// <param name="e">Specifies the occured event</param>
        private void ViewPageSelected(object sender, EventArgs e)
        {
            // Remove the used data
            ClearData();

            if (((ContextPopupItem)sender).Text == "Map")
            {
                // Hide the label for the end position
                toLabel.Hide();
                // Set the viewpage
                view = ViewPage.MAP;
            }
            else if (((ContextPopupItem)sender).Text == "POI")
            {
                // Hide the label for the end position
                toLabel.Hide();
                // Set the viewpage
                view = ViewPage.POI;

                // Create the ContextPopup for the category selection
                categoryCtxPopup = new ContextPopup(window)
                {
                    // Set the AutoHide value
                    AutoHide = true,
                };

                // Get the categories of the here provider
                foreach (string category in HereCategory)
                {
                    // Append items for the ContextPopup and add event handlers
                    (categoryCtxPopup.Append(category)).Selected += CategorySelected;
                }

                // Move the ContextPopup
                categoryCtxPopup.Move(0, window.ScreenSize.Height);
                // Show the ContextPopup
                categoryCtxPopup.Show();
            }
            else if (((ContextPopupItem)sender).Text == "Route")
            {
                // Show the label for the end position
                toLabel.Show();
                // Set the viewpage
                view = ViewPage.ROUTE;
            }

            if (viewCtxPopup != null)
            {
                // Dismiss the ContextPopup object
                viewCtxPopup.Dismiss();
                viewCtxPopup = null;
            }
        }
        /// <summary>
        /// Create a base UI.
        /// </summary>
        void Initialize()
        {
            // Create the window
            window = new Window("MapApp");
            window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, false);
            window.KeyUp += (s, e) =>
            {
                if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
                {
                    // Close the map if the back key is selected
                    CloseApp();
                }
                else if (e.KeyName == EvasKeyEventArgs.PlatformMenuButtonName)
                {
                    // Create the ContextPopup for the ViewPage selection
                    viewCtxPopup = new ContextPopup(window)
                    {
                        // Set the AutoHide value
                        AutoHide = true,
                    };
                    // Append items for the ContextPopup and add event handlers
                    (viewCtxPopup.Append("Map")).Selected   += ViewPageSelected;
                    (viewCtxPopup.Append("POI")).Selected   += ViewPageSelected;
                    (viewCtxPopup.Append("Route")).Selected += ViewPageSelected;
                    // Move the ContextPopup
                    viewCtxPopup.Move(0, window.ScreenSize.Height);
                    // Show the ContextPopup
                    viewCtxPopup.Show();
                }
            };
            // Show the window
            window.Show();

            var box = new Box(window)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            box.Show();

            var bg = new Background(window)
            {
                Color = Color.White
            };

            bg.SetContent(box);

            var conformant = new Conformant(window);

            conformant.Show();
            conformant.SetContent(bg);

            // Create the MapView
            s_mapview = new MapView(window, s_maps);
            // Move the MapView
            s_mapview.Move(0, 0);
            // Resize the MapView
            s_mapview.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
            // Show the MapView
            s_mapview.Show();
            // Set the latitude and longitude for the center position of the MapView
            //s_mapview.Center = new Geocoordinates(SEOUL_LAT, SEOUL_LON);
            s_mapview.Center = new Geocoordinates(DEFAULT_LAT, DEFAULT_LON);
            // Set the zoom level
            s_mapview.ZoomLevel = 9;
            // Add the handler for the longpress event on MapView
            s_mapview.LongPressed += MapViewLongPressed;

            CreateLabel();
        }