예제 #1
0
        private void RemoveShape(object viewModel)
        {
            var shape = _mapLayer.Shapes.FirstOrDefault(p => MapElementProperties.GetViewModel(p) == viewModel);

            if (shape != null)
            {
                _mapLayer.Shapes.Remove(shape);
                shape.Tapped -= ShapeTapped;
            }
        }
예제 #2
0
        private void ShapeTapped(object sender, TappedRoutedEventArgs e)
        {
            var shape = sender as MapShape;

            if (shape != null)
            {
                var viewModel = MapElementProperties.GetViewModel(shape);
                if (viewModel != null)
                {
                    FireViewmodelCommand(viewModel, TapCommand);
                }
            }
        }
예제 #3
0
        private void ReplaceShape(object viewModel)
        {
            var shape = _mapLayer.Shapes.FirstOrDefault(p => MapElementProperties.GetViewModel(p) == viewModel);

            if (shape != null)
            {
                var shapeLocation = _mapLayer.Shapes.IndexOf(shape);
                if (shapeLocation != -1)
                {
                    var newShape = CreateShape(viewModel);
                    if (newShape != null)
                    {
                        _mapLayer.Shapes[shapeLocation].Tapped -= ShapeTapped;
                        _mapLayer.Shapes[shapeLocation]         = CreateShape(viewModel);
                    }
                }
            }
            else
            {
                AddNewShape(viewModel);
            }
        }