/// <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> /// Handle the event of the category selection in the ContextPopup. /// </summary> /// <param name="sender">Specifies the sender object</param> /// <param name="e">Specifies the occured event</param> private void CategorySelected(object sender, EventArgs e) { // Remove the used data ClearData(); // Request the pois with the center position RequestPOI(new Geocoordinates(s_mapview.Center.Latitude, s_mapview.Center.Longitude), ((ContextPopupItem)sender).Text); if (categoryCtxPopup != null) { // Dismiss the ContextPopup object categoryCtxPopup.Dismiss(); categoryCtxPopup = null; } }
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(); }