Skip to content

Commit

Permalink
Filter Colorizer dialog languages
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencohn committed Jan 2, 2025
1 parent 4810790 commit 8d5a924
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion OneMore/Commands/Edit/ColorizeDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

namespace River.OneMoreAddIn.Commands
{
using River.OneMoreAddIn.Settings;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Xml.Linq;
using Colorizer = Colorizer.Colorizer;
using Resx = Properties.Resources;

Expand All @@ -29,7 +32,7 @@ public ColorizeDialog()
});
}

var languages = Colorizer.LoadLanguageNames();
var languages = LoadFilteredLanguages();
var imageList = MakeImageList(languages);

view.SmallImageList = imageList;
Expand All @@ -50,6 +53,26 @@ public ColorizeDialog()
}


public static IDictionary<string, string> LoadFilteredLanguages()
{
var languages = Colorizer.LoadLanguageNames();

// load hidden languages from Settings
var hidden = new SettingsProvider()
.GetCollection(nameof(ColorizerSheet))
.Get(ColorizerSheet.HiddenKey, new XElement(ColorizerSheet.HiddenKey));

// remove hidden languages
var keys = languages.Keys.ToList();
foreach (var key in keys.Where(key => hidden.Element(languages[key]) is not null))
{
languages.Remove(key);
}

return languages;
}


public string LanguageKey => view.SelectedItems.Count == 0
? null
: view.SelectedItems[0].Tag as string;
Expand Down

0 comments on commit 8d5a924

Please sign in to comment.