Add project files.
This commit is contained in:
parent
0083ede1e1
commit
ac2a10ee01
25
BTD-PDF.sln
Normal file
25
BTD-PDF.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.2.32505.173
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTD-PDF", "BTD-PDF\BTD-PDF.csproj", "{6FEF3E67-A180-415D-8CD5-9742FADDDC79}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{6FEF3E67-A180-415D-8CD5-9742FADDDC79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6FEF3E67-A180-415D-8CD5-9742FADDDC79}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6FEF3E67-A180-415D-8CD5-9742FADDDC79}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6FEF3E67-A180-415D-8CD5-9742FADDDC79}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {3DFE2C56-46DA-41CF-B117-63126E933493}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
16
BTD-PDF/BTD-PDF.csproj
Normal file
16
BTD-PDF/BTD-PDF.csproj
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<RootNamespace>BTD_PDF</RootNamespace>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="BenchtopParser" Version="1.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
121
BTD-PDF/ConfigToPDF.Designer.cs
generated
Normal file
121
BTD-PDF/ConfigToPDF.Designer.cs
generated
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
namespace BTD_PDF {
|
||||||
|
partial class ConfigToPDF {
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing) {
|
||||||
|
if (disposing && (components != null)) {
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent() {
|
||||||
|
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||||
|
this.btnFile = new System.Windows.Forms.Button();
|
||||||
|
this.lblFilename = new System.Windows.Forms.Label();
|
||||||
|
this.btnParse = new System.Windows.Forms.Button();
|
||||||
|
this.comboParser = new System.Windows.Forms.ComboBox();
|
||||||
|
this.lblContents = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// openFileDialog1
|
||||||
|
//
|
||||||
|
this.openFileDialog1.FileName = "openFileDialog1";
|
||||||
|
this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
|
||||||
|
//
|
||||||
|
// btnFile
|
||||||
|
//
|
||||||
|
this.btnFile.AllowDrop = true;
|
||||||
|
this.btnFile.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.btnFile.Name = "btnFile";
|
||||||
|
this.btnFile.Size = new System.Drawing.Size(122, 36);
|
||||||
|
this.btnFile.TabIndex = 0;
|
||||||
|
this.btnFile.Text = "Open File";
|
||||||
|
this.btnFile.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// lblFilename
|
||||||
|
//
|
||||||
|
this.lblFilename.AutoSize = true;
|
||||||
|
this.lblFilename.Location = new System.Drawing.Point(140, 23);
|
||||||
|
this.lblFilename.Name = "lblFilename";
|
||||||
|
this.lblFilename.Size = new System.Drawing.Size(16, 15);
|
||||||
|
this.lblFilename.TabIndex = 1;
|
||||||
|
this.lblFilename.Text = "...";
|
||||||
|
//
|
||||||
|
// btnParse
|
||||||
|
//
|
||||||
|
this.btnParse.Enabled = false;
|
||||||
|
this.btnParse.Location = new System.Drawing.Point(12, 92);
|
||||||
|
this.btnParse.Name = "btnParse";
|
||||||
|
this.btnParse.Size = new System.Drawing.Size(122, 36);
|
||||||
|
this.btnParse.TabIndex = 2;
|
||||||
|
this.btnParse.Text = "Parse";
|
||||||
|
this.btnParse.UseVisualStyleBackColor = true;
|
||||||
|
this.btnParse.Click += new System.EventHandler(this.btnParse_Click);
|
||||||
|
//
|
||||||
|
// comboParser
|
||||||
|
//
|
||||||
|
this.comboParser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboParser.FormattingEnabled = true;
|
||||||
|
this.comboParser.Items.AddRange(new object[] {
|
||||||
|
"Program Config",
|
||||||
|
"Hardware Calibration Report",
|
||||||
|
"Transducer Verify"});
|
||||||
|
this.comboParser.Location = new System.Drawing.Point(12, 54);
|
||||||
|
this.comboParser.Name = "comboParser";
|
||||||
|
this.comboParser.Size = new System.Drawing.Size(176, 23);
|
||||||
|
this.comboParser.TabIndex = 3;
|
||||||
|
this.comboParser.SelectedIndexChanged += new System.EventHandler(this.comboParser_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// lblContents
|
||||||
|
//
|
||||||
|
this.lblContents.AutoSize = true;
|
||||||
|
this.lblContents.Location = new System.Drawing.Point(12, 144);
|
||||||
|
this.lblContents.Name = "lblContents";
|
||||||
|
this.lblContents.Size = new System.Drawing.Size(16, 15);
|
||||||
|
this.lblContents.TabIndex = 4;
|
||||||
|
this.lblContents.Text = "...";
|
||||||
|
//
|
||||||
|
// ConfigToPDF
|
||||||
|
//
|
||||||
|
this.AllowDrop = true;
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.lblContents);
|
||||||
|
this.Controls.Add(this.comboParser);
|
||||||
|
this.Controls.Add(this.btnParse);
|
||||||
|
this.Controls.Add(this.lblFilename);
|
||||||
|
this.Controls.Add(this.btnFile);
|
||||||
|
this.Name = "ConfigToPDF";
|
||||||
|
this.Text = "ConfigToPDF";
|
||||||
|
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.ConfigToPDF_DragDrop);
|
||||||
|
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.ConfigToPDF_DragEnter);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private OpenFileDialog openFileDialog1;
|
||||||
|
private Button btnFile;
|
||||||
|
private Label lblFilename;
|
||||||
|
private Button btnParse;
|
||||||
|
private ComboBox comboParser;
|
||||||
|
private Label lblContents;
|
||||||
|
}
|
||||||
|
}
|
108
BTD-PDF/ConfigToPDF.cs
Normal file
108
BTD-PDF/ConfigToPDF.cs
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
using BenchtopParser;
|
||||||
|
|
||||||
|
namespace BTD_PDF {
|
||||||
|
enum Parser {
|
||||||
|
ProgramConfig,
|
||||||
|
TransducerVerify,
|
||||||
|
HardwareCalibrationReport
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class ConfigToPDF : Form {
|
||||||
|
string? fileName = null;
|
||||||
|
Parser? parser = null;
|
||||||
|
|
||||||
|
private void setParseEnabled() {
|
||||||
|
if (fileName != null && fileName.Length > 0) {
|
||||||
|
if (parser != null) {
|
||||||
|
btnParse.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigToPDF_DragEnter(object sender, DragEventArgs e) {
|
||||||
|
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigToPDF_DragDrop(object sender, DragEventArgs e) {
|
||||||
|
IDataObject? data = e.Data;
|
||||||
|
string[] files = (string[])data.GetData(DataFormats.FileDrop);
|
||||||
|
fileName = 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnParse_Click(object sender, EventArgs e) {
|
||||||
|
if (fileName == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
string value = comboParser.Text;
|
||||||
|
switch (value) {
|
||||||
|
case "Program Config":
|
||||||
|
parser = Parser.ProgramConfig;
|
||||||
|
break;
|
||||||
|
case "Hardware Calibration Report":
|
||||||
|
parser = Parser.HardwareCalibrationReport;
|
||||||
|
break;
|
||||||
|
case "Transducer Verify":
|
||||||
|
parser = Parser.TransducerVerify;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setParseEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
63
BTD-PDF/ConfigToPDF.resx
Normal file
63
BTD-PDF/ConfigToPDF.resx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
14
BTD-PDF/Program.cs
Normal file
14
BTD-PDF/Program.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace BTD_PDF {
|
||||||
|
internal static class Program {
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main() {
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new ConfigToPDF());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user