leocb / MaterialSkin

Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles.
MIT License
439 stars 131 forks source link

UserControl #382

Open pmcstjean opened 1 year ago

pmcstjean commented 1 year ago

Are UserControl supported or not ? I read that they were not : https://github.com/leocb/MaterialSkin/issues/320

But so far, it looks like it's working on my side. The only problem I am experiencing is that the controls I put in my UserControl appears smaller. For example, I have a button with a given size on my main form and the same button in my UserControl too, and that one appears smaller.

Is there something I am missing ?

PixelKiwi commented 1 year ago

Try changing the “AutoSize” of the button to “false”. Maybe it could help.

pmcstjean commented 1 year ago

It's already AutoSize=false. At design time these button are Size (40, 44) but at runtime they become (29, 30) when in the userControl (which is also inside a UC) and they stay the same when not in a UC. They contains only an icon, no text.

I tried to isolate the problem with a lighter test project, and the only difference is that it modifies the Size a little bit bigger instead of smaller (they become 46, 50). As soon as I set EnforceBackcolorOnAllComponents to false, the sizing problem disappear.

  materialSkinManager = MaterialSkinManager.Instance; 
  materialSkinManager.EnforceBackcolorOnAllComponents = false;
  materialSkinManager.AddFormToManage(this);

Obviously, setting this value to false is not an option, as it is causing some other problems.

valimaties commented 1 year ago

Hi @pmcstjean This project is not in development anymore. Is somehow deprecated. WinForms is also an old way of programming, if you want to do something, move yourself to WPF, MAUI or some other programming language. In WPF there is also a MaterialDesign theme if you want to use it!

Cheers.

pmcstjean commented 1 year ago

Thanks for sharing those options but I'll stick with the less dead of all the MS UI options ;) My humble opinion, of course.

InfiSoftApps commented 1 year ago

I found the Work around for the size issues.

Simply go to the designer file of YOUR UserControl (.designer.vb file)

Inside, Private Sub InitializeComponent() logic, comment out these 2 lines as below. Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

image

Now you'll be able to use UC with no UI level glitch

Hope my solution helps you guys @pmcstjean, @Boiled-Yakult, @valimaties and others as well.

valimaties commented 1 year ago

I didn't say its not working, @InfiSoftApps ... I said that leo marked it as deprecated, it says in first page, in readme file. I didn't tried your solution, because I don't intend to use it anymore as long as the PR are not anymore merged, or merged very rare.

Regards, Vali