-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecondscreenFRM.cs
167 lines (128 loc) · 5.06 KB
/
secondscreenFRM.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
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
namespace countersystemV1
{
public partial class secondscreenFRM : KryptonForm
{
string[] Imgs_slider;
public secondscreenFRM()
{
InitializeComponent();
timer1.Interval = 2000; // Set the interval time to 2000 milliseconds = 2seconds
timer1.Enabled = true;
}
/*METHODS ************/
public static class Util // no conditions for today here .. extra code for effects
{
public enum Effect { Roll, Slide, Center, Blend }
public static void Animate(Control ctl, Effect effect, int msec, int angle)
{
int flags = effmap[(int)effect];
if (ctl.Visible)
{
flags |= 0x10000; angle += 180;
}
else
{
if (ctl.TopLevelControl == ctl) flags |= 0x20000;
else if (effect == Effect.Blend) throw new ArgumentException();
}
flags |= dirmap[(angle % 360) / 45];
bool ok = AnimateWindow(ctl.Handle, msec, flags);
if (!ok) throw new Exception("Animation failed");
ctl.Visible = !ctl.Visible;
}
private static int[] dirmap = { 1, 5, 4, 6, 2, 10, 8, 9 };
private static int[] effmap = { 0, 0x40000, 0x10, 0x80000 };
[DllImport("user32.dll")]
private static extern bool AnimateWindow(IntPtr handle, int msec, int flags);
}
static string[] LstImgs(string FilePath)
{
string Imagepaths = Application.StartupPath + @"\" + FilePath;
DirectoryInfo d = new DirectoryInfo(Imagepaths);
FileInfo[] Files = d.GetFiles(); // Getting Files
string[] ret = new string[Files.Length];
for (int x = 0; x < Files.Length; x++)
{
ret[x] = Files[x].Name;
}
return ret;
}
int cnt = 0;
public void _condition()
{
if (Imgs_slider.Length != 0)
{
string file_extension = Path.GetExtension(Imgs_slider[cnt]);
if (file_extension == ".jpeg" || file_extension == ".jpg" || file_extension == ".JPG" || file_extension == ".png" || file_extension == ".png" || file_extension == ".PNG")
{
timer2.Interval = 5000;
pictureBox1.BringToFront();
pictureBox1.Image = Image.FromFile(Application.StartupPath + @"\Advertisement\" + Imgs_slider[cnt]);
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
}
else
{
axWindowsMediaPlayer1.BringToFront();
var clip = axWindowsMediaPlayer1.newMedia(string.Format(Application.StartupPath + @"\Advertisement\" + Imgs_slider[cnt]));
TimeSpan Duration = TimeSpan.FromSeconds(clip.duration);
Int32 hr_Duration = Duration.Hours * 60 * 60 * 1000;
Int32 Min_Duration = Duration.Minutes * 60 * 1000;
Int32 Sec_Duration = Duration.Seconds * 1000;
timer2.Interval = Sec_Duration + Min_Duration + hr_Duration;
axWindowsMediaPlayer1.URL = string.Format(Application.StartupPath + @"\Advertisement\" + Imgs_slider[cnt]);
axWindowsMediaPlayer1.Ctlcontrols.play();
axWindowsMediaPlayer1.settings.volume = 0;
}
cnt = cnt + 1;
if (cnt == (Imgs_slider.Length))
{
cnt = 0;
}
}
}
private void setFormLocation(Form form, Screen screen)
{
Rectangle bounds = screen.Bounds;
form.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height);
}
/* EVENTS ************/
private void timer1_Tick(object sender, EventArgs e)
{
LBL_COUNTER1.Text = RelayTrigger.getcounter1;
LBL_COUNTER2.Text = RelayTrigger.getcounter2;
}
// Method that stops the timer
public void StopTimer()
{
timer1.Stop();
}
// Dispose method to clean up resources when the class instance is destroyed
public void Dispose()
{
timer1.Dispose();
}
private void timer2_Tick(object sender, EventArgs e)
{
_condition();
}
private void secondscreenFRM_Load(object sender, EventArgs e)
{
Imgs_slider = LstImgs("Advertisement");// load all images names
// for video
timer2.Start();
timer2.Interval = 1000;
}
}
}