-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
211 lines (186 loc) · 6.21 KB
/
Copy pathProgram.cs
File metadata and controls
211 lines (186 loc) · 6.21 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Media;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DesktopAssistant
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
///
public static volatile Form1 form;
public static volatile Form2 form2;
public static Thread thread1;
public static Thread thread2;
public static Thread thread3;
public static Thread thread4;
public static Thread thread5;
public static Thread thread6;
public static bool playing = false;
public static bool wasplaying = false;
public static volatile bool closed = false;
public const int smoothingx = 10;
static void form1(object data)
{
Application.Run((Form1) data);
}
public static void form2x(object data)
{
Application.Run((Form2)data);
}
static void playaudio1(object data)
{
SoundPlayer sound = new SoundPlayer();
sound.Stream = (Stream)data;
sound.Play();
playing = false;
thread5 = new Thread(playaudio1);
return;
}
static void playaudio2(object data)
{
SoundPlayer sound = new SoundPlayer();
sound.Stream = (Stream)data;
sound.Play();
playing = false;
thread6 = new Thread(playaudio2);
return;
}
static void moveimage(object data)
{
Form2 imgview = (Form2)data;
Random rng = new Random();
int xdif;
int ydif;
int xpos2 = rng.Next(0, Screen.FromControl(form2).Bounds.Width - 341);
int ypos2 = rng.Next(0, Screen.FromControl(form2).Bounds.Height - 364);
int xpos = 0;
int ypos = 0;
int steps = 1;
xdif = imgview.Location.X - xpos2;
ydif = imgview.Location.Y - ypos2;
while (xdif != 0 || ydif != 0)
{
xdif = imgview.Location.X - xpos2;
ydif = imgview.Location.Y - ypos2;
if (xdif > 0)
{
xpos = imgview.Location.X - steps;
}
else if (xdif < 0)
{
xpos = imgview.Location.X + steps;
}
if (ydif > 0)
{
ypos = imgview.Location.Y - steps;
}
else if (ydif < 0)
{
ypos = imgview.Location.Y + steps;
}
imgview.Location = new Point(xpos, ypos);
Thread.Sleep(1);
}
thread4 = new Thread(moveimage);
}
static void movechar(object data)
{
Random rng = new Random();
Form1 formx = (Form1)data;
int xdif;
int ydif;
int xpos = 0;
int ypos = 0;
int steps = 1;
int ytemp = 0;
bool window = false;
bool firstrun = true;
bool canopen = false;
while (true)
{
canopen = closed || firstrun;
if (rng.Next(0, 1000) == 0 && canopen)
{
firstrun = false;
window = true;
closed = false;
ytemp = Cursor.Position.Y;
}
xdif = formx.obrazok.Location.X - Cursor.Position.X;
ydif = formx.obrazok.Location.Y - Cursor.Position.Y;
if (window)
{
xdif = formx.obrazok.Location.X;
ydif = formx.obrazok.Location.Y - ytemp;
if (xdif == 5)
{
window = false;
form2.Location = new Point(0, ytemp);
thread3.Start(form2);
form2.Location = new Point(0, ytemp);
thread4.Start(form2);
if (!playing)
{
playing = true;
thread6.Start(Properties.Resources.image_open);
}
}
}
if (xdif == 0)
{
formx.obrazok.Image = Properties.Resources.tucan1;
}
if (xdif > 5)
{
xpos = formx.obrazok.Location.X - steps;
formx.obrazok.Image = Properties.Resources.tucan1;
}
else if (xdif < -5)
{
xpos = formx.obrazok.Location.X + steps;
formx.obrazok.Image = Properties.Resources.tucan0;
}
if (ydif > 5)
{
ypos = formx.obrazok.Location.Y - steps;
}
else if (ydif < -5)
{
ypos = formx.obrazok.Location.Y + steps;
}
formx.obrazok.Location = new Point(xpos, ypos);
Thread.Sleep(1);
}
}
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Control.CheckForIllegalCrossThreadCalls = false; // daj sa vypchat c#
form = new Form1();
thread1 = new Thread(form1);
thread1.Start(form);
while (!form.ready) {
Thread.Sleep(10);
}
form2 = new Form2();
thread2 = new Thread(movechar);
thread2.Start(form);
thread3 = new Thread(form2x);
thread4 = new Thread(moveimage);
thread5 = new Thread(playaudio1);
thread6 = new Thread(playaudio2);
playing = true;
thread5.Start(Properties.Resources.start);
}
}
}