LabelUtils.cs
4.17 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System.Collections.Generic;
using OS.Spin.View.MainWindowControls;
using OS.Spin.ViewModle.Models;
namespace OS.Spin.View.Utils
{
public class LabelUtils
{
private static LabelUtils _LabelUtils = null;
private static List<UserControl1> _UserControl = null; //动态添加标签
private static LabelData _LabelData = null; //添加标签的初始值
private static SetData _SetData = null; //设置显示的初始值
//private static UserControl2 _UserControl2 = null; //全局缩放按钮
private static UserControl3 _UserControl3 = null; //cm标签
private static object LabelUtils_lock = new object();
//图标数据保存
private static List<ImageData> _ImageData = null;
//初始化清空图标数据
public void clearImageData()
{
if (_ImageData != null && _ImageData.Count > 0)
{
_ImageData.Clear();
}
}
//该图标数据集合是否为空
public bool isNullImageData()
{
bool imageData = false;
if (_ImageData != null && _ImageData.Count > 0)
{
imageData = true;
}
return imageData;
}
//从集合中添加ImageData数据
public void addImageData(ImageData image)
{
if (_ImageData != null && !_ImageData.Contains(image))
{
_ImageData.Add(image);
}
}
//返回图标数据集合
public List<ImageData> GetImageDatas()
{
return _ImageData;
}
public LabelUtils()
{
_UserControl = new List<UserControl1>();
_ImageData = new List<ImageData>();
_LabelData = new LabelData();
_SetData = new SetData();
//_UserControl2 = new UserControl2();
_UserControl3 = new UserControl3();
}
public UserControl3 getUserControl3()
{
return _UserControl3;
}
//public UserControl2 getUserControl2()
//{
// return _UserControl2;
//}
public static LabelUtils getInstance()
{
if (_LabelUtils == null) //双if + lock
{
lock (LabelUtils_lock)
{
if (_LabelUtils == null)
{
_LabelUtils = new LabelUtils();
}
}
}
return _LabelUtils;
}
//管理内存中动态创建的Labels
public void addLabels(UserControl1 userControl1)
{
if (!_UserControl.Contains(userControl1))
{
_UserControl.Add(userControl1);
}
}
//清空List里面所有的Label对象
public void deleteLabels()
{
if (_UserControl != null && _UserControl.Count > 0) //不为空且存在元素
{
_UserControl.Clear();
}
}
//获取标签的个数
public static int getNumbers()
{
return _UserControl.Count;
}
//返回该List集合的对象
public List<UserControl1> getListObject()
{
return _UserControl;
}
//返回LabelData对象
public LabelData getLabelData()
{
return _LabelData;
}
//返回SetData对象
public SetData getSetData()
{
return _SetData;
}
//如果两个两个都为零即是默认方式不用管
public bool isNullSetData()
{
bool setData = false;
if (_SetData.Start != 0 || _SetData.End != 0)
{
setData = true;
}
return setData;
}
//获取属性的值的方式有问题(简单的讲是判断条件有问题)
public bool isNull()
{
bool data = false;
if (_LabelData.Start != 0 || _LabelData.End != 0)
{
//return true;
data = true;
}
return data;
}
}
}