Krypton-Suite / Standard-Toolkit

An update to Component factory's krypton toolkit to support .NET Framework 4.6.2 - 4.8.1 to .NET 6 - 8
BSD 3-Clause "New" or "Revised" License
390 stars 57 forks source link

[Bug]: Not Implemented Exception thrown for `GetRibbonBackColorStyle` `PaletteOffice2010Base.cs` #1715

Closed DigitalMills closed 4 days ago

DigitalMills commented 1 month ago

Describe the bug Not Implemented Exception thrown for GetRibbonBackColorStyle for PaletteOffice2010Base.cs

To Reproduce Steps to reproduce the behavior:

  1. Attempt to render and paint a Ribbon Group component

Expected behavior Ribbon Group renders and paints

Actual behavior Error is thrown, suggesting part of the flow is not yet implemented. Stack trace:

System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'https://github.com/Krypton-Suite/Standard-Toolkit/issues/new/choose' with working directory 'C:\Git\Aireforge\Aireforge Suite\OmniCompare\bin\Debug\net8.0-windows'. The system cannot find the file specified. at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at Krypton.Toolkit.DebugTools.NotImplemented(String outOfRange, String callingFilePath, Int32 lineNumber, String callingMethod) at Krypton.Toolkit.PaletteOffice2010Base.GetRibbonBackColorStyle(PaletteRibbonBackStyle style, PaletteState state) at Krypton.Toolkit.PaletteRedirect.GetRibbonBackColorStyle(PaletteRibbonBackStyle style, PaletteState state) at Krypton.Toolkit.PaletteRibbonBackInheritRedirect.GetRibbonBackColorStyle(PaletteState state) at Krypton.Toolkit.PaletteRibbonBack.GetRibbonBackColorStyle(PaletteState state) at Krypton.Toolkit.PaletteRibbonBack.GetRibbonBackColorStyle(PaletteState state) at Krypton.Ribbon.ViewDrawRibbonGroup.RenderNormalBefore(RenderContext context) at Krypton.Ribbon.ViewDrawRibbonGroup.RenderBefore(RenderContext context) at Krypton.Toolkit.ViewComposite.Render(RenderContext context) at Krypton.Toolkit.ViewComposite.Render(RenderContext context) at Krypton.Toolkit.ViewControl.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at Krypton.Toolkit.ViewControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)

Screenshots image

Desktop (please complete the following information):

OS: Microsoft Windows 11 Business Version: 10.0.22631 Build 22631 Framework/.NET Version: net8.0-windows Toolkit Version: 90.24.7.204-beta

PWagner1 commented 4 weeks ago

Hi @DigitalMills

Does this happen when an event has occurred, I.e. hovering over it?

DigitalMills commented 3 weeks ago

Hi @Wagnerp, this occurs when attempting to render any form.cs with a ribbon group component within it. The issue occurs before any hover events can take place.

PWagner1 commented 3 weeks ago

Hi @Wagnerp, this occurs when attempting to render any form.cs with a ribbon group component within it. The issue occurs before any hover events can take place.

Hi @DigitalMills

Can you try nightly please, as I think it's been fixed?

DigitalMills commented 2 weeks ago

Hi @Wagnerp ,

Unfortunately we're still experiencing the same issue on the latest nightly build.

thanks

PWagner1 commented 2 weeks ago

Hi @DigitalMills

Is it possible to upload a clip to show what's going on?

DigitalMills commented 2 weeks ago

Hi @Wagnerp,

please find video and screenshot attached:

https://github.com/user-attachments/assets/292e3b75-5af7-4868-a1b9-d4570afdb802

image

PWagner1 commented 2 weeks ago

Hi @DigitalMills

Does it just happen on a contextual tab?

DigitalMills commented 2 weeks ago

@Wagnerp Here's our stack trace for you, appears to relate to Krypton.Toolkit.PaletteOffice2010Base.GetRibbonBackColorStyle.

It seems closely associated with the Ribbon Group component

