⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tracerecord.cs

📁 gps
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace GPSClassLibrary
{
    public class TraceRecord
    {
        #region Private
        List<MapPoint> allTrace = new List<MapPoint>(); // 记录轨迹的列表
        bool showTrace = false; // 是否显示轨迹
        bool recordTrace = false; // 是否记录轨迹
        Log log = new Log("trace");
        #endregion 

        #region Index
        public List<Point> this[int index]
        {
            get
            {
                // 如果不显示轨迹,则不计算
                if (!showTrace)
                    return null;
                // 返回在本地图上的轨迹
                List<Point> points = new List<Point>();
                foreach (MapPoint mappoint in allTrace)
                {
                    if (mappoint.IndexOfMap == index)
                        points.Add(new Point(mappoint.point.X, mappoint.point.Y));
                }
                if(points.Count >=2)
                    return points;
                return null;
            }
        }
        #endregion

        #region Construction
        public TraceRecord()
        {
            if (log.IsValid)
            {
                string[] strings = log.ReadLog();
                foreach (string str in strings)
                    allTrace.Add(new MapPoint(str));
            }
        }
        #endregion

        #region Properties
        /// <summary>
        /// 设置是否显示轨迹
        /// </summary>
        public bool ShowTrace
        {
            set { showTrace = value; }
            get { return showTrace; }
        }
        /// <summary>
        /// 设置是否记录轨迹
        /// </summary>
        public bool RecordTrace
        {
            set { recordTrace = value; }
        }
        #endregion

        #region Method
        public void Add(MapPoint mappoint)
        {
            if (recordTrace)
            {
                allTrace.Add(new MapPoint(mappoint));
                log.writeLog(mappoint.ToString());
            }
        }
        public void Clear()
        {
            allTrace.Clear();
            log.ClearLog();
        }
        #endregion
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -