dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.4k stars 977 forks source link

[Spec] Themes Implementation in Winforms #5166

Open davidbuckleyni opened 3 years ago

davidbuckleyni commented 3 years ago

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

merriemcgaw commented 3 years ago

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 /

alanhoman commented 3 years ago

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!

merriemcgaw commented 3 years ago

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.

sylveon commented 3 years ago

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

davidbuckleyni commented 3 years ago

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 commented 3 years ago

Related: microsoft/WindowsAppSDK#41

That only deals with UWP and WPF Im talking winforms here

mdtauk commented 3 years ago

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.

davidbuckleyni commented 3 years ago

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.

sylveon commented 3 years ago

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

kirsan31 commented 3 years ago

@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?

RussKie commented 3 years ago

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

merriemcgaw commented 3 years ago

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.

davidbuckleyni commented 3 years ago

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