at System.Windows.Forms.MessageBox.Show(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) at Krypton.Toolkit.DebugTools.NotImplemented(String outOfRange, String callingFilePath, Int32 lineNumber, String callingMethod) at Krypton.Toolkit.PaletteOffice2010Base.GetRibbonBackColorStyle(PaletteRibbonBackStyle style, PaletteState state) at Krypton.Toolkit.PaletteRedirect.GetRibbonBackColorStyle(PaletteRibbonBackStyle style, PaletteState state) at Krypton.Toolkit.PaletteRibbonBackInheritRedirect.GetRibbonBackColorStyle(PaletteState state) at Krypton.Toolkit.PaletteRibbonBack.GetRibbonBackColorStyle(PaletteState state) at Krypton.Toolkit.PaletteRibbonBack.GetRibbonBackColorStyle(PaletteState state) at Krypton.Ribbon.ViewDrawRibbonGroup.RenderNormalBefore(RenderContext context) at Krypton.Ribbon.ViewDrawRibbonGroup.RenderBefore(RenderContext context) at Krypton.Toolkit.ViewComposite.Render(RenderContext context) at Krypton.Toolkit.ViewComposite.Render(RenderContext context) at Krypton.Toolkit.ViewControl.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at Krypton.Toolkit.ViewControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)

PWagner1 commented 2 weeks ago

Hi @DigitalMills

Is this a duplicate of #1299?

cc. @Smurf-IV & @giduac

giduac commented 2 weeks ago

Hi @DigitalMills (cc: @Wagnerp )

We need a bit more info to be able replicate this properly:

image

giduac commented 2 weeks ago

Hi @DigitalMills

Is this a duplicate of #1299?

cc. @Smurf-IV & @giduac

@Wagnerp Indeed it seems that this is present in more themes. :thumbsup:

PWagner1 commented 2 weeks ago

Hi @DigitalMills

Is it possible to attach a sample?

@giduac

Is it possible to get the values into a buffer.

DigitalMills commented 1 week ago

@PWagner1 for my error the state being sent that throws an error is 'ContextNormal'

image

Seems one of the PaletteRibbonBackStyle types is missing a PaletteState of ContextNormal:

giduac commented 1 week ago

@DigitalMills

Thanks for the response. Indeed we found this as well.

We both might reproduce the error in a different way. Therefore, what we would like to know from you is how the error is provoked in code on your side. So we can be sure to catch all possibilities for the fix.

PWagner1 commented 1 week ago

@giduac

Correct me if this is wrong, but I've added:

case PaletteState.ContextNormal:
                            return PaletteRibbonColorStyle.RibbonGroupAreaBorderContext;
DigitalMills commented 1 week ago

@PWagner1

Unfortunately I can't get a breakpoint on GetRibbonBackColorStyle method to confirm the style and the state, hopefully the above will suffice.

The application is rendering a new form when the issue occurs.

@giduac

Correct me if this is wrong, but I've added:

case PaletteState.ContextNormal:
                            return PaletteRibbonColorStyle.RibbonGroupAreaBorderContext;

Do let me know if you'd like me to test any builds with changes above

giduac commented 1 week ago

@PWagner1

These 5 states need checking:

  PaletteState.ContextPressed
  PaletteState.ContextTracking
  PaletteState.ContextCheckedTracking
  PaletteState.ContextNormal
  PaletteState.ContextCheckedNormal

The error is present in ALL themes and can be provoked by setting the ContextName property: KRibbon.SelectedTab.ContextName

Before making any changes make sure to reproduce the error...

PWagner1 commented 6 days ago

Hi @giduac & @DigitalMills

I don't quite understand what's going on. If you use the Ribbon + Navigator + Workspace demo, it works as expected, yet if you try to do it yourself, it ends up with showing the said dialog. There are no structural changes between V90 & V4.

cc. @Smurf-IV

giduac commented 6 days ago

Hi @giduac & @DigitalMills

I don't quite understand what's going on. If you use the Ribbon + Navigator + Workspace demo, it works as expected, yet if you try to do it yourself, it ends up with showing the said dialog. There are no structural changes between V90 & V4.

cc. @Smurf-IV

I also get the error in Workspace Navigator test form:

https://github.com/user-attachments/assets/ac570a59-91d2-411e-b0b7-55e19bc6a408

giduac commented 6 days ago

Also happens when no context is created and only the ContextName property is set.

PWagner1 commented 6 days ago

Hi @giduac & @DigitalMills I don't quite understand what's going on. If you use the Ribbon + Navigator + Workspace demo, it works as expected, yet if you try to do it yourself, it ends up with showing the said dialog. There are no structural changes between V90 & V4. cc. @Smurf-IV

I also get the error in Workspace Navigator test form:

devenv_vQ2PUdeg2u.mp4

@giduac

Would you mind testing on the changes I've recently pushed, using the Ribbon test, as it's a clone of the Ribbon + Navigator + Workspace demo app? Thanks :)

giduac commented 6 days ago

My branch is up-to-date until:

image

Is that correct ?

PWagner1 commented 6 days ago

