Files
aistudio-wpf-diagram/AIStudio.Wpf.Mind/Helpers/MindThemeHelper.cs
2023-03-29 06:26:00 +08:00

726 lines
28 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Xml.Linq;
using AIStudio.Wpf.DiagramDesigner;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
using AIStudio.Wpf.Mind.ViewModels;
namespace AIStudio.Wpf.Mind.Helpers
{
public static class MindThemeHelper
{
public static MindThemeModel GetTheme(string theme)
{
switch (theme)
{
case "天空蓝": return GetSkyBlueTheme();
case "紧凑蓝": return GetSkyBlueMiniTheme();
case "文艺绿": return GetLiteratureGreenTheme();
case "紧凑绿": return GetLiteratureGreenMiniTheme();
case "脑残粉": return GetBrainDeadPinkTheme();
case "紧凑粉": return GetBrainDeadPinkMiniTheme();
case "浪漫紫": return GetRomanticPurpleTheme();
case "紧凑紫": return GetRomanticPurpleMiniTheme();
case "清新红": return GetFreshRedTheme();
case "紧凑红": return GetFreshRedMiniTheme();
case "泥土黄": return GetEarthyYellowTheme();
case "紧凑黄": return GetEarthyYellowMiniTheme();
case "冷光黄": return GetCoolLightYellowTheme();
case "紧凑冷": return GetCoolLightYellowMiniTheme();
default: return GetSkyBlueTheme();
}
}
public static MindThemeModel GetSkyBlueTheme()
{
return new MindThemeModel()
{
Name = "天空蓝",
Key = "SkyBlue",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0x73, 0xa1, 0xbf),
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(50, 15),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xee, 0xf3, 0xf6),
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
}
};
}
public static MindThemeModel GetSkyBlueMiniTheme()
{
return new MindThemeModel()
{
Name = "紧凑蓝",
Key = "SkyBlueMini",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0x73, 0xa1, 0xbf),
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xee, 0xf3, 0xf6),
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
}
};
}
public static MindThemeModel GetLiteratureGreenTheme()
{
return new MindThemeModel()
{
Name = "文艺绿",
Key = "LiteratureGreen",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0x73, 0xbf, 0x76),
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(50, 15),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xee, 0xf6, 0xee),
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
}
};
}
public static MindThemeModel GetLiteratureGreenMiniTheme()
{
return new MindThemeModel()
{
Name = "紧凑绿",
Key = "LiteratureGreenMini",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0x73, 0xbf, 0x76),
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xee, 0xf6, 0xee),
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
}
};
}
public static MindThemeModel GetBrainDeadPinkTheme()
{
return new MindThemeModel()
{
Name = "脑残粉",
Key = "BrainDeadPink",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0xbf, 0x73, 0x94),
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(50, 15),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xf6, 0xee, 0xf2),
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
}
};
}
public static MindThemeModel GetBrainDeadPinkMiniTheme()
{
return new MindThemeModel()
{
Name = "紧凑粉",
Key = "BrainDeadPinkMini",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0xbf, 0x73, 0x94),
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xf6, 0xee, 0xf2),
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
}
};
}
public static MindThemeModel GetRomanticPurpleTheme()
{
return new MindThemeModel()
{
Name = "浪漫紫",
Key = "RomanticPurple",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0x7b, 0x73, 0xbf),
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(50, 15),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xef, 0xee, 0xf6),
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
}
};
}
public static MindThemeModel GetRomanticPurpleMiniTheme()
{
return new MindThemeModel()
{
Name = "紧凑紫",
Key = "RomanticPurpleMini",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0x7b, 0x73, 0xbf),
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xef, 0xee, 0xf6),
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
}
};
}
public static MindThemeModel GetFreshRedTheme()
{
return new MindThemeModel()
{
Name = "清新红",
Key = "FreshRed",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0xbf, 0x73, 0x73),
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(50, 15),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xf6, 0xee, 0xee),
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
}
};
}
public static MindThemeModel GetFreshRedMiniTheme()
{
return new MindThemeModel()
{
Name = "紧凑红",
Key = "FreshRedMini",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0xbf, 0x73, 0x73),
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xf6, 0xee, 0xee),
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
}
};
}
public static MindThemeModel GetEarthyYellowTheme()
{
return new MindThemeModel()
{
Name = "泥土黄",
Key = "EarthyYellow",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0xbf, 0x93, 0x73),
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(50, 15),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xf6, 0xf2, 0xee),
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
}
};
}
public static MindThemeModel GetEarthyYellowMiniTheme()
{
return new MindThemeModel()
{
Name = "紧凑黄",
Key = "EarthyYellowMini",
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0xbf, 0x93, 0x73),
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
FontColor = Colors.White,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xf6, 0xf2, 0xee),
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.Transparent,
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
}
};
}
public static MindThemeModel GetCoolLightYellowTheme()
{
return new MindThemeModel()
{
Name = "冷光黄",
Key = "CoolLightYellow",
Dark = true,
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0xe9, 0xdf, 0x98),
LineColor = Color.FromRgb(0xe9, 0xdf, 0x98),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(50, 15),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xa4, 0xc5, 0xc0),
LineColor = Color.FromRgb(0xa4, 0xc5, 0xc0),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.White,
LineColor = Colors.White,
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(15, 15),
}
};
}
public static MindThemeModel GetCoolLightYellowMiniTheme()
{
return new MindThemeModel()
{
Name = "紧凑黄",
Key = "CoolLightYellowMini",
Dark = true,
MindThemeLevel1 = new MindTheme()
{
ItemWidth = 120,
ItemHeight = 40,
FillColor = Color.FromRgb(0xe9, 0xdf, 0x98),
LineColor = Color.FromRgb(0xe9, 0xdf, 0x98),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel2 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Color.FromRgb(0xa4, 0xc5, 0xc0),
LineColor = Color.FromRgb(0xa4, 0xc5, 0xc0),
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
},
MindThemeLevel3 = new MindTheme()
{
ItemWidth = 100,
ItemHeight = 25,
FillColor = Colors.White,
LineColor = Colors.White,
FontColor = Colors.Black,
FontSize = 15,
Spacing = new SizeBase(10, 10),
}
};
}
public static void ThemeChange(MindNode mindNode, MindThemeModel mindThemeModel, bool initAppearance = false)
{
switch (mindNode.NodeLevel)
{
case 0:
{
if (initAppearance)
{
mindNode.ItemWidth = mindThemeModel.MindThemeLevel1.ItemWidth;
mindNode.ItemHeight = mindThemeModel.MindThemeLevel1.ItemHeight;
}
mindNode.ColorViewModel.FillColor.Color = mindThemeModel.MindThemeLevel1.FillColor;
mindNode.ColorViewModel.LineColor.Color = mindThemeModel.MindThemeLevel1.LineColor;
mindNode.FontViewModel.FontColor = mindThemeModel.MindThemeLevel1.FontColor;
mindNode.FontViewModel.FontSize = mindThemeModel.MindThemeLevel1.FontSize;
mindNode.Spacing = mindThemeModel.MindThemeLevel1.Spacing;
break;
}
case 1:
{
if (initAppearance)
{
mindNode.ItemWidth = mindThemeModel.MindThemeLevel2.ItemWidth;
mindNode.ItemHeight = mindThemeModel.MindThemeLevel2.ItemHeight;
}
mindNode.ColorViewModel.FillColor.Color = mindThemeModel.MindThemeLevel2.FillColor;
mindNode.ColorViewModel.LineColor.Color = mindThemeModel.MindThemeLevel2.LineColor;
mindNode.FontViewModel.FontColor = mindThemeModel.MindThemeLevel2.FontColor;
mindNode.FontViewModel.FontSize = mindThemeModel.MindThemeLevel2.FontSize;
mindNode.Spacing = mindThemeModel.MindThemeLevel2.Spacing;
break;
}
default:
{
if (initAppearance)
{
mindNode.ItemWidth = mindThemeModel.MindThemeLevel3.ItemWidth;
mindNode.ItemHeight = mindThemeModel.MindThemeLevel3.ItemHeight;
}
mindNode.ColorViewModel.FillColor.Color = mindThemeModel.MindThemeLevel3.FillColor;
mindNode.ColorViewModel.LineColor.Color = mindThemeModel.MindThemeLevel3.LineColor;
mindNode.FontViewModel.FontColor = mindThemeModel.MindThemeLevel3.FontColor;
mindNode.FontViewModel.FontSize = mindThemeModel.MindThemeLevel3.FontSize;
mindNode.Spacing = mindThemeModel.MindThemeLevel3.Spacing;
break;
}
}
}
public static MindThemeModel GetThemeModel(MindNode mindNode)
{
MindThemeModel mindThemeModel = new MindThemeModel()
{
MindThemeLevel1 = new MindTheme()
{
ItemWidth = mindNode.ItemWidth,
ItemHeight = mindNode.ItemHeight,
FillColor = mindNode.ColorViewModel.FillColor.Color,
LineColor = mindNode.ColorViewModel.LineColor.Color,
FontColor = mindNode.FontViewModel.FontColor,
FontSize = mindNode.FontViewModel.FontSize,
Spacing = mindNode.Spacing,
},
};
return mindThemeModel;
}
public static void SetThemeModel(MindNode mindNode, MindThemeModel mindThemeModel)
{
mindNode.ItemWidth = mindThemeModel.MindThemeLevel1.ItemWidth;
mindNode.ItemHeight = mindThemeModel.MindThemeLevel1.ItemHeight;
mindNode.ColorViewModel.FillColor.Color = mindThemeModel.MindThemeLevel1.FillColor;
mindNode.ColorViewModel.LineColor.Color = mindThemeModel.MindThemeLevel1.LineColor;
mindNode.FontViewModel.FontColor = mindThemeModel.MindThemeLevel1.FontColor;
mindNode.FontViewModel.FontSize = mindThemeModel.MindThemeLevel1.FontSize;
mindNode.Spacing = mindThemeModel.MindThemeLevel1.Spacing;
}
public static IColorViewModel GetColorViewModel(MindNode mindNode)
{
ColorViewModel colorViewModel = new ColorViewModel();
CopyHelper.CopyPropertyValue(mindNode.ColorViewModel, colorViewModel);
return colorViewModel;
}
public static IFontViewModel GetFontViewModel(MindNode mindNode)
{
FontViewModel fontViewModel = new FontViewModel();
CopyHelper.CopyPropertyValue(mindNode.FontViewModel, fontViewModel);
return fontViewModel;
}
}
public class MindTheme
{
public double ItemWidth
{
get; set;
}
public double ItemHeight
{
get; set;
}
public Color FillColor
{
get; set;
}
public Color LineColor
{
get; set;
}
public Color FontColor
{
get; set;
}
public double FontSize
{
get; set;
}
public SizeBase Spacing
{
get; set;
}
}
public class MindThemeModel
{
public string Key
{
get; set;
}
public string Name
{
get; set;
}
public bool Dark
{
get; set;
}
public MindTheme MindThemeLevel1
{
get; set;
}
public MindTheme MindThemeLevel2
{
get; set;
}
public MindTheme MindThemeLevel3
{
get; set;
}
}
}