public TCContextPopup() { InitializeComponent(); _popup = new ContextPopup(); var item1 = new ContextPopupItem("item 1"); var item2 = new ContextPopupItem("item 2"); _popup.Items.Add(item1); _popup.Items.Add(item2); _popup.ItemSelected += (s, e) => { Console.WriteLine($"{_popup.SelectedItem?.Label} is selected"); label1.Text = _popup.SelectedItem?.Label + " is selected!"; }; _popup.Dismissed += (s, e) => { if (_popupVisibility) { Console.WriteLine("Popup is dismissed"); label1.Text = "Popup is dismissed!"; _popupVisibility = false; } }; }
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(); }
public override void Initialize(IComponent component) { base.Initialize(component); // this.m_ContextPopup = base.Component as ContextPopup; if (this.m_ContextPopup == null) { GISShare.Controls.WinForm.WFNew.Forms.TBMessageBox.Show("ContextPopup == null"); return; } }
/// <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; } }
/// <summary> /// Remove the used resource and close the app. /// </summary> public void CloseApp() { // Remove the used resource ClearData(); // check the viewCtxPopup if (viewCtxPopup != null) { // Dismiss the ContextPopup object viewCtxPopup.Dismiss(); viewCtxPopup = null; } // check the categoryCtxPopup if (categoryCtxPopup != null) { // Dismiss the ContextPopup object categoryCtxPopup.Dismiss(); categoryCtxPopup = null; } // check the s_mapview if (s_mapview != null) { // Dispose the MapView s_mapview.Dispose(); s_mapview = null; } // check the s_maps if (s_maps != null) { // Dispose the MapService s_maps.Dispose(); s_maps = null; } // check the window if (window != null) { // Unrealize the Window object window.Unrealize(); window = null; } Exit(); }
private void HandleRightButtonUp(MouseButtonEventArgs e) { if (ContextPopup == null) { return; } PreviewTarget = ((UIElement)e.OriginalSource).TryFindParent <DataGridRow>(); if (PreviewTarget == null) { ContextPopup.IsOpen = false; } else { ContextPopup.PlacementTarget = (DataGridRow)PreviewTarget; PreviewTarget = ((DataGridRow)PreviewTarget).Item; ContextPopup.IsOpen = true; ContextPopup.Focus(); } }
/// <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(); }