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.

83 lines
2.9 KiB
C#

1 month ago
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
{
1 month ago
void ShowSymbolEditor(string symbolPath);
void ShowSymbolEditor(object sender, string symbolPath);
1 month ago
Form CreateSymbolSelectForm(GeoSigmaDrawLib.GeoSigmaXY geo, string symbolPath, Func<string, string> getSymbolName);
}
public class SymbolHelp
{
1 month ago
public static void ShowSymbolUI(string symbolPath)
1 month ago
{
1 month ago
ShowSymbolUI(null, symbolPath);
1 month ago
}
//public static System.Windows.Forms.DialogResult ShowSymbolUI(object sender, string symbolPath)
//{
// return ShowSymbolUI(sender, new SymbolPathArgs(symbolPath));
//}
1 month ago
public static void ShowSymbolUI(object sender, string symbolPath)
1 month ago
{
1 month ago
string path = AppDomain.CurrentDomain.BaseDirectory + "SymbolLibManager.dll";
1 month ago
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)
{
1 month ago
symbolManager.ShowSymbolEditor(sender, symbolPath);
1 month ago
}
}
/// <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;
}
}
}