Skip to content

Commit

Permalink
Extra safety code around the recent menu popups. Non-repeatable error…
Browse files Browse the repository at this point in the history
…, but a couple of safety checks should improve reliability in edge cases.
  • Loading branch information
RickStrahl committed Jun 21, 2018
1 parent ea50af2 commit 59f95a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MarkdownMonster/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
</MenuItem>

<MenuItem Name="ButtonRecentFiles" Header="Recent Documents"
SubmenuOpened="ButtonRecentFiles_SubmenuOpened" Click="Button_Handler" >
SubmenuOpened="ButtonRecentFiles_SubmenuOpened" >
<MenuItem>.</MenuItem>
</MenuItem>

Expand Down
18 changes: 9 additions & 9 deletions MarkdownMonster/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ public void UpdateRecentDocumentsContextMenu(RecentFileDropdownModes mode)

if (mode == RecentFileDropdownModes.MenuDropDown)
ButtonRecentFiles.Items.Clear();
else if (mode == RecentFileDropdownModes.ToolbarDropdown)
ToolbarButtonRecentFiles.ContextMenu = contextMenu;

var icon = new AssociatedIcons();
MenuItem mi = null;
Expand Down Expand Up @@ -636,9 +638,7 @@ public void UpdateRecentDocumentsContextMenu(RecentFileDropdownModes mode)
else
ButtonRecentFiles.Items.Add(mi);
}

if (mode == RecentFileDropdownModes.ToolbarDropdown)
ToolbarButtonRecentFiles.ContextMenu = contextMenu;

}

}
Expand Down Expand Up @@ -1961,12 +1961,12 @@ public void Button_Handler(object sender, RoutedEventArgs e)
editor.MarkdownDocument.CurrentText = markdown;
PreviewBrowser.PreviewMarkdown();
}
else if (button == ButtonRecentFiles)
{
var mi = button as MenuItem;
UpdateRecentDocumentsContextMenu(RecentFileDropdownModes.MenuDropDown);
mi.IsSubmenuOpen = true;
}
//else if (button == ButtonRecentFiles)
//{
// var mi = button as MenuItem;
// UpdateRecentDocumentsContextMenu(RecentFileDropdownModes.MenuDropDown);
// mi.IsSubmenuOpen = true;
//}
else if (button == ToolbarButtonRecentFiles)
{
var mi = button as Button;
Expand Down

0 comments on commit 59f95a1

Please sign in to comment.