-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrayMenuPreset.cs
98 lines (86 loc) · 2.8 KB
/
TrayMenuPreset.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
using System.IO;
using System.Text;
namespace ViPER4WindowsBin
{
public class TrayMenuPreset
{
private string m_szPresetName = "";
private int m_nPresetMode;
private string m_szPresetFile = "";
public string PresetName
{
get => m_szPresetName;
set => m_szPresetName = value;
}
public int PresetMode
{
get => m_nPresetMode;
set => m_nPresetMode = value;
}
public string PresetFile
{
get => m_szPresetFile;
set => m_szPresetFile = value;
}
public string PresetFileShort
{
get
{
if (string.IsNullOrEmpty(m_szPresetFile))
return "";
int num = m_szPresetFile.LastIndexOf("\\");
return num <= 0 ? "" : m_szPresetFile.Substring(num + 1, m_szPresetFile.Length - num - 1);
}
}
public TrayMenuPreset(string szName, int nMode, string szFile)
{
m_szPresetName = szName;
m_nPresetMode = nMode;
m_szPresetFile = szFile;
}
public bool Valid()
{
return m_nPresetMode == 0 || m_nPresetMode == 1 || m_nPresetMode == 2;
}
public bool PresetLoadable()
{
return !string.IsNullOrEmpty(m_szPresetFile) && File.Exists(m_szPresetFile);
}
public TrayMenuPreset Clone()
{
return new TrayMenuPreset(m_szPresetName, m_nPresetMode, m_szPresetFile);
}
public override bool Equals(object obj)
{
if (obj == null || obj.GetType() != typeof(TrayMenuPreset))
return false;
TrayMenuPreset trayMenuPreset = obj as TrayMenuPreset;
return trayMenuPreset.PresetName == m_szPresetName && trayMenuPreset.PresetMode == m_nPresetMode && trayMenuPreset.PresetFile == m_szPresetFile;
}
public override int GetHashCode()
{
if (!Valid())
return 0;
int num = 0;
byte[] bytes1 = Encoding.Default.GetBytes(m_szPresetFile);
byte[] bytes2 = Encoding.Default.GetBytes(m_szPresetName);
if (bytes1 != null)
{
for (int index = 0; index < bytes1.Length; ++index)
num += bytes1[index];
num <<= m_nPresetMode;
}
if (bytes2 != null)
{
for (int index = 0; index < bytes2.Length; ++index)
num += bytes2[index];
num >>= m_nPresetMode;
}
return (num + m_nPresetMode) * (m_nPresetMode + 1);
}
public override string ToString()
{
return m_szPresetName;
}
}
}