viewing paste Unknown #15042 | C#

Posted on the
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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
 
namespace League_of_Legends_Preping_checker
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            comboBox1.Text = "EUROPE WEST";
            if (Properties.Settings.Default.save)
            {
                comboBox1.Text = Properties.Settings.Default.server;
                host = Properties.Settings.Default.IP;
            }
            backgroundWorker1.RunWorkerAsync();
           
           
        }
 
        public const int WM_NCLBUTTONDOWN = 0xA1;
        public const int HT_CAPTION = 0x2;
 
        [DllImportAttribute("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd,
                         int Msg, int wParam, int lParam);
        [DllImportAttribute("user32.dll")]
        public static extern bool ReleaseCapture();
 
        string host = "95.172.65.1";
 
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                BackgroundWorker backgroundWorker = (BackgroundWorker)sender;
                long totalTime = 0;
                int timeout = 120;
                Ping pingSender = new Ping();
                PingReply reply = pingSender.Send(host, timeout);
                if (reply.Status == IPStatus.Success)
                {
                    totalTime = reply.RoundtripTime;
                }
                backgroundWorker.ReportProgress((int)totalTime);
                Thread.Sleep(1000);
            }
        }
 
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e.ProgressPercentage != 0)
            {
                UpdatePing(e.ProgressPercentage);
            }
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            backgroundWorker1.RunWorkerAsync();
        }
 
        Color GetColor(Int32 rangeStart /*Complete Red*/, Int32 rangeEnd /*Complete Green*/, Int32 actualValue)
        {
            if (actualValue >= rangeEnd) return Color.Red;
 
            Int32 max = rangeEnd - rangeStart; // make the scale start from 0
            Int32 value = actualValue - rangeStart; // adjust the value accordingly
 
            Int32 red = (255 * value) / max; // calculate green (the closer the value is to max, the greener it gets)
            Int32 green = 255 - red; // set red as inverse of green
 
            return Color.FromArgb((Byte)red, (Byte)green, (Byte)0);
        }
 
        private void UpdatePing(int ping)
        {
            try
            {
                Font font = new Font("Helvetica", 7.0f);
                Brush b = new SolidBrush(GetColor(10, 200, ping));
                Point p = new Point(0, 3);
 
                using (var image = new Bitmap(16, 16))
                using (var g = Graphics.FromImage(image))
                {
                    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
                    g.DrawString(ping.ToString(), font, b, p);
                    this.Icon = Icon.FromHandle(image.GetHicon());
                    notifyIcon1.Icon = Icon.FromHandle(image.GetHicon());
                    label1.Text = ping.ToString() + "ms";
                    label1.ForeColor = GetColor(10, 200, ping);
                }
            }
            catch
            { }
 
        }
 
 
        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            this.Show();
        }
 
        private void button1_Click_1(object sender, EventArgs e)
        {
            this.Hide();
            notifyIcon1.ShowBalloonTip(3);
        }
 
        private void button1_MouseHover(object sender, EventArgs e)
        {
            button1.BackgroundImage = Properties.Resources.btnH2;
        }
 
        private void button1_MouseLeave(object sender, EventArgs e)
        {
            button1.BackgroundImage = Properties.Resources.btn3;
        }
 
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
        }
 
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.save)
            {
                Properties.Settings.Default.IP = host;
                Properties.Settings.Default.server = comboBox1.Text;
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default.save = false;
                Properties.Settings.Default.Save();
            }
            this.Close();
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            this.Hide();
            notifyIcon1.ShowBalloonTip(3);
        }
 
        private void comboBox1_Click(object sender, EventArgs e)
        {
 
            if (comboBox1.Text == "NORTH AMERICA")
            {
                comboBox1.Text = "EUROPE WEST";
                host = "95.172.65.1";
            }
            else if (comboBox1.Text == "EUROPE WEST")
            {
                comboBox1.Text = "EUROPE NORDIC-EAST";
                host = "95.172.65.1";
            }
            else if (comboBox1.Text == "EUROPE NORDIC-EAST")
            {
                comboBox1.Text = "NORTH AMERICA";
                host = "64.7.194.1";
            }
            else if (comboBox1.Text == "OCEANIA")
            {
                host = "UNAVAILABLE";
            }
            else if (comboBox1.Text == "PBE Game Servers")
            {
                host = "UNAVAILABLE";
            }
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
           
        }
 
        private void button4_Click(object sender, EventArgs e)
        {
            Form2 settingsForm = new Form2(Cursor.Position.X, Cursor.Position.Y);
            settingsForm.ShowDialog(this);
        }
 
        private void label3_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }
 
        private void comboBox1_MouseHover(object sender, EventArgs e)
        {
            comboBox1.BackgroundImage = Properties.Resources.btnH2;
        }
 
        private void comboBox1_MouseLeave(object sender, EventArgs e)
        {
            comboBox1.BackgroundImage = Properties.Resources.btn3;
        }
    }
}
 
 
 
 
 
 
 
 
 
 
 
 
---------------------SETTINGS VINDU----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
 
namespace League_of_Legends_Preping_checker
{
    public partial class Form2 : Form
    {
        private int desiredStartLocationX;
        private int desiredStartLocationY;
 
        public Form2(int x, int y)
        {
            InitializeComponent();
            this.desiredStartLocationX = x;
            this.desiredStartLocationY = y;
 
            Load += new EventHandler(Form2_Load);
        }
 
        public const int WM_NCLBUTTONDOWN = 0xA1;
        public const int HT_CAPTION = 0x2;
 
        [DllImportAttribute("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd,
                         int Msg, int wParam, int lParam);
        [DllImportAttribute("user32.dll")]
        public static extern bool ReleaseCapture();
 
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }
 
        private void Form2_Load(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.save)
            {
                checkBox1.Checked = true;
            }
            else
            {
                checkBox1.Checked = false;
            }
            this.SetDesktopLocation(desiredStartLocationX, desiredStartLocationY);
        }
 
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            Properties.Settings.Default.save = checkBox1.Checked;
        }
 
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=sondre%2enjaastad%40gmail%2ecom&lc=NO&item_name=Njastad%2ecom&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted");
        }
 
        private void label1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }
    }
}
Viewed 904 times, submitted by Dynasty.