hytos / DTI_PID / ID2PSN / Form / PBSSetting.cs @ 2ade1e61
이력 | 보기 | 이력해설 | 다운로드 (7.9 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
4 |
using System.Data; |
5 |
using System.Drawing; |
6 |
using System.Linq; |
7 |
using System.Text; |
8 |
using System.Threading.Tasks; |
9 |
using System.Windows.Forms; |
10 |
using System.IO; |
11 |
using DevExpress.XtraEditors.Repository; |
12 |
using DevExpress.XtraGrid.Columns; |
13 |
using DevExpress.XtraGrid; |
14 |
using DevExpress.XtraGrid.Views.Grid; |
15 |
using DevExpress.Utils.StructuredStorage.Internal.Reader; |
16 |
using DevExpress.XtraTreeList; |
17 |
using DevExpress.XtraTreeList.Columns; |
18 |
using DevExpress.XtraTreeList.Nodes; |
19 |
using DevExpress.Utils.Extensions; |
20 |
using DevExpress.Utils; |
21 |
using DevExpress.Utils.Drawing; |
22 |
|
23 |
namespace ID2PSN |
24 |
{ |
25 |
public partial class PBSSetting : DevExpress.XtraBars.Ribbon.RibbonForm |
26 |
{ |
27 |
ID2Info ID2Info = ID2Info.GetInstance(); |
28 |
|
29 |
public PBSSetting() |
30 |
{ |
31 |
InitializeComponent(); |
32 |
//PBS |
33 |
spinEditStart.Properties.Mask.EditMask = "f0"; |
34 |
spinEditEnd.Properties.Mask.EditMask = "f0"; |
35 |
comboBoxEditPBSAttr.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; |
36 |
radioGroupPBS1.SelectedIndex = -1; |
37 |
SetPBSSettingUI(); |
38 |
|
39 |
for (int i = 0; i < radioGroupPBS1.Properties.Items.Count; i++) |
40 |
{ |
41 |
if (string.IsNullOrEmpty(Properties.Settings.Default.PBSSetting)) |
42 |
{ |
43 |
radioGroupPBS1.SelectedIndex = 4; |
44 |
break; |
45 |
} |
46 |
|
47 |
if (radioGroupPBS1.Properties.Items[i].Value.Equals(Properties.Settings.Default.PBSSetting)) |
48 |
{ |
49 |
radioGroupPBS1.SelectedIndex = i; |
50 |
break; |
51 |
} |
52 |
} |
53 |
|
54 |
|
55 |
} |
56 |
private void radioGroupPBS_SelectedIndexChanged(object sender, EventArgs e) |
57 |
{ |
58 |
SetPBSSettingUI(); |
59 |
} |
60 |
private void SetPBSSettingUI() |
61 |
{ |
62 |
string selectedValue = string.Empty; |
63 |
if (radioGroupPBS1.SelectedIndex < 0) |
64 |
{ |
65 |
layoutControlItemPBSAttribute.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
66 |
layoutControlItemStart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
67 |
layoutControlItemEnd.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
68 |
selectedValue = "No selection (Empty PBS)"; |
69 |
} |
70 |
else |
71 |
{ |
72 |
selectedValue = radioGroupPBS1.Properties.Items[radioGroupPBS1.SelectedIndex].Value.ToString(); |
73 |
} |
74 |
|
75 |
if (selectedValue.Equals("Line Number")) |
76 |
{ |
77 |
layoutControlItemStart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
78 |
layoutControlItemEnd.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
79 |
layoutControlItemPBSAttribute.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
80 |
|
81 |
comboBoxEditPBSAttr.Properties.Items.Clear(); |
82 |
comboBoxEditPBSAttr.SelectedIndex = -1; |
83 |
DataTable dt = DB.SelectLineProperties(); |
84 |
foreach (DataRow row in dt.Rows) |
85 |
{ |
86 |
string value = row["Name"].ToString(); |
87 |
comboBoxEditPBSAttr.Properties.Items.Add(value); |
88 |
if (!string.IsNullOrEmpty(Properties.Settings.Default.PBSSettingValue) && value.Equals(Properties.Settings.Default.PBSSettingValue)) |
89 |
comboBoxEditPBSAttr.SelectedItem = value; |
90 |
} |
91 |
} |
92 |
else if (selectedValue.Equals("Item Attribute")) |
93 |
{ |
94 |
layoutControlItemStart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
95 |
layoutControlItemEnd.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
96 |
layoutControlItemPBSAttribute.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
97 |
|
98 |
|
99 |
comboBoxEditPBSAttr.Properties.Items.Clear(); |
100 |
comboBoxEditPBSAttr.SelectedIndex = -1; |
101 |
DataTable dt = DB.SelectSymbolAttribute(); |
102 |
foreach (DataRow row in dt.Rows) |
103 |
{ |
104 |
string value = row["Attribute"].ToString(); |
105 |
comboBoxEditPBSAttr.Properties.Items.Add(value); |
106 |
if (!string.IsNullOrEmpty(Properties.Settings.Default.PBSSettingValue) && value.Equals(Properties.Settings.Default.PBSSettingValue)) |
107 |
comboBoxEditPBSAttr.SelectedItem = value; |
108 |
} |
109 |
} |
110 |
else if (selectedValue.Equals("Drawing No")) |
111 |
{ |
112 |
layoutControlItemPBSAttribute.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
113 |
layoutControlItemStart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
114 |
layoutControlItemEnd.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
115 |
|
116 |
spinEditStart.Value = Properties.Settings.Default.PBSSettingStartValue; |
117 |
spinEditEnd.Value = Properties.Settings.Default.PBSSettingEndValue; |
118 |
} |
119 |
else if (selectedValue.Equals("Unit Area")) |
120 |
{ |
121 |
layoutControlItemPBSAttribute.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
122 |
layoutControlItemStart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
123 |
layoutControlItemEnd.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
124 |
} |
125 |
else if (selectedValue.Equals("No selection (Empty PBS)")) |
126 |
{ |
127 |
layoutControlItemPBSAttribute.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
128 |
layoutControlItemStart.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
129 |
layoutControlItemEnd.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
130 |
} |
131 |
|
132 |
} |
133 |
|
134 |
private void btnSave_Click(object sender, EventArgs e) |
135 |
{ |
136 |
try |
137 |
{ |
138 |
if (radioGroupPBS1.SelectedIndex < 0) |
139 |
{ |
140 |
MessageBox.Show("PBS setting is empty!", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error); |
141 |
return; |
142 |
} |
143 |
else if (radioGroupPBS1.Properties.Items[radioGroupPBS1.SelectedIndex].Value.ToString() == "Drawing No" && |
144 |
Convert.ToInt32(spinEditStart.Value) >= Convert.ToInt32(spinEditEnd.Value)) |
145 |
{ |
146 |
MessageBox.Show("PBS setting (from/to) invalid value!", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error); |
147 |
return; |
148 |
} |
149 |
|
150 |
Properties.Settings.Default.PBSSetting = radioGroupPBS1.Properties.Items[radioGroupPBS1.SelectedIndex].Value.ToString(); |
151 |
if (Properties.Settings.Default.PBSSetting == "Line Number" || Properties.Settings.Default.PBSSetting == "Item Attribute") |
152 |
Properties.Settings.Default.PBSSettingValue = comboBoxEditPBSAttr.SelectedItem.ToString(); |
153 |
else if (Properties.Settings.Default.PBSSetting == "Drawing No") |
154 |
{ |
155 |
Properties.Settings.Default.PBSSettingStartValue = Convert.ToInt32(spinEditStart.Value); |
156 |
Properties.Settings.Default.PBSSettingEndValue = Convert.ToInt32(spinEditEnd.Value); |
157 |
} |
158 |
Properties.Settings.Default.Save(); |
159 |
MessageBox.Show("Save was successful", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
160 |
} |
161 |
catch (Exception ex) |
162 |
{ |
163 |
MessageBox.Show("Failed to save", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
164 |
} |
165 |
} |
166 |
|
167 |
|
168 |
private void btnClose_Click(object sender, EventArgs e) |
169 |
{ |
170 |
DialogResult = DialogResult.Cancel; |
171 |
} |
172 |
} |
173 |
} |