천호석
2022-11-01 0b5386e7314cc125c0808deec2d948281f397c0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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<Panel_Count_Info_Manager> _instatnce = new Lazy<Panel_Count_Info_Manager>(() => new Panel_Count_Info_Manager());
 
        public static Panel_Count_Info_Manager Instance
        {
            get
            {
                return _instatnce.Value;
            }
        }
        #endregion
 
        #region Field
        private Xml_Manager<Panel_Count_Info> xml_manager = new Xml_Manager<Panel_Count_Info>();
 
        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
    }
}