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.
84 lines
3.0 KiB
C#
84 lines
3.0 KiB
C#
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;
|
|
// }
|
|
// /// <summary>
|
|
// /// 符号库所在路径
|
|
// /// </summary>
|
|
// 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<string, string> 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;
|
|
}
|
|
/// <summary>
|
|
/// 创建符号选择窗口
|
|
/// </summary>
|
|
/// <param name="geo">GeoSigmaXY</param>
|
|
/// <param name="symbolPath">符号库路径</param>
|
|
/// <returns>窗口</returns>
|
|
public static Form CreateSymbolSelectForm(GeoSigmaDrawLib.GeoSigmaXY geo, string symbolPath, Func<string, string> 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;
|
|
}
|
|
}
|
|
}
|