-
Notifications
You must be signed in to change notification settings - Fork 0
/
WTRegistry.cs
116 lines (103 loc) · 3.49 KB
/
WTRegistry.cs
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
107
108
109
110
111
112
113
114
115
116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Dapper;
using Microsoft.Win32;
using System.Data.SqlClient;
namespace WTUSA
{
public class WTRegistry
{
//private wtVersionSpecificRegistryInfo = @"Software\Datos\WinTool"; //2013
public const string wtVersionSpecificRegistryInfo = @"Software\WinTool\WinTool"; //2014
private RegistryKey pRegKey;
public enum RegistryItem
{
WTGUID,
UserName,
WTIsReady,
CNCIsReady,
LVal,
SentinelSerial,
LValCNC,
ActiveCutDataNrT,
ActiveMaskNr,
SelFilter,
ActivePartPicID,
ActiveActionTypeNr,
ActiveActionNr,
ActiveCutDataNrP,
ActiveMatchCodeID,
ActiveNCObjectFileNr,
ActiveMachineNr,
ActiveJobMasterId,
ActiveNCFolderNr,
ActiveCommissionNr,
ActiveRoleActionAccountNr,
ActiveToolListNr,
ActivePartID,
ActiveGroupTreeID,
ActiveToolListEntryNr,
ActiveToolNr,
Connection
};
public object this[RegistryItem item]
{
get
{
string tempName = Enum.GetName(typeof(RegistryItem), item);
return pRegKey.GetValue(tempName);
}
set
{
pRegKey.SetValue((string)Enum.GetName(typeof(RegistryItem), item), value);
}
}
public WTRegistry()
{
pRegKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(wtVersionSpecificRegistryInfo + @"\Settings\Temp", true);
}
public byte[] GetBytesFromRegistry()
{
var bFromArray = (byte[])pRegKey.GetValue("Connection");
bFromArray = Encryption.AES_Decrypt(bFromArray);
return bFromArray;
}
public void WriteBytesToRegistry(SqlConnectionStringBuilder csbuilder)
{
byte[] bytes = System.Text.ASCIIEncoding.ASCII.GetBytes(csbuilder.ConnectionString);
bytes = Encryption.AES_Encrypt(bytes);
(new WTRegistry())[RegistryItem.Connection] = bytes;
}
// WriteBytesToRegistry(csbuilder As SqlConnectionStringBuilder)
// Dim bytes As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(csbuilder.ConnectionString)
// bytes = WTLicense.AES_Encrypt(bytes, password)
// TempSetting(RegistryItem.Connection) = bytes
public string WinToolAppPath()
{
return Microsoft.Win32.Registry.CurrentUser.OpenSubKey(wtVersionSpecificRegistryInfo, false).GetValue("WTAppPath").ToString();
}
}
public static class WTRefresh
{
private static RegistryKey WinReqRegistryKey = Registry.CurrentUser.OpenSubKey(WTRegistry.wtVersionSpecificRegistryInfo + @"\WindowReq", true);
public static void RefreshPart()
{
WinReqRegistryKey.SetValue("PartFrame",1);
}
public static void RefreshTool()
{
WinReqRegistryKey.SetValue("ToolFrame", 1);
}
public static void RefreshList()
{
WinReqRegistryKey.SetValue("ToolListFrame",1);
}
public static void RefreshNCFolder()
{
WinReqRegistryKey.SetValue("NCFolderFrame", 1);
}
}
}