.NET 2.x Создание клиента(Платформы) [Обсуждение, критика] #3 Relase AlfaTest(#1) - C#

Узнай цену своей работы

Формулировка задачи:

Здравствуйте... Сейчас решил много каких проблем и много что пофиксил... Сделал ClientProtect Launcher... По новому и из за этого от части я больше не буду выкладывать цельный проект а всего лишь Лаунчер который сам всё скачает и поставит нормально и файлы проекта...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Library1;
using Resourse;
 
namespace Gunrei
{
    public partial class Form1 : Form
    {
        private bool drag = false;
        private Point start_point = new Point(0, 0);
        public Form1()
        {
            InitializeComponent();
            Form1_button_login.Text = Client.GetLangueElement("Form1_button_login");
            Form1_button_reg.Text = Client.GetLangueElement("Form1_button_reg");
            Form1_lable_login.Text = Client.GetLangueElement("Form1_lable_login");
            Form1_lable_pass.Text = Client.GetLangueElement("Form1_lable_pass");
        }
 
        private void label1_MouseDown(object sender, MouseEventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Red;
        }
 
        private void label1_MouseEnter(object sender, EventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Orange;
        }
 
        private void label1_MouseUp(object sender, MouseEventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Orange;
        }
 
        private void label1_MouseLeave(object sender, EventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.White;
        }
 
        private void label1_Click(object sender, EventArgs e)
        {
            Close();
        }
 
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            this.drag = true;
            this.start_point = new Point(e.X, e.Y);
        }
 
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (this.drag)
            {
                Point p1 = new Point(e.X, e.Y);
                Point p2 = this.PointToScreen(p1);
                Point p3 = new Point(p2.X - this.start_point.X, p2.Y - this.start_point.Y);
                this.Location = p3;
            }
        }
 
        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            this.drag = false;
        }

        private void piccherbox2_MouseDown(object sender, MouseEventArgs e)
        {
            panel3.BackgroundImage = global::Gunrei.Properties.Resources.Buttom_Down;
            Form1_button_login.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
        }
 
        private void piccherbox2_MouseEnter(object sender, EventArgs e)
        {
            panel3.BackgroundImage = global::Gunrei.Properties.Resources.Buttom_hover;
        }
 
        private void piccherbox2_MouseLeave(object sender, EventArgs e)
        {
            panel3.BackgroundImage = global::Gunrei.Properties.Resources.Buttom;
        }
 
        private void piccherbox2_MouseUp(object sender, MouseEventArgs e)
        {
            panel3.BackgroundImage = global::Gunrei.Properties.Resources.Buttom_hover;
            Form1_button_login.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
        }
 
        private void panel2_MouseDown(object sender, MouseEventArgs e)
        {
            panel2.BackgroundImage = global::Gunrei.Properties.Resources.Buttom_Down;
            Form1_button_reg.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
        }
 
        private void panel2_MouseEnter(object sender, EventArgs e)
        {
            panel2.BackgroundImage = global::Gunrei.Properties.Resources.Buttom_hover;
        }
 
        private void panel2_MouseLeave(object sender, EventArgs e)
        {
            panel2.BackgroundImage = global::Gunrei.Properties.Resources.Buttom;
        }
 
        private void panel2_MouseUp(object sender, MouseEventArgs e)
        {
            panel2.BackgroundImage = global::Gunrei.Properties.Resources.Buttom_hover;
            Form1_button_reg.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
        }
 
        private void Form1_button_login_Click_1(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                if (textBox2.Text != "")
                {

                    Sousnd.Interface("ButtonClick");
                    string[] otvet = Server.Auth(textBox1.Text, textBox2.Text).Split(new Char[] { ';' }); 
                    if (otvet[0] == "error-auth")
                    {
                        Sousnd.Interface("Warning");
                        MessageBox.Show(Client.GetLangueElement(otvet[0]));
                    }
 
                    if (otvet[0] == "ok-auth")
                    {
                        ClientForm.user[0] = otvet[1];
                        ClientForm.user[2] = otvet[2];
                        ClientForm.user[1] = textBox1.Text;
                        Sousnd.Interface("ok");
                        this.Hide();
                        ClientForm f3 = new ClientForm();
                        f3.Show();
                        f3.Activate();

                    }
                }
            } 
        }
 
        private void panel2_Click(object sender, EventArgs e)
        {
            Sousnd.Interface("ButtonClick");
            Rega f2 = new Rega();
            f2.ShowDialog();
        }
 
        private void textBox2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                if (textBox1.Text != "")
                {
                    if (textBox2.Text != "")
                    {

                        Sousnd.Interface("ButtonClick");
                        string[] otvet = Server.Auth(textBox1.Text, textBox2.Text).Split(new Char[] { ';' });
                        if (otvet[0] == "error-auth")
                        {
                            Sousnd.Interface("Warning");
                            MessageBox.Show(Client.GetLangueElement(otvet[0]));
                        }
 
                        if (otvet[0] == "ok-auth")
                        {
                            ClientForm.user[0] = otvet[1];
                            ClientForm.user[2] = otvet[2];
                            ClientForm.user[1] = textBox1.Text;
                            Sousnd.Interface("ok");
                            this.Hide();
                            ClientForm f3 = new ClientForm();
                            f3.Show();
                            f3.Activate();

                        }
                    }
                } 
 
            }
        }
    }
}using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Library1;
 
