프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / APIDConverter / Utils / GUIUtils.cs @ 1c5bd296

이력 | 보기 | 이력해설 | 다운로드 (5.1 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

    
7
using AVEVA.PID.Utilities;
8

    
9
namespace AVEVA.PID.CustomizationUtility
10
{
11
    public class GUIUtils
12
    {
13
        public static object FindItem(Autodesk.Windows.RibbonItemCollection items, string automationName)
14
        {
15
            foreach (var item in items)
16
            {
17
                if (item.AutomationName == automationName)
18
                    return item;
19
                else if (item.GetType() == typeof(Autodesk.Windows.RibbonRowPanel))
20
                {
21
                    Autodesk.Windows.RibbonRowPanel rowPanel = item as Autodesk.Windows.RibbonRowPanel;
22
                    foreach (var item2 in rowPanel.Items)
23
                    {
24
                        if (item2.AutomationName == automationName)
25
                            return item2;
26
                    }
27
                }
28
            }
29

    
30
            return null;
31
        }
32
        
33
        public static void SetAutoLabelUnCehck()
34
        {
35
            Autodesk.Windows.RibbonChecklistButton autoLabelCheckListButton = null;
36
            Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL");
37
            object objAutoLabel = GUIUtils.FindItem(items, "Auto Label");
38
            if (objAutoLabel != null)
39
                autoLabelCheckListButton = objAutoLabel as Autodesk.Windows.RibbonChecklistButton;
40
            
41
            if (autoLabelCheckListButton != null)
42
            {
43
                foreach (var item in autoLabelCheckListButton.Items)
44
                {
45
                    if (item.GetType() == typeof(Autodesk.Windows.RibbonButton))
46
                    {
47
                        Autodesk.Windows.RibbonButton ribbonButton = item as Autodesk.Windows.RibbonButton;
48
                        if (ribbonButton.IsChecked)
49
                            ribbonButton.IsChecked = false;
50
                    }
51
                }
52
            }
53

    
54
            DrawingUtilities.bPipeLabel = false;
55
            DrawingUtilities.bEquipLabel = false;
56
            DrawingUtilities.bNozzleLabel = false;
57
            DrawingUtilities.bInstrLabel = false;
58
            DrawingUtilities.bValveLabel = false;
59
            DrawingUtilities.bReducerLabel = false;
60
            DrawingUtilities.bLinefittingLabel = false;
61

    
62
            DrawingData drawingData = new DrawingData();
63
            drawingData.AutoLabelPipe = DrawingUtilities.bPipeLabel;
64
            drawingData.AutoLabelEquipment = DrawingUtilities.bEquipLabel;
65
            drawingData.AutoLabelNozzle = DrawingUtilities.bNozzleLabel;
66
            drawingData.AutoLabelInstrument = DrawingUtilities.bInstrLabel;
67
            drawingData.AutoLabelValue = DrawingUtilities.bValveLabel;
68
            drawingData.AutoLabelReducer = DrawingUtilities.bReducerLabel;
69
            drawingData.AutoLabelLinefitting = DrawingUtilities.bLinefittingLabel;
70
        }
71

    
72
        public static void SetPipeStyle(string style)
73
        {
74
            Autodesk.Windows.RibbonCombo pipeStyleCombo = null;
75
            Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL");
76
            object objPipeStyle = GUIUtils.FindItem(items, "PIPESTYLE");
77
            if (objPipeStyle != null)
78
                pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo;
79

    
80
            if (pipeStyleCombo.Current != null)
81
            {
82
                Autodesk.Windows.RibbonButton button = pipeStyleCombo.Current as Autodesk.Windows.RibbonButton;
83
                if (button.AutomationName != style)
84
                {
85
                    foreach (var item in pipeStyleCombo.Items)
86
                    {
87
                        Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton;
88
                        if (loop.AutomationName == style)
89
                        {
90
                            pipeStyleCombo.Current = loop;
91
                            break;
92
                        }
93
                    }
94
                }
95
            }
96
        }
97

    
98
        public static void SetSignalStyle(string style)
99
        {
100
            Autodesk.Windows.RibbonCombo signalStyleCombo = null;
101
            Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_SIGNAL_PANEL");
102
            object objSignalStyle = GUIUtils.FindItem(items, "SIGNALSTYLE");
103
            if (objSignalStyle != null)
104
                signalStyleCombo = objSignalStyle as Autodesk.Windows.RibbonCombo;
105
            if (signalStyleCombo.Current != null)
106
            {
107
                Autodesk.Windows.RibbonButton button = signalStyleCombo.Current as Autodesk.Windows.RibbonButton;
108
                if (button.AutomationName != style)
109
                {
110
                    foreach (var item in signalStyleCombo.Items)
111
                    {
112
                        Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton;
113
                        if (loop.AutomationName == style)
114
                        {
115
                            signalStyleCombo.Current = loop;
116
                            break;
117
                        }
118
                    }
119
                }
120
            }
121
        }
122

    
123
        
124
    }
125
}
클립보드 이미지 추가 (최대 크기: 500 MB)