Color display Error in Panel. Rhino 7 + Rhino 8 С#

In Rhino 7 and in Rhino 8 I have an error of color display in the Panel.



I think the problem is related to the BackgroundColor assignment in the button :face_with_monocle:

1 Like

ToolPaneltest.zip (399.3 KB)
ToolPanel1.rhp (42 KB)

I think the problem is related to Rhino 7-8. and need a fix for McNeel

Hi @taraskydon,

This is a side effect of the styles we apply to panel controls, by default, so they follow the same color theme, which get applied when your panel is added to the panel host.

There is an API you can use to opt-out of this process:

Rhino.UI.Controls.RhinoLayout.DisablePanelColorStyling(myControl)

which you can apply on a specific control or even the top level panel to opt out of everything.

Hope this helps,

– Dale

1 Like

I had the same issues and as off a discussion with @curtisw I used the same API code @dale suggested. There are two type of call of this method:

public static void DisablePanelColorStyling(Control etoControl, DisablePanelColorStylingProperty colorProperty)
{
    etoControl?.Properties.Set(DisableColorStylingKey, colorProperty, DisablePanelColorStylingProperty.None);
}

public static void DisablePanelColorStyling(Panel panel)
{
    panel?.Properties.Set(DisableColorStylingKey, DisablePanelColorStylingProperty.All, DisablePanelColorStylingProperty.None);
}

The second DisablePanelColorStyling(Panel panel) works fine (tested on Version 7 SR17) and applies to all subcontrols in the panel. The first DisablePanelColorStyling(Control etoControl, DisablePanelColorStylingProperty colorProperty) seems to have a bug regarding Rhino.UI.Controls.Divider. This bug is filed RH-68508 and @JohnM fixed it and will be available in the next public 7.x release.

Kindest
Christian

1 Like

Oh. Thank you. I’ll wait for the update.
Maybe a fix will be added for Rhino.UI.dll 6 Rhino not to make two versions of the plugin. :upside_down_face:

The fix only applies to the Rhino.UI.Controls.Divider control. Any other control seems to work.

The buttons can be cured, but the Expander doesn’t want to be healthy. :cold_sweat:
Скриншот 2022-05-03 12
SampleCsEtoPanel.cs (2.8 KB)

Well what I did:

/// <summary>
/// Constructor
/// </summary>
public AFPanel(uint documentSerialNumber)
{
    RhinoLayout.DisablePanelColorStyling(this);
    this.ViewModel = new AFPanelViewModel();
    this.DataContext = this.ViewModel;
}

That applies to all subcontrols in the Panel.

Does that work for you?

ToolPaneltest.zip (10.8 MB)

I’m sorry, I don’t know how to fit that in. :sob:
Try in this project. show me. thank you.

using System;
using Eto.Drawing;
using Eto.Forms;
using Rhino.UI;
using Rhino.UI.Controls;
using static Rhino.UI.Controls.RhinoLayout;

namespace SampleCsEto.Views
{
    
    [System.Runtime.InteropServices.Guid("143ae3f7-3b9d-4964-afc3-759de81d029e")]
    public class SampleCsEtoPanel2 : Panel
    {
   
        ToggleButton tV1 = new ToggleButton();
        ToggleButton tL1 = new ToggleButton();
   
        public static System.Guid PanelId => typeof(SampleCsEtoPanel2).GUID;
 
        public SampleCsEtoPanel2(uint documentSerialNumber)
        {
            DisablePanelColorStyling(this); // Try this
            Padding = 0;
            Title = GetType().Name;
            BackgroundColor = Eto.Drawing.Colors.White;

            int stL = 300;
            int stV = 40;
1 Like

Thank you !!! it cured all the components in the panel. :smiling_face_with_three_hearts:

RhinoLayout.DisablePanelColorStyling(this);

I accidentally found a way to avoid panel color problems in Rhino 7. without using Rhino.UI.Controls from rhino 7. (RhinoLayout.DisablePanelColorStyling(this):wink: Instead of that I created a fake DynamicLayout. I plugged layout2 into it. I output layout2 into the Panel content.

 var layout1 = new DynamicLayout { DefaultSpacing = new Size(1, 1), Padding = new Padding(1) };
                var layout2 = new DynamicLayout { DefaultSpacing = new Size(1, 1), Padding = new Padding(1) };
    
                var layoutF = new DynamicLayout { DefaultSpacing = new Size(1, 1), Padding = new Padding(1) };//fake.

                layout1.AddSeparateRow(Add_Folder_button, Folder_Manenger,null);
                layout1.Add(Droptext,false);
                layout1.AddRow(ExportFile_button);

                layout2.BeginHorizontal();
                layout2.AddSeparateRow(layout1, null);
                layout2.Add(scroll, true);
                layout2.EndHorizontal();


                layoutF.Add(layout2);//fake.

        
                Content = layout2;

And now the panel for rhino 6 also works on rhino 7-8.