Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Editor/ControlAppearanceEditorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,12 @@ private void colorPickerControl_ColorPicked(object sender, EventArgs e)
ControlAppearanceColors key = (ControlAppearanceColors)Enum.Parse(
typeof(ControlAppearanceColors), lstColors.SelectedItem.ToString());

grid.ControlStyle.SetColor(key, colorPickerControl.SolidColor);

grid.ControlStyle = grid.ControlStyle;
grid.ControlStyle[key] = colorPickerControl.SolidColor;
}

private void NumSelectionWidth_ValueChanged(object sender, EventArgs e)
{
grid.ControlStyle.SelectionBorderWidth = (float)numSelectionWidth.Value;
grid.Invalidate();
}
#endregion // Set Styles

Expand Down
34 changes: 26 additions & 8 deletions ReoGrid/Control/ControlShare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void InitControl()
this.builtInCrossCursor = LoadCursorFromResource(unvell.ReoGrid.Properties.Resources.cross);
#endif // WINFORM || WPF

this.controlStyle = ControlAppearanceStyle.CreateDefaultControlStyle();
this.ControlStyle = ControlAppearanceStyle.CreateDefaultControlStyle();
}

private void InitWorkbook(IControlAdapter adapter)
Expand Down Expand Up @@ -1273,21 +1273,39 @@ public ControlAppearanceStyle ControlStyle
get { return this.controlStyle; }
set
{
this.controlStyle = value ?? throw new ArgumentNullException("ControlStyle", "cannot set ControlStyle to null");
if (value == null)
{
throw new ArgumentNullException("ControlStyle", "cannot set ControlStyle to null");
}

if (this.controlStyle != value)
{
if (this.controlStyle != null) this.controlStyle.CurrentControl = null;
this.controlStyle = value;
}
//workbook.SetControlStyle(value);

this.adapter.Invalidate();
this.ApplyControlStyle();
}
}

internal void ApplyControlStyle()
{
this.controlStyle.CurrentControl = this;

#if WINFORM
sheetTab.BackColor = value[ControlAppearanceColors.SheetTabBackground];
this.BackColor = value[ControlAppearanceColors.GridBackground];
sheetTab.BackColor = this.controlStyle[ControlAppearanceColors.SheetTabBackground];
this.BackColor = this.controlStyle[ControlAppearanceColors.GridBackground];
#elif WPF
sheetTab.Background = new System.Windows.Media.SolidColorBrush(value[ControlAppearanceColors.SheetTabBackground]);
sheetTab.Background = new System.Windows.Media.SolidColorBrush(this.controlStyle[ControlAppearanceColors.SheetTabBackground]);
#endif // WINFORM & WPF

}
this.adapter?.Invalidate();
}
#endregion // App

//private AppearanceStyle appearanceStyle = new AppearanceStyle(this);

#endregion // Appearance

#region Mouse
private void OnWorksheetMouseDown(RGPointF location, MouseButtons buttons)
Expand Down
8 changes: 7 additions & 1 deletion ReoGrid/Core/Workbook/Appearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public enum ControlAppearanceColors : short
/// </summary>
public class ControlAppearanceStyle
{
internal ReoGridControl CurrentControl { get; set; }

private Dictionary<ControlAppearanceColors, SolidColor> colors = new Dictionary<ControlAppearanceColors, SolidColor>(100);

internal Dictionary<ControlAppearanceColors, SolidColor> Colors
Expand Down Expand Up @@ -116,6 +118,7 @@ public bool GetColor(ControlAppearanceColors colorKey, out SolidColor color)
public void SetColor(ControlAppearanceColors colorKey, SolidColor color)
{
colors[colorKey] = color;
this.CurrentControl?.ApplyControlStyle();
}

/// <summary>
Expand All @@ -133,7 +136,10 @@ public SolidColor this[ControlAppearanceColors colorKey]
else
return SolidColor.Black;
}
set { SetColor(colorKey, value); }
set
{
SetColor(colorKey, value);
}
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion ReoGrid/WinForm/WinFormControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ public void ShowEditControl(Graphics.Rectangle bounds, Cell cell)
editTextbox.InitialSize = rect.Size;
editTextbox.VAlign = cell.InnerStyle.VAlign;
editTextbox.Font = cell.RenderFont;
editTextbox.ForeColor = cell.InnerStyle.TextColor;
editTextbox.ForeColor = cell.InnerStyle.HasStyle(PlainStyleFlag.TextColor)
? cell.InnerStyle.TextColor : this.control.ControlStyle[ControlAppearanceColors.GridText];
editTextbox.BackColor = cell.InnerStyle.HasStyle(PlainStyleFlag.BackColor)
? cell.InnerStyle.BackColor : this.control.ControlStyle[ControlAppearanceColors.GridBackground];
editTextbox.ResumeLayout();
Expand Down