I don't think this has anything to do with themes per se, rather this is a fundamental Ribbon issue.

PWagner1 commented 6 days ago

My branch is up-to-date until:

image

Is that correct ?

@giduac

Here's the branch

giduac commented 6 days ago

Our branches are on par... I have my own local branch here. Where there have been no corrections and the error is still present on all levels.

I don't think this has anything to do with themes per se, rather this is a fundamental Ribbon issue.

The error ends up in theme code where those styles are missing. So it's either that or who put those styles in the ribbon ???

PWagner1 commented 6 days ago

Our branches are on par... I have my own local branch here. Where there have been no corrections and the error is still present on all levels.

I don't think this has anything to do with themes per se, rather this is a fundamental Ribbon issue.

The error ends up in theme code where those styles are missing. So it's either that or who put those styles in the ribbon ???

If you do a diff comparison on the same block of code on V90 and V4 by CF, there are no changes in the case statements being used, which makes it even more odd.

giduac commented 6 days ago

The one who added those states to the ribbon didn't update the themes with those styles, I would say. So if you want to get to the bottom of that will be possible starting point.

For the fix: If you change the ribbon it will possibly be a breaking change. So my choice would be to add the styles to the themes...

PWagner1 commented 6 days ago

So my choice would be to add the styles to the themes...

Do you mean adding new PaletteRibbonColorStyle definitions?

giduac commented 6 days ago

No the missing case styles that come up now in the error. Those are the things that are missing or not ?

PWagner1 commented 6 days ago

No the missing case styles that come up now in the error. Those are the things that are missing or not ?

Ahh adding the missing cases, might be better to add all of them. Yes the switch might be big, but we would cover all eventualities.

giduac commented 6 days ago

Not all of those I listed are triggered in the error but also not present. So it makes sense imo to check all those states and see if they should be part of the fix

giduac commented 6 days ago

Once that has been established a standard fix for all themes can be devised.

PWagner1 commented 6 days ago

@giduac

Hold on... could it be because KRibbon.SelectedTab might be null?

giduac commented 6 days ago

if selectedtab is null could the contextname be set and the case be triggered?

PWagner1 commented 6 days ago

image

giduac commented 6 days ago

if selectedtab is null could the contextname be set and the case be triggered?

@PWagner1 well ?

PWagner1 commented 6 days ago

if selectedtab is null could the contextname be set and the case be triggered?

@PWagner1 well ?

@giduac

Just trying something...

PWagner1 commented 6 days ago

@giduac & @giduac

Yes!!!! It's now fixed!

All it required was...

image

PR coming soon

giduac commented 6 days ago

You sure that all the states should react the same ?

PWagner1 commented 6 days ago

You sure that all the states should react the same ?

No, that will be the second part. For now, let's deal with the crux of the bug, then add the colour states :)

giduac commented 6 days ago

Oh, those can differ among the themes, yes ?

giduac commented 6 days ago

also, like in PaletteOffice2010Base some of these context styles are already addressed. Like ContextCheckedNormal here...

    case PaletteRibbonBackStyle.RibbonGroupArea:
        switch (state)
        {
            case PaletteState.Normal:
            case PaletteState.CheckedNormal:
                return PaletteRibbonColorStyle.RibbonGroupAreaBorder3;
            case PaletteState.ContextCheckedNormal:
                return PaletteRibbonColorStyle.RibbonGroupAreaBorder4;
            case PaletteState.Tracking:
                return PaletteRibbonColorStyle.RibbonGroupNormalTrackingLight;
            case PaletteState.FocusOverride:
                return PaletteRibbonColorStyle.RibbonTabFocus2010;
            default:
                // Should never happen!
                Debug.Assert(false);
                DebugTools.NotImplemented(state.ToString());
                break;
        }
PWagner1 commented 6 days ago

Oh, those can differ among the themes, yes ?

Yes, as the statements can be rearranged. For now, I'm just setting a default for them, it might not look pretty but at least it wont crash applications.

giduac commented 6 days ago

Should finish the rest straight after that ???

giduac commented 6 days ago

and make it whole

giduac commented 6 days ago

can I work on 1241 now ?

giduac commented 6 days ago

;)

PWagner1 commented 6 days ago

Should finish the rest straight after that ???

The statements will be moved into position once we know it's working

can I work on 1241 now ?

Yes, go ahead :)

PWagner1 commented 5 days ago

Hi @DigitalMills

Please try using the next nightly build.

PWagner1 commented 4 days ago

Hi @DigitalMills

Please retry using nightly build >= .253

cc. @Smurf-IV & @giduac