added files
This commit is contained in:
commit
b502964c9a
25 files changed
+1769
No files matched your search
+187
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
internal class PasswordGate : Form
|
||||
{
|
||||
private const int W = 380;
|
||||
|
||||
private const int H = 320;
|
||||
|
||||
private const string Pass = "FloppaClient";
|
||||
|
||||
private PField field;
|
||||
|
||||
private Label err;
|
||||
|
||||
private Rectangle clsR = new Rectangle(340, 14, 22, 22);
|
||||
|
||||
private int hover;
|
||||
|
||||
private Timer fade = new Timer();
|
||||
|
||||
private float fadeT;
|
||||
|
||||
public bool Ok;
|
||||
|
||||
[DllImport("gdi32")]
|
||||
private static extern IntPtr CreateRoundRectRgn(int a, int b, int c, int d, int e, int f);
|
||||
|
||||
[DllImport("user32")]
|
||||
private static extern bool ReleaseCapture();
|
||||
|
||||
[DllImport("user32")]
|
||||
private static extern IntPtr SendMessage(IntPtr h, int m, int w, int l);
|
||||
|
||||
public PasswordGate()
|
||||
{
|
||||
Text = "Floppa Clicker";
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
ClientSize = new Size(380, 320);
|
||||
BackColor = G.Bg;
|
||||
DoubleBuffered = true;
|
||||
Opacity = 0.0;
|
||||
Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, 381, 321, 24, 24));
|
||||
field = new PField();
|
||||
field.SetBounds(40, 172, 300, 40);
|
||||
Controls.Add(field);
|
||||
err = new Label();
|
||||
err.Text = "";
|
||||
err.Font = G.S;
|
||||
err.ForeColor = Color.FromArgb(235, 100, 100);
|
||||
err.AutoSize = false;
|
||||
err.TextAlign = ContentAlignment.MiddleCenter;
|
||||
err.SetBounds(0, 216, 380, 18);
|
||||
Controls.Add(err);
|
||||
PBtn pBtn = new PBtn();
|
||||
pBtn.Text2 = "Unlock";
|
||||
pBtn.SetBounds(40, 248, 300, 42);
|
||||
Controls.Add(pBtn);
|
||||
pBtn.Click2 += Check;
|
||||
TextBox box = field.Box;
|
||||
KeyEventHandler value = (object s, KeyEventArgs e) =>
|
||||
{
|
||||
if (e.KeyCode == Keys.Return)
|
||||
{
|
||||
Check();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
};
|
||||
box.KeyDown += value;
|
||||
MouseDown += (object s, MouseEventArgs e) =>
|
||||
{
|
||||
if (e.Y < 40 && e.Button == MouseButtons.Left)
|
||||
{
|
||||
ReleaseCapture();
|
||||
SendMessage(Handle, 161, 2, 0);
|
||||
}
|
||||
};
|
||||
MouseMove += (object s, MouseEventArgs e) =>
|
||||
{
|
||||
int num = (clsR.Contains(e.Location) ? 1 : 0);
|
||||
if (num != hover)
|
||||
{
|
||||
hover = num;
|
||||
Invalidate(new Rectangle(324, 8, 56, 40));
|
||||
}
|
||||
Cursor = ((num > 0) ? Cursors.Hand : Cursors.Default);
|
||||
};
|
||||
MouseDown += (object s, MouseEventArgs e) =>
|
||||
{
|
||||
if (clsR.Contains(e.Location))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
};
|
||||
fade.Interval = 15;
|
||||
fade.Tick += (object param0, EventArgs param1) =>
|
||||
{
|
||||
fadeT += 3f / 52f;
|
||||
float num = Math.Min(1f, fadeT);
|
||||
Opacity = 1.0 - Math.Pow(1f - num, 3.0);
|
||||
if (num >= 1f)
|
||||
{
|
||||
Opacity = 1.0;
|
||||
fade.Stop();
|
||||
}
|
||||
};
|
||||
Shown += (object param0, EventArgs param1) =>
|
||||
{
|
||||
fade.Start();
|
||||
field.Box.Focus();
|
||||
};
|
||||
}
|
||||
|
||||
private void Check()
|
||||
{
|
||||
if (field.Box.Text == Pass)
|
||||
{
|
||||
Ok = true;
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
err.Text = "Incorrect password";
|
||||
field.Box.Clear();
|
||||
field.Box.Focus();
|
||||
Shake();
|
||||
}
|
||||
|
||||
private void Shake()
|
||||
{
|
||||
int baseX = Left;
|
||||
Timer t = new Timer();
|
||||
t.Interval = 18;
|
||||
int n = 0;
|
||||
int[] off = new int[7] { 6, -6, 5, -5, 3, -3, 0 };
|
||||
t.Tick += (object param0, EventArgs param1) =>
|
||||
{
|
||||
if (n >= off.Length)
|
||||
{
|
||||
t.Stop();
|
||||
Left = baseX;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = baseX + off[n];
|
||||
n++;
|
||||
}
|
||||
};
|
||||
t.Start();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics graphics = e.Graphics;
|
||||
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
||||
using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, 380, 320), Color.FromArgb(255, 18, 20, 28), Color.FromArgb(255, 9, 10, 14), 105f))
|
||||
{
|
||||
graphics.FillRectangle(brush, 0, 0, 380, 320);
|
||||
}
|
||||
using (GraphicsPath graphicsPath = new GraphicsPath())
|
||||
{
|
||||
graphicsPath.AddEllipse(-30f, -120f, 440f, 440f);
|
||||
using PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath);
|
||||
pathGradientBrush.CenterColor = Color.FromArgb(70, G.Acc);
|
||||
pathGradientBrush.SurroundColors = new Color[1] { Color.FromArgb(0, G.Acc) };
|
||||
pathGradientBrush.CenterPoint = new PointF(190f, -20f);
|
||||
graphics.FillPath(pathGradientBrush, graphicsPath);
|
||||
}
|
||||
G.Fill(graphics, new RectangleF(164f, 34f, 52f, 52f), 26f, G.Acc);
|
||||
G.Circle(graphics, G.Logo, new RectangleF(166f, 36f, 48f, 48f));
|
||||
G.T(graphics, "Floppa Clicker", G.H, G.Txt, 190f, 100f, StringAlignment.Center);
|
||||
G.T(graphics, "Enter the password to continue", G.N, G.Dim, 190f, 126f, StringAlignment.Center);
|
||||
G.T(graphics, "Password", G.S, G.Dim, 40f, 156f, StringAlignment.Near);
|
||||
if (hover == 1)
|
||||
{
|
||||
G.Fill(graphics, clsR, 8f, Color.FromArgb(200, 70, 70));
|
||||
}
|
||||
using Pen pen = new Pen(G.Txt, 1.6f);
|
||||
graphics.DrawLine(pen, clsR.X + 6, clsR.Y + 6, clsR.Right - 6, clsR.Bottom - 6);
|
||||
graphics.DrawLine(pen, clsR.Right - 6, clsR.Y + 6, clsR.X + 6, clsR.Bottom - 6);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user