-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCloseReason.cs
More file actions
144 lines (124 loc) · 5.57 KB
/
CloseReason.cs
File metadata and controls
144 lines (124 loc) · 5.57 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
143
144
using ScriptEngine.Machine.Contexts;
using ScriptEngine.Machine;
using System.Collections;
using System.Collections.Generic;
namespace osf
{
[ContextClass("КлПричинаЗакрытия", "ClCloseReason")]
public class ClCloseReason : AutoContext<ClCloseReason>, ICollectionContext, IEnumerable<IValue>
{
private int m_none = (int)System.Windows.Forms.CloseReason.None; // 0 Причина закрытия не была определена или не может быть определена.
private int m_windowsShutDown = (int)System.Windows.Forms.CloseReason.WindowsShutDown; // 1 Операционная система закрывает все приложения перед завершением работы.
private int m_mdiFormClosing = (int)System.Windows.Forms.CloseReason.MdiFormClosing; // 2 Родительская форма этой формы многодокументного интерфейса (MDI) закрывается.
private int m_userClosing = (int)System.Windows.Forms.CloseReason.UserClosing; // 3 Форма закрывается программными способами или с помощью действия пользователя в пользовательском интерфейсе (например нажатием кнопки Закрыть в окне формы, выбором параметра Закрыть в системном меню окна или нажатием сочетания клавиш ALT+F4).
private int m_taskManagerClosing = (int)System.Windows.Forms.CloseReason.TaskManagerClosing; // 4 Диспетчер задач Microsoft Windows закрывает приложение.
private int m_formOwnerClosing = (int)System.Windows.Forms.CloseReason.FormOwnerClosing; // 5 Форма-владелец закрывается.
private int m_applicationExitCall = (int)System.Windows.Forms.CloseReason.ApplicationExitCall; // 6 Был вызван метод Exit() класса Application.
private List<IValue> _list;
public int Count()
{
return _list.Count;
}
public CollectionEnumerator GetManagedIterator()
{
return new CollectionEnumerator(this);
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<IValue>)_list).GetEnumerator();
}
IEnumerator<IValue> IEnumerable<IValue>.GetEnumerator()
{
foreach (var item in _list)
{
yield return (item as IValue);
}
}
[ContextProperty("Количество", "Count")]
public int CountProp
{
get { return _list.Count; }
}
[ContextMethod("Получить", "Get")]
public IValue Get(int index)
{
return _list[index];
}
[ContextMethod("Имя")]
public string NameRu(decimal p1)
{
return namesRu.TryGetValue(p1, out string name) ? name : p1.ToString();
}
[ContextMethod("Name")]
public string NameEn(decimal p1)
{
return namesEn.TryGetValue(p1, out string name) ? name : p1.ToString();
}
private static readonly Dictionary<decimal, string> namesRu = new Dictionary<decimal, string>
{
{5, "Владелец"},
{6, "Выход"},
{4, "Диспетчер"},
{0, "Отсутствие"},
{3, "Пользователь"},
{1, "Система"},
{2, "ФормаMDI"},
};
private static readonly Dictionary<decimal, string> namesEn = new Dictionary<decimal, string>
{
{5, "FormOwnerClosing"},
{6, "ApplicationExitCall"},
{4, "TaskManagerClosing"},
{0, "None"},
{3, "UserClosing"},
{1, "WindowsShutDown"},
{2, "MdiFormClosing"},
};
public ClCloseReason()
{
_list = new List<IValue>();
_list.Add(ValueFactory.Create(ApplicationExitCall));
_list.Add(ValueFactory.Create(FormOwnerClosing));
_list.Add(ValueFactory.Create(MdiFormClosing));
_list.Add(ValueFactory.Create(None));
_list.Add(ValueFactory.Create(TaskManagerClosing));
_list.Add(ValueFactory.Create(UserClosing));
_list.Add(ValueFactory.Create(WindowsShutDown));
}
[ContextProperty("Владелец", "FormOwnerClosing")]
public int FormOwnerClosing
{
get { return m_formOwnerClosing; }
}
[ContextProperty("Выход", "ApplicationExitCall")]
public int ApplicationExitCall
{
get { return m_applicationExitCall; }
}
[ContextProperty("Диспетчер", "TaskManagerClosing")]
public int TaskManagerClosing
{
get { return m_taskManagerClosing; }
}
[ContextProperty("Отсутствие", "None")]
public int None
{
get { return m_none; }
}
[ContextProperty("Пользователь", "UserClosing")]
public int UserClosing
{
get { return m_userClosing; }
}
[ContextProperty("Система", "WindowsShutDown")]
public int WindowsShutDown
{
get { return m_windowsShutDown; }
}
[ContextProperty("ФормаMDI", "MdiFormClosing")]
public int MdiFormClosing
{
get { return m_mdiFormClosing; }
}
}
}