Exemplo n.º 1
0
        public User(bool showAll, int idUser, string userName, string password, string server, int missionSelect, string UA, string proxy, bool autoConvert, string startDateManufacture, string endDateManufacture, bool isManufacture)
        {
            InitializeComponent();
            lang = Languages.Instance;

            #region Translate
            label5.Text           = lang.Get("Misc", "UA");
            label7.Text           = lang.Get("Piracy", "AutoConvertToCrew");
            this.autoConvert.Text = lang.Get("Piracy", "AutoConvertToCrew");
            label3.Text           = lang.Get("Misc", "Server");
            label4.Text           = lang.Get("Piracy", "Mission");
            label2.Text           = lang.Get("Misc", "Password");
            label9.Text           = lang.Get("Piracy", "EndManufactur");
            label1.Text           = lang.Get("Misc", "Username");
            label8.Text           = lang.Get("Piracy", "StartManufactur");
            label6.Text           = lang.Get("Misc", "Proxy");
            Text                   = lang.Get("Piracy", "EditUser");
            cancel.Text            = lang.Get("Misc", "Cancel");
            save.Text              = lang.Get("Misc", "Save");
            duplicate.Text         = lang.Get("Misc", "Duplicate");
            delete.Text            = lang.Get("Misc", "DeleteUser");
            manufactureOption.Text = lang.Get("Piracy", "Manufacture");
            raiderOption.Text      = lang.Get("Piracy", "Raider");
            #endregion

            this.idUser        = idUser;
            this.userName.Text = userName;
            this.password.Text = password;
            this.missionSelect.SelectedIndex = missionSelect;
            this.UA.Text                           = UA;
            this.proxy.Text                        = proxy;
            this.autoConvert.Checked               = autoConvert;
            this.startDateManufacture.Value        = DateTime.Parse(startDateManufacture);
            this.startDateManufacture.Format       = DateTimePickerFormat.Time;
            this.startDateManufacture.ShowUpDown   = true;
            this.startDateManufacture.CustomFormat = Form1.DATE_TIME_FORMAT;
            this.endDateManufacture.Value          = DateTime.Parse(endDateManufacture);
            this.endDateManufacture.Format         = DateTimePickerFormat.Time;
            this.endDateManufacture.CustomFormat   = Form1.DATE_TIME_FORMAT;
            this.endDateManufacture.ShowUpDown     = true;
            manufactureOption.Checked              = isManufacture;
            raiderOption.Checked                   = !isManufacture;

            client = new WebClient();

            if (!showAll)
            {
                duplicate.Enabled = false;
                delete.Enabled    = false;
            }

            tor.Checked = proxy.Equals(Form1.TOR);

            world = "";
            if (server.Split('-').Length > 0)
            {
                world = server.Split('-')[0];
            }
            client.Encoding = Encoding.UTF8;

            try
            {
                string          countriesHTML = client.DownloadString("https://us.ikariam.gameforge.com/");
                MatchCollection countries     = Regex.Matches(countriesHTML, "<li.*><a href=\"//(.+?)\\.ikariam\\.gameforge\\.com/\\?kid=.*\" target=\"_top\" rel=\"nofollow\" class=\".*\">(.+?)</a></li>");
                string          build         = string.Empty;
                foreach (Match match in countries)
                {
                    GroupCollection groups = match.Groups;
                    if (groups.Count >= 2)
                    {
                        this.server.Items.Add(string.Format("{1} - {0}", groups[1].Value, groups[2].Value));
                        if (server.Split('-').Length > 0 && !server.Equals(string.Empty) && groups[1].Value.Equals(server.Split('-')[1]))
                        {
                            this.server.SelectedIndex = this.server.Items.Count - 1;
                        }
                    }
                }
            }
            catch (WebException e)
            {
                MessageBox.Show(e.ToString());
            }
        }