winforms icon indicating copy to clipboard operation
winforms copied to clipboard

[Spec] Themes Implementation in Winforms

Open davidbuckleyni opened this issue 4 years ago • 13 comments

Please bring the ability of themes to winforms every other platform has it but WinForms.

We should be able to set the theme on startup and change it on the fly with a listener.

Should be something like this

services.configure(themeName);

This would then look in resources.resx for dark or light theme pallets. That could be used to style the entire application for example

DarkControlColor

There should also be some way of getting the value from here as some sort of enumeration query able. And be able to retrive the system colours once selected. Making it that the above is not necessary with the resources.

For example an internal enum that would pick up any custom themes the user has created.

NameSpace Suggestion:

Microsoft.WInforms.AppThemes

Enum Suggestion:

public enum AppThemeEnum
{
   Unspecified,
   Light,
   Dark,
   UserTheme
}

Detect & Change User Interface Style DeviceInfo

API DESCRIPTION
AppTheme CurrentAppTheme What is the actual theme
AppTheme.ApplyTheme This can be called from the this.ApplyTheme maybe they don't want all forms to be theme.

The theme should also allow us to implement rounded corner where we could set a radius of the corner in what ever dpi the user wanted. Be it inches pixels cm mm.

Already While this is implemented for xamrain it would give a clear conception of what is expected for the winforms flavour.

https://github.com/xamarin/Essentials/pull/927

VisualElement AppThemeChanged Event

API DESCRIPTION
void AppThemeChanged(AppThemeChangedEventArgs args) Event that is fired whenever the app theme changed
public class AppThemeChangedEventArgs : EventArgs
{
  public AppTheme RequestedTheme { get; }
}
   

To Apply the theme on a form one could or one could have a class derived from form for example

 public class Form1 : ThemeForm
 {

  }

Resources could be based off Colours per app theme

Theme.AppTheme =AppThemeEnum.Dark

Availability This should go into .net core,5 and 6.

image

davidbuckleyni avatar Jun 28 '21 20:06 davidbuckleyni

This is absolutely something that is on our long term roadmap. We have to work with Windows to make sure that some of the Windows APIs we need are made public so we can read them as we bring up the form. These are discussions that are happening internally and we will be sure to let everyone know when we get a plan in place. This happens to be a favorite topic of mine and @RussKie /

merriemcgaw avatar Jun 29 '21 19:06 merriemcgaw

Hi @merriemcgaw, I wanted to add that this is extremely important for my organization and I appreciate the high priority you are placing on this feature!

alanhoman avatar Jun 29 '21 20:06 alanhoman

I'm glad it's a feature that has so much enthusiasm behind it! I can't make a prediction yet as to when we would release this type of feature, but it is totally on my radar. We'll keep everyone posted as we get more info from Windows and as we are able to settle on a steady design.

merriemcgaw avatar Jun 29 '21 20:06 merriemcgaw

Related: https://github.com/microsoft/WindowsAppSDK/issues/41

sylveon avatar Jul 01 '21 18:07 sylveon

This is absolutely something that is on our long term roadmap. We have to work with Windows to make sure that some of the Windows APIs we need are made public so we can read them as we bring up the form. These are discussions that are happening internally and we will be sure to let everyone know when we get a plan in place. This happens to be a favorite topic of mine and @RussKie /

Glad to here it was talking with ollia on twitter. I love how telerik handle it with the sep dlls for the themes might be worth talking to them

davidbuckleyni avatar Jul 03 '21 16:07 davidbuckleyni

Related: microsoft/WindowsAppSDK#41

That only deals with UWP and WPF Im talking winforms here

davidbuckleyni avatar Jul 03 '21 20:07 davidbuckleyni

Ideally it should be possibly to specify a bundled MSStyles with values for Light and Dark control resource and colours. With an ability to specify Dark or Light as the app's chosen theme, as well as following the OS setting.

Each app could use a locally produced Style - or the current version of WinForms as a package could have a style included to match the version of the OS the app is run on.

The OS can keep it's own UX Theme and MsStyles implementation, but future or updated apps can get updated ones as the future OS design is updated.

mdtauk avatar Jul 03 '21 20:07 mdtauk

Ideally it should be possibly to specify a bundled MSStyles with values for Light and Dark control resource and colours. With an ability to specify Dark or Light as the app's chosen theme, as well as following the OS setting.

Each app could use a locally produced Style - or the current version of WinForms as a package could have a style included to match the version of the OS the app is run on.

The OS can keep it's own UX Theme and MsStyles implementation, but future or updated apps can get updated ones as the future OS design is updated.

If u ever used the telerik ones where their is a theme option on each form that was something like i was thinking but, agreed a global option would be good as well.

davidbuckleyni avatar Jul 03 '21 21:07 davidbuckleyni

That only deals with UWP and WPF Im talking winforms here

The issue I opened on the Windows App SDK repo is about dark theming for Win32/WinForms apps specifically, not WPF nor UWP

sylveon avatar Jul 03 '21 21:07 sylveon

@merriemcgaw

This is absolutely something that is on our long term roadmap. We have to work with Windows to make sure that some of the Windows APIs we need are made public so we can read them as we bring up the form.

Any hope that this can some how speed up #3691 fixing?

kirsan31 avatar Jul 05 '21 06:07 kirsan31

This bug needs to be fixed by the Windows team, it's on their backlog.

RussKie avatar Jul 05 '21 10:07 RussKie

We haven't gotten any feedback from the Windows team on #3691 but we are asking again. It is on their radar and they've acknowledged it's on their end.

merriemcgaw avatar Jul 06 '21 16:07 merriemcgaw

This bug needs to be fixed by the Windows team, it's on their backlog.

Its not a bug if its not their its an enhancement

davidbuckleyni avatar Jul 19 '21 23:07 davidbuckleyni