Ejemplo n.º 1
0
        public StrokeModel GetStroke(string id)
        {
            StrokeModel stroke;

            StrokesMap.TryGetValue(id, out stroke);
            return(stroke);
        }
Ejemplo n.º 2
0
        public void UpdateStroke(string id, StrokeModel stroke)
        {
            if (stroke != null)
            {
                stroke.AuthorId             = AuthService.CurrentUser?.Id ?? AuthService.OfflineClientId;
                stroke.LastModificationDate = DateTime.Now;
                Logger.Debug($"Adding stroke ${id}");
                if (IsOffline)
                {
                    StrokesMap[id] = stroke;
                }
            }
            else
            {
                Logger.Debug($"Removing stroke ${id}");
                if (IsOffline)
                {
                    StrokeModel _;
                    StrokesMap.TryRemove(id, out _);
                }
            }

            StrokesToUpdate[id]    = stroke;
            StrokesMapOverride[id] = stroke;

            if (IsOffline)
            {
                StrokesUpdated?.Invoke();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Merges the strokes map with the strokes map override to give the most recent strokes list available.
        /// </summary>
        public StrokeModelsList GetMergedStrokeMaps()
        {
            StrokeModel _;

            foreach (var stroke in StrokesMapOverride)
            {
                if (stroke.Value == null)
                {
                    StrokesMap.TryRemove(stroke.Key, out _);
                }
                else
                {
                    StrokesMap[stroke.Key] = stroke.Value;
                }
            }

            var strokes = StrokesMap.Select(x => x.Value).ToList();

            strokes.Sort((x, y) => DateTime.Compare(x.CreatedDate, y.CreatedDate));
            return(strokes);
        }
Ejemplo n.º 4
0
        private void PurgeOverrideMap()
        {
            StrokeModel _;

            foreach (var stroke in StrokesMapOverride)
            {
                if (stroke.Value != null && StrokesMap.ContainsKey(stroke.Key))
                {
                    StrokeModel currentStroke;
                    StrokesMap.TryGetValue(stroke.Value.Id, out currentStroke);
                    if (currentStroke.LastModificationDate >= stroke.Value.LastModificationDate)
                    {
                        StrokesMapOverride.TryRemove(stroke.Key, out _);
                    }
                }
                else if (stroke.Value == null && !StrokesMap.ContainsKey(stroke.Key))
                {
                    StrokesMapOverride.TryRemove(stroke.Key, out _);
                }
            }
        }