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.
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
// <copyright file="FileHandler.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Specialized;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using GeoSigma.SigmaDrawerUtil;
|
|
using UCDraw;
|
|
|
|
namespace PcgDraw
|
|
{
|
|
public delegate void OpenRecentFile(string file, bool withZColor);
|
|
|
|
public class FileHandler
|
|
{
|
|
public OpenRecentFile LoadFileEvent;
|
|
private List<string> fileList;
|
|
private int fileNumbers;
|
|
private RecentFileConfig config = null;
|
|
public FileHandler()
|
|
{
|
|
config = new RecentFileConfig();
|
|
fileList = config.Files;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新最近菜单单项
|
|
/// </summary>
|
|
public void UpdateMenu(ToolStripSplitButton RecentFileMenu)
|
|
{
|
|
if (RecentFileMenu == null)
|
|
{
|
|
return;
|
|
}
|
|
// 清除当前菜单项
|
|
RecentFileMenu.DropDownItems.Clear();
|
|
foreach (var file in fileList)
|
|
{
|
|
ToolStripItem menuItem = new ToolStripMenuItem();
|
|
menuItem.Text = file;
|
|
menuItem.Click += (sender, e) => { LoadFileEvent?.Invoke(file, false); };
|
|
// LoadFileEvent?.Invoke(file, false);
|
|
RecentFileMenu.DropDownItems.Add(menuItem);
|
|
}
|
|
}
|
|
|
|
public void AddRecentFile(string filePath)
|
|
{
|
|
config.AddTop(filePath);
|
|
config.Save();
|
|
}
|
|
}
|
|
}
|