繁体   English   中英

使用Materialdesign C#的Winform的不同配色方案

[英]Different color schemes for winform with materialdesign C#

我在Winform应用程序中使用MaterialSkin。 我想为两种形式使用不同的配色方案,但是当我打开第二种形式时,这两种样式都会更改。
第一种(主要)形式的代码:

public partial class Form1 : MaterialForm
{
    private readonly MaterialSkinManager materialSkinManager  = MaterialSkinManager.Instance;

    public Form1()
    {
        InitializeComponent();
        // Create a material theme manager and add the form to manage (this)
        materialSkinManager.AddFormToManage(this);
        materialSkinManager.Theme = MaterialSkinManager.Themes.DARK;

        // Configure color schema
        materialSkinManager.ColorScheme = new ColorScheme(
            Primary.BlueGrey800, Primary.BlueGrey900,
            Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
    }

    private void materialRaisedButton3_Click(object sender, EventArgs e)
    {
        Form2 form2 = new Form2();
        if(form2.ShowDialog() == DialogResult.OK)
        {
            MessageBox.Show("OK");
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    }

第二种形式的代码:

public partial class Form2 : MaterialForm
{
    private readonly MaterialSkinManager materialSkinManager2 = MaterialSkinManager.Instance;

    public Form2()
    {
        InitializeComponent();
        materialSkinManager2.AddFormToManage(this);

        // Configure color schema
        materialSkinManager2.ColorScheme = new ColorScheme(
            Primary.DeepOrange300, Primary.BlueGrey900,
            Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE);
    }

    private void Form2_Load(object sender, EventArgs e)
    {

    }
}

此代码的结果是: 在此处输入图片说明 在此处输入图片说明

请帮帮我

MaterialSkinManager是单例,这意味着它只有一个实例。 因此,当您在第二个窗口中更改配色方案时,它也会同时更改第一个窗口的配色方案。

我查看了GitHub上的代码,但我认为不支持两种不同的方案,这很有意义,因为您希望UI看起来一致。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM