Skip to content

Commit

Permalink
custom event buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
mike committed Feb 28, 2014
1 parent cc68af7 commit 51e2da9
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 10 deletions.
9 changes: 7 additions & 2 deletions TrainingAssistant.userprefs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench />
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release" />
<MonoDevelop.Ide.Workbench ActiveDocument="TrainingAssistant/Helpers.cs">
<Files>
<File FileName="TrainingAssistant/Properties/AssemblyInfo.cs" Line="1" Column="1" />
<File FileName="TrainingAssistant/Helpers.cs" Line="1" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
Expand Down
15 changes: 15 additions & 0 deletions TrainingAssistant/models/Report.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ protected string generateEventLog()
log += nEvents.ContainsKey("coordination") ? nEvents["coordination"] + " missed or incorrect controller coordination\r\n" : "";
}

if (this.sesh.customMarkdowns.Count > 0)
{
foreach(string s in this.sesh.customMarkdowns)
{
log += "-" + s + "\r\n";
}
}

if (pEvents.Count == 0) { log += "No markups were returned from the session.\r\n"; }
else
{
Expand All @@ -234,6 +242,13 @@ protected string generateEventLog()
log += pEvents.ContainsKey("pointouts") ? pEvents["pointouts"] + " instances of good traffic and safety pointouts\r\n" : "";
log += pEvents.ContainsKey("sequencing") ? pEvents["sequencing"] + " instances of good sequencing and spacing\r\n" : "";
}
if(this.sesh.customMarkups.Count > 0)
{
foreach(string s in this.sesh.customMarkups)
{
log += "-" + s + "\r\n";
}
}
return log + "\r\n";
}

Expand Down
12 changes: 10 additions & 2 deletions TrainingAssistant/models/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ public enum WeatherConditions { vfr, mvfr, ifr}
public int markups { get; set; }
public int markdowns { get; set; }
public List<string> reviewed { get; set; }
public List<string> customMarkdowns { get; set; }
public List<string> customMarkups { get; set; }
public int ots { get; set; }

public int posPoints { get; set; }
public int negPoints { get; set; }
public int omdPoints { get; set; }
public int omuPoints { get; set; }
public double score { get; set; }
public TrafficLevel traffic { get; set; }
public ComplexityLevel complexity { get; set; }
Expand All @@ -39,7 +43,11 @@ public Session()
this.posPoints = 120;
this.modifier = 1;
this.ots = 0;
this.omdPoints = 0;
this.omuPoints = 0;
this.reviewed = new List<string>();
this.customMarkdowns = new List<string>();
this.customMarkups = new List<string>();
this.combos = new Dictionary<string, int>()
{
{"brief", 10},
Expand Down Expand Up @@ -216,7 +224,7 @@ public int calcNegPoints()
n += this.genEvents["incident"] * 6;
n += this.genEvents["coordination"] * 2;
n += this.genEvents["readback"] * 1;

n += this.omdPoints;
return n;
}

Expand All @@ -229,7 +237,7 @@ public int calcPosPoints()
n += this.posEvents["separation"] * 3;
n += this.posEvents["pointouts"] * 2;
n += this.posEvents["sequencing"] * 3;

n += this.omuPoints;
return n;
}
}
Expand Down
40 changes: 34 additions & 6 deletions TrainingAssistant/views/training.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions TrainingAssistant/views/training.cs
Original file line number Diff line number Diff line change
Expand Up @@ -626,5 +626,78 @@ private void chk_r_brief_CheckedChanged(object sender, EventArgs e)

}

private void btn_u_other_Click(object sender, EventArgs e)
{
string str = "";
InputBox("Custom Markup", "Please enter your event", ref str, true, this.s);
this.s.customMarkups.Add(str);
}

private void btn_d_other_Click(object sender, EventArgs e)
{
string str = "";
InputBox("Custom Markdown", "Please enter your custom event", ref str, false, this.s);
this.s.customMarkdowns.Add(str);
}
public static DialogResult InputBox(string title, string promptText, ref string value, bool isMarkup, Session s)
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Label pointLabel = new Label();
TextBox points = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();

form.Text = title;
label.Text = promptText;
textBox.Text = value;
points.Text = "0";

buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;

label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
pointLabel.SetBounds(9, 61, 372, 13);
points.SetBounds(12, 81, 372, 20);
buttonOk.SetBounds(228, 107, 75, 23);
buttonCancel.SetBounds(309, 107, 75, 23);

pointLabel.Text = "Point value: (1 = wrong squawk, 6 = crashed planes)";
label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
points.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

form.ClientSize = new Size(396, 137);
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel, pointLabel, points });
textBox.TabIndex = 1;
pointLabel.TabIndex = 2;
buttonOk.TabIndex = 3;
buttonCancel.TabIndex = 4;
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
DialogResult dialogResult = form.ShowDialog();
value = textBox.Text;
if(isMarkup)
{
s.omuPoints += int.Parse(points.Text);
}
else
{
s.omdPoints += int.Parse(points.Text);
}
return dialogResult;
}

}
}

0 comments on commit 51e2da9

Please sign in to comment.