...
zhangyuekai
2024-08-15 4f89840b0c95ebd0ed79dff1ff1973d030a6c17d
HStation.RevitDev/RevitDataExport/Utility/DockPaneUtil.cs
@@ -1,54 +1,91 @@
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Events;
using HStation.RevitDev.Model.ModelEnum;
using HStation.RevitDev.RevitDataExport.Common;
using HStation.RevitDev.RevitDataExport.Forms;
using System;
using System.Data.SqlTypes;
namespace HStation.RevitDev.RevitDataExport.Utility
{
    public class DockPaneUtil
    {
        public static void HideInstanceDockablePane(UIControlledApplication uiControlledApp, string strGuid)
        {
            Guid guid = new Guid(strGuid);
            DockablePaneId id = new DockablePaneId(guid);
            DockablePane pane = null;
            try
            {
                pane = uiControlledApp.GetDockablePane(id);
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            if (pane != null && pane.IsShown())
            {
                pane.Hide();
            }
        }
        public static void HideInstanceDockablePane(UIApplication uiApp, string strGuid)
        {
            Guid guid = new Guid(strGuid);
            DockablePaneId id = new DockablePaneId(guid);
            DockablePane pane = null;
            try
            {
                pane = uiApp.GetDockablePane(id);
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            if (pane != null && pane.IsShown())
            {
                pane.Hide();
            }
        }
        public static void HideAllDockablePane(UIControlledApplication uiControlledApp)
        {
            foreach (var panelPair in Common.GlobalResource.DockablePanelDict)
            HideInstanceDockablePane(uiControlledApp, GlobalResource.InstancePaneGuid);
            foreach (var panelPair in GlobalResource.DockablePanelDict)
            {
                var strGuid = panelPair.Value;
                Guid guid = new Guid(strGuid);
                DockablePaneId id = new DockablePaneId(guid);
                DockablePane pane = null;
                try
                {
                    pane = uiControlledApp.GetDockablePane(id);
                }
                catch (Exception ex)
                {
                    string message = ex.Message;
                }
                if (pane != null && pane.IsShown())
                {
                    pane.Hide();
                }
                HideInstanceDockablePane(uiControlledApp, strGuid);
            }
        }
        public static void HideAllDockablePane(UIApplication uiApp)
        {
            foreach (var panelPair in Common.GlobalResource.DockablePanelDict)
        {
            HideInstanceDockablePane(uiApp, GlobalResource.InstancePaneGuid);
            foreach (var panelPair in GlobalResource.DockablePanelDict)
            {
                var strGuid = panelPair.Value;
                Guid guid = new Guid(strGuid);
                DockablePaneId id = new DockablePaneId(guid);
                DockablePane pane = null;
                try
                {
                    pane = uiApp.GetDockablePane(id);
                }
                catch (Exception ex)
                {
                    string message = ex.Message;
                }
                if (pane != null && pane.IsShown())
                {
                    pane.Hide();
                }
                var strGuid = panelPair.Value;
                HideInstanceDockablePane(uiApp, strGuid);
            }
        }
        }
        public static void RegistDockablePanel(UIControlledApplication uiControlledApp, RevitType type)
        {
            var strId = GlobalResource.DockablePanelDict[type];
            Guid guid = new Guid(strId);
            DockablePaneId id = new DockablePaneId(guid);
            Wpf_FamilyPanel panel = new Wpf_FamilyPanel(type);
            GlobalResource.FamilyPanel = panel;
            uiControlledApp.RegisterDockablePane(id, type.GetDescription(), panel);
        }
        public static void RegistInstanceDockablePanel(UIControlledApplication uiControlledApp)
        {
            var strId = GlobalResource.InstancePaneGuid;
            Guid guid = new Guid(strId);
            DockablePaneId id = new DockablePaneId(guid);
            Wpf_InstancePanel panel = new Wpf_InstancePanel();
            GlobalResource.InstancePanel = panel;
            uiControlledApp.RegisterDockablePane(id, "构件列表", panel);
        }
    }
}