namespace Gunrei
{
    public partial class Rega : Form
    {
        public Rega()
        {
            InitializeComponent();
            this.Rega_lable_reg.Text = Client.GetLangueElement("Rega_lable_reg");
            this.Text = Client.GetLangueElement("Rega_lable_reg");
            Reg_button_reg.Text = Client.GetLangueElement("Reg_button_reg");
            Reg_lable_email.Text = Client.GetLangueElement("Reg_lable_email");
            Reg_lable_login.Text = Client.GetLangueElement("Reg_lable_login");
            Reg_lable_pass.Text = Client.GetLangueElement("Reg_lable_pass");
            Reg_lable_pass2.Text = Client.GetLangueElement("Reg_lable_pass2");
 
        }
 
        private void label1_MouseDown(object sender, MouseEventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Red;
        }
 
        private void label1_MouseEnter(object sender, EventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Orange;
        }
 
        private void label1_MouseLeave(object sender, EventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Black;
        }
 
        private void label1_MouseUp(object sender, MouseEventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Orange;
        }
 
        private void label1_Click(object sender, EventArgs e)
        {
            Close();
        }
 
        private void Reg_button_reg_Click(object sender, EventArgs e)
        {

        }
 
        private void label2_MouseDown(object sender, MouseEventArgs e)
        {
            this.pictureBox1.BackgroundImage = global::Gunrei.Properties.Resources.Buttom_Down;
            this.Reg_button_reg.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
        }
 
        private void label2_MouseEnter(object sender, EventArgs e)
        {
            this.pictureBox1.BackgroundImage = global::Gunrei.Properties.Resources.Buttom_hover;
            this.Reg_button_reg.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
        }
 
        private void label2_MouseLeave(object sender, EventArgs e)
        {
            this.pictureBox1.BackgroundImage = global::Gunrei.Properties.Resources.Buttom;
            this.Reg_button_reg.ForeColor = System.Drawing.SystemColors.ControlText;
        }
 
        private void label2_MouseUp(object sender, MouseEventArgs e)
        {
            this.pictureBox1.BackgroundImage = global::Gunrei.Properties.Resources.Buttom_hover;
            this.Reg_button_reg.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
        }
 
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (t_email.Text != "")
            {
                if (t_login.Text != "")
                {
                    if (t_pass.Text != "")
                    {
                        if (t_pass2.Text != "")
                        {
                            Sousnd.Interface("ButtonClick");
                            string otvet = Server.Reg(t_login.Text, t_pass.Text, t_pass2.Text, t_email.Text);
                            if (otvet == "ok")
                            {
                                Sousnd.Interface("ok");
                                t_email.Clear();
                                t_login.Clear();
                                t_pass.Clear();
                                t_pass2.Clear();
                                Close();
                                MessageBox.Show(Client.GetLangueElement(otvet));
                            }
                            else
                            {
                                Sousnd.Interface("Warning");
                                MessageBox.Show(Client.GetLangueElement(otvet));
                                
                            }
                        }
                    }
                }
            }
        }
    }
}using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Media;
using System.Text.RegularExpressions;
 
