public IModelPoiInstance GetPoiInstance(PoI poi) { var ppp = new PathPlannerPoi { Poi = poi, Model = this }; var key = Id + ".VisitedLocations"; // NOTE the key with the same name in PathPlannerViewModel if (poi.Labels.ContainsKey(key) && !string.IsNullOrEmpty(poi.Labels[key])) { ppp.VisitedLocations = new VisitedLocations(); var visitedLocations = poi.Labels[key].Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var split in visitedLocations) { var visitedLocation = new VisitedLocation(); visitedLocation.FromString(split); ppp.VisitedLocations.Add(visitedLocation); } } poi.ModelInstances[Id] = ppp; return ppp; }
public void JumpToTime(VisitedLocation visitedLocation) { AppState.TimelineManager.SetFocusTime(visitedLocation.TimeOfVisit); //AppState.TimelineManager.ForceTimeChanged(); }
public void RemoveVisitedLocation(VisitedLocation visitedLocation) { var notificationEventArgs = new NotificationEventArgs { Id = Guid.NewGuid(), Background = Brushes.Red, Foreground = Brushes.Black, Header = "Delete location?", Text = string.Format("Do you want to delete {0}?", visitedLocation.Title), Duration = TimeSpan.FromDays(1), Options = new List<string> { "YES", "NO" } }; notificationEventArgs.OptionClicked += (sender, args) => { switch (args.Option) { case "NO": return; case "YES": VisitedLocations.Remove(visitedLocation); SaveVisitedLocationsLabel(); UpdateVisitedPath(); break; } }; AppState.TriggerNotification(notificationEventArgs); }
public void SelectTransition(VisitedLocation visitedLocation, FrameworkElement el) { if (animations == null) return; SelectedVisitedLocation = visitedLocation; var m = GetMenu(el); foreach (var animation in animations) m.AddMenuItem(animation.ToSentenceCase()); //foreach (MovementAnimationMode mode in Enum.GetValues(typeof(MovementAnimationMode))) //{ // m.AddMenuItem(mode.ToString().ToSentenceCase()); //} m.Selected += (s, f) => { var selectedMode = f.Object.ToString(); foreach (var mode in animations.Where(mode => string.Equals(selectedMode, mode.ToSentenceCase()))) { SelectedVisitedLocation.Transition = mode; foreach (var link in Model.Service.PoIs.OfType<PoI>().Where(p => p.Labels != null && p.Labels.ContainsKey(KeyCreatorId) && p.Labels.ContainsKey(KeySourceId) && string.Equals(p.Labels[KeyCreatorId], PoI.Id.ToString(), StringComparison.InvariantCultureIgnoreCase) && string.Equals(p.Labels[KeySourceId], SelectedVisitedLocation.Id.ToString(), StringComparison.InvariantCultureIgnoreCase)) .OrderBy(p => p.Labels[KeyLabelPathIndex])) { link.Labels[KeyAnimateMove] = mode; //if (!AppState.TimelineManager.IsPlaying || !PoI.Sensors.ContainsKey(KeyAnimateMove)) continue; //PoI.Sensors[KeyAnimateMove].Data.Keys.AsParallel().ForEach(k => PoI.Sensors[KeyAnimateMove].Data[k] = animation); } } SaveVisitedLocationsLabel(); }; AppStateSettings.Instance.Popups.Add(m); }
/// <summary> /// Create a path between source and sink. /// </summary> /// <param name="source"></param> /// <param name="sink"></param> /// <returns>A path containing two or more points.</returns> private static ObservableCollection<Point> CreatePath(VisitedLocation source, VisitedLocation sink) { return new ObservableCollection<Point> { new Point {X = source.Position.Longitude, Y = source.Position.Latitude}, new Point {X = sink.Position.Longitude, Y = sink.Position.Latitude} }; }
/// <summary> /// Create a link between source and sink. /// </summary> /// <param name="source"></param> /// <param name="sink"></param> /// <returns></returns> private PoI CreateLinkBetweenPoIs(VisitedLocation source, VisitedLocation sink) { var link = new PoI { Id = Guid.NewGuid(), Name = "Path", Position = source.Position, // Although not needed, if I don't supply this, the app freezes PoiTypeId = linkPoiType, UserId = PoI.Id.ToString(), Layer = PoI.Layer + "_path", Labels = new Dictionary<string, string> { {KeyCreatorId, PoI.Id.ToString()}, {KeySourceId, source.Id.ToString()}, {KeySinkId, sink.Id.ToString()}, {KeyStrokeColor, sink.StrokeColor}, {KeyLabelStartTime, source.TimeOfVisit.ToString("yyyy-MM-dd HH:mm:ss")}, {KeyLabelEndTime, sink .TimeOfVisit.ToString("yyyy-MM-dd HH:mm:ss")}, {KeyLabelDuration, (sink.TimeOfVisit - source.TimeOfVisit).ToString("dd'.'hh':'mm':'ss")}, {KeyAnimateMove, source.Transition}, {"IsActive", "false"} }, Points = CreatePath(source, sink) }; var convertFromString = ColorConverter.ConvertFromString(sink.StrokeColor); link.Style = new PoIStyle { CanMove = false, CanDelete = false, StrokeColor = convertFromString != null ? (Color)convertFromString : Colors.Blue, StrokeWidth = 3 }; link.Style.DrawingMode = DrawingModes.Polyline; link.UpdateEffectiveStyle(); var s = link.DrawingMode; return link; }