Skip to content

Commit

Permalink
Merge pull request #40 from fritzophrenic/include-defaults-checkbox
Browse files Browse the repository at this point in the history
"Include defaults" checkbox
  • Loading branch information
fireout committed Feb 26, 2016
2 parents dd41783 + ca16f3f commit fa38781
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,31 @@ public static PropertyInfo[] GetProperties<TValue>(
}
}

private void tsbOptions_Click(object sender, EventArgs e)
{
try
{
SequenceItem item = GetSelectedSequenceItem<SequenceItem>();
WordSequenceItem wordItem = item as WordSequenceItem;
if (wordItem != null)
{
includeDefaultsToolStripMenuItem.Checked = !wordItem.Words.Override;
}
else
{
CharacterSequenceItem charItem = item as CharacterSequenceItem;
if (charItem != null)
{
includeDefaultsToolStripMenuItem.Checked = !charItem.Characters.Override;
}
}
}
catch (NullReferenceException)
{
includeDefaultsToolStripMenuItem.Checked = false;
}
}

private void probabilityToolStripMenuItem_Click(object sender, EventArgs e)
{
ReadUserInputFor<SequenceItem, PercentEnum>("Probability [Never|Always|1-99]", "[Never|Always|1-99]", i => i.Probability);
Expand Down Expand Up @@ -457,8 +482,23 @@ private void includeDefaultsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
ReadUserInputFor<CharacterSequenceItem, bool>("Omit default characters [true|false]", "[true|false]", i => i.Characters.Override);
ReadUserInputFor<WordSequenceItem, bool>("Omit default words [true|false]", "[true|false]", i => i.Words.Override);
SequenceItem item = GetSelectedSequenceItem<SequenceItem>();
WordSequenceItem wordItem = item as WordSequenceItem;
if (wordItem != null)
{
wordItem.Words.Override = !wordItem.Words.Override;
includeDefaultsToolStripMenuItem.Checked = !wordItem.Words.Override;
}
else
{
CharacterSequenceItem charItem = item as CharacterSequenceItem;
if (charItem != null)
{
charItem.Characters.Override = !charItem.Characters.Override;
includeDefaultsToolStripMenuItem.Checked = !charItem.Characters.Override;
}
}
LoadConfigurationDetails();
}
catch (NullReferenceException)
{
Expand Down Expand Up @@ -901,6 +941,7 @@ private void InitializeComponent()
this.tsbOptions.Size = new System.Drawing.Size(29, 22);
this.tsbOptions.Text = "Options";
this.tsbOptions.ToolTipText = "Configure Item";
this.tsbOptions.Click += new System.EventHandler(this.tsbOptions_Click);
//
// probabilityToolStripMenuItem
//
Expand Down

0 comments on commit fa38781

Please sign in to comment.