Skip to content

Commit

Permalink
- Fixed #63 Group header in options page of syntax highlight was hard…
Browse files Browse the repository at this point in the history
… to read
  • Loading branch information
wmjordan committed Dec 15, 2018
1 parent 6d06d79 commit 1fd9224
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Codist/Options/SyntaxListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ protected override void WndProc(ref Message m) {
if (m.Msg == 0x0F) {
BackColor = ThemeHelper.DocumentPageColor;
ForeColor = ThemeHelper.DocumentTextColor;
foreach (SyntaxListViewItem item in Items) {
item.ApplyTheme();
foreach (var item in Items) {
(item as SyntaxListViewItem)?.ApplyTheme();
}
}
base.WndProc(ref m);
Expand Down
64 changes: 32 additions & 32 deletions Codist/Options/SyntaxStyleOptionPage.Designer.cs

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

30 changes: 20 additions & 10 deletions Codist/Options/SyntaxStyleOptionPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ internal SyntaxStyleOptionPage(ConfigPage service, Func<IEnumerable<StyleBase>>

protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
_StyleSettingsBox.Enabled = _SyntaxListBox.SelectedIndices.Count > 0 && _SyntaxListBox.SelectedItems[0] is SyntaxListViewItem;
if (_loaded) {
return;
}
Expand Down Expand Up @@ -146,8 +147,11 @@ void _SyntaxListBox_ItemSelectionChanged(object sender, ListViewItemSelectionCha
}
var i = (e.Item as SyntaxListViewItem)?.Style;
if (i == null) {
e.Item.Selected = false;
_StyleSettingsBox.Enabled = false;
return;
}
_StyleSettingsBox.Enabled = true;
_uiLock = true;
_activeStyle = i;
UpdateUIControls(i);
Expand Down Expand Up @@ -189,24 +193,30 @@ static ListViewItem GetListItemForStyle(string category, ListViewItem vi) {
void LoadStyleList() {
_uiLock = true;
_SyntaxListBox.Items.Clear();
_SyntaxListBox.Groups.Clear();
var groups = new List<ListViewGroup>(5);
//_SyntaxListBox.Groups.Clear();
//var groups = new List<ListViewGroup>(5);
var defaultStyles = _defaultStyleLoader();
var styles = _styleLoader();
foreach (var item in defaultStyles) {
if (groups.FirstOrDefault(i => i.Header == item.Category) != null) {
continue;
}
groups.Add(new ListViewGroup(item.Category, HorizontalAlignment.Center));
}
_SyntaxListBox.Groups.AddRange(groups.ToArray());
//foreach (var item in defaultStyles) {
// if (groups.FirstOrDefault(i => i.Header == item.Category) != null) {
// continue;
// }
// groups.Add(new ListViewGroup(item.Category, HorizontalAlignment.Center));
//}
//_SyntaxListBox.Groups.AddRange(groups.ToArray());
string category = null;
foreach (var item in defaultStyles) {
if (item.Category.Length == 0) {
continue;
}
var style = styles.FirstOrDefault(i => i.Id == item.Id) ?? item;
if (item.Category != category) {
_SyntaxListBox.Items.Add(new ListViewItem(" - " + (category = item.Category) + " -") {
Font = new Font(_SyntaxListBox.Font, FontStyle.Bold)
});
}
_SyntaxListBox.Items.Add(new SyntaxListViewItem(item.ToString(), style) {
Group = groups.FirstOrDefault(i => i.Header == item.Category),
//Group = groups.FirstOrDefault(i => i.Header == item.Category),
Font = new Font(_SyntaxListBox.Font, style.GetFontStyle())
});
}
Expand Down

0 comments on commit 1fd9224

Please sign in to comment.