using Microsoft.Win32; using System; using System.Collections.Generic; using System.IO; namespace SHARP_CLAS_UI { public class Panel_Count_Info_Manager { #region Define string str_panel_count = "panel_count.xml"; #endregion #region Property private static readonly Lazy _instatnce = new Lazy(() => new Panel_Count_Info_Manager()); public static Panel_Count_Info_Manager Instance { get { return _instatnce.Value; } } #endregion #region Field private Xml_Manager xml_manager = new Xml_Manager(); Panel_Count_Info panel_count_info; private string file_path; #endregion #region Construct public Panel_Count_Info_Manager() { panel_count_info = new Panel_Count_Info(); Get_Panel_Count_Info(); } #endregion #region Function private void Get_File_Path() { RegistryKey rkk = Registry.CurrentUser.OpenSubKey(Equipment.Registry_Path, true); try { if (rkk == null) { rkk = Registry.CurrentUser.CreateSubKey(Equipment.Registry_Path); rkk.SetValue("USER_INFO", @"C:\SHARP_CLAS\Config\"); file_path = @"C:\SHARP_CLAS\Config\"; } else { object value = rkk.GetValue("USER_INFO"); if (value == null) { rkk.SetValue("USER_INFO", @"C:\SHARP_CLAS\Config\"); file_path = @"C:\SHARP_CLAS\Config\"; } else { file_path = value.ToString(); } } } finally { rkk.Close(); } } private void Get_Panel_Count_Info() { Get_File_Path(); if (Directory.Exists(file_path)) { Panel_Count_Info count_info = xml_manager.Read_File(file_path + str_panel_count); if (count_info != null) { this.panel_count_info = count_info; } } else { Directory.CreateDirectory(file_path); } } public bool Save_Panel_Count_Info(Panel_Count_Info panel_count_info) { this.panel_count_info = panel_count_info.Clone(); return xml_manager.Try_Save_File(file_path + str_panel_count, panel_count_info); } public Panel_Count_Info Get_Panel_Count() { return panel_count_info.Clone(); } #endregion } }