/// <summary> /// Constructor /// </summary> /// <param name="Params">The current param string</param> public ClientParamsForm(string Params) { InitializeComponent(); ParamString = Params; // Set resolution to defaults HeightText.Text = Screen.PrimaryScreen.Bounds.Height.ToString(); WidthText.Text = Screen.PrimaryScreen.Bounds.Width.ToString(); // Parse params screen LoadProfiles(); ParseParamString(); // Set tooltips Tipsy.SetToolTip(WindowedMode, "If checked, Battlfield 2 will be started in windowed mode"); Tipsy.SetToolTip(CustomRes, "If checked, Battlefield 2 will be forced to use the custom resolution below"); Tipsy.SetToolTip(AutoLogin, "If checked, the account name below will automatically login"); Tipsy.SetToolTip(AccountPass, "Password is Case-Sensitive!"); Tipsy.SetToolTip(JoinServerIp, "To auto join a server, make sure to enable Auto Login!"); Tipsy.SetToolTip(PlayNow, "If checked, BF2 will automatically uses the 'Play Now' functionality"); Tipsy.SetToolTip(Restart, "Used by BF2 to restart the game without showing video for example when mod switching." + Environment.NewLine + "Can also be used to start BF 2 without showing videos"); Tipsy.SetToolTip(DisableSwiff, "Disables the swiff player. Basically this disables the flash that is used at the main menu area."); Tipsy.SetToolTip(NoSound, "If checked, Battlefield 2 will start with sound disabled."); Tipsy.SetToolTip(LowPriority, "If checked, Battlefield 2 will start with a lower process priority(less CPU intensive, lower performance)"); }
public XpackMedalsConfigForm() { InitializeComponent(); int controlsAdded = 0; // Add each valid mod found in the servers Mods directory for (int i = 0; i < BF2Server.Mods.Count; i++) { // Get our current working mod BF2Mod Mod = BF2Server.Mods[i]; // Bf2 is predefined if (Mod.Name.Equals("bf2", StringComparison.InvariantCultureIgnoreCase)) { checkBox1.Tag = Mod.Name; checkBox1.Checked = StatsPython.Config.XpackMedalMods.Contains(Mod.Name.ToLowerInvariant()); continue; } // Xpack is predefined if (Mod.Name.Equals("xpack", StringComparison.InvariantCultureIgnoreCase)) { checkBox2.Tag = Mod.Name; checkBox2.Checked = StatsPython.Config.XpackMedalMods.Contains(Mod.Name.ToLowerInvariant()); continue; } // Stop if over 10 added mods. I chose to use continue here instead of break // So that Xpack can get ticked if it may be at the bottom of the list if (controlsAdded >= 10) { continue; } try { // Fetch our checkbox int index = controlsAdded + 3; CheckBox ChkBox = panel2.Controls["checkBox" + index] as CheckBox; // Configure the Checkbox string title = (Mod.Title.Length > 32) ? Mod.Title.CutTolength(29) + "..." : Mod.Title; ChkBox.Text = String.Format("{0} [{1}]", title, Mod.Name); ChkBox.Checked = StatsPython.Config.XpackMedalMods.Contains(Mod.Name.ToLowerInvariant()); ChkBox.Tag = Mod.Name; ChkBox.Show(); // Add tooltip to checkbox with the full title Tipsy.SetToolTip(ChkBox, Mod.Title); } catch { continue; } // Increment controlsAdded++; } }
/// <summary> /// This method sets the address, image, and image balloon text for the services /// listed in this form by service index. /// </summary> /// <param name="i">The service index</param> /// <param name="address">The text to display in the IP address box</param> /// <param name="Img">The image to display in the image box for this service</param> /// <param name="ImgText">The mouse over balloon text to display</param> private void SetStatus(int i, string address, Bitmap Img, string ImgText = "") { // Prevent exception if (!IsHandleCreated) { return; } // Invoke this in the thread that created the handle Invoke((Action) delegate { switch (i) { case 0: Address1.Text = address; Status1.Image = Img; Tipsy.SetToolTip(Status1, ImgText); break; case 1: Address2.Text = address; Status2.Image = Img; Tipsy.SetToolTip(Status2, ImgText); break; case 2: Address3.Text = address; Status3.Image = Img; Tipsy.SetToolTip(Status3, ImgText); break; case 3: Address4.Text = address; Status4.Image = Img; Tipsy.SetToolTip(Status4, ImgText); break; case 4: Address5.Text = address; Status5.Image = Img; Tipsy.SetToolTip(Status5, ImgText); break; } }); // Let Gui Update Thread.Sleep(100); }
/// <summary> /// Fills in the details of a Hosts(Ics) tab progress step on the GUI /// </summary> /// <param name="i">The picturebox id</param> /// <param name="ImgText">The tooltip message for this step image</param> /// <param name="Img">The image to set</param> private void SetHostStatus(int i, string ImgText, Bitmap Img) { // Prevent exception if (!IsHandleCreated) { return; } // Fetch the picture box for this step Control[] cons = this.Controls.Find("pictureBox" + i, true); PictureBox pic = cons[0] as PictureBox; // Set the new image pic.Image = Img; // Set the tooltip for the image control if we have one if (!String.IsNullOrWhiteSpace(ImgText)) { Tipsy.SetToolTip(pic, ImgText); } }
/// <summary> /// Loads the players stats from the database, and fills out the forms /// labels with the current information /// </summary> private void LoadPlayer() { StatsDatabase Driver; // Establish DB connection try { Driver = new StatsDatabase(); } catch (DbConnectException Ex) { ExceptionForm.ShowDbConnectError(Ex); HttpServer.Stop(); Load += (s, e) => Close(); // Close form return; } // Fetch Player from database SelectQueryBuilder Builder = new SelectQueryBuilder(Driver); Builder.SelectFromTable("player"); Builder.SelectColumns( "name", "score", "cmdscore", "skillscore", "teamscore", "joined", "country", "rank", "wins", "losses", "permban", "clantag", "isbot"); Builder.AddWhere("id", Comparison.Equals, Pid); List <Dictionary <string, object> > Rows = Driver.ExecuteReader(Builder.BuildCommand()); Player = Rows[0]; // Set window title this.Text = String.Concat(Player["name"].ToString().Trim(), " (", Pid, ")"); // Set country flag try { string Country = String.IsNullOrEmpty(Player["country"].ToString()) ? "XX" : Player["country"].ToString(); CountryPicture.Image = Image.FromStream(Program.GetResource("BF2Statistics.Resources." + Country.ToUpper() + ".png")); } catch { } // Joined Label int Joind = Int32.Parse(Player["joined"].ToString()); DateTime D = DateTime.UtcNow.FromUnixTimestamp(Joind); LabelJoined.Text = String.Concat(D.ToString("yyyy-MM-dd HH:mm"), " GMT"); Tipsy.SetToolTip(LabelJoined, String.Concat(D.ToLocalTime().ToString("yyyy-MM-dd HH:mm"), " Local Time.")); // Fill out the rest of the labels LabelNick.Text = Player["name"].ToString().Trim(); ClanTagBox.Text = Player["clantag"].ToString(); RankSelect.SelectedIndex = Int32.Parse(Player["rank"].ToString()); PermBanSelect.SelectedIndex = Int32.Parse(Player["permban"].ToString()); LabelGlobalScore.Text = Player["score"].ToString(); LabelWinLoss.Text = String.Concat(Player["wins"], " / ", Player["losses"]); LabelTeamScore.Text = Player["teamscore"].ToString(); LabelCombatScore.Text = Player["skillscore"].ToString(); LabelCommandScore.Text = Player["cmdscore"].ToString(); // Get Leaderboard Position Rows = Driver.Query("SELECT COUNT(id) as count FROM player WHERE score > @P0", Int32.Parse(Player["score"].ToString())); int Position = Int32.Parse(Rows[0]["count"].ToString()) + 1; LabelPosition.Text = Position.ToString(); SaveBtn.Enabled = false; // Lock unlocks button if player is Bot if (Int32.Parse(Player["isbot"].ToString()) > 0) { ResetUnlocksBtn.Enabled = false; } // Close Connection Driver.Dispose(); }