Skip to content

Commit

Permalink
Boilerplate dropdown now refreshes properly when you add/remove boile…
Browse files Browse the repository at this point in the history
…rplate
  • Loading branch information
Perlkonig committed Jul 8, 2017
1 parent 773cf96 commit b3e1d6a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 48 deletions.
62 changes: 31 additions & 31 deletions EditTools/Ribbon1.Designer.cs

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

40 changes: 23 additions & 17 deletions EditTools/Ribbon1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,7 @@ public partial class Ribbon1

private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{
//Boilerplate
StringCollection bps = Properties.Settings.Default.boilerplate;
List<string> keys = new List<string>(); ;
for (int i = 0; i < bps.Count; i++)
{
if (i % 2 == 0)
{
keys.Add(bps[i]);
}
}
keys.Sort();
foreach (string key in keys)
{
RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
item.Label = key;
dd_Boilerplate.Items.Add(item);
}
loadBoilerplate();

//Languages
Word.Languages langs = Globals.ThisAddIn.Application.Languages;
Expand Down Expand Up @@ -77,6 +61,28 @@ private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
//Debug.WriteLine("Model loaded.");
}

public void loadBoilerplate()
{
//Boilerplate
dd_Boilerplate.Items.Clear();
StringCollection bps = Properties.Settings.Default.boilerplate;
List<string> keys = new List<string>(); ;
for (int i = 0; i < bps.Count; i++)
{
if (i % 2 == 0)
{
keys.Add(bps[i]);
}
}
keys.Sort();
foreach (string key in keys)
{
RibbonDropDownItem item = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
item.Label = key;
dd_Boilerplate.Items.Add(item);
}
}

private void button1_Click(object sender, RibbonControlEventArgs e)
{
ImportDialog id = new ImportDialog();
Expand Down
2 changes: 2 additions & 0 deletions EditTools/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ private void SettingsDialog_Closing(object sender, FormClosingEventArgs e)
Properties.Settings.Default.boilerplate = strings;

Properties.Settings.Default.Save();

Globals.Ribbons.Ribbon1.loadBoilerplate();
}

private void btn_Close_Click_1(object sender, EventArgs e)
Expand Down

0 comments on commit b3e1d6a

Please sign in to comment.