我在我的winform应用程序中使用MaterialSkin。我希望为两个窗体使用不同的配色方案,但当我打开第二个窗体时,它们的样式都会发生变化。
第一个(Main)表单的代码:
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)
{
}
}这段代码的结果是:


请帮帮我
发布于 2017-11-12 15:50:39
MaterialSkinManager是一个单例,这意味着它只有一个实例。因此,当您在第二个窗口中更改配色方案时,也会更改第一个窗口的配色方案。
我查看了GitHub上的代码,我认为不支持两种不同的方案,这是有意义的,因为您希望您的UI看起来一致。
https://stackoverflow.com/questions/47246539
复制相似问题