-
Notifications
You must be signed in to change notification settings - Fork 294
Expand file tree
/
Copy pathApplicationUserControl.cs
More file actions
170 lines (152 loc) · 4.54 KB
/
ApplicationUserControl.cs
File metadata and controls
170 lines (152 loc) · 4.54 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
* Copyright (c) 2005-2026 - OPC Foundation
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property of
* OPC Foundation. The intellectual and technical concepts contained
* herein are proprietary to OPC Foundation and may be covered by
* U.S. and Foreign Patents, patents in process, and are protected by trade secret
* or copyright law. Dissemination of this information or reproduction of this
* material is strictly forbidden unless prior written permission is obtained
* from OPC Foundation.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.IO;
using System.Diagnostics;
namespace WelcomeApplication
{
public partial class ApplicationUserControl : UserControl
{
[Browsable(true)]
public string ApplicationName
{
get
{
return AppState.ApplicationName;
}
set
{
AppState.ApplicationName = value;
lblAppName.Text = value;
}
}
[Browsable(false)]
public string ProcessName
{
get
{
return AppState.ProcessName;
}
}
[Browsable( true )]
public string ExeFilePath
{
get
{
return AppState.ExeFilePath;
}
set
{
AppState.ExeFilePath = value;
if (!this.DesignMode && !string.IsNullOrEmpty( value ))
{
this.Visible = File.Exists( Path.Combine( Application.StartupPath, value ) );
}
}
}
[Browsable(true)]
public string HelpFile
{
get
{
return AppState.HelpFile;
}
set
{
AppState.HelpFile = value;
}
}
[Browsable(true)]
public string ApplicationDescription
{
get
{
return AppState.ApplicationDescription;
}
set
{
AppState.ApplicationDescription = value;
}
}
public bool PendingRefresh { get; set; }
public ApplicationState AppState { get; set; }
public ApplicationUserControl()
{
InitializeComponent();
AppState = new ApplicationState();
PendingRefresh = false;
}
public void Initialize(Action<string,bool,string> OnHelpFileEvent, Action<string> OnApplicationLaunchEvent)
{
AppState.StateChanged += OnStateChanged;
HelpFileEvent += OnHelpFileEvent;
ApplicationLaunchEvent += OnApplicationLaunchEvent;
}
// Events Treated by the Main Application
Action<string, bool, string> HelpFileEvent;
public event Action<string> ApplicationLaunchEvent;
private void btnPlay_Click(object sender, EventArgs e)
{
try
{
if (ApplicationLaunchEvent != null)
ApplicationLaunchEvent.Invoke(ExeFilePath);
}
catch (Exception)
{ }
}
private void btnInfo_Click(object sender, EventArgs e)
{
try
{
if (HelpFileEvent != null)
HelpFileEvent.Invoke(AppState.HelpFile, AppState.State, AppState.ApplicationDescription);
}
catch (System.Exception)
{ }
}
private delegate void stateChangedDelegate(bool newState);
private void OnStateChanged(bool newState)
{
PendingRefresh = true;
/* NP Jan-20-2012:
* Check if the form is running in another thread, if so then marshall to other thread */
if (ParentForm.InvokeRequired)
{
ParentForm.Invoke(new stateChangedDelegate(OnStateChanged), newState);
}
else
{
if (newState)
{
ovsState.FillColor = Color.Green;
btnPlay.Enabled = false;
}
else
{
ovsState.FillColor = Color.Red;
btnPlay.Enabled = true;
}
}
}
}
}