Skip to content

Commit

Permalink
Ensure that IsDarkModeEnabled always returns a valid result.
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausLoeffelmann committed Apr 4, 2024
1 parent 89e5fe3 commit 8d3b64e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ public static DarkMode EnvironmentDarkMode
{
DarkMode.Enabled => true,
DarkMode.Disabled => false,
_ => throw new InvalidOperationException("DefaultDarkMode is not set.")

// We return false even if DarkMode is not supported so that we ALWAYS have a valid result here.
_ => false
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,9 @@ private PropertyGridView CreateGridView(IServiceProvider? serviceProvider)
}

[Conditional("DEBUG")]
#pragma warning disable CA1822 // Mark members as static
internal void CheckInCreate()
#pragma warning restore CA1822 // Mark members as static
{
#if DEBUG
if (_inGridViewCreate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ public void StatusStrip_Ctor_Default()
Assert.Null(control.Region);
Assert.NotNull(control.Renderer);
Assert.Same(control.Renderer, control.Renderer);
Assert.IsType<ToolStripSystemRenderer>(control.Renderer);
Assert.Equal(ToolStripRenderMode.System, control.RenderMode);

// TODO: Assume control.Renderer can be either ToolStripSystemRenderer or ToolStripProfessionalRenderer for the Moment.
Assert.True(control.Renderer is ToolStripSystemRenderer or ToolStripProfessionalRenderer, "Renderer is not one of the expected types.");
Assert.True(control.RenderMode is ToolStripRenderMode.System or ToolStripRenderMode.ManagerRenderMode);

Assert.True(control.ResizeRedraw);
Assert.Equal(200, control.Right);
Assert.Equal(RightToLeft.No, control.RightToLeft);
Expand Down Expand Up @@ -1257,15 +1260,15 @@ private class NonReadOnlyControlsStatusStrip : StatusStrip

private class SubStatusStrip : StatusStrip
{
public new const int ScrollStateAutoScrolling = StatusStrip.ScrollStateAutoScrolling;
public new const int ScrollStateAutoScrolling = ScrollableControl.ScrollStateAutoScrolling;

public new const int ScrollStateHScrollVisible = StatusStrip.ScrollStateHScrollVisible;
public new const int ScrollStateHScrollVisible = ScrollableControl.ScrollStateHScrollVisible;

public new const int ScrollStateVScrollVisible = StatusStrip.ScrollStateVScrollVisible;
public new const int ScrollStateVScrollVisible = ScrollableControl.ScrollStateVScrollVisible;

public new const int ScrollStateUserHasScrolled = StatusStrip.ScrollStateUserHasScrolled;
public new const int ScrollStateUserHasScrolled = ScrollableControl.ScrollStateUserHasScrolled;

public new const int ScrollStateFullDrag = StatusStrip.ScrollStateFullDrag;
public new const int ScrollStateFullDrag = ScrollableControl.ScrollStateFullDrag;

public new bool CanEnableIme => base.CanEnableIme;

Expand Down

0 comments on commit 8d3b64e

Please sign in to comment.