Пример #1
0
        public static SubjectBase ReadSubject(string xml, List<SubjectBase> floatSubjects, out MapTheme theme,out MapViewModel viewmodel)
        {
            XmlDocument NexusDocument = new XmlDocument();

            NexusDocument.LoadXml(xml);

            theme = MapTheme.Default;
            viewmodel = MapViewModel.ExpandRightSide;
            //Read Map Attributes
            foreach (XmlAttribute att in NexusDocument.DocumentElement.Attributes)
            {
                string name = att.Name;
                string value = att.Value;
                if(name=="Theme")
                {
                    theme = (MapTheme)Enum.Parse(typeof(MapTheme), value);
                }
                else if (name == "ViewModel")
                {
                    viewmodel = (MapViewModel)Enum.Parse(typeof(MapViewModel), value);
                }
            }
            //Read CenterSubject,FloatSubject
            SubjectBase centetSubject = null;
            foreach (XmlNode node in NexusDocument.DocumentElement.ChildNodes)
            {
                if(node.Name=="CenterSubject")
                {
                    centetSubject = ReadSubjectInfo(node);
                }
                else
                {
                    SubjectBase floatSubject = ReadSubjectInfo(node);
                    floatSubjects.Add(floatSubject);
                }
            }
            return centetSubject;
        }
Пример #2
0
 public void SetXml(string xml)
 {
     ClearSubject();
     List<SubjectBase> floatSubjects = new List<SubjectBase>();
     MapTheme mapTheme = MapTheme.Default;
     MapViewModel mapViewModel = MapViewModel.ExpandRightSide;
     SubjectBase subject = XmlManage.ReadSubject(xml, floatSubjects, out mapTheme, out mapViewModel);
     centerProject = subject;
     SubjectBase.FloatSubjects = floatSubjects;
     Theme = mapTheme;
     ViewModel = mapViewModel;
     subjectNodes.Clear();
     AddSubjectNode(centerProject);
     foreach (SubjectBase floatSubject in SubjectBase.FloatSubjects)
     {
         AddSubjectNode(floatSubject);
     }
     Invalidate();
 }
Пример #3
0
        /// <summary>
        /// Should return all individual parts of the displayed layer in the Themes
        /// </summary>
        protected override IList <MapThemeLayerElementViewModel> NewThemeLayerElements(MapViewModel map, MapLayerViewModel layer)
        {
            // Get the base presentation for the Layer (style bits, parameter bits, mode bits)
            var elements = base.NewThemeLayerElements(map, layer);

            var geometryLayer = layer as FeatureGeometryMapLayerViewModel;

            if (geometryLayer != null)
            {
                elements.Insert(0, new LiteMapThemeLayerFeatureGeometryElement(map, geometryLayer));
            }

            return(elements);
        }
Пример #4
0
 public StartJourneyCommand(MapViewModel mapViewModel)
 {
     _mapViewModel = mapViewModel;
 }
 /// <summary>
 /// Provides a deterministic way to delete the MapViewModelPropertyName property.
 /// </summary>
 public static void ClearMapViewModelPropertyName()
 {
     if (_mapViewModel != null)
     {
         _mapViewModel.Cleanup();
         _mapViewModel = null;
     }
 }
Пример #6
0
        public static string SaveSubject(SubjectBase centerSubject, List<SubjectBase> floatSubjects,MapTheme theme,MapViewModel viewmodel)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement("JmMap");

            CreateObjectAttribute(doc, root, "Theme", theme.ToString());
            CreateObjectAttribute(doc, root, "ViewModel", viewmodel.ToString());

            SaveSubjectInfo(doc,root, centerSubject);
            foreach(SubjectBase floatSubject in floatSubjects)
            {
                SaveSubjectInfo(doc, root, floatSubject);
            }

            doc.AppendChild(root);
            string ss = doc.InnerXml;
            return ss;
        }
 public SearchCommand(MapViewModel map)//
 {
     this.mapViewModel = map;
 }
