using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SymbolLibInterface
{
//public class SymbolPathArgs : EventArgs
//{
// public SymbolPathArgs(string path)
// {
// this.SymbolPath = path;
// }
// ///
// /// 符号库所在路径
// ///
// public string SymbolPath { get; set; }
//}
public interface ISymbolManager
{
DialogResult ShowSymbolEditor(string symbolPath);
DialogResult ShowSymbolEditor(object sender, string symbolPath);
Form CreateSymbolSelectForm(GeoSigmaDrawLib.GeoSigmaXY geo, string symbolPath, Func getSymbolName);
}
public class SymbolHelp
{
public static DialogResult ShowSymbolUI(string symbolPath)
{
return ShowSymbolUI(null, symbolPath);
}
//public static System.Windows.Forms.DialogResult ShowSymbolUI(object sender, string symbolPath)
//{
// return ShowSymbolUI(sender, new SymbolPathArgs(symbolPath));
//}
public static DialogResult ShowSymbolUI(object sender, string symbolPath)
{
string path = AppDomain.CurrentDomain.BaseDirectory + "SymbolLibManager.exe";
Assembly assembly = Assembly.LoadFrom(path);
ISymbolManager symbolManager = null;
if (assembly != null)
{
Type type = assembly.GetType("SymbolLibManager.SymbolManager");
if (type != null)
{
symbolManager = Activator.CreateInstance(type) as ISymbolManager;
}
}
if (symbolManager != null)
{
return symbolManager.ShowSymbolEditor(sender, symbolPath);
}
return DialogResult.Cancel;
}
///
/// 创建符号选择窗口
///
/// GeoSigmaXY
/// 符号库路径
/// 窗口
public static Form CreateSymbolSelectForm(GeoSigmaDrawLib.GeoSigmaXY geo, string symbolPath, Func acceptSymbolName)
{
string path = AppDomain.CurrentDomain.BaseDirectory + "SymbolLibManager.exe";
Assembly assembly = Assembly.LoadFrom(path);
ISymbolManager symbolManager = null;
if (assembly != null)
{
Type type = assembly.GetType("SymbolLibManager.SymbolManager");
if (type != null)
{
symbolManager = Activator.CreateInstance(type) as ISymbolManager;
}
}
if (symbolManager != null)
{
return symbolManager.CreateSymbolSelectForm(geo, symbolPath, acceptSymbolName);
}
return null;
}
}
}