You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
C#
57 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GeoSigma.SigmaDrawerUtil
|
|
{
|
|
public class RecentFileConfig : XmlConfig
|
|
{
|
|
public override string SectionName {get;set;}= "RecentFiles";
|
|
private int maxFiles = 10;
|
|
public RecentFileConfig()
|
|
: base()
|
|
{
|
|
SectionAttributes.Add(new System.Xml.Linq.XAttribute("FileNumbers", maxFiles));
|
|
ResetAttributes();
|
|
files = this.FindValues("FileName");
|
|
}
|
|
private List<string> files;
|
|
public List<string> Files
|
|
{
|
|
get
|
|
{
|
|
if(files == null)
|
|
{
|
|
files = new List<string>();
|
|
}
|
|
return files;
|
|
}
|
|
set
|
|
{
|
|
files = value;
|
|
}
|
|
}
|
|
|
|
public bool AddTop(string filePath)
|
|
{
|
|
if (Files.Count > 0)
|
|
{
|
|
if(Files[0].Equals(filePath, StringComparison.CurrentCultureIgnoreCase))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
Files.Remove(filePath);
|
|
Files.Insert(0, filePath);
|
|
if (Files.Count > maxFiles)
|
|
{
|
|
Files.RemoveAt(maxFiles);
|
|
}
|
|
ResetValues("FileName", Files);
|
|
return true;
|
|
}
|
|
}
|
|
}
|