123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Media;
- namespace HistoryDLL
- {
- public class WindowsResolution
- {
- public CyclicScroller.MonitorFlag ncm;
- public WindowsResolution()
- {
- int Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
- int Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
- //判斷是否為多螢幕~由 width 判斷
- double value = Math.Ceiling((double)Width / 1920);
- value = 3;
- if (value == 1)
- {
- ncm = CyclicScroller.MonitorFlag.Monitor1_1;
- ConfigSettingClass.MainBackCollect.ScreenSetting = 1;
- }
- else if (value == 2)
- {
- ncm = CyclicScroller.MonitorFlag.Monitor2_1;
- ConfigSettingClass.MainBackCollect.ScreenSetting = 2;
- }
- else if (value == 3)
- {
- ncm = CyclicScroller.MonitorFlag.Monitor3_1;
- ConfigSettingClass.MainBackCollect.ScreenSetting = 3;
- }
- else if (value == 4)
- {
- ncm = CyclicScroller.MonitorFlag.Monitor4_1;
- ConfigSettingClass.MainBackCollect.ScreenSetting = 4;
- }
- else if (value == 5)
- {
- ncm = CyclicScroller.MonitorFlag.Monitor5_1;
- ConfigSettingClass.MainBackCollect.ScreenSetting = 5;
- }
- else if (value == 6)
- {
- ncm = CyclicScroller.MonitorFlag.Monitor6_1;
- ConfigSettingClass.MainBackCollect.ScreenSetting = 6;
- }
- }
- }
- public class ConfigSettingClass
- {
- #region Static Members
- public static MainBackground MainBackCollect = new MainBackground()
- {
- BackgroundColor = Color.FromArgb(255, 255, 255, 255),
- BackgroundColorPoint = new Point(0, 0),
- ImgBackground = String.Empty,
- ImgLogo = String.Empty,
- DefaultLangIndex = 0,
- BackHomeMillisecond = 20,
- ScreenSetting = 1,
- LangText = new string[] { "中文", "English", "", "" },
- LangFlowDir = new FlowDirection[] { FlowDirection.LeftToRight, FlowDirection.LeftToRight, FlowDirection.LeftToRight, FlowDirection.LeftToRight },
- IsUsing4kResolution = false
- };
- public static Event EventCollect = new Event()
- {
- BackgroundColor = Color.FromArgb(230, 3, 115, 185),
- BackgroundColorPoint = new Point(0, 0),
- TextColor = Color.FromArgb(255, 232, 238, 255),
- TextColorPoint = new Point(0, 0),
- ThicknessColor = Color.FromArgb(255, 177, 232, 255),
- ThicknessColorPoint = new Point(0, 0)
- };
- public static EventContent EventContentCollect = new EventContent()
- {
- BackgroundColor = Color.FromArgb(233, 115, 217, 255),
- BackgroundColorPoint = new Point(0, 0),
- TextColor = Color.FromArgb(198, 0, 6, 9),
- TextColorPoint = new Point(0, 0),
- ThicknessColor = Color.FromArgb(255, 198, 255, 255),
- ThicknessColorPoint = new Point(0, 0)
- };
- public static Timeline TimelineCollect = new Timeline()
- {
- BackgroundColor = Color.FromArgb(177, 168, 197, 255),
- BackgroundColorPoint = new Point(0, 0),
- TextColor = Color.FromArgb(176, 255, 255, 255),
- TextColorPoint = new Point(0, 0),
- ThicknessColor = Color.FromArgb(255, 0, 87, 154),
- ThicknessColorPoint = new Point(0, 0)
- };
- public static TimelineExtent TimelineExtentCollect = new TimelineExtent()
- {
- BackgroundColor = Color.FromArgb(204, 0, 41, 104),
- BackgroundColorPoint = new Point(0, 0),
- TextColor = Color.FromArgb(255, 162, 220, 255),
- TextColorPoint = new Point(0, 0),
- ThicknessColor = Color.FromArgb(255, 76, 49, 0),
- ThicknessColorPoint = new Point(0, 0)
- };
- public static ButtonSelect BtnSelectCollect = new ButtonSelect()
- {
- BackgroundColor = Color.FromArgb(168, 12, 0, 0),
- BackgroundColorPoint = new Point(0, 0),
- TextColor = Color.FromArgb(255, 222, 241, 255),
- TextColorPoint = new Point(0, 0),
- BackgroundColorUnselect = Color.FromArgb(168, 0, 129, 181),
- BackgroundColorUnselectPoint = new Point(0, 0),
- TextColorUnselect = Color.FromArgb(120, 255, 255, 255),
- TextColorUnselectPoint = new Point(0, 0)
- };
- #endregion
- public ConfigSettingClass(string ConfigPath, WindowsResolution windowsresolution)
- {
- if (File.Exists(ConfigPath))
- {
- string jsonResult;
- using (StreamReader sr = new StreamReader(ConfigPath))
- {
- jsonResult = sr.ReadToEnd();
- }
- var container = DeserializeFromJson<DataCollect>(jsonResult);
- if (container != null)
- {
- MainBackCollect = container.MainBackgroundCollect;
- EventCollect = container.EventCollect;
- EventContentCollect = container.EventContentCollect;
- TimelineCollect = container.TimelineCollect;
- TimelineExtentCollect = container.TimelineExtentCollect;
- BtnSelectCollect = container.ButtonSelectCollect;
- }
- try
- {
- if (ConfigSettingClass.MainBackCollect.LangFlowDir == null || ConfigSettingClass.MainBackCollect.LangFlowDir.Length < 4 ||
- ConfigSettingClass.MainBackCollect.LangText == null || ConfigSettingClass.MainBackCollect.LangText.Length < 4)
- {
- MainBackCollect = null;
- return;
- }
- }
- catch (Exception ex)
- {
- MainBackCollect = null;
- return;
- }
- }
- else
- {
- SetDefaultBgAndLogo(windowsresolution);
- }
- if (ConfigSettingClass.MainBackCollect.BackHomeMillisecond <= 5)
- {
- ConfigSettingClass.MainBackCollect.BackHomeMillisecond = 5;
- }
- }
- private void SetDefaultBgAndLogo(WindowsResolution windowsresolution)
- {
- MainBackCollect.ImgLogo = "logo.png";
- switch (windowsresolution.ncm)
- {
- case CyclicScroller.MonitorFlag.Monitor1_1:
- {
- //MainBackCollect.ImgBackground = "1x1.jpg";
- break;
- }
- case CyclicScroller.MonitorFlag.Monitor2_1:
- {
- MainBackCollect.ImgBackground = "2x1.jpg";
- break;
- }
- case CyclicScroller.MonitorFlag.Monitor3_1:
- {
- MainBackCollect.ImgBackground = "3x1.jpg";
- break;
- }
- }
- }
- public static T DeserializeFromJson<T>(string json)
- {
- T deserializedProduct = JsonConvert.DeserializeObject<T>(json);
- return deserializedProduct;
- }
- }
- }
|