Files
RookieStation/RookieStation/CmdArrangeShelfCards.cs
2021-06-24 11:42:33 +08:00

82 lines
2.7 KiB
C#

using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using RookieStation.PackAreaModule.View;
using RookieStation.UserClient;
using RookieStation.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace RookieStation.PackAreaModule
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
internal class CmdArrangeShelfCards : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
string addinPath = typeof(RsApp).Assembly.Location;
string assemblyDirectory = System.IO.Path.GetDirectoryName(addinPath);
AssemblyLoader loader = new AssemblyLoader(assemblyDirectory);
try
{
loader.HookAssemblyResolve();
WpfShelfCards shelfCards = new WpfShelfCards(uiapp);
System.Windows.Interop.WindowInteropHelper mainui = new System.Windows.Interop.WindowInteropHelper(shelfCards)
{
Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle
};
shelfCards.ShowDialog();
}
catch (Exception ex)
{
Log.WriteLog(ex.Message);
}
finally
{
loader.UnhookAssemblyResolve();
}
//if (shelfcards.IsPlace)
//{
// PlaceCards(shelfcards, uidoc);
//}
//else
//{
// NumberCards(shelfcards, uidoc);
//}
return Result.Succeeded;
//if (IsVisible("端牌编号"))
//{
// WinIntPtr.ShowAndActive("端牌编号");
//}
//else
//{
// cardsPlacement = new WpfNumberShelfCard();
// System.Windows.Interop.WindowInteropHelper mainUI = new System.Windows.Interop.WindowInteropHelper(cardsPlacement);
// mainUI.Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
// cardsPlacement.ShowDialog();
//}
}
//public static bool IsVisible(string winname)
//{
// IntPtr ParenthWndldsl = WinIntPtr.FindWindow(null, winname);
// if (!ParenthWndldsl.Equals(IntPtr.Zero))
// {
// return true;
// }
// return false;
//}
}
}