qin
2024-09-28 e358beb08f5be49703009b64f058ecfbcfeefbd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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)
        {
            HideInstanceDockablePane(uiControlledApp, GlobalResource.InstancePaneGuid);
            foreach (var panelPair in GlobalResource.DockablePanelDict)
            {
                var strGuid = panelPair.Value;
                HideInstanceDockablePane(uiControlledApp, strGuid);
            }
        }
 
        public static void HideAllDockablePane(UIApplication uiApp)
        {
            HideInstanceDockablePane(uiApp, GlobalResource.InstancePaneGuid);
            foreach (var panelPair in GlobalResource.DockablePanelDict)
            {
                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);
        }
    }
}