96 lines
3.2 KiB
C#
96 lines
3.2 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Interop;
|
|
using Autodesk.Revit.Attributes;
|
|
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.UI;
|
|
using Sai.Database.Shared;
|
|
using Sai.RvKits.Operation;
|
|
using SZBIM.StandardTools;
|
|
using SZBIM.StandardTools.ParameterManager;
|
|
|
|
namespace Sai.Common.Shared.ParameterManager
|
|
{
|
|
[Transaction(TransactionMode.Manual)]
|
|
[Regeneration(RegenerationOption.Manual)]
|
|
public class MetroParamsManagerCmd : IExternalCommand
|
|
{
|
|
private static readonly string DbString = $"Data Source={RelativePaths.DirAssembly}\\Database\\SZBIM.DeliveryStandard.db";
|
|
private readonly DapperUtil dapperUtil = new(DbString);
|
|
|
|
|
|
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
|
|
{
|
|
//程序UI界面
|
|
UIApplication uiapp = commandData.Application;
|
|
//获取元素(选择) 显示元素 视图(活动视图)管理(对象)
|
|
|
|
if (WinIntPtr.IsVisible("轨交参数管理"))
|
|
{
|
|
WinIntPtr.ShowAndActive("轨交参数管理");
|
|
}
|
|
else
|
|
{
|
|
var addParamsEventHandler = new AddProjectInfoParamsEventHandler();
|
|
var addParamsEvent = ExternalEvent.Create(addParamsEventHandler);
|
|
dapperUtil.CreateConnect();
|
|
try
|
|
{
|
|
MetroParamsManagerWin paramsesWin = new MetroParamsManagerWin(dapperUtil)
|
|
{
|
|
AddProjectInfoParameterEventHandler = addParamsEventHandler,
|
|
AddParameterEvent = addParamsEvent,
|
|
UiApplication = uiapp
|
|
};
|
|
|
|
_ = new WindowInteropHelper(paramsesWin)
|
|
{
|
|
Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle
|
|
};
|
|
paramsesWin.Show();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
dapperUtil.CloseConnect();
|
|
}
|
|
}
|
|
|
|
|
|
return Result.Succeeded;
|
|
}
|
|
|
|
//[DllImport("user32.dll", EntryPoint = "FindWindow")]
|
|
//public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
|
|
|
//public static bool IsVisible(string winname)
|
|
//{
|
|
// IntPtr parenthWndldsl = FindWindow(null, winname);
|
|
// if (!parenthWndldsl.Equals(IntPtr.Zero))
|
|
// {
|
|
// return true;
|
|
// }
|
|
|
|
// return false;
|
|
//}
|
|
|
|
//[DllImport("user32.dll")]
|
|
//public static extern IntPtr SetActiveWindow(IntPtr hWnd);
|
|
|
|
//public static void ShowAndActive(string winName)
|
|
//{
|
|
// IntPtr parenthWndldsl = FindWindow(null, winName);
|
|
// if (!parenthWndldsl.Equals(IntPtr.Zero))
|
|
// {
|
|
// ShowWindow(parenthWndldsl, 1);
|
|
// SetActiveWindow(parenthWndldsl);
|
|
// }
|
|
//}
|
|
|
|
//[DllImport("user32.dll")]
|
|
//public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
|
}
|
|
} |