/// <summary> /// Constructor. /// </summary> /// <param name="zone">Zone to show.</param> private ZoneGraphicObject(Zone zone) : base(zone) { _zone = zone; _zone.PropertyChanged += new PropertyChangedEventHandler(_ZonePropertyChanged); ESRI.ArcGIS.Client.Geometry.Geometry geometry = _CreateGeometry(zone); Geometry = geometry; Attributes.Add(SymbologyContext.FILL_ATTRIBUTE_NAME, null); _CreateSymbol(); }
/// <summary> /// Create zone geometry. /// </summary> /// <param name="zone">Zone for creating geometry.</param> /// <returns>Created geometry.</returns> private ESRI.ArcGIS.Client.Geometry.Geometry _CreateGeometry(Zone zone) { ESRI.ArcGIS.Client.Geometry.Geometry geometry = null; if (zone.Geometry != null) { if (zone.Geometry is ESRI.ArcLogistics.Geometry.Point?) { ESRI.ArcLogistics.Geometry.Point? point = zone.Geometry as ESRI.ArcLogistics.Geometry.Point?; geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(point.Value.X, point.Value.Y); } else { int? spatialReference = null; if (ParentLayer != null) { spatialReference = ParentLayer.SpatialReferenceID; } geometry = MapHelpers.ConvertToArcGISPolygon( zone.Geometry as ESRI.ArcLogistics.Geometry.Polygon, spatialReference); } } else { geometry = null; } return geometry; }
/// <summary> /// Create graphic object for zone. /// </summary> /// <param name="zone">Source zone.</param> /// <returns>Graphic object for zone.</returns> public static ZoneGraphicObject Create(Zone zone) { ZoneGraphicObject graphic = null; graphic = new ZoneGraphicObject(zone); return graphic; }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns></returns> public override object Clone() { Zone obj = new Zone(); this.CopyTo(obj); return obj; }
/// <summary> /// Fill zone tip /// </summary> /// <param name="inlines">Inlines to fill</param> /// <param name="location">Source zone</param> private static void _FillZone(InlineCollection inlines, Zone zone) { string name = zone.Name; _AddLine(_nameCaption, name, inlines, false); if (App.Current.MainWindow.CurrentPage == _optimizeAndEditPage) { string zoneAssignment = ""; foreach (Route route in _optimizeAndEditPage.CurrentSchedule.Routes) { if (route.Zones.Contains(zone)) { if (zoneAssignment.Length != 0) zoneAssignment += ROUTE_SEPARATOR; zoneAssignment += route.Name; } } if (zoneAssignment.Length > 0) _AddLine(_zoneAssignmentCaption, zoneAssignment, inlines, false); } }
public static void makeEdit(string field, string value) { field = field.Replace(" ", ""); string message = "Changing " + field + " to " + value + " for all seleced routes."; App.Current.Messenger.AddInfo(message); ISupportSelection selector = (ISupportSelection)App.Current.MainWindow.CurrentPage; for (int i = 0; i < selector.SelectedItems.Count; i++) { Route routeRef = (Route)selector.SelectedItems[i]; double tempD; DateTime TWdateTime; try { switch (field) { #region Case Statements case "RouteName": routeRef.Name = value; break; case "Vehicle": foreach (Vehicle v in App.Current.Project.Vehicles) { if (v.Name == value) routeRef.Vehicle = v; } break; case "Driver": foreach (Driver d in App.Current.Project.Drivers) { if (d.Name == value) routeRef.Driver = d; } break; case"StartTimeWindowStart": if (DateTime.TryParse(value, out TWdateTime)) { if (TWdateTime.TimeOfDay != TimeSpan.Zero) { routeRef.StartTimeWindow.From = TWdateTime.TimeOfDay; routeRef.StartTimeWindow.IsWideOpen = false; } } break; case "StartTimeWindowFinish": if (DateTime.TryParse(value, out TWdateTime)) { if (TWdateTime.TimeOfDay != TimeSpan.Zero) { routeRef.StartTimeWindow.To = TWdateTime.TimeOfDay; routeRef.StartTimeWindow.IsWideOpen = false; } } break; case "StartLocation": foreach (Location l in App.Current.Project.Locations) { if (l.Name == value) routeRef.StartLocation = l; } break; case "TimeAtStart": if (Double.TryParse(value.ToString(), out tempD)) routeRef.TimeAtStart = tempD; break; case "EndLocation": foreach (Location l in App.Current.Project.Locations) { if (l.Name == value) routeRef.EndLocation = l; } break; case "TimeAtEnd": if (Double.TryParse(value.ToString(), out tempD)) routeRef.TimeAtEnd = tempD; break; case "RenewalLocation": if (value != "") { string[] stringSeparators2 = new string[] { ";", "," }; string[] locations2 = value.Split(stringSeparators2, StringSplitOptions.None); foreach (string s in locations2) { bool locationFound = false; bool addToRoute = true; Location l = new Location(); l.Name = s; foreach (Location L in App.Current.Project.Locations) { if (String.Compare(L.Name, l.Name, true) == 0) { L.CopyTo(l); locationFound = true; break; } } foreach (Location L in routeRef.RenewalLocations) { if (String.Compare(L.Name, l.Name, true) == 0) { addToRoute = false; break; } } if(locationFound && addToRoute) routeRef.RenewalLocations.Add(l); } } break; case "TimeAtRenewal": if (Double.TryParse(value.ToString(), out tempD)) routeRef.TimeAtRenewal = tempD; break; case "MaxOrders": if (Double.TryParse(value.ToString(), out tempD)) routeRef.MaxOrders =(int) tempD; break; case "MaxTravelDistance": if (Double.TryParse(value.ToString(), out tempD)) routeRef.MaxTravelDistance = tempD; break; case "MaxTravelDuration": if (Double.TryParse(value.ToString(), out tempD)) routeRef.MaxTravelDuration = tempD; break; case "MaxTotalDuration": if (Double.TryParse(value.ToString(), out tempD)) routeRef.MaxTotalDuration = tempD; break; case "Zones": if (value != "") { string[] stringSeparators = new string[] { ";", "," }; string[] zones = value.Split(stringSeparators, StringSplitOptions.None); foreach (string s in zones) { bool zoneFound = false; bool addToRoute = true; Zone z = new Zone(); z.Name = s; foreach (Zone Z in App.Current.Project.Zones) { if (String.Compare(Z.Name, z.Name, true) == 0) { Z.CopyTo(z); zoneFound = true; break; } } foreach (Zone Z in routeRef.Zones) { if (String.Compare(Z.Name, z.Name, true) == 0) { addToRoute = false; break; } } if (zoneFound && addToRoute) routeRef.Zones.Add(z); } } break; case "HardZones": if ((String.Compare(value, "Yes", true) == 0) || (String.Compare(value, "Y", true) == 0) || (String.Compare(value, "True", true) == 0)) routeRef.HardZones = true; else if ((String.Compare(value, "NO", true) == 0) || (String.Compare(value, "N", true) == 0) || (String.Compare(value, "False", true) == 0)) routeRef.HardZones = false; break; case "Comment":routeRef.Comment = value; break; #endregion }// End Switch } catch (Exception e) { message = "Error: " + e.Message; App.Current.Messenger.AddError(message); } } App.Current.Project.Save(); }