Files
mRemoteNG/mRemoteV1/UI/Controls/Base/NGListView.cs
Camilo Alvarez 991d1d82b8 Misc fixes
- Clear redundant settings form app.config
- Deleted DesignModeTest as ThemeManager can now be used in design time without adjustements, removed usage from all custo elements
- Instance _themeManager in NGNumericUpDown at object creation to avoid null reference errors
- Errorsform instancing is now defaulted to DockBottomAutoHide  in frmMain
-Fix missing panel at startup by adding a blank panel, temporary solution as magic library is beign phased out
2017-12-26 12:15:11 -05:00

71 lines
2.5 KiB
C#

using BrightIdeasSoftware;
using mRemoteNG.Themes;
using System.Drawing;
namespace mRemoteNG.UI.Controls.Base
{
//Simple coloring of ObjectListView
//This is subclassed to avoid repeating the code in multiple places
internal class NGListView : ObjectListView
{
private CellBorderDecoration deco;
//Control if the gridlines are styled, must be set before the OnCreateControl is fired
public bool DecorateLines { get; set; } = true;
public NGListView()
{
ThemeManager.getInstance().ThemeChanged += OnCreateControl;
}
protected override void OnCreateControl()
{
base.OnCreateControl();
var _themeManager = ThemeManager.getInstance();
if (!_themeManager.ThemingActive) return;
//List back color
BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("List_Background");
ForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("List_Item_Foreground");
//Selected item
SelectedBackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("List_Item_Selected_Background");
SelectedForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("List_Item_Selected_Foreground");
//Header style
HeaderUsesThemes = false;
var headerStylo = new HeaderFormatStyle();
headerStylo.Normal.BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("List_Header_Background");
headerStylo.Normal.ForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("List_Header_Foreground");
HeaderFormatStyle = headerStylo;
//Border style
if(DecorateLines)
{
UseCellFormatEvents = true;
GridLines = false;
deco = new CellBorderDecoration
{
BorderPen = new Pen(_themeManager.ActiveTheme.ExtendedPalette.getColor("List_Item_Border")),
FillBrush = null,
BoundsPadding = Size.Empty,
CornerRounding = 0
};
FormatCell += NGListView_FormatCell;
}
if (Items != null && Items.Count != 0)
BuildList();
Invalidate();
}
private void NGListView_FormatCell(object sender, FormatCellEventArgs e)
{
if (e.Column.IsVisible)
{
e.SubItem.Decoration = deco;
}
}
}
}