License
This commit is contained in:
parent
ac2a10ee01
commit
97bf00c0f9
11
BTD-PDF/ConfigToPDF.Designer.cs
generated
11
BTD-PDF/ConfigToPDF.Designer.cs
generated
@ -23,7 +23,7 @@
|
|||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent() {
|
private void InitializeComponent() {
|
||||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
this.ofdFile = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.btnFile = new System.Windows.Forms.Button();
|
this.btnFile = new System.Windows.Forms.Button();
|
||||||
this.lblFilename = new System.Windows.Forms.Label();
|
this.lblFilename = new System.Windows.Forms.Label();
|
||||||
this.btnParse = new System.Windows.Forms.Button();
|
this.btnParse = new System.Windows.Forms.Button();
|
||||||
@ -31,10 +31,10 @@
|
|||||||
this.lblContents = new System.Windows.Forms.Label();
|
this.lblContents = new System.Windows.Forms.Label();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// openFileDialog1
|
// ofdFile
|
||||||
//
|
//
|
||||||
this.openFileDialog1.FileName = "openFileDialog1";
|
this.ofdFile.FileName = "openFileDialog1";
|
||||||
this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
|
this.ofdFile.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
|
||||||
//
|
//
|
||||||
// btnFile
|
// btnFile
|
||||||
//
|
//
|
||||||
@ -45,6 +45,7 @@
|
|||||||
this.btnFile.TabIndex = 0;
|
this.btnFile.TabIndex = 0;
|
||||||
this.btnFile.Text = "Open File";
|
this.btnFile.Text = "Open File";
|
||||||
this.btnFile.UseVisualStyleBackColor = true;
|
this.btnFile.UseVisualStyleBackColor = true;
|
||||||
|
this.btnFile.Click += new System.EventHandler(this.btnFile_Click);
|
||||||
//
|
//
|
||||||
// lblFilename
|
// lblFilename
|
||||||
//
|
//
|
||||||
@ -111,7 +112,7 @@
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private OpenFileDialog openFileDialog1;
|
private OpenFileDialog ofdFile;
|
||||||
private Button btnFile;
|
private Button btnFile;
|
||||||
private Label lblFilename;
|
private Label lblFilename;
|
||||||
private Button btnParse;
|
private Button btnParse;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using BenchtopParser;
|
using BenchtopParser;
|
||||||
|
|
||||||
namespace BTD_PDF {
|
namespace BTD_PDF {
|
||||||
|
|
||||||
|
// Easy enum for switches
|
||||||
enum Parser {
|
enum Parser {
|
||||||
ProgramConfig,
|
ProgramConfig,
|
||||||
TransducerVerify,
|
TransducerVerify,
|
||||||
@ -11,14 +13,16 @@ namespace BTD_PDF {
|
|||||||
string? fileName = null;
|
string? fileName = null;
|
||||||
Parser? parser = null;
|
Parser? parser = null;
|
||||||
|
|
||||||
private void setParseEnabled() {
|
/* Initialization */
|
||||||
if (fileName != null && fileName.Length > 0) {
|
public ConfigToPDF() {
|
||||||
if (parser != null) {
|
InitializeComponent();
|
||||||
btnParse.Enabled = true;
|
this.AllowDrop = true;
|
||||||
}
|
this.DragEnter += new DragEventHandler(ConfigToPDF_DragEnter);
|
||||||
}
|
this.DragDrop += new DragEventHandler(ConfigToPDF_DragDrop);
|
||||||
|
this.ofdFile.Title = "Select a File";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Events */
|
||||||
void ConfigToPDF_DragEnter(object sender, DragEventArgs e) {
|
void ConfigToPDF_DragEnter(object sender, DragEventArgs e) {
|
||||||
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
||||||
return;
|
return;
|
||||||
@ -30,62 +34,23 @@ namespace BTD_PDF {
|
|||||||
void ConfigToPDF_DragDrop(object sender, DragEventArgs e) {
|
void ConfigToPDF_DragDrop(object sender, DragEventArgs e) {
|
||||||
IDataObject? data = e.Data;
|
IDataObject? data = e.Data;
|
||||||
string[] files = (string[])data.GetData(DataFormats.FileDrop);
|
string[] files = (string[])data.GetData(DataFormats.FileDrop);
|
||||||
fileName = files[0];
|
setFilename(files[0]);
|
||||||
if (fileName != null) {
|
|
||||||
lblFilename.Text = fileName;
|
|
||||||
parser = null;
|
|
||||||
comboParser.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigToPDF() {
|
|
||||||
InitializeComponent();
|
|
||||||
this.AllowDrop = true;
|
|
||||||
this.DragEnter += new DragEventHandler(ConfigToPDF_DragEnter);
|
|
||||||
this.DragDrop += new DragEventHandler(ConfigToPDF_DragDrop);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Interactions */
|
||||||
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e) {
|
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||||
|
this.Activate();
|
||||||
|
string[] files = ofdFile.FileNames;
|
||||||
|
setFilename(files[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnParse_Click(object sender, EventArgs e) {
|
private void btnParse_Click(object sender, EventArgs e) {
|
||||||
if (fileName == null) {
|
if (fileName != null) {
|
||||||
return;
|
parse();
|
||||||
}
|
|
||||||
|
|
||||||
var contents = File.ReadAllText(Path.Combine(fileName));
|
|
||||||
switch (parser) {
|
|
||||||
case Parser.ProgramConfig:
|
|
||||||
parseProgramConfig(contents);
|
|
||||||
break;
|
|
||||||
case Parser.HardwareCalibrationReport:
|
|
||||||
parseHardwareCalibrationReport(contents);
|
|
||||||
break;
|
|
||||||
case Parser.TransducerVerify:
|
|
||||||
parseTransducerVerify(contents);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseProgramConfig(string contents) {
|
|
||||||
ProgramConfig pc = new ProgramConfig(contents);
|
|
||||||
Console.WriteLine("Parsed PC");
|
|
||||||
lblContents.Text = pc.Programs["P1"].ProgramNumber;
|
|
||||||
}
|
|
||||||
private void parseHardwareCalibrationReport(string contents) {
|
|
||||||
HardwareCalibrationReport hr = new HardwareCalibrationReport(contents);
|
|
||||||
Console.WriteLine("Parsed HR");
|
|
||||||
lblContents.Text = hr.Instrument.Name;
|
|
||||||
|
|
||||||
}
|
|
||||||
private void parseTransducerVerify(string contents) {
|
|
||||||
TransducerVerify tv = new TransducerVerify(contents);
|
|
||||||
Console.WriteLine("Parsed TV");
|
|
||||||
lblContents.Text = tv.Transducers[1].Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void comboParser_SelectedIndexChanged(object sender, EventArgs e) {
|
private void comboParser_SelectedIndexChanged(object sender, EventArgs e) {
|
||||||
string value = comboParser.Text;
|
string value = comboParser.Text;
|
||||||
switch (value) {
|
switch (value) {
|
||||||
@ -102,7 +67,58 @@ namespace BTD_PDF {
|
|||||||
setParseEnabled();
|
setParseEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnFile_Click(object sender, EventArgs e) {
|
||||||
|
ofdFile.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Methods */
|
||||||
|
|
||||||
|
private void setParseEnabled() {
|
||||||
|
if (fileName != null && fileName.Length > 0) {
|
||||||
|
if (parser != null) {
|
||||||
|
btnParse.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFilename(string? _fileName) {
|
||||||
|
if (_fileName != null) {
|
||||||
|
fileName = _fileName;
|
||||||
|
lblFilename.Text = fileName;
|
||||||
|
parser = null;
|
||||||
|
comboParser.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parse() {
|
||||||
|
var contents = File.ReadAllText(fileName);
|
||||||
|
switch (parser) {
|
||||||
|
case Parser.ProgramConfig:
|
||||||
|
parseProgramConfig(contents);
|
||||||
|
break;
|
||||||
|
case Parser.HardwareCalibrationReport:
|
||||||
|
parseHardwareCalibrationReport(contents);
|
||||||
|
break;
|
||||||
|
case Parser.TransducerVerify:
|
||||||
|
parseTransducerVerify(contents);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void parseProgramConfig(string contents) {
|
||||||
|
ProgramConfig pc = new ProgramConfig(contents);
|
||||||
|
Console.WriteLine("Parsed PC");
|
||||||
|
lblContents.Text = pc.Programs["P1"].ProgramNumber;
|
||||||
|
}
|
||||||
|
private void parseHardwareCalibrationReport(string contents) {
|
||||||
|
HardwareCalibrationReport hr = new HardwareCalibrationReport(contents);
|
||||||
|
Console.WriteLine("Parsed HR");
|
||||||
|
lblContents.Text = hr.Instrument.Name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private void parseTransducerVerify(string contents) {
|
||||||
|
TransducerVerify tv = new TransducerVerify(contents);
|
||||||
|
Console.WriteLine("Parsed TV");
|
||||||
|
lblContents.Text = tv.Transducers[1].Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -57,7 +57,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="ofdFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
</root>
|
</root>
|
7
LICENSE
Normal file
7
LICENSE
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Copyright 2022 Tyrel Souza
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
Loading…
Reference in New Issue
Block a user