搭建Wpf框架(12) —— MahApps2.0.0.0自定义主题

AIStudio框架汇总及介绍

一、查看官方文档 https://mahapps.com/docs/themes/thememanager

  按照官方文档,基本可以完成自定义主题。

 但是所有的颜色需要自己按照https://github.com/MahApps/MahApps.Metro/blob/develop/src/MahApps.Metro/Styles/Themes/Theme.Template.xaml这个模板填充,岂不是会累死人。

二、本文介绍一下比较省事的方法

1.下载MahApps.Metro的源码,编译通过

2.在文件夹MahApps.Metro\Styles\Themes下有一个GeneratorParameters.json文件

{
  "TemplateFile": "Theme.Template.xaml",
  "DefaultValues": {
    "MahApps.Colors.IdealForeground": "White"
  },
  "BaseColorSchemes": [
    {
      "Name": "Dark",
      "Values": {
        "MahApps.Colors.ThemeForeground": "#FFFFFFFF",
        "MahApps.Colors.ThemeForeground20": "#51FFFFFF",
        "MahApps.Colors.ThemeBackground": "#FF252525",
        "MahApps.Colors.ThemeBackground20": "#51252525",
        "MahApps.Colors.Gray1": "#FFF9F9F9",
        "MahApps.Colors.Gray2": "#FF7F7F7F",
        "MahApps.Colors.Gray3": "#FF9D9D9D",
        "MahApps.Colors.Gray4": "#FFA59F93",
        "MahApps.Colors.Gray5": "#FFB9B9B9",
        "MahApps.Colors.Gray6": "#FFCCCCCC",
        "MahApps.Colors.Gray7": "#FF7E7E7E",
        "MahApps.Colors.Gray8": "#FF454545",
        "MahApps.Colors.Gray9": "#5EC9C9C9",
        "MahApps.Colors.Gray10": "#FF2F2F2F",
        "MahApps.Colors.Gray": "#FF7D7D7D",
        "MahApps.Colors.Gray.MouseOver": "#FFAAAAAA",
        "MahApps.Colors.Gray.SemiTransparent": "#40808080",
        "MahApps.Colors.SemiTransparent": "#55FFFFFF",
        "MahApps.Colors.Flyout": "#FF2B2B2B",
        "MahApps.Colors.ContextMenu.Border": "#E0717070",
        "MahApps.Colors.SubMenu.Border": "#E0717070",
        "MahApps.Colors.MenuShadow": "#99B2B2B2",
        "MahApps.Colors.MenuItem.DisabledForeground": "#FF7E7E7E",
        "MahApps.Colors.SliderValue.Disabled": "#FF535353",
        "MahApps.Colors.SliderTrack.Disabled": "#FF383838",
        "MahApps.Colors.SliderThumb.Disabled": "#FF7E7E7E",
        "MahApps.Colors.SliderTrack.Hover": "#FF737373",
        "MahApps.Colors.SliderTrack.Normal": "#FF6C6C6C",
        "MahApps.Colors.Button.Flat.Background.Pressed": "#444444",
        "MahApps.Colors.Button.Flat.Foreground.Pressed": "#FFFFFF",
        "MahApps.Colors.MenuItem.SelectionFill": "#313131",
        "MahApps.Colors.MenuItem.SelectionStroke": "#313131",
        "MahApps.Colors.TopMenuItem.PressedFill": "#313131",
        "MahApps.Colors.TopMenuItem.PressedStroke": "#E0717070",
        "MahApps.Colors.TopMenuItem.SelectionStroke": "#90717070",
        "MahApps.Colors.Badged.Background.Disabled": "#FF666666",
        "MahApps.Colors.Badged.Foreground.Disabled": "#99000000",
        "MahApps.Colors.SystemAltHigh": "#FF000000",
        "MahApps.Colors.SystemAltLow": "#33000000",
        "MahApps.Colors.SystemAltMedium": "#99000000",
        "MahApps.Colors.SystemAltMediumHigh": "#CC000000",
        "MahApps.Colors.SystemAltMediumLow": "#66000000",
        "MahApps.Colors.SystemBaseHigh": "#FFFFFFFF",
        "MahApps.Colors.SystemBaseLow": "#33FFFFFF",
        "MahApps.Colors.SystemBaseMedium": "#99FFFFFF",
        "MahApps.Colors.SystemBaseMediumHigh": "#CCFFFFFF",
        "MahApps.Colors.SystemBaseMediumLow": "#66FFFFFF",
        "MahApps.Colors.SystemChromeAltLow": "#FFF2F2F2",
        "MahApps.Colors.SystemChromeBlackHigh": "#FF000000",
        "MahApps.Colors.SystemChromeBlackLow": "#33000000",
        "MahApps.Colors.SystemChromeBlackMediumLow": "#66000000",
        "MahApps.Colors.SystemChromeBlackMedium": "#CC000000",
        "MahApps.Colors.SystemChromeDisabledHigh": "#FF333333",
        "MahApps.Colors.SystemChromeDisabledLow": "#FF858585",
        "MahApps.Colors.SystemChromeHigh": "#FF767676",
        "MahApps.Colors.SystemChromeLow": "#FF171717",
        "MahApps.Colors.SystemChromeMedium": "#FF1F1F1F",
        "MahApps.Colors.SystemChromeMediumLow": "#FF2B2B2B",
        "MahApps.Colors.SystemChromeWhite": "#FFFFFFFF",
        "MahApps.Colors.SystemChromeGray": "#FF767676",
        "MahApps.Colors.SystemListLow": "#19FFFFFF",
        "MahApps.Colors.SystemListMedium": "#33FFFFFF",
        "MahApps.Colors.SystemErrorText": "#FFF000",
        "MahApps.Brushes.SystemControlHighlightAltListAccentHigh.Opacity": "0.9",
        "MahApps.Brushes.SystemControlHighlightAltListAccentLow.Opacity": "0.6",
        "MahApps.Brushes.SystemControlHighlightAltListAccentMedium.Opacity": "0.8",
        "MahApps.Brushes.SystemControlHighlightListAccentHigh.Opacity": "0.9",
        "MahApps.Brushes.SystemControlHighlightListAccentLow.Opacity": "0.6",
        "MahApps.Brushes.SystemControlHighlightListAccentMedium.Opacity": "0.8",
        "MahApps.Brushes.SystemControlTransientBorder.Opacity": "0.36"
      }
    },
    {
      "Name": "Light",
      "Values": {
        "MahApps.Colors.ThemeForeground": "#FF000000",
        "MahApps.Colors.ThemeForeground20": "#51000000",
        "MahApps.Colors.ThemeBackground": "#FFFFFFFF",
        "MahApps.Colors.ThemeBackground20": "#51FFFFFF",
        "MahApps.Colors.Gray1": "#FF333333",
        "MahApps.Colors.Gray2": "#FF7F7F7F",
        "MahApps.Colors.Gray3": "#FF9D9D9D",
        "MahApps.Colors.Gray4": "#FFA59F93",
        "MahApps.Colors.Gray5": "#FFB9B9B9",
        "MahApps.Colors.Gray6": "#FFCCCCCC",
        "MahApps.Colors.Gray7": "#FFD8D8D9",
        "MahApps.Colors.Gray8": "#FFE0E0E0",
        "MahApps.Colors.Gray9": "#5EC9C9C9",
        "MahApps.Colors.Gray10": "#FFF7F7F7",
        "MahApps.Colors.Gray": "#FFBEBEBE",
        "MahApps.Colors.Gray.MouseOver": "#FF333333",
        "MahApps.Colors.Gray.SemiTransparent": "#40808080",
        "MahApps.Colors.SemiTransparent": "#55000000",
        "MahApps.Colors.Flyout": "#FFFFFFFF",
        "MahApps.Colors.ContextMenu.Border": "#E0717070",
        "MahApps.Colors.SubMenu.Border": "#E0717070",
        "MahApps.Colors.MenuShadow": "#FF000000",
        "MahApps.Colors.MenuItem.DisabledForeground": "#FF7F7F7F",
        "MahApps.Colors.SliderValue.Disabled": "#FFBABABA",
        "MahApps.Colors.SliderTrack.Disabled": "#FFDBDBDB",
        "MahApps.Colors.SliderThumb.Disabled": "#FFA0A0A0",
        "MahApps.Colors.SliderTrack.Hover": "#FFD0D0D0",
        "MahApps.Colors.SliderTrack.Normal": "#FFC6C6C6",
        "MahApps.Colors.Button.Flat.Background.Pressed": "#333333",
        "MahApps.Colors.Button.Flat.Foreground.Pressed": "#FFFFFF",
        "MahApps.Colors.MenuItem.SelectionFill": "#DEDEDE",
        "MahApps.Colors.MenuItem.SelectionStroke": "#DEDEDE",
        "MahApps.Colors.TopMenuItem.PressedFill": "#DEDEDE",
        "MahApps.Colors.TopMenuItem.PressedStroke": "#E0717070",
        "MahApps.Colors.TopMenuItem.SelectionStroke": "#90717070",
        "MahApps.Colors.Badged.Background.Disabled": "#FF999999",
        "MahApps.Colors.Badged.Foreground.Disabled": "#99000000",
        "MahApps.Colors.SystemAltHigh": "#FFFFFFFF",
        "MahApps.Colors.SystemAltLow": "#33FFFFFF",
        "MahApps.Colors.SystemAltMedium": "#99FFFFFF",
        "MahApps.Colors.SystemAltMediumHigh": "#CCFFFFFF",
        "MahApps.Colors.SystemAltMediumLow": "#66FFFFFF",
        "MahApps.Colors.SystemBaseHigh": "#FF000000",
        "MahApps.Colors.SystemBaseLow": "#33000000",
        "MahApps.Colors.SystemBaseMedium": "#99000000",
        "MahApps.Colors.SystemBaseMediumHigh": "#CC000000",
        "MahApps.Colors.SystemBaseMediumLow": "#66000000",
        "MahApps.Colors.SystemChromeAltLow": "#FF171717",
        "MahApps.Colors.SystemChromeBlackHigh": "#FF000000",
        "MahApps.Colors.SystemChromeBlackLow": "#33000000",
        "MahApps.Colors.SystemChromeBlackMediumLow": "#66000000",
        "MahApps.Colors.SystemChromeBlackMedium": "#CC000000",
        "MahApps.Colors.SystemChromeDisabledHigh": "#FFCCCCCC",
        "MahApps.Colors.SystemChromeDisabledLow": "#FF7A7A7A",
        "MahApps.Colors.SystemChromeHigh": "#FFCCCCCC",
        "MahApps.Colors.SystemChromeLow": "#FFF2F2F2",
        "MahApps.Colors.SystemChromeMedium": "#FFE6E6E6",
        "MahApps.Colors.SystemChromeMediumLow": "#FFF2F2F2",
        "MahApps.Colors.SystemChromeWhite": "#FFFFFFFF",
        "MahApps.Colors.SystemChromeGray": "#FF767676",
        "MahApps.Colors.SystemListLow": "#19000000",
        "MahApps.Colors.SystemListMedium": "#33000000",
        "MahApps.Colors.SystemErrorText": "#C50500",
        "MahApps.Brushes.SystemControlHighlightAltListAccentHigh.Opacity": "0.7",
        "MahApps.Brushes.SystemControlHighlightAltListAccentLow.Opacity": "0.4",
        "MahApps.Brushes.SystemControlHighlightAltListAccentMedium.Opacity": "0.6",
        "MahApps.Brushes.SystemControlHighlightListAccentHigh.Opacity": "0.7",
        "MahApps.Brushes.SystemControlHighlightListAccentLow.Opacity": "0.4",
        "MahApps.Brushes.SystemControlHighlightListAccentMedium.Opacity": "0.6",
        "MahApps.Brushes.SystemControlTransientBorder.Opacity": "0.14"
      }
    }
  ],
  "ColorSchemes": [
    {
      "Name": "Amber",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFF0A30A",
        "MahApps.Colors.Accent": "#CCF0A30A",
        "MahApps.Colors.Accent2": "#99F0A30A",
        "MahApps.Colors.Accent3": "#66F0A30A",
        "MahApps.Colors.Accent4": "#33F0A30A",
        "MahApps.Colors.Highlight": "#FFB17807"
      }
    },
    {
      "Name": "Blue",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF0078D7",
        "MahApps.Colors.Accent": "#CC0078D7",
        "MahApps.Colors.Accent2": "#990078D7",
        "MahApps.Colors.Accent3": "#660078D7",
        "MahApps.Colors.Accent4": "#330078D7",
        "MahApps.Colors.Highlight": "#FF00589F"
      }
    },
    {
      "Name": "Brown",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF825A2C",
        "MahApps.Colors.Accent": "#CC825A2C",
        "MahApps.Colors.Accent2": "#99825A2C",
        "MahApps.Colors.Accent3": "#66825A2C",
        "MahApps.Colors.Accent4": "#33825A2C",
        "MahApps.Colors.Highlight": "#FF604220"
      }
    },
    {
      "Name": "Cobalt",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF0050EF",
        "MahApps.Colors.Accent": "#CC0050EF",
        "MahApps.Colors.Accent2": "#990050EF",
        "MahApps.Colors.Accent3": "#660050EF",
        "MahApps.Colors.Accent4": "#330050EF",
        "MahApps.Colors.Highlight": "#FF003BB0"
      }
    },
    {
      "Name": "Crimson",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFA20025",
        "MahApps.Colors.Accent": "#CCA20025",
        "MahApps.Colors.Accent2": "#99A20025",
        "MahApps.Colors.Accent3": "#66A20025",
        "MahApps.Colors.Accent4": "#33A20025",
        "MahApps.Colors.Highlight": "#FF77001B"
      }
    },
    {
      "Name": "Cyan",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF1BA1E2",
        "MahApps.Colors.Accent": "#CC1BA1E2",
        "MahApps.Colors.Accent2": "#991BA1E2",
        "MahApps.Colors.Accent3": "#661BA1E2",
        "MahApps.Colors.Accent4": "#331BA1E2",
        "MahApps.Colors.Highlight": "#FF1377A7"
      }
    },
    {
      "Name": "Emerald",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF008A00",
        "MahApps.Colors.Accent": "#CC008A00",
        "MahApps.Colors.Accent2": "#99008A00",
        "MahApps.Colors.Accent3": "#66008A00",
        "MahApps.Colors.Accent4": "#33008A00",
        "MahApps.Colors.Highlight": "#FF006600"
      }
    },
    {
      "Name": "Green",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF60A917",
        "MahApps.Colors.Accent": "#CC60A917",
        "MahApps.Colors.Accent2": "#9960A917",
        "MahApps.Colors.Accent3": "#6660A917",
        "MahApps.Colors.Accent4": "#3360A917",
        "MahApps.Colors.Highlight": "#FF477D11"
      }
    },
    {
      "Name": "Indigo",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF6A00FF",
        "MahApps.Colors.Accent": "#CC6A00FF",
        "MahApps.Colors.Accent2": "#996A00FF",
        "MahApps.Colors.Accent3": "#666A00FF",
        "MahApps.Colors.Accent4": "#336A00FF",
        "MahApps.Colors.Highlight": "#FF4E00BC"
      }
    },
    {
      "Name": "Lime",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFA4C400",
        "MahApps.Colors.Accent": "#CCA4C400",
        "MahApps.Colors.Accent2": "#99A4C400",
        "MahApps.Colors.Accent3": "#66A4C400",
        "MahApps.Colors.Accent4": "#33A4C400",
        "MahApps.Colors.Highlight": "#FF799100"
      }
    },
    {
      "Name": "Magenta",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFD80073",
        "MahApps.Colors.Accent": "#CCD80073",
        "MahApps.Colors.Accent2": "#99D80073",
        "MahApps.Colors.Accent3": "#66D80073",
        "MahApps.Colors.Accent4": "#33D80073",
        "MahApps.Colors.Highlight": "#FF9F0055"
      }
    },
    {
      "Name": "Mauve",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF76608A",
        "MahApps.Colors.Accent": "#CC76608A",
        "MahApps.Colors.Accent2": "#9976608A",
        "MahApps.Colors.Accent3": "#6676608A",
        "MahApps.Colors.Accent4": "#3376608A",
        "MahApps.Colors.Highlight": "#FF574766"
      }
    },
    {
      "Name": "Olive",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF6D8764",
        "MahApps.Colors.Accent": "#CC6D8764",
        "MahApps.Colors.Accent2": "#996D8764",
        "MahApps.Colors.Accent3": "#666D8764",
        "MahApps.Colors.Accent4": "#336D8764",
        "MahApps.Colors.Highlight": "#FF50634A"
      }
    },
    {
      "Name": "Orange",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFFA6800",
        "MahApps.Colors.Accent": "#CCFA6800",
        "MahApps.Colors.Accent2": "#99FA6800",
        "MahApps.Colors.Accent3": "#66FA6800",
        "MahApps.Colors.Accent4": "#33FA6800",
        "MahApps.Colors.Highlight": "#FFB94C00"
      }
    },
    {
      "Name": "Pink",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFF472D0",
        "MahApps.Colors.Accent": "#CCF472D0",
        "MahApps.Colors.Accent2": "#99F472D0",
        "MahApps.Colors.Accent3": "#66F472D0",
        "MahApps.Colors.Accent4": "#33F472D0",
        "MahApps.Colors.Highlight": "#FFB45499"
      }
    },
    {
      "Name": "Purple",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF6459DF",
        "MahApps.Colors.Accent": "#CC6459DF",
        "MahApps.Colors.Accent2": "#996459DF",
        "MahApps.Colors.Accent3": "#666459DF",
        "MahApps.Colors.Accent4": "#336459DF",
        "MahApps.Colors.Highlight": "#FF4A41A5"
      }
    },
    {
      "Name": "Red",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFE51400",
        "MahApps.Colors.Accent": "#CCE51400",
        "MahApps.Colors.Accent2": "#99E51400",
        "MahApps.Colors.Accent3": "#66E51400",
        "MahApps.Colors.Accent4": "#33E51400",
        "MahApps.Colors.Highlight": "#FFA90E00"
      }
    },
    {
      "Name": "Sienna",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFA0522D",
        "MahApps.Colors.Accent": "#CCA0522D",
        "MahApps.Colors.Accent2": "#99A0522D",
        "MahApps.Colors.Accent3": "#66A0522D",
        "MahApps.Colors.Accent4": "#33A0522D",
        "MahApps.Colors.Highlight": "#FF763C21"
      }
    },
    {
      "Name": "Steel",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF647687",
        "MahApps.Colors.Accent": "#CC647687",
        "MahApps.Colors.Accent2": "#99647687",
        "MahApps.Colors.Accent3": "#66647687",
        "MahApps.Colors.Accent4": "#33647687",
        "MahApps.Colors.Highlight": "#FF4A5763"
      }
    },
    {
      "Name": "Taupe",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF87794E",
        "MahApps.Colors.Accent": "#CC87794E",
        "MahApps.Colors.Accent2": "#9987794E",
        "MahApps.Colors.Accent3": "#6687794E",
        "MahApps.Colors.Accent4": "#3387794E",
        "MahApps.Colors.Highlight": "#FF635939"
      }
    },
    {
      "Name": "Teal",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF00ABA9",
        "MahApps.Colors.Accent": "#CC00ABA9",
        "MahApps.Colors.Accent2": "#9900ABA9",
        "MahApps.Colors.Accent3": "#6600ABA9",
        "MahApps.Colors.Accent4": "#3300ABA9",
        "MahApps.Colors.Highlight": "#FF007E7D"
      }
    },
    {
      "Name": "Violet",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFAA00FF",
        "MahApps.Colors.Accent": "#CCAA00FF",
        "MahApps.Colors.Accent2": "#99AA00FF",
        "MahApps.Colors.Accent3": "#66AA00FF",
        "MahApps.Colors.Accent4": "#33AA00FF",
        "MahApps.Colors.Highlight": "#FF7D00BC"
      }
    },
    {
      "Name": "Yellow",
      "Values": {
        "MahApps.Colors.AccentBase": "#FFFEDE06",
        "MahApps.Colors.Accent": "#CCFEDE06",
        "MahApps.Colors.Accent2": "#99FEDE06",
        "MahApps.Colors.Accent3": "#66FEDE06",
        "MahApps.Colors.Accent4": "#33FEDE06",
        "MahApps.Colors.Highlight": "#FFBBA404",
        "MahApps.Colors.IdealForeground": "Black"
      }
    },
    {
      "Name": "Gray",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF303241",
        "MahApps.Colors.Accent": "#CC303241",
        "MahApps.Colors.Accent2": "#99303241",
        "MahApps.Colors.Accent3": "#66303241",
        "MahApps.Colors.Accent4": "#33303241",
        "MahApps.Colors.Highlight": "#FF086F9E"
      }
    },
  ]
}
View Code

看出规律了吧,你只需要加上自己的即可,如:

    {
      "Name": "MyColor",
      "Values": {
        "MahApps.Colors.AccentBase": "#FF825A2C",
        "MahApps.Colors.Accent": "#CC825A2C",
        "MahApps.Colors.Accent2": "#99825A2C",
        "MahApps.Colors.Accent3": "#66825A2C",
        "MahApps.Colors.Accent4": "#33825A2C",
        "MahApps.Colors.Highlight": "#FF604220"
      }
    },
 
3.然后重新编译源码,你会发现MahApps.Metro\Styles\Themes多了你自定义的主题。
4.这个时候,你拿个这个编译完成的dll去引用,那么你的工程就可以使用你自定义的主题。
5.但是,这不是最佳方法,下面介绍还是安装nuget包的方法进行自定义主题。
6.打开你的工程,安装MahApps.Metro包
7.把上面3过程生成的主题拷贝到你的工程一个文件夹下,可能有很多个主题,用一个文件清单加入
{
  "Dark": [
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Dark.BlueGray.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Dark.Primary.xaml"
  ],
  "Light": [
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Light.BlueGray.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Light.Primary.xaml"
  ],
  "Gray11": [
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Amber.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Blue.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.BlueGray.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Brown.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Cobalt.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Crimson.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Cyan.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Emerald.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Gray.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Green.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Indigo.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Lime.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Magenta.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Mauve.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Olive.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Orange.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Pink.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Primary.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Purple.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Red.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Sienna.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Steel.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Taupe.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Teal.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Violet.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/Gray11.Yellow.xaml"
  ],
  "LightGray": [
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Amber.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Blue.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.BlueGray.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Brown.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Cobalt.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Crimson.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Cyan.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Emerald.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Gray.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Green.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Indigo.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Lime.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Magenta.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Mauve.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Olive.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Orange.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Pink.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Primary.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Purple.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Red.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Sienna.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Steel.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Taupe.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Teal.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Violet.xaml",
    "pack://application:,,,/AIStudio.Resource;component/Brushs/LightGray.Yellow.xaml"
  ]
}
View Code
8.最后一步:程序加载主题
   StreamReader reader = new StreamReader(Application.GetResourceStream(new Uri("pack://application:,,,/AIStudio.Resource;component/Brushs/brush.json", UriKind.RelativeOrAbsolute)).Stream);
                string text = reader.ReadToEnd();
                var dic = JsonConvert.DeserializeObject<Dictionary<string, string[]>>(text);
                foreach (var brush in dic.Values.SelectMany(p => p))
                {
                    ThemeManager.Current.AddLibraryTheme(new LibraryTheme(new Uri(brush), MahAppsLibraryThemeProvider.DefaultInstance));
                }
posted @ 2021-07-28 15:16  竹天笑  阅读(865)  评论(0编辑  收藏  举报