-
Notifications
You must be signed in to change notification settings - Fork 0
/
CycleGUI.cs
171 lines (141 loc) · 6.34 KB
/
CycleGUI.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
167
168
169
170
171
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PokeMMOCycleGUI
{
public partial class PokeMMO_Cycle : Form
{
// pour effectuer le décalage, il faut savoir à quel point de la fenetre on a cliqué
private Point p;
private int lastCycle = -1;
public bool updatePics = false;
public PokeMMO_Cycle()
{
InitializeComponent();
}
private void Exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
Location = new Point(Location.X + e.Location.X - p.X, Location.Y + e.Location.Y - p.Y);
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
p = e.Location;
}
private void Update(object sender, EventArgs e)
{
PokeMMOCycle pokeCycle = new PokeMMOCycle();
int cycle = pokeCycle.Cycle;
CurrentCycle.Text = "Cycle " + cycle;
TimeSpan timeLeftTS = pokeCycle.TimeLeft;
TimeLeft.Text = String.Format("Time Left : {0:00}:{1:00}:{2:00}", timeLeftTS.Hours, timeLeftTS.Minutes, timeLeftTS.Seconds);
if (cycle != lastCycle)
{
lastCycle = cycle;
updatePics = true;
}
if(updatePics)
{
updatePics = false;
// updating the list of pokemons to show
String[,] PokemonList = pokeCycle.PokemonListCurrentCycle;
int width = this.ClientSize.Width;
int elmntWidth = (width) / PokemonList.GetLength(0);
int padding = 5;
// remove the pictures components from the frame
Control[] Carray = new Control[this.Controls.Count];
this.Controls.CopyTo(Carray, 0);
foreach (Control c in Carray)
{
if (c.Name.Contains("pokemonBox"))
this.Controls.Remove(c);
}
String extention;
if (Properties.Settings.Default.AnimatedSprits)
extention = ".gif";
else
extention = ".png";
for(int i = 0; i < PokemonList.GetLength(0)-1; i++)
{
System.Windows.Forms.PictureBox pictureBoxPKM;
pictureBoxPKM = new System.Windows.Forms.PictureBox();
pictureBoxPKM.Name = "pokemonBox" + (i+1);
//((System.ComponentModel.ISupportInitialize)(pictureBoxPKM)).BeginInit();
pictureBoxPKM.ErrorImage = global::PokeMMOCycleGUI.Properties.Resources.imageNotFound;
pictureBoxPKM.BackgroundImage = Image.FromFile("./resources/pokemonFrame.png");
pictureBoxPKM.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
pictureBoxPKM.Location = new System.Drawing.Point(padding + elmntWidth*i, 40);
pictureBoxPKM.Size = new System.Drawing.Size(elmntWidth - 5, elmntWidth + 8);
pictureBoxPKM.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
pictureBoxPKM.BringToFront();
pictureBoxPKM.BackColor = System.Drawing.Color.Transparent;
try
{
pictureBoxPKM.Image = Image.FromFile("./resources/" + PokemonList[i, 0] + extention);
}
catch
{
pictureBoxPKM.Image = Properties.Resources.imageNotFound;
}
pictureBoxPKM.Tag = PokemonList[i, 0] + "\nEncounter Rate : " + PokemonList[i, 1] + "% \nLevel : " + PokemonList[i, 2];
pictureBoxPKM.MouseHover += pictureBox_MouseHover;
this.Controls.Add(pictureBoxPKM);
//((System.ComponentModel.ISupportInitialize)(pictureBoxPKM)).EndInit();
}
//
// Zubat
//
System.Windows.Forms.PictureBox pictureBoxZubat;
pictureBoxZubat = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(pictureBoxZubat)).BeginInit();
pictureBoxZubat.Name = "pokemonBox0";
pictureBoxZubat.ErrorImage = global::PokeMMOCycleGUI.Properties.Resources.imageNotFound;
pictureBoxZubat.Location = new System.Drawing.Point(315, 7);
pictureBoxZubat.Size = new System.Drawing.Size(40, 40);
pictureBoxZubat.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
pictureBoxZubat.BringToFront();
pictureBoxZubat.BackColor = System.Drawing.Color.Transparent;
try
{
pictureBoxZubat.Image = Image.FromFile("./resources/" + PokemonList[PokemonList.GetLength(0) - 1, 0] + extention);
}
catch
{
pictureBoxZubat.Image = Properties.Resources.imageNotFound;
}
pictureBoxZubat.Tag = "Zubat\nEncounter Rate : " + PokemonList[PokemonList.GetLength(0) - 1, 1] +
"% \nLevel : " + PokemonList[PokemonList.GetLength(0)-1, 2];
pictureBoxZubat.MouseHover += pictureBox_MouseHover;
this.Controls.Add(pictureBoxZubat);
((System.ComponentModel.ISupportInitialize)(pictureBoxZubat)).EndInit();
}
}
private void pictureBox_MouseHover(object sender, EventArgs e)
{
ToolTip tt = new ToolTip();
tt.SetToolTip((Control)sender, ((Control)sender).Tag.ToString());
}
private void Option_Click(object sender, EventArgs e)
{
Options o = new Options(this);
o.Show();
}
public void SetRefreshTime(int interval)
{
this.timer.Interval = interval;
}
}
}