namespace Library1
{
    public class Client
    {
        public static string GetLangue()
        {
            string[] otvet;
            using (StreamReader sr = new StreamReader("./Data/cfg.dat"))
            {
                while (true)
                {
 
                    otvet = sr.ReadLine().Split(new Char[] { '=' });
                    if (otvet[0] == "langue") break;
                }
            }
            return otvet[1];
        }
        public static string GetLangueElement(string name)
        {
            string[] otvet;
            using (StreamReader sr = new StreamReader("./Langue/" + GetLangue() + ".dat"))
            {
 
                while (true)
                {
 
                    otvet = sr.ReadLine().Split(new Char[] { '=' });
                    if (otvet[0] == name) break;
                }
            }
            return otvet[1];
        }
    }
    public class Server
    {
        public static string server = "http://msoma.ts6.ru/";
        public static string Reg(string login, string password, string password2, string email)
        {
            string otvet;
            if (password != password2) { otvet = "!pass"; return otvet; }
            string pattern = "[.\\-_a-z0-9]+@([a-z0-9][\\-a-z0-9]+\\.)+[a-z]{2,6}";
            Match isMatch = Regex.Match(email, pattern, RegexOptions.IgnoreCase);
            if (isMatch.Success) { } else { otvet = "Noemail"; return otvet; }
            pattern = "[.\\-_a-z0-9]{4,15}";
            isMatch = Regex.Match(login, pattern, RegexOptions.IgnoreCase);
            if (isMatch.Success) { } else { otvet = "Login_or_pass"; return otvet; }
            isMatch = Regex.Match(password, pattern, RegexOptions.IgnoreCase);
            if (isMatch.Success) { } else { otvet = "Login_or_pass"; return otvet; }
            otvet = (new System.Net.WebClient()).DownloadString(server + "reg/" + login + "/" + password + "/" + email);
            return otvet;
 
        }
        public static string Auth(string login, string password)
        {
            string otvet;
            if (password == null || login == null) { otvet = "NoAllText"; return otvet; }
            string pattern = "[.\\-_a-z0-9]{4,15}";
            Match isMatch = Regex.Match(login, pattern, RegexOptions.IgnoreCase);
            if (isMatch.Success) { } else { otvet = "Login_or_pass"; return otvet; }
            isMatch = Regex.Match(password, pattern, RegexOptions.IgnoreCase);
            if (isMatch.Success) { } else { otvet = "Login_or_pass"; return otvet; }
            otvet = (new System.Net.WebClient()).DownloadString(server + "auth/" + login + "/" + password);
            return otvet;
 
        }
        public static string onlines(string user)
        {
           string otvet = (new System.Net.WebClient()).DownloadString(server + "online/" + user);
           return otvet;
        }
    }
    public class Sousnd
    {
        public static void Interface(string sousnd)
        {
            SoundPlayer play = new SoundPlayer("./Sousnd/Interface/" + sousnd + ".wav");
            play.Play();
        }
 
    }
}using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Library1;
 
namespace Resourse
{
    public partial class ClientForm : Form
    {
        public static string[] user = new string[5];
        public static string[] access = new string[10];
        public ClientForm()
        {
            access[0] = "Basic Member";
            access[1] = "Member of Honor";
            access[2] = "Premium Member";
            access[3] = "Moderator";
            access[4] = "Super Moderator";
            access[5] = "Admin";
            access[6] = "Super Admin";
            access[7] = "Developer";
            InitializeComponent();
            label5.Text = "UID: "+user[0];
            Client_lable_login.Text = Client.GetLangueElement("Client_lable_login") + " " + user[1];
            Client_lable_group.Text = Client.GetLangueElement("Client_lable_group") + " " + access[Convert.ToInt32(user[2])];

        }
 
        private void label1_MouseDown(object sender, MouseEventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Red;
        }
 
        private void label1_MouseEnter(object sender, EventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Orange;
        }
 
        private void label1_MouseLeave(object sender, EventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Cornsilk;
        }
 
        private void label1_MouseUp(object sender, MouseEventArgs e)
        {
            this.label1.ForeColor = System.Drawing.Color.Orange;
        }
 
        private void label1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
 
        private void ClientForm_Load(object sender, EventArgs e)
        {
 
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            string[] otvet = Server.onlines(user[0]).Split(new Char[] { ';' });
            int i = 0;
            while (true)
            {
                try
                {
                    if (otvet[i] == null) break;
                }
                catch { break; }
                listView1.Items.Add(otvet[i]);
                i++;
            }
            Client_lable_online.Text = Client.GetLangueElement("Client_lable_online") + ": " + i;
            timer1.Stop();
        }
 
        private void timer2_Tick(object sender, EventArgs e)
        {
            
            timer2.Interval = 30000;
            string[] otvet = Server.onlines(user[0]).Split(new Char[] { ';' });
            int i = 0;
            listView1.Clear();
            while (true)
            {
                try
                {
                    if (otvet[i] == null) break;
                }
                catch { break; }
                listView1.Items.Add(otvet[i]);
                i++;
            }
            Client_lable_online.Text = Client.GetLangueElement("Client_lable_online") + ": " + i;
        }
    }
}
Прошу - предлагаем как оптимизировать код, какие косяки есть и просто говорим о найденых багах.. )

Решение задачи: «.NET 2.x Создание клиента(Платформы) [Обсуждение, критика] #3 Relase AlfaTest(#1)»

textual
Листинг программы
if(a!="" && b!=""){
}

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

8   голосов , оценка 4.125 из 5
Похожие ответы