Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            RecentFileInfo recentInfo = (RecentFileInfo)obj;

            return(FilePath.Equals(recentInfo.FilePath, StringComparison.CurrentCultureIgnoreCase));
        }
Exemplo n.º 2
0
            static public void DeleteFilePath(string recentType, string filePath)
            {
                List <RecentFileInfo> list = _recentFiles[recentType];

                for (int i = 0; i < list.Count; i++)
                {
                    RecentFileInfo info = list[i];
                    if (info.FilePath == filePath)
                    {
                        list.RemoveAt(i);
                        break;
                    }
                }
                Save();
            }
Exemplo n.º 3
0
            //TODO:朱才:最近打开的文件
            static public RecentFileInfo[] GetFiles(string recentType)
            {
                ///取出这种类型的列表(类型目前是RecentOpenProjects和RecentOpenFiles两种)
                List <RecentFileInfo> list;

                if (!_recentFiles.TryGetValue(recentType, out list))
                {
                    list = new List <RecentFileInfo>();
                    _recentFiles.Add(recentType, list);
                }

                ///根据最大长度构造数组
                int length = Math.Min(list.Count, MaxShowCount);

                RecentFileInfo[] arrs = new RecentFileInfo[length];
                list.CopyTo(0, arrs, 0, arrs.Length);
                return(arrs);
            }
Exemplo n.º 4
0
        /// <summary>
        /// 返回最近打开的项目,供欢迎界面列表显示
        /// </summary>
        /// <returns></returns>
        public string LatestProject()
        {
            RecentFileInfo[] recentFiles = Service.RecentFiles.GetFiles(Service.RecentFiles.RecentOpenProjects);
            string           retstr      = "";

            for (int i = 0; i < recentFiles.Length; i++)
            {
                RecentFileInfo project = recentFiles[i];
                if (i != recentFiles.Length - 1)
                {
                    retstr += project.FilePath + ",";
                }
                else
                {
                    retstr += project.FilePath + "";
                }
            }
            return(retstr);
        }
Exemplo n.º 5
0
            /// <summary>
            /// 添加文件路径
            /// </summary>
            /// <param name="recentType">保存的最近记录的类型。请使用当前类的常量</param>
            /// <param name="filePath">文件路径</param>
            static public void AddFilePath(string recentType, string filePath)
            {
                List <RecentFileInfo> list;

                if (!_recentFiles.TryGetValue(recentType, out list))
                {
                    list = new List <RecentFileInfo>();
                    _recentFiles.Add(recentType, list);
                }

                ///若第一个就是这个文件,则不处理
                if (list.Count != 0 && list[0].FilePath.Equals(filePath, StringComparison.CurrentCultureIgnoreCase))
                {
                    return;
                }

                ///若列表有此文件,先删除
                for (int i = 0; i < list.Count; i++)
                {
                    RecentFileInfo info = list[i];
                    if (info.FilePath.Equals(filePath, StringComparison.CurrentCultureIgnoreCase))
                    {
                        list.RemoveAt(i);
                        break;
                    }
                }

                ///若列表长度大于最大值,删除最后一个
                if (list.Count >= MaxSaveCount)
                {
                    list.RemoveRange(MaxSaveCount - 1, list.Count - MaxSaveCount + 1);
                }

                ///插入到第一个
                list.Insert(0, new RecentFileInfo(filePath, DateTime.Now));

                Save();
            }