summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-01-14 12:44:57 -0500
committerGitHub <[email protected]>2021-01-14 12:44:57 -0500
commitc1cd6664a4479ff2210d2461dac5ad84c514bb75 (patch)
treeaf13c3a7cd3f2a3f4d1f88121b06db259c0a9bf1
parentMerge pull request #64 from Tatsujinichi/master (diff)
downloadrawaccel-c1cd6664a4479ff2210d2461dac5ad84c514bb75.tar.xz
rawaccel-c1cd6664a4479ff2210d2461dac5ad84c514bb75.zip
show custom dialog on bad input (#63)
* show custom dialog on bad input fixes #62 * Update MessageDialog constructor args
-rw-r--r--grapher/MessageDialog.Designer.cs98
-rw-r--r--grapher/MessageDialog.cs24
-rw-r--r--grapher/Models/AccelGUI.cs2
-rw-r--r--grapher/grapher.csproj7
4 files changed, 130 insertions, 1 deletions
diff --git a/grapher/MessageDialog.Designer.cs b/grapher/MessageDialog.Designer.cs
new file mode 100644
index 0000000..f7fa8d6
--- /dev/null
+++ b/grapher/MessageDialog.Designer.cs
@@ -0,0 +1,98 @@
+
+namespace grapher
+{
+ partial class MessageDialog
+ {
+ /// <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.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
+ this.okButton = new System.Windows.Forms.Button();
+ this.messageLabel = new System.Windows.Forms.Label();
+ this.tableLayoutPanel.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // tableLayoutPanel
+ //
+ this.tableLayoutPanel.AutoSize = true;
+ this.tableLayoutPanel.ColumnCount = 1;
+ this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel.Controls.Add(this.okButton, 0, 1);
+ this.tableLayoutPanel.Controls.Add(this.messageLabel, 0, 0);
+ this.tableLayoutPanel.ForeColor = System.Drawing.SystemColors.ControlText;
+ this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
+ this.tableLayoutPanel.Name = "tableLayoutPanel";
+ this.tableLayoutPanel.Padding = new System.Windows.Forms.Padding(5);
+ this.tableLayoutPanel.RowCount = 2;
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F));
+ this.tableLayoutPanel.Size = new System.Drawing.Size(224, 61);
+ this.tableLayoutPanel.TabIndex = 2;
+ //
+ // okButton
+ //
+ this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
+ this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.okButton.Location = new System.Drawing.Point(74, 30);
+ this.okButton.Name = "okButton";
+ this.okButton.Size = new System.Drawing.Size(75, 23);
+ this.okButton.TabIndex = 4;
+ this.okButton.Text = "&OK";
+ this.okButton.UseVisualStyleBackColor = true;
+ //
+ // messageLabel
+ //
+ this.messageLabel.AutoSize = true;
+ this.messageLabel.Location = new System.Drawing.Point(8, 5);
+ this.messageLabel.Name = "messageLabel";
+ this.messageLabel.Size = new System.Drawing.Size(35, 13);
+ this.messageLabel.TabIndex = 3;
+ this.messageLabel.Text = "label1";
+ //
+ // MessageDialog
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoSize = true;
+ this.CancelButton = this.okButton;
+ this.ClientSize = new System.Drawing.Size(224, 61);
+ this.Controls.Add(this.tableLayoutPanel);
+ this.Name = "MessageDialog";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.tableLayoutPanel.ResumeLayout(false);
+ this.tableLayoutPanel.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
+ private System.Windows.Forms.Button okButton;
+ private System.Windows.Forms.Label messageLabel;
+ }
+} \ No newline at end of file
diff --git a/grapher/MessageDialog.cs b/grapher/MessageDialog.cs
new file mode 100644
index 0000000..0e153f8
--- /dev/null
+++ b/grapher/MessageDialog.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher
+{
+ public partial class MessageDialog : Form
+ {
+ public MessageDialog(string message, string title = "")
+ {
+ InitializeComponent();
+ Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
+ Text = title;
+ messageLabel.Text = message;
+ }
+
+ }
+}
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 81b3e13..bb634ff 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -162,7 +162,7 @@ namespace grapher
}
else
{
- throw new Exception($"Bad arguments:\n\n{errors}");
+ new MessageDialog(errors.ToString(), "bad input").ShowDialog();
}
}
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index 2788cca..35d7e0c 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -81,6 +81,12 @@
<Compile Include="Constants\Constants.cs" />
<Compile Include="Layouts\MotivityLayout.cs" />
<Compile Include="Layouts\NaturalGainLayout.cs" />
+ <Compile Include="MessageDialog.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="MessageDialog.Designer.cs">
+ <DependentUpon>MessageDialog.cs</DependentUpon>
+ </Compile>
<Compile Include="Models\AccelGUIFactory.cs" />
<Compile Include="Models\Calculations\AccelCalculator.cs" />
<Compile Include="Models\Calculations\AccelChartData.cs" />
@@ -133,6 +139,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="AboutBox.resx">
<DependentUpon>AboutBox.cs</DependentUpon>
+ <SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>