Пример #8
0
        private void Command_Open(object sender, ExecutedRoutedEventArgs e)
        {
            var openDialog = new OpenFileDialog
                {
                    CheckFileExists = true,
                    CheckPathExists = true,
                    Title = "Select map file",
                    Filter = "Map files (.m)|*.m"
                };

            if (openDialog.ShowDialog(this) == true)
            {
                var filename = openDialog.FileName;

                try
                {
                    DataContext = new MapViewModel(FileOps.Load(filename));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Error loading: " + ex.Message);
                }
            }
        }
Пример #9
0
 public MapPage()
 {
     InitializeComponent();
     BindingContext = new MapViewModel();
 }
Пример #10
0
 public MapPage()
 {
     this.InitializeComponent();
     ViewModel             = new MapViewModel();
     MyMap.MapServiceToken = AppSettings.Default.MapsAPIKey;
 }
 /// <summary>
 /// If we leave the map, make sure we reset any button down events
 /// </summary>
 protected override void OnMouseLeave(MapViewModel map, MapMouseEventArgs args)
 {
     _mapButtonDownArgs = null;
     base.OnMouseLeave(map, args);
 }
        /// <summary>
        /// Override for the leftButtonDown event on the Map
        /// </summary>
        protected override void OnMouseLeftButtonDown(MapViewModel map, MapMouseEventArgs args)
        {
            _mapButtonDownArgs = args;

            base.OnMouseLeftButtonDown(map, args);
        }
 // Setting the map control view model
 public void SetVM(MapViewModel map_VM)
 {
     this.vmMap = map_VM;
 }
Пример #14
0
 /// <summary>
 /// On mouse rmc handler
 /// </summary>
 protected override void OnMouseRightButtonDown(MapViewModel sender, MapMouseEventArgs args)
 {
     Owner.OpenPopupMenu(args);
 }
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            try
            {
                var xOffset       = 8;
                var yOffset       = 28;
                var controlHeight = 30;
                var spacing       = 6;
                var viewWidth     = View.Bounds.Width;
                var viewHeight    = View.Bounds.Height;

                // --- First Row - from location ---

                // Add marker image
                var markerImage = UIImage.FromFile("./MarkerA.png");
                var imageView   = new UIImageView(markerImage)
                {
                    Frame       = new CGRect(xOffset, yOffset, controlHeight, controlHeight),
                    ContentMode = UIViewContentMode.ScaleToFill
                };
                View.AddSubview(imageView);

                // Add from text field
                var textFieldOffset = xOffset + imageView.Frame.Width + spacing;
                var textFieldWidth  = viewWidth - (textFieldOffset * 2);
                _fromTextField = new UITextField()
                {
                    Frame       = new CGRect(textFieldOffset, yOffset, textFieldWidth, controlHeight),
                    Placeholder = "from office or conference room",
                    BorderStyle = UITextBorderStyle.RoundedRect
                };
                _fromTextField.EditingChanged += FromTextField_EditingChanged;
                View.AddSubview(_fromTextField);

                // Add QR image
                var qrOffset = _fromTextField.Frame.Right + spacing;
                var qrImage  = UIImage.FromFile("./QRScan_Black.png");
                imageView = new UIImageView(qrImage)
                {
                    Frame       = new CGRect(qrOffset, yOffset, controlHeight, controlHeight),
                    ContentMode = UIViewContentMode.ScaleToFill
                };
                View.AddSubview(imageView);


                //// --- Second row - to location ---

                yOffset += controlHeight + spacing;

                // Add marker image
                markerImage = UIImage.FromFile("./MarkerB.png");
                imageView   = new UIImageView(markerImage)
                {
                    Frame       = new CGRect(xOffset, yOffset, controlHeight, controlHeight),
                    ContentMode = UIViewContentMode.ScaleToFill
                };
                View.AddSubview(imageView);

                // Add to text field
                _toTextField = new UITextField()
                {
                    Frame       = new CGRect(textFieldOffset, yOffset, textFieldWidth, controlHeight),
                    Placeholder = "to office or conference room",
                    BorderStyle = UITextBorderStyle.RoundedRect
                };
                _toTextField.EditingChanged += ToTextField_EditingChanged;
                View.AddSubview(_toTextField);

                // Add calendar image
                var calendarOffset = _toTextField.Frame.Right + spacing;
                var calendarImage  = UIImage.FromBundle("Calendar.png");
                imageView = new UIImageView(calendarImage)
                {
                    Frame       = new CGRect(calendarOffset, yOffset, controlHeight, controlHeight),
                    ContentMode = UIViewContentMode.ScaleToFill
                };
                View.AddSubview(imageView);



                // --- Third row - map view ---

                yOffset += controlHeight + spacing;

                // Initialize view-model
                _mapViewModel = new MapViewModel();
                await _mapViewModel.LoadAsync();

                _mapViewModel.RequestViewpoint += MapViewModel_RequestViewpoint;
                _mapViewModel.PropertyChanged  += MapViewModel_PropertyChanged;

                // Initialize map view
                _mapView = new MapView()
                {
                    Map = _mapViewModel.Map,
                    GraphicsOverlays = _mapViewModel.Overlays,
                    Frame            = new CGRect(0, yOffset, viewWidth, viewHeight - yOffset)
                };
                _mapView.DrawStatusChanged   += MapView_DrawStatusChanged;
                _mapView.NavigationCompleted += MapView_NavigationCompleted;
                View.AddSubview(_mapView);

                // --- Auto-complete drop-downs ---

                // Add table-view for auto-complete entries for "from" field
                _fromAutoCompleteTableView = new UITableView()
                {
                    Frame  = new CGRect(textFieldOffset, _fromTextField.Frame.Bottom, textFieldWidth, controlHeight),
                    Hidden = true
                };
                View.AddSubview(_fromAutoCompleteTableView);

                // Add table-view for auto-complete entries for "to" field
                _toAutoCompleteTableView = new UITableView()
                {
                    Frame  = new CGRect(textFieldOffset, _toTextField.Frame.Bottom, textFieldWidth, controlHeight),
                    Hidden = true
                };
                View.AddSubview(_toAutoCompleteTableView);


                // --- Walk-time UI ---

                controlHeight = 24;
                var routeDetailsHeight = (controlHeight * 2) + spacing + (xOffset * 2);
                _routeDetailsView = new UIView()
                {
                    BackgroundColor = UIColor.White,
                    Frame           = new CGRect(0, viewHeight - routeDetailsHeight, viewWidth, routeDetailsHeight),
                    Hidden          = true
                };

                var titleWidth    = 200;
                var fontSize      = 22;
                var cfBlue        = System.Drawing.Color.CornflowerBlue;
                var cfBlueUIColor = UIColor.FromRGB(cfBlue.R, cfBlue.G, cfBlue.B);
                _walkTimeTitle = new UILabel()
                {
                    TextColor = cfBlueUIColor,
                    Font      = UIFont.BoldSystemFontOfSize(fontSize),
                    Text      = "Walk Time",
                    Frame     = new CGRect(xOffset, xOffset, titleWidth, controlHeight)
                };
                _routeDetailsView.AddSubview(_walkTimeTitle);

                var timeLabelOffset = _walkTimeTitle.Frame.Right;
                var timeLabelWidth  = viewWidth - xOffset - timeLabelOffset;
                _walkTime = new UILabel()
                {
                    TextColor     = cfBlueUIColor,
                    Font          = UIFont.BoldSystemFontOfSize(fontSize),
                    Text          = "00:00:00",
                    TextAlignment = UITextAlignment.Right,
                    Frame         = new CGRect(timeLabelOffset, xOffset, timeLabelWidth, controlHeight)
                };
                _routeDetailsView.AddSubview(_walkTime);

                var altFontSize = 18;
                var altYOffset  = _walkTime.Frame.Bottom + spacing;
                _walkTimeAltTitle = new UILabel()
                {
                    TextColor = UIColor.Gray,
                    Font      = UIFont.BoldSystemFontOfSize(altFontSize),
                    Text      = "Alternate Route",
                    Frame     = new CGRect(xOffset, altYOffset, titleWidth, controlHeight)
                };
                _routeDetailsView.AddSubview(_walkTimeAltTitle);

                _walkTimeAlt = new UILabel()
                {
                    TextColor     = UIColor.Gray,
                    Font          = UIFont.BoldSystemFontOfSize(altFontSize),
                    Text          = "00:00:00",
                    TextAlignment = UITextAlignment.Right,
                    Frame         = new CGRect(timeLabelOffset, altYOffset, timeLabelWidth, controlHeight)
                };
                _routeDetailsView.AddSubview(_walkTimeAlt);

                View.AddSubview(_routeDetailsView);

                // --- Busy indicator view ---

                _busyView = new UIView()
                {
                    BackgroundColor = UIColor.White,
                    Frame           = _routeDetailsView.Frame,
                    Hidden          = true
                };

                var busyIndicatorSize = 44;
                var busyIndicatorTop  = (_busyView.Frame.Height - busyIndicatorSize) / 2;
                _busyIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge)
                {
                    Color = UIColor.Gray,
                    Frame = new CGRect(xOffset, busyIndicatorTop, busyIndicatorSize, busyIndicatorSize)
                };
                _busyIndicator.StartAnimating();
                _busyView.AddSubview(_busyIndicator);

                _busyLabel = new UILabel()
                {
                    TextColor = cfBlueUIColor,
                    Font      = UIFont.BoldSystemFontOfSize(fontSize),
                    Text      = "Calculating...",
                    Frame     = new CGRect(busyIndicatorSize + xOffset, busyIndicatorTop, titleWidth, busyIndicatorSize)
                };
                _busyView.AddSubview(_busyLabel);

                View.AddSubview(_busyView);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"{ex.Message}\n{ex.StackTrace}");
            }
        }
Пример #16
0
 private void Command_New(object sender, ExecutedRoutedEventArgs e)
 {
     DataContext = new MapViewModel(new Map());
 }
Пример #17
0
        /// ------------------------------------------------------------------------------------------------
        ///
        protected override void OnElementChanged(Xamarin.Forms.Platform.iOS.ElementChangedEventArgs <View> e)
        {
            try
            {
                base.OnElementChanged(e);
                if (e.OldElement != null)
                {
                    if (formsMap == null)
                    {
                        formsMap = (CustomMap)e.NewElement;
                    }
                    this.MapViewInstance().GetViewForAnnotation = null;
                    customPins.Clear();
                }
                if (e.NewElement != null)
                {
                    if (formsMap == null)
                    {
                        formsMap = (CustomMap)e.NewElement;
                    }
                    var customView = Control as CustomMKAnnotationView;

                    if (Control != null)
                    {
                        Control.RemoveGestureRecognizer(_tapRecogniser);
                    }
                    base.OnElementChanged(e);
                    if (Control != null)
                    {
                        Control.AddGestureRecognizer(_tapRecogniser);
                    }

                    if (customPins == null)
                    {
                        customPins = new List <CustomPin>();
                    }
                    else if (customPins != null && customPins.Count != 0)
                    {
                        customPins.Clear();
                    }

                    var singlePin = MapViewModel.GetCurrentPin();
                    if (singlePin != null)
                    {
                        formsMap.Pins.Add(singlePin.Pin);
                        customPins.Add(singlePin);
                    }
                    formsMap.ClearPins = () =>
                    {
                        if (customPins != null)
                        {
                            formsMap?.Pins.Clear();
                            customPins.Clear();
                        }
                    };
                    formsMap.LoadPins = Pins =>
                    {
                        if (Pins != null)
                        {
                            customPins.Clear();
                            formsMap.Pins.Clear();
                            foreach (var pin in Pins)
                            {
                                formsMap.CustomPins = Pins;
                                formsMap.Pins.Add(pin.Pin);
                                customPins.Add(pin);
                            }
                        }
                    };
                    this.MapViewInstance().GetViewForAnnotation = GetViewForAnnotation;
                    formsMap.DisposeMapControl = () =>
                    {
                        try
                        {
                            //
                            annotationView?.RemoveFromSuperview();
                            annotationView?.Dispose();
                            //
                            _nativeMap?.RemoveFromSuperview();
                            _nativeMap?.Delegate?.Dispose();
                            _nativeMap.Delegate = null;
                            _nativeMap?.Dispose();
                            //
                            NativeView?.RemoveFromSuperview();
                            NativeView?.Dispose();
                            //
                            formsMap   = null;
                            customPins = null;
                            singlePin  = null;
                            //
                            customView?.RemoveFromSuperview();
                            customView?.Dispose();
                            //
                            Control?.RemoveFromSuperview();
                            Control?.Dispose();
                            //
                        }
                        catch (ObjectDisposedException ex)
                        {
                        }
                        catch (Exception ex)
                        {
                        }
                    };
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #18
0
 private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     model = DataContext as MapViewModel;
 }
Пример #19
0
 public ContainerAddViewModel CreateAddViewModel(MapViewModel selectedMap)
 {
     return(new ContainerAddViewModel(CreateNewContainerModel(selectedMap), m_AvvWasteTypeProvider));
 }
Пример #20
0
		public MapView(MapViewModel mapViewModel) : base()
		{
			MapSpan span;

//			this.BindingContext = mapViewModel;

			map = new ExtendedMap(mapViewModel.VisibleRegion) 
				{
					HorizontalOptions = LayoutOptions.FillAndExpand,
					VerticalOptions = LayoutOptions.FillAndExpand,
					IsShowingUser = true,
				};

			this.mapViewModel = mapViewModel;
			this.mapViewModel.Map = map;

			var tapRecognizer = new TapGestureRecognizer 
				{
					Command = this.mapViewModel.CommandButtonCenterPressed,
					NumberOfTapsRequired = 1
				};

			var mapButtonCenter = new Image() {
				BindingContext = mapViewModel,
				Source = "IconMapCenter.png",
			};
			mapButtonCenter.GestureRecognizers.Add(tapRecognizer);

			#if __IOS__

			tapRecognizer = new TapGestureRecognizer 
				{
					Command = this.mapViewModel.CommandButtonOrientationPressed,
					NumberOfTapsRequired = 1
				};

			var mapButtonOrientation = new Image() {
				BindingContext = mapViewModel,
				Source = "IconMapNorth.png",
			};
			mapButtonOrientation.SetBinding(Image.SourceProperty, MapViewModel.MapOrientationSourcePropertyName);
			mapButtonOrientation.GestureRecognizers.Add(tapRecognizer);

			#endif

			tapRecognizer = new TapGestureRecognizer 
				{
					Command = this.mapViewModel.CommandButtonTypePressed,
					NumberOfTapsRequired = 1
				};

			var mapButtonType = new Image() {
				BindingContext = mapViewModel,
				Source = "IconMapType.png",
			};
			mapButtonType.GestureRecognizers.Add(tapRecognizer);

			// Do this, because Xamarin.Forms don't update the relative layout after calculationg the size of the direction stack.
			mapButtonType.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
				if(e.PropertyName == "Height" || e.PropertyName == "Width")
				{
					layout.ForceLayout();
				}
			};

			layout = new RelativeLayout() 
			{
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
			};

			layout.Children.Add(map,
				Constraint.Constant(0),
				Constraint.Constant(0),
				Constraint.RelativeToView(layout, (p, v) => v.Width),
				Constraint.RelativeToView(layout, (p, v) => v.Height));

			layout.Children.Add(mapButtonCenter, 
				Constraint.Constant(frame),
				Constraint.Constant(38 + frame));

			#if __IOS__

			layout.Children.Add(mapButtonOrientation, 
				Constraint.Constant(frame),
				Constraint.RelativeToParent(p => 38 + frame + mapButtonCenter.Width + frame));

			#endif

			layout.Children.Add(mapButtonType, 
				Constraint.RelativeToParent(p => p.Width - frame - mapButtonType.Width),
				Constraint.Constant(38 + frame));

			var font = Device.OnPlatform(Font.SystemFontOfSize(16).WithAttributes(FontAttributes.Bold), Font.SystemFontOfSize(14), Font.SystemFontOfSize(16).WithAttributes(FontAttributes.Bold));
			// Create position entries at bottom of screen
			var latitude = new Label() 
				{
					HorizontalOptions = LayoutOptions.FillAndExpand,
					XAlign = TextAlignment.Start,
					TextColor = Color.White,
					Font = font,
				};
			latitude.SetBinding(Label.TextProperty, MapViewModel.PositionPropertyName, BindingMode.OneWay, new ConverterToLatitude());

			var longitude = new Label() 
				{
					HorizontalOptions = LayoutOptions.FillAndExpand,
					XAlign = TextAlignment.Start,
					TextColor = Color.White,
					Font = font,
				};
			longitude.SetBinding(Label.TextProperty, MapViewModel.PositionPropertyName, BindingMode.OneWay, new ConverterToLongitude());

			var altitude = new Label() 
				{
					XAlign = TextAlignment.End,
					TextColor = Color.White,
					Font = font,
				};
			altitude.SetBinding(Label.TextProperty, MapViewModel.PositionPropertyName, BindingMode.OneWay, new ConverterToAltitude());

			var accuracy = new Label() 
				{
					XAlign = TextAlignment.End,
					TextColor = Color.White,
					Font = font,
				};
			accuracy.SetBinding(Label.TextProperty, MapViewModel.PositionPropertyName, BindingMode.OneWay, new ConverterToAccuracy());

			var imageAltitude = new Image() 
				{
					WidthRequest = 16,
					HeightRequest = 16,
					Source = "IconAltitudeLight.png",
				};

			var imageAccuracy = new Image() 
				{
					WidthRequest = 16,
					HeightRequest = 16,
					Source = "IconAccuracyLight.png",
				};

			var layoutPosition = new Grid() 
				{
					BackgroundColor = Color.Gray.MultiplyAlpha(0.8),
					HorizontalOptions = LayoutOptions.FillAndExpand,
					Padding = new Thickness(10, Device.OnPlatform(4, 2, 4)),
					RowSpacing = 2,
				};

			layoutPosition.RowDefinitions = new RowDefinitionCollection {
				new RowDefinition { Height = 16 },
				new RowDefinition { Height = 16 }
			};

			layoutPosition.ColumnDefinitions = new ColumnDefinitionCollection {
				new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) },
				new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
				new ColumnDefinition { Width = 16 }
			};

			layoutPosition.Children.Add(latitude, 0, 0);
			layoutPosition.Children.Add(longitude, 0, 1);
			layoutPosition.Children.Add(imageAltitude, 2, 0);
			layoutPosition.Children.Add(imageAccuracy, 2, 1);
			layoutPosition.Children.Add(altitude, 1, 0);
			layoutPosition.Children.Add(accuracy, 1, 1);

			layout.Children.Add(layoutPosition, 
				Constraint.Constant(0), //.RelativeToParent(p => p.Width - layoutBottomHori.Width - 8),
				Constraint.Constant(0), //RelativeToParent(p => p.Height - 44 - 8));
				Constraint.RelativeToParent(p => p.Width),
				Constraint.Constant(40));

			this.Content = layout;
		}
Пример #21
0
 public MeterAddViewModel CreateAddViewModel(MapViewModel selectedMap)
 {
     return(new MeterAddViewModel(CreateNewMeterModel(selectedMap)));
 }
Пример #22
0
 public MapPage(Position startingposition)
 {
     InitializeComponent();
     BindingContext = new MapViewModel(startingposition, Navigation);
 }
Пример #23
0
 public MapView()
 {
     InitializeComponent();
     DataContext = new MapViewModel(Dispatcher);
 }
 /// <summary>
 /// Provides a deterministic way to create the MapViewModelPropertyName property.
 /// </summary>
 public static void CreateMapViewModelPropertyName()
 {
     _mapViewModel = new MapViewModel();
 }
Пример #25
0
 public string Map(MapViewModel mapModel)
 {
     return("Lat: " + mapModel.Lat + "\nLong: " + mapModel.Long);
 }