Ejemplo n.º 1
0
        public void Refresh(Thing refreshThing = null)
        {
            if (refreshThing != null)
            {
                // Only one thing needs an update
            }
            else
            {
                // All things must be updated

                // All zones
                WherigoCollection <Zone> zones = ctrl.Engine.ActiveVisibleZones;

                foreach (Zone z in zones)
                {
                    CreateZone(z);
                }

                // All items
                WherigoCollection <Thing> things = ctrl.Engine.VisibleObjects;

                foreach (Thing t in things)
                {
                    CreateThing(t);                    //					createThing (t);
                }
            }

            if (thing != null)
            {
                NavigationItem.Title = thing.Name;
            }
        }
		public void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
		{
			bool remove = false;

			if (activeObject == null)
				return;

			if (e.PropertyName.Equals("Commands"))
				commands = ((Thing)activeObject).ActiveCommands;

			// Check, if one of the visible entries changed
			if (!(e is PropertyChangedEventArgs) || (e is PropertyChangedEventArgs && properties.Contains(((PropertyChangedEventArgs)e).PropertyName)))
				_refresh.Call(e.PropertyName);

			// The object is set to not visible or not active, so it should removed from screen
			if (e.PropertyName.Equals("Visible") || e.PropertyName.Equals("Active"))
				remove = !activeObject.Visible;
			// The object is moved to nil, so it should removed from screen
			if (e.PropertyName.Equals("Container") && !(activeObject is Task) && ((Thing)activeObject).Container == null)
				remove = true;

			if (remove) {
				StopEvents ();
				ctrl.RemoveScreen (this);
			}
		}
Ejemplo n.º 3
0
            public void SetTargetZone(Zone zone)
            {
                // Orders points by key.
                WherigoCollection <ZonePoint> zonePoints = zone.Points;

                if (zonePoints == null)
                {
                    TargetZonePoints     = new Point[] { };
                    TargetZonePointCount = 0;
                }
                else
                {
                    TargetZonePoints     = zonePoints.Select(zp => new Point(zp)).ToArray();
                    TargetZonePointCount = TargetZonePoints.Count();
                }
            }
Ejemplo n.º 4
0
        /// <summary>
        /// Compares the points from polygon and zone.
        /// </summary>
        /// <returns><c>true</c>, if points from polygon and zone are the same, <c>false</c> otherwise.</returns>
        /// <param name="polygonPoints">Polygon points.</param>
        /// <param name="zonePoints">Zone points.</param>
        bool ComparePoints(IList <LatLng> polygonPoints, WherigoCollection <ZonePoint> zonePoints)
        {
            if (polygonPoints.Count != zonePoints.Count)
            {
                return(false);
            }

            for (int i = 0; i < polygonPoints.Count; i++)
            {
                if (polygonPoints[i].Latitude != zonePoints[i].Latitude || polygonPoints[i].Longitude != zonePoints[i].Longitude)
                {
                    return(false);
                }
            }

            return(true);
        }
        public void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            bool remove = false;

            if (activeObject == null)
            {
                return;
            }

            if (e.PropertyName.Equals("Commands"))
            {
                commands = ((Thing)activeObject).ActiveCommands;
            }

            // Check, if one of the visible entries changed
            if (!(e is PropertyChangedEventArgs) || (e is PropertyChangedEventArgs && properties.Contains(((PropertyChangedEventArgs)e).PropertyName)))
            {
                _refresh.Call(e.PropertyName);
            }

            // The object is set to not visible or not active, so it should removed from screen
            if (e.PropertyName.Equals("Visible") || e.PropertyName.Equals("Active"))
            {
                remove = !activeObject.Visible;
            }
            // The object is moved to nil, so it should removed from screen
            if (e.PropertyName.Equals("Container") && !(activeObject is Task) && ((Thing)activeObject).Container == null)
            {
                remove = true;
            }

            if (remove)
            {
                StopEvents();
                ctrl.RemoveScreen(this);
            }
        }
Ejemplo n.º 6
0
        void CreateZone(Zone z)
        {
            Overlay polygon;
            Marker  marker;

            if (!z.Active || !z.Visible)
            {
                if (overlays.ContainsKey(z.ObjIndex))
                {
                    overlays.TryGetValue(z.ObjIndex, out polygon);
                    if (polygon != null)
                    {
                        polygon.Map = null;
                    }
                    overlays.Remove(z.ObjIndex);
                    markers.TryGetValue(z.ObjIndex, out marker);
                    if (marker != null)
                    {
                        marker.Map = null;
                    }
                    markers.Remove(z.ObjIndex);
                }
                return;
            }

            if (!overlays.TryGetValue(z.ObjIndex, out polygon))
            {
                polygon = new Polygon()
                {
                    FillColor   = Colors.ZoneFill,
                    StrokeColor = Colors.ZoneStroke,
                    StrokeWidth = 2,
                    Tappable    = true,
                    Map         = mapView
                };
                overlays.Add(z.ObjIndex, polygon);
            }

            if (!markers.TryGetValue(z.ObjIndex, out marker))
            {
                marker = new Marker()
                {
                    Tappable         = true,
                    Icon             = (z.Icon != null ? UIImage.LoadFromData(NSData.FromArray(z.Icon.Data)) : Images.IconMapZone),
                    GroundAnchor     = z.Icon != null ? new PointF(0.5f, 0.5f) : new PointF(0.075f, 0.95f),
                    InfoWindowAnchor = z.Icon != null ? new PointF(0.5f, 0.5f) : new PointF(0.075f, 0.0f),
                    Map = mapView
                };
                markers.Add(z.ObjIndex, marker);
            }

            polygon.Title = z.Name;
            marker.Title  = z.Name;

            var inventory = (WherigoCollection <Thing>)z.Inventory;

            if (inventory.Count > 0)
            {
                StringBuilder s = new StringBuilder();

                foreach (Thing thing in inventory)
                {
                    s.Append((s.Length > 0 ? ", " : "") + (thing.Name == null ? "" : thing.Name));
                }

                marker.Snippet = Catalog.Format(Catalog.GetString("Contains {0}"), s.ToString());
            }

            MutablePath path = new MutablePath();;
            WherigoCollection <ZonePoint> points = z.Points;

            double lat = 0;
            double lon = 0;

            foreach (ZonePoint zp in points)
            {
                lat += zp.Latitude;
                lon += zp.Longitude;
                path.AddLatLon(zp.Latitude, zp.Longitude);
            }

            ((Polygon)polygon).Path = path;
            polygon.ZIndex          = 50;

            marker.Position = new CLLocationCoordinate2D((float)lat / (float)points.Count, (float)lon / (float)points.Count);
            marker.ZIndex   = 100;
        }
Ejemplo n.º 7
0
		/// <summary>
		/// Compares the points from polygon and zone.
		/// </summary>
		/// <returns><c>true</c>, if points from polygon and zone are the same, <c>false</c> otherwise.</returns>
		/// <param name="polygonPoints">Polygon points.</param>
		/// <param name="zonePoints">Zone points.</param>
		bool ComparePoints(IList<LatLng> polygonPoints, WherigoCollection<ZonePoint> zonePoints)
		{
			if (polygonPoints.Count != zonePoints.Count)
				return false;

			for (int i = 0; i < polygonPoints.Count; i++) {
				if (polygonPoints[i].Latitude != zonePoints[i].Latitude || polygonPoints[i].Longitude != zonePoints[i].Longitude)
					return false;
			}

			return true;
		}