using PaintDotNet.Base.CommTool; using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using PaintDotNet.Base.SettingModel; using System.Drawing; using System.Windows.Forms; namespace PaintDotNet.Preview2 { public static class CommonDefine { public static readonly string Preview2Root = Application.StartupPath + @"\Preview2\"; public static readonly string Preview2ConfigFile = Preview2Root + "Preview2Config.xml"; public static readonly string ToolkitPathLeft = Preview2Root + "ToolkitLeft.xml"; public static readonly string ToolkitPathRight = Preview2Root + "ToolkitRight.xml"; public static readonly string ToolkitLibPath = Preview2Root + "ToolkitLib.txt"; public static readonly string ToolkitLibTxt = "1200,1211,700,701,702,704,705,706,707,708,7080,7081,7082,7083,7084,709,7090,7092,7091,7093,710,7100,7101,7102,711,7110,7111,7112,7113,7114,7115,7116,712,7120,7121,7122,7123,7124,7125,715,7150,7151,7152,7153,7154,713,7130,7131,7132,7133,714,7140,7141,7142,7143,7144,7145,7146,716,717,720,721,722,718"; public static Color Blue = Color.FromArgb(0, 174, 219); public const string DefaultCamCfg = "CameraParam"; } internal static class Preview2Context { internal static int ShandingCorrectionState = 0; static Preview2Context() { if (!Directory.Exists(CommonDefine.Preview2Root)) { Directory.CreateDirectory(CommonDefine.Preview2Root); } } private static Preview2Config _p2Config; public static Preview2Config P2Config { get { if (_p2Config == null) { _p2Config = new Preview2Config(); if (System.IO.File.Exists(CommonDefine.Preview2ConfigFile)) _p2Config = XmlSerializeHelper.Load(CommonDefine.Preview2ConfigFile); } return _p2Config; } } static string[] _toolLibArray; public static string[] ToolLibArray { get { if (_toolLibArray == null) { if (!System.IO.File.Exists(CommonDefine.ToolkitLibPath)) { System.IO.File.WriteAllText(CommonDefine.ToolkitLibPath, CommonDefine.ToolkitLibTxt); } _toolLibArray = System.IO.File.ReadAllText(CommonDefine.ToolkitLibPath).Split(','); } return _toolLibArray; } } static ShortcutbarModel _toolbarModelLeft; public static ShortcutbarModel ToolbarModelLeft { get { if (_toolbarModelLeft == null) { if (System.IO.File.Exists(CommonDefine.ToolkitPathLeft)) _toolbarModelLeft = XmlSerializeHelper.Load(CommonDefine.ToolkitPathLeft); else { _toolbarModelLeft = new ShortcutbarModel(); _toolbarModelLeft.Menus = new List(); } } return _toolbarModelLeft; } } static ShortcutbarModel _toolbarModelRight; public static ShortcutbarModel ToolbarModelRight { get { if (_toolbarModelRight == null) { if (System.IO.File.Exists(CommonDefine.ToolkitPathRight)) _toolbarModelRight = XmlSerializeHelper.Load(CommonDefine.ToolkitPathRight); else { _toolbarModelRight = new ShortcutbarModel(); _toolbarModelRight.Menus = new List(); } } return _toolbarModelRight; } } public static void SaveP2Config() { XmlSerializeHelper.Save(P2Config, CommonDefine.Preview2ConfigFile); } public static void SaveToolkit() { XmlSerializeHelper.Save(ToolbarModelLeft, CommonDefine.ToolkitPathLeft); XmlSerializeHelper.Save(ToolbarModelRight, CommonDefine.ToolkitPathRight); } } }