Exemplo n.º 1
0
        public bool Load(string fileName = "marks.json")
        {
            lock (locker)
            {
                var configFile = AppDomain.CurrentDomain.BaseDirectory + fileName;
                if (!File.Exists(configFile))
                {
                    Marks = new List <Mark>();
                    return(true);
                }

                string jsonStr = string.Empty;
                try
                {
                    jsonStr = File.ReadAllText(configFile);
                    Marks   = JsonHelper.DeserializeJsonToList <Mark>(jsonStr);

                    MarksChanged?.Invoke();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
Exemplo n.º 2
0
        public void AddMark(Mark mark)
        {
            lock (locker)
            {
                foreach (var m in Marks)
                {
                    if (mark.Date.Date == m.Date.Date)
                    {
                        return;
                    }
                }

                Marks.Add(mark);

                MarksChanged?.Invoke();
            }
        }
Exemplo n.º 3
0
        public void UpdateMarks()
        {
            Marks.Clear();

            var snapshot = _view.VisualSnapshot;
            var span     = new SnapshotSpan(snapshot, 0, snapshot.Length);

            foreach (var tag in _aggregator.GetTags(span))
            {
                var mark = TextMark.Create(tag);
                if (mark != null)
                {
                    Marks.Add(mark);
                }
            }

            MarksChanged?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Marks specified field with specified mark if the field is not already marked.
        /// </summary>
        /// <param name="point">Coordinate of a field to mark.</param>
        /// <param name="mark">Mark to put on the field.</param>
        /// <returns>If field was successfully marked, returns true. Otherwise, returns false.</returns>
        public bool MarkPoint(Point point, Mark mark)
        {
            bool ret;

            lock (this)
            {
                ret = IsPointOnMap(point) && !IsPointMarked(point);
                if (ret)
                {
                    markedPoints[point] = mark;
                }
            }

            if (ret)
            {
                MarksChanged?.Invoke(this, new MarksChangedEventArgs(point));
            }
            return(ret);
        }
Exemplo n.º 5
0
        public void RemoveMark(DateTime date)
        {
            lock (locker)
            {
                List <Mark> remove = new List <Mark>();

                foreach (var m in Marks)
                {
                    if (date.Date == m.Date.Date)
                    {
                        remove.Add(m);
                    }
                }

                foreach (var mark in remove)
                {
                    Marks.Remove(mark);
                }

                MarksChanged?.Invoke();
            }
        }