-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
309 lines (253 loc) · 10.5 KB
/
Form1.cs
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BMDtoExcel
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void MainForm_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void MainForm_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false);
foreach (string fileName in files)
{
string extension = fileName.Substring(fileName.Length - 4);
if (String.Compare(extension, ".std") == 0)
{
Preferences.stdFilePath = fileName;
Preferences.stdFileManager.readStdFile(Preferences.stdFilePath);
// Set filename
Preferences.setFileName(Preferences.stdFilePath);
//Read
Preferences.stdFileManager.getBeamMembers();
}
if (String.Compare(extension, ".bmd") == 0)
{
Preferences.bmdFilePath = fileName;
Preferences.bmdFileManager.readBmdFile(Preferences.bmdFilePath);
// Set filename
Preferences.setFileName(Preferences.bmdFilePath);
}
if (String.Compare(extension, ".msh") == 0)
{
Preferences.mshFilePath = fileName;
Preferences.mshFileManager.readMshFile(Preferences.mshFilePath);
// Set filename
Preferences.setFileName(Preferences.mshFilePath);
}
}
refreshAllValues();
}
private void panel1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
// Refresh all statuc values in all labels, ..
private void refreshAllValues()
{
stdFileNameLabel.Text = Path.GetFileName(Preferences.stdFilePath);
bmdFileNameLabel.Text = Path.GetFileName(Preferences.bmdFilePath);
mshFileNameLabel.Text = Path.GetFileName(Preferences.mshFilePath);
//STD
int beamCount = Preferences.stdFileManager.getBeamMembersCount();
beamMemberCountLabel.Text = Convert.ToString(beamCount);
loadCountLabel.Text = Convert.ToString(Preferences.bmdFileManager.calculateLoadCount(beamCount));
//BMD
bmdBytesCountLabel.Text = Convert.ToString(Preferences.bmdFileManager.getBytesCount());
//MSH
mshModeCountLabel.Text = Convert.ToString(Preferences.mshFileManager.getModeCount());
mshNodeCountLabel.Text = Convert.ToString(Preferences.mshFileManager.getNodeCount());
}
private void button2_Click(object sender, EventArgs e)
{
bool[] sections = new bool[13] { false, false, false, false, false, false, false, false, false, false, false, false, false };
//Prepare sections array
foreach (Control c in this.Controls)
{
if (c is CheckBox)
{
if (c.Name.Contains("sectionCheckBox"))
{
CheckBox checkBox = (CheckBox)c;
// Take sectionNumber from name of CheckBox
int sectionNumber = Convert.ToInt32(checkBox.Name.Substring(15));
// Update array
sections[sectionNumber - 1] = checkBox.Checked;
}
}
}
// Prepare export factory
ExcelExportFactory factory = new ExcelExportFactory();
factory.sections = sections;
factory.elementNumbers = Preferences.stdFileManager.getBeamNumberList();
//Get list of loads
int[] xlsLoadList = Preferences.convertStringToLoadArray(xlsLoadListTextBox.Text, false);
int[] bmdLoadList = Preferences.convertStringToLoadArray(bmdLoadListTextBox.Text);
int[] mshLoadList = Preferences.convertStringToLoadArray(mshModeListTextBox.Text);
int loadCount = bmdLoadList.Count();
// Set Frequency Flag
if (mshLoadList.Count() != 0)
{
Preferences.isFrequencyUsed = true;
}
// Check correspondance of lists
if (xlsLoadList.Count() != loadCount)
{
MessageBox.Show("Wrong Load List !!!");
return;
}
if (Preferences.isFrequencyUsed && mshLoadList.Count() !=loadCount)
{
MessageBox.Show("Wrong Mode List !!!");
return;
}
// Validate load numbers
for (int i = 0; i < loadCount; i++)
{
if (!Preferences.bmdFileManager.validateLoadNumber(i)) {
return;
}
}
if (Preferences.isFrequencyUsed) {
for (int i = 0; i < loadCount; i++)
{
if (!Preferences.mshFileManager.validateModeNumber(i))
{
return;
}
}
}
// Prepare loads for
for (int i = 0; i < loadCount; i++)
{
LoadForExport load = new LoadForExport();
/**/
load.bytes = Preferences.bmdFileManager.getBytesForLoad(bmdLoadList[i]);
load.name = xlsLoadList[i].ToString();
load.frequency = Preferences.mshFileManager.getFrequency(mshLoadList[i]);
factory.loads.Add(load);
}
// Add combination rules
if (srssCheckBox.Checked)
{
factory.rules.Add(new SRSSCombinationRule("SRSS", 1.0));
}
if (multiSrssCheckBox.Checked)
{
factory.rules.Add(new SRSSCombinationRule("sqrt(1.3)_SRSS", Math.Sqrt(1.3)));
}
if (uzCheсkBox.Checked)
{
factory.rules.Add(new UZCombinationRule("UZ", 1.0));
}
if (modulusUzCheckBox.Checked)
{
factory.rules.Add(new UZModulusCombinationRule("|UZ|", 1.0));
}
if (Preferences.isFrequencyUsed)
{
if (cqcCheckBox.Checked)
{
factory.rules.Add(new CQCCombinationRule("CQC", 1.0, 0.03));
}
if (asceCheckBox.Checked)
{
factory.rules.Add(new ASCECombinationRule("ASCE", 1.0, 0.03, 2, 33));
}
if (sp14CheckBox.Checked)
{
factory.rules.Add(new SP14CombinationRule("SP14.13330", 1.0, 0.03));
}
if (absCheckBox.Checked)
{
factory.rules.Add(new ABSCombinationRule("ABS", 1.0, 0.03));
}
}
factory.saveToExcelFile(Directory.GetCurrentDirectory() + "\\" + Preferences.fileName + ".xls");
factory = null;
}
private void button3_Click(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e)
{
// Process the list of files found in the directory.
string[] fileEntries = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\"+ "Files_For_Search");
//Prepare array for search
double[] array = new double[] { 1.079, 1.166, 1.362, 1.772, 2.348, 2.349, 2.391, 2.394, 2.459 };
//double[] array = new double[] { 0.92654, 0.858, 0.73413, 0.73397, 0.56422, 0.42590, 0.42579, 0.41819, 0.41774, 0.40662 };
double precision = 0.001;
Preferences.floatSearchManager.clearReport();
foreach (string path in fileEntries)
{
Preferences.floatSearchManager.searchFile(path, array, precision);
}
Preferences.floatSearchManager.writeReportToFile(Directory.GetCurrentDirectory() + "\\log.txt");
}
private void button2_Click_1(object sender, EventArgs e)
{
byte[] bytes = File.ReadAllBytes(Directory.GetCurrentDirectory() + "\\" + "Files_For_Search" + "\\" +
"Simple Piperack SRSS ABS CQC ASCE.msh");
int n1 = BitConverter.ToInt32(bytes, 0);
int n2 = BitConverter.ToInt32(bytes, 4);
int n3 = BitConverter.ToInt32(bytes, 8);
MessageBox.Show("1 - " + n1.ToString() + "\n" +
"2 - " + n2.ToString() + "\n" +
"3 - " + n3.ToString());
}
private void button3_Click_1(object sender, EventArgs e)
{
byte[] bytes = File.ReadAllBytes(Directory.GetCurrentDirectory() + "\\" + "Files_For_Search" + "\\" +
"1.txt");
int offset = 0;
List<string> text = new List<string> { };
for (int i=0; i < 40; i++)
{
string s = "";
int intNum = BitConverter.ToInt32(bytes, offset);
s += intNum.ToString() + " ";
offset += 4;
for (int j=0; j<6; j++)
{
double doubleNum = BitConverter.ToDouble(bytes, offset);
s += string.Format("{0:0.000}", doubleNum) + " ";
offset += 8;
}
s += "\n";
text.Add(s);
}
System.IO.File.WriteAllLines(Directory.GetCurrentDirectory() + "\\1.log.txt", text.ToArray());
}
private void mshModeListTextBox_TextChanged(object sender, EventArgs e)
{
bool flag = true;
if (mshModeListTextBox.Text == "")
{
flag = false;
}
sp14CheckBox.Enabled = flag;
absCheckBox.Enabled = flag;
cqcCheckBox.Enabled = flag;
asceCheckBox.Enabled = flag;
}
}
}