private async void MyMap_Tapped_1(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            var mp = MyMap.ScreenToMap(e.GetPosition(MyMap));
            Graphic g = new Graphic() { Geometry = mp };
            var graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.Add(g);

            var bufferResult = GeometryEngine.Buffer(mp, 100);
            var bufferLayer = MyMap.Layers["BufferLayer"] as GraphicsLayer;
            bufferLayer.Graphics.Add(new Graphic() { Geometry = bufferResult });


            var queryTask = new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2"));
            var query = new ESRI.ArcGIS.Runtime.Tasks.Query()
            {
                ReturnGeometry = true,
                OutSpatialReference = MyMap.SpatialReference,
                Geometry = bufferResult
            };
            query.OutFields.Add("OWNERNME1");

            try
            {
                var queryResult = await queryTask.ExecuteAsync(query);
                if (queryResult != null && queryResult.FeatureSet != null)
                {
                    var resultLayer = MyMap.Layers["MyResultsGraphicsLayer"] as GraphicsLayer;
                    resultLayer.Graphics.AddRange(queryResult.FeatureSet.Features);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Example #2
0
        private void FlyButtonBehavior_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            if (sender is FrameworkElement)
            {
                FrameworkElement element = sender as FrameworkElement;
                FrameworkElement flyImg = element.FindName(ElementName) as FrameworkElement;

                Point pTouchInElement = e.GetPosition(element);
                Point pTouchInFrame = e.GetPosition(Window.Current.Content as Frame);

                Point pElementCenter = new Point();
                pElementCenter.X = pTouchInFrame.X - pTouchInElement.X + element.ActualWidth / 2 - flyImg.Height / 2;
                pElementCenter.Y = pTouchInFrame.Y - pTouchInElement.Y + element.ActualHeight / 2 - flyImg.Width/2;

                Point pElementTo = new Point(Window.Current.Bounds.Width, (Window.Current.Bounds.Height - flyImg.ActualHeight) / 2);

                flyImg.Visibility = Visibility.Visible;

                MoveAnimation.MoveFromTo(flyImg, pElementCenter.X, pElementCenter.Y, pElementTo.X, pElementTo.Y, TimeSpan.FromSeconds(0.8), (ele) => { flyImg.Visibility = Visibility.Collapsed; });
            }
        }
 private async void MyMap_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
 {
     var mp = MyMap.ScreenToMap(e.GetPosition(MyMap));
     Graphic g = new Graphic() { Geometry = mp };
     var stopsLayer = MyMap.Layers["MyStopsGraphicsLayer"] as GraphicsLayer;
     var barriersLayer = MyMap.Layers["MyBarriersGraphicsLayer"] as GraphicsLayer;
     if (StopsRadioButton.IsChecked.Value)
     {
         stopsLayer.Graphics.Add(g);
     }
     else if (BarriersRadioButton.IsChecked.Value)
     {
         barriersLayer.Graphics.Add(g);
     }
     if (stopsLayer.Graphics.Count > 1)
     {
         try
         {
             var routeTask = new RouteTask(new Uri("http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route"));
             var result = await routeTask.SolveAsync(new RouteParameter()
             {
                 Stops = new FeatureStops(stopsLayer.Graphics),
                 Barriers = new FeatureBarriers(barriersLayer.Graphics),
                 UseTimeWindows = false,
                 OutSpatialReference = MyMap.SpatialReference
             });
             if (result != null)
             {
                 if (result.Directions != null && result.Directions.Count > 0)
                 {
                     var direction = result.Directions.FirstOrDefault();
                     if (direction != null && direction.RouteSummary != null)
                         await new MessageDialog(string.Format("{0} minutes", direction.RouteSummary.TotalDriveTime.ToString("#0.000"))).ShowAsync();
                 }
                 GraphicsLayer routeLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
                 routeLayer.Graphics.Clear();
                 routeLayer.Graphics.AddRange(result.Routes);
             }
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message);
         }
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void pushpinTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            Pushpin tappedpin = sender as Pushpin;  // gets the pin that was tapped
            if (null == tappedpin) return;          // null check to prevent bad stuff if it wasn't a pin.

            var x = MapLayer.GetPosition(tappedpin);

            if (Map.ZoomLevel < 16.0)
            {
                Map.SetView(x, 16.0F);
            }
            else
            {
                if (e.GetPosition(Map).Y < 150 || e.GetPosition(Map).X < 100 || e.GetPosition(Map).X > Map.ActualWidth - 200)
                {
                    Map.SetView(x, Map.ZoomLevel);
                }
            }

            if (((Pushpin)sender).Name[0] == '@')
            {
                InfoBoxToReportButton.Visibility = Visibility.Collapsed;
                try
                {
                    await ShowMapBuildingInfoBox((Pushpin)sender);
                }
                catch (Exception)
                {
                    //QueuedBlock.Text = "ERROR DISPLAYING BUILDING INFOBOX";
                }
            }
            else
            {
                InfoBoxToReportButton.Visibility = Visibility.Visible;
                try
                {
                    await ShowMapReportInfoBox((Pushpin)sender);
                }
                catch (Exception)
                {
                    //QueuedBlock.Text = "ERROR DISPLAYING REPORT INFOBOX";
                }
            }
        }
 void DiagramCanvas_DoubleTapped(object sender, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e)
 {
     addFigureRectangle(e.GetPosition(this));
 }
        private void Parent_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            if (SelectedTool == InkingToolMode.Annotate)
            {
                Point position = e.GetPosition(null);
                // Find if we're intersecting with the toolbar, because we don't want annotation screens there.
                IEnumerable<UIElement> intersectedElements = VisualTreeHelper.FindElementsInHostCoordinates(position, _inkToolbar);
                // Check what elements of the sender we're on top of. If there's a button, we'll intersect with our toggle button collection
                // to confirm whether we'd like to simply 'hittest' that button.
                IEnumerable<UIElement> allIntersectedElements = VisualTreeHelper.FindElementsInHostCoordinates(position, (UIElement)sender);

                // Not intersected with the toolbar and no togglebuttons (of ours) in the way indicating there's another annotation, go ahead
                // and create the XAML.
                if (intersectedElements.Count() == 0 && (AnnotationTogglers.Intersect(allIntersectedElements.OfType<ButtonBase>())).Count() == 0)
                {
                    var panel = new Grid { Width = 300, Height = 200 };
                    StackPanel collapsingPanel = new StackPanel { Orientation = Orientation.Horizontal };
                    var toggleButtonText = new TextBlock { DataContext = this, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
                    var toggleButtonId = "tb" + Guid.NewGuid().ToString();
                    var toggleButtonContent = new Grid();
                    toggleButtonContent.Children.Add(toggleButtonText);
                    toggleButtonContent.Children.Add(new FontIcon { FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = "\uE70B" });
                    var toggleButton = new ToggleButton { Content = new Viewbox { Child = toggleButtonContent }, Name = toggleButtonId, RenderTransform = new TranslateTransform { X = -10 }, Width = 32, Height = 32, Template = null, VerticalAlignment = VerticalAlignment.Top };
                    toggleButton.AddHandler(ToggleButton.PointerPressedEvent, new PointerEventHandler(ToggleButton_PointerPressed), true);
                    toggleButton.AddHandler(ToggleButton.PointerReleasedEvent, new PointerEventHandler(ToggleButton_PointerReleased), true);
                    toggleButton.AddHandler(ToggleButton.PointerMovedEvent, new PointerEventHandler(ToggleButton_PointerMoved), true);

                    toggleButton.PointerReleased += ToggleButton_PointerReleased;
                    AnnotationTogglers.Add(toggleButton);
                    toggleButtonText.SetBinding(TextBlock.TextProperty, new Binding { Path = new PropertyPath("AnnotationTogglers"), Converter = listIndexerConverter, ConverterParameter = toggleButtonId, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
                    collapsingPanel.Children.Add(toggleButton);

                    var innerGrid = new Grid();

                    CommandBar richTextEditBar = new CommandBar();
                    var boldButton = new AppBarButton { Label = "Bold", Icon = new SymbolIcon(Symbol.Bold) };
                    // TODO: remove when destroyed
                    boldButton.Click += BoldButton_Click;
                    richTextEditBar.PrimaryCommands.Add(boldButton);
                    var italicButton = new AppBarButton { Label = "Italic", Icon = new SymbolIcon(Symbol.Italic) };
                    // TODO: remove when destroyed
                    italicButton.Click += ItalicButton_Click;
                    richTextEditBar.PrimaryCommands.Add(italicButton);

                    innerGrid.Children.Add(new RichEditBox { Header = richTextEditBar, Width = 200 });
                    var deleteIcon = new FontIcon { Name = "deleteIcon", FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = "\uE74D", Margin = new Thickness(0, 0, 5, 5), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom };
                    deleteIcon.Tapped += new Windows.UI.Xaml.Input.TappedEventHandler((o, a) => { DeleteAnnotation(panel); });
                    innerGrid.Children.Add(deleteIcon);
                    innerGrid.SetBinding(Grid.VisibilityProperty, new Binding { ElementName = toggleButton.Name, Path = new PropertyPath("IsChecked"), Converter = booleanToVisibilityConverter });
                    collapsingPanel.Children.Add(innerGrid);
                    panel.Children.Add(collapsingPanel);

                    Canvas.SetLeft(panel, position.X);
                    Canvas.SetTop(panel, position.Y);

                    _annotationCanvas.Children.Add(panel);
                }
            }
        }
 private async void MyMap_Tapped_1(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
 {
     var mp = MyMap.ScreenToMap(e.GetPosition(MyMap));
     await RunIdentify(mp);
 }
Example #8
0
        /// <summary>
        /// ${ui_action_Pan_event_OnDoubleTapped_D}
        /// </summary>
        public override void OnDoubleTapped(Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e)
        {
            base.OnDoubleTapped(e);
            Point curMousePos = e.GetPosition(Map);
            Map.ZoomToResolution(Map.GetNextResolution(!(KeyboardHelper.ShiftIsDown())), Map.ScreenToMap(curMousePos));

        }
Example #9
0
 private void StackPanel_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e)
 {
     var stackpanelitem = (StackPanel)sender;
     SiteKeyItemFlyout.ShowAt(stackpanelitem, e.GetPosition(stackpanelitem));
     sitekeyRightClicked = (Model.SiteKeyItem)((FrameworkElement)sender).DataContext;
 }
		private void OnGridChartArea_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
		{
			if (GridChartArea.Visibility == Visibility.Visible && GridChartArea.ActualHeight > 0.0 && GridChartArea.ActualWidth > 0.0)
			{
				Point touchPosition = e.GetPosition(GridChartArea);
				ChartTapped?.Invoke(this, new ChartTappedArguments() { X = touchPosition.X, Y = touchPosition.Y, XMax = GridChartArea.ActualWidth, YMax = GridChartArea.ActualHeight });
			}
		}