summaryrefslogtreecommitdiff
path: root/src/Notepad/Presentation/Model/Menu/IMenuItemComparer.cs
diff options
context:
space:
mode:
authormo <mo.khan@gmail.com>2018-11-04 15:22:16 -0700
committermo <mo.khan@gmail.com>2018-11-04 15:22:16 -0700
commit5ee1f55497a4e30322a56f133f897ecde1612967 (patch)
treebf544e0879234c3623869627d8786776cb19b8e9 /src/Notepad/Presentation/Model/Menu/IMenuItemComparer.cs
initial commit.HEADmaster
Diffstat (limited to 'src/Notepad/Presentation/Model/Menu/IMenuItemComparer.cs')
-rw-r--r--src/Notepad/Presentation/Model/Menu/IMenuItemComparer.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Notepad/Presentation/Model/Menu/IMenuItemComparer.cs b/src/Notepad/Presentation/Model/Menu/IMenuItemComparer.cs
new file mode 100644
index 0000000..2fd15c7
--- /dev/null
+++ b/src/Notepad/Presentation/Model/Menu/IMenuItemComparer.cs
@@ -0,0 +1,23 @@
+using System.Collections.Generic;
+
+namespace Notepad.Presentation.Model.Menu {
+ public interface IMenuItemComparer : IComparer<IMenuItem> {}
+
+ public class MenuItemComparer : IMenuItemComparer {
+ private IList<string> rankedMenuItems;
+
+ public MenuItemComparer() {
+ rankedMenuItems = new List<string> {
+ MenuItemNames.New,
+ MenuItemNames.Save,
+ MenuItemNames.SaveAs,
+ MenuItemNames.Exit,
+ MenuItemNames.About
+ };
+ }
+
+ public int Compare(IMenuItem x, IMenuItem y) {
+ return rankedMenuItems.IndexOf(x.Name()).CompareTo(rankedMenuItems.IndexOf(y.Name()));
+ }
+ }
+} \ No newline at end of file