/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { try { if (disposing) { // Release the added managed resources btnBrowse.Dispose(); lblResults.Dispose(); txtResults.Dispose(); lblSearchText.Dispose(); txtSearchText.Dispose(); lblFiles.Dispose(); txtFiles.Dispose(); btnSearch.Dispose(); ckRecursive.Dispose(); lblDir.Dispose(); txtDir.Dispose(); lblCurFile.Dispose(); txtCurFile.Dispose(); } } finally { // Call Dispose on your base class. base.Dispose(disposing); } }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { Label lb = new Label(); lb.AutoSize = true; lb.Margin = new Padding(3, 3, 3, 3); lb.BorderStyle = BorderStyle.FixedSingle; lb.Text = string.Format("{0} - {1}", this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString(), this.dataGridView1.SelectedRows[0].Cells[1].Value.ToString()); lb.Tag = string.Format("{0} {1}", this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString(), this.dataGridView1.SelectedRows[0].Cells[2].Value.ToString()); OnButtonClick lbClick = (object sender1, EventArgs e1) => { lb.Dispose(); }; lb.DoubleClick += new EventHandler(lbClick); this.flowLayoutPanel1.Controls.Add(lb); } catch (Exception ex) { //MessageBox.Show(ex.ToString()); MessageBox.Show(ex.Message); return; } }
public static DialogResult MessageShowAgain(string title, string promptText) { Form form = new Form(); System.Windows.Forms.Label label = new System.Windows.Forms.Label(); CheckBox chk = new CheckBox(); Controls.MyButton buttonOk = new Controls.MyButton(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2)); form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); form.Text = title; label.Text = promptText; chk.Tag = ("SHOWAGAIN_" + title.Replace(" ", "_").Replace('+', '_')); chk.AutoSize = true; chk.Text = Strings.ShowMeAgain; chk.Checked = true; chk.Location = new Point(9, 80); if (Settings.Instance.GetBoolean((string)chk.Tag) == false) // skip it { form.Dispose(); chk.Dispose(); buttonOk.Dispose(); label.Dispose(); return(DialogResult.OK); } chk.CheckStateChanged += new EventHandler(chk_CheckStateChanged); buttonOk.Text = Strings.OK; buttonOk.DialogResult = DialogResult.OK; buttonOk.Location = new Point(form.Right - 100, 80); label.SetBounds(9, 40, 372, 13); label.AutoSize = true; form.ClientSize = new Size(396, 107); form.Controls.AddRange(new Control[] { label, chk, buttonOk }); form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height); form.FormBorderStyle = FormBorderStyle.FixedDialog; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; ThemeManager.ApplyThemeTo(form); DialogResult dialogResult = form.ShowDialog(); form.Dispose(); form = null; return(dialogResult); }
protected override void OnTermination() { if (ChartControl != null) { if (frm != null) { //remove the buttons this.button_LONG.Click -= new System.EventHandler(button_LONG_Click); frm.Controls.Remove(button_LONG); this.button_LONG.Dispose(); this.button_SHORT.Click -= new System.EventHandler(button_SHORT_Click); frm.Controls.Remove(button_SHORT); this.button_SHORT.Dispose(); frm.Controls.Remove(textBox_Size); textBox_Size.Dispose(); frm.Controls.Remove(textBox_Risk); textBox_Risk.Dispose(); frm.Controls.Remove(label2); label2.Dispose(); frm.Controls.Remove(label1); label1.Dispose(); frm.Controls.Remove(label_Size5); label_Size5.Dispose(); frm.Controls.Remove(label_Size4); label_Size3.Dispose(); frm.Controls.Remove(label_Size3); label_Size3.Dispose(); frm.Controls.Remove(label_Size2); label_Size2.Dispose(); frm.Controls.Remove(label_Size1); label_Size1.Dispose(); frm.Controls.Remove(label_Size0); label_Size0.Dispose(); frm.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(frm_FormClosing); frm.Close(); frm.Dispose(); } } }
private void button1_Click(object sender, EventArgs e) { Label tmp; for (int i = 0; i < 200; i++) { tmp = new Label(); tmp.Dispose(); } GC.Collect(); }
public static int GetDropdownWidth(IEnumerable<string> values) { int maxWidth = 0; int temp = 0; Label label1 = new Label(); label1.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); foreach (var val in values) { label1.Text = val; temp = label1.PreferredWidth; if (temp > maxWidth) { maxWidth = temp; } } label1.Dispose(); return maxWidth; }
int DropDownWidth(System.Windows.Forms.ComboBox myCombo) { int maxWidth = 0; int temp = 0; System.Windows.Forms.Label label1 = new System.Windows.Forms.Label(); foreach (var obj in myCombo.Items) { label1.Text = obj.ToString(); temp = label1.PreferredWidth; if (temp > maxWidth) { maxWidth = temp; } } label1.Dispose(); return(maxWidth); }
//=========================================================================== // // Functions // //=========================================================================== // // GetName(string text, string oldName) // Opens the get name form, allowing the user to input a name // private string GetName(string text, string oldName) { //Construct the form string name = null; Form nameForm = new Form() { FormBorderStyle = FormBorderStyle.FixedSingle, MinimizeBox = false, MaximizeBox = false }; nameForm.StartPosition = FormStartPosition.CenterParent; nameForm.Width = 200; nameForm.Height = 110; nameForm.Text = "NSS Keylogger"; nameForm.Icon = Properties.Resources.nsskeylogger; nameForm.BackColor = Color.Black; Label lblName = new Label() { Width = 190, Height = 20, Location = new Point(5, 2), Text = text, ForeColor = Color.White }; TextBox tbName = new TextBox() { Width = 185, Height = 20, Location = new Point(5, 23), Text = oldName }; Button btnOK = new Button() { Width = 92, Height = 25, Location = new Point(5, 48), ImageAlign = ContentAlignment.MiddleCenter, TextAlign = ContentAlignment.MiddleCenter, Text = "OK", BackColor = SystemColors.ButtonFace, UseVisualStyleBackColor = true }; btnOK.Click += (btnOKSender, btnOKe) => { name = tbName.Text; //save the name nameForm.Close(); //close the form }; Button btnCancel = new Button() { Width = 92, Height = 25, Location = new Point(98, 48), ImageAlign = ContentAlignment.MiddleCenter, TextAlign = ContentAlignment.MiddleCenter, Text = "Cancel", BackColor = SystemColors.ButtonFace, UseVisualStyleBackColor = true }; btnCancel.Click += (btnCancelSender, btnCancele) => { nameForm.Close(); //close the form without saving }; //Build the form and show it nameForm.AcceptButton = btnOK; nameForm.CancelButton = btnCancel; nameForm.Controls.Add(lblName); nameForm.Controls.Add(tbName); nameForm.Controls.Add(btnOK); nameForm.Controls.Add(btnCancel); nameForm.ShowDialog(); //Dispose the form's elements btnCancel.Dispose(); btnOK.Dispose(); tbName.Dispose(); lblName.Dispose(); nameForm.Dispose(); return name; }
public void Dispose() { wLabel?.Dispose(); }
public static Boolean InputQuery(String caption, String prompt, ref String value) { Form form; form = new Form { AutoScaleMode = AutoScaleMode.Font, Font = SystemFonts.IconTitleFont }; SizeF dialogUnits; dialogUnits = form.AutoScaleDimensions; form.FormBorderStyle = FormBorderStyle.FixedDialog; form.MinimizeBox = false; form.MaximizeBox = false; form.Text = caption; form.ClientSize = new Size( MulDiv(180, (int)dialogUnits.Width, 4), MulDiv(63, (int)dialogUnits.Height, 8)); form.StartPosition = FormStartPosition.CenterScreen; System.Windows.Forms.Label lblPrompt; lblPrompt = new System.Windows.Forms.Label { Parent = form, AutoSize = true, Left = MulDiv(8, (int)dialogUnits.Width, 4), Top = MulDiv(8, (int)dialogUnits.Height, 8), Text = prompt }; System.Windows.Forms.TextBox edInput; edInput = new TextBox { Parent = form, Left = lblPrompt.Left, Top = MulDiv(19, (int)dialogUnits.Height, 8), Width = MulDiv(164, (int)dialogUnits.Width, 4), Text = value }; edInput.SelectAll(); lblPrompt.Dispose(); int buttonTop = MulDiv(41, (int)dialogUnits.Height, 8); //Command buttons should be 50x14 dlus //Size buttonSize = ScaleSize(new Size(50, 14), dialogUnits.Width / 4, dialogUnits.Height / 8); System.Windows.Forms.Button bbOk = new System.Windows.Forms.Button { Parent = form, Text = "OK", DialogResult = DialogResult.OK }; form.AcceptButton = bbOk; bbOk.Location = new Point(MulDiv(38, (int)dialogUnits.Width, 4), buttonTop); //bbOk.Size = buttonSize; System.Windows.Forms.Button bbCancel = new System.Windows.Forms.Button { Parent = form, Text = "Cancel", DialogResult = DialogResult.Cancel }; form.CancelButton = bbCancel; bbCancel.Location = new Point(MulDiv(92, (int)dialogUnits.Width, 4), buttonTop); //bbCancel.Size = buttonSize; if (form.ShowDialog() == DialogResult.OK) { value = edInput.Text; edInput.Dispose(); return(true); } edInput.Dispose(); return(false); }
private void magnify() { try { if ((this.zoom.Width >= 5) && (this.zoom.Height >= 5)) { this.picBox.Dock = DockStyle.None; Graphics graphics1 = this.picBox.CreateGraphics(); int num1 = 0x10; int num2 = this.picBox.Width; int num3 = this.picBox.Height; int num4 = this.pnlImg.Width / this.zoom.Width; int num5 = this.pnlImg.Height / this.zoom.Height; if (num4 > num1) { num4 = num1; } if (num5 > num1) { num5 = num1; } this.picBox.Width = num2 * num4; this.picBox.Height = num3 * num5; Label label1 = new Label(); label1.Location = new Point(this.zoom.Left, this.zoom.Top); label1.Size = new Size(this.zoom.Width, this.zoom.Height); label1.Name = "label"; label1.Text = "LABEL!ADDED!"; label1.Visible = true; this.pnlImg.Controls.Add(label1); this.pnlImg.ScrollControlIntoView(label1); graphics1.DrawImageUnscaled(this.bmp, 0, 0); this.picBox.Invalidate(); graphics1.Dispose(); label1.Dispose(); } } catch (Exception exception1) { MessageBox.Show("Error: " + exception1.Message, "Error!"); } }
public static DialogResult MessageShowAgain(string title, string promptText) { Form form = new Form(); System.Windows.Forms.Label label = new System.Windows.Forms.Label(); CheckBox chk = new CheckBox(); Controls.MyButton buttonOk = new Controls.MyButton(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2)); form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); string link = ""; string linktext = ""; Regex linkregex = new Regex(@"(\[link;([^\]]+);([^\]]+)\])", RegexOptions.IgnoreCase); Match match = linkregex.Match(promptText); if (match.Success) { link = match.Groups[2].Value; linktext = match.Groups[3].Value; promptText = promptText.Replace(match.Groups[1].Value, ""); } form.Text = title; label.Text = promptText; chk.Tag = ("SHOWAGAIN_" + title.Replace(" ", "_").Replace('+', '_')); chk.AutoSize = true; chk.Text = Strings.ShowMeAgain; chk.Checked = true; chk.Location = new Point(9, 80); if (Settings.Instance.ContainsKey((string)chk.Tag) && Settings.Instance.GetBoolean((string)chk.Tag) == false) // skip it { form.Dispose(); chk.Dispose(); buttonOk.Dispose(); label.Dispose(); return(DialogResult.OK); } chk.CheckStateChanged += new EventHandler(chk_CheckStateChanged); buttonOk.Text = Strings.OK; buttonOk.DialogResult = DialogResult.OK; buttonOk.Location = new Point(form.Right - 100, 80); label.SetBounds(9, 9, 372, 13); label.AutoSize = true; form.Controls.AddRange(new Control[] { label, chk, buttonOk }); if (link != "" && linktext != "") { Size textSize2 = TextRenderer.MeasureText(linktext, SystemFonts.DefaultFont); var linklbl = new LinkLabel { Left = 9, Top = label.Bottom, Width = textSize2.Width, Height = textSize2.Height, Text = linktext, Tag = link, AutoSize = true }; linklbl.Click += (sender, args) => { try { System.Diagnostics.Process.Start(((LinkLabel)sender).Tag.ToString()); } catch (Exception exception) { CustomMessageBox.Show("Failed to open link " + ((LinkLabel)sender).Tag.ToString()); } }; form.Controls.Add(linklbl); form.Width = Math.Max(form.Width, linklbl.Right + 16); } form.ClientSize = new Size(396, 107); form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height); form.FormBorderStyle = FormBorderStyle.FixedDialog; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; ThemeManager.ApplyThemeTo(form); DialogResult dialogResult = form.ShowDialog(); form.Dispose(); form = null; return(dialogResult); }
//テキスト表示用の幅を取得する protected int TextWidth(string str) { var label = new Label { Text = str }; var width = label.PreferredWidth; label.Dispose(); return width; }
//Disk - wmi query for Win32_LogicalDisk public string Disk() { string s = ""; string sLetter = ""; string sFSType = ""; string query = "SELECT * FROM Win32_LogicalDisk WHERE FileSystem IS NOT NULL"; ManagementObjectSearcher seeker = new ManagementObjectSearcher(query); ManagementObjectCollection oReturnCollection = seeker.Get(); int i = 0; System.Windows.Forms.Label lTemp = new System.Windows.Forms.Label(); //temporary lable for getting the necessary max size of pbar lTemp.AutoSize = true; foreach (ManagementObject m in oReturnCollection) { sLetter = m["DeviceID"].ToString(); sFSType = m["FileSystem"].ToString(); s += sLetter + " " + CalcSize(m["FreeSpace"].ToString(), 1) + " " + sFSType + "\n"; if (bHDDPBar == true) { long iFS = Convert.ToInt64(m["FreeSpace"]); long iSize = Convert.ToInt64(m["Size"]); if (iSize > 0) _hddBar[i].Value = Convert.ToInt16((100 * (iSize - iFS) / iSize)); //percent used space: 100* (size - free space) / size //if you want display free space: 100* freespace / size else _hddBar[i].Value = 100; if (_hddBar[i].Value <= 50) _pHddProg[i].Color = cColorHDDBar50; if (_hddBar[i].Value > 50 && _hddBar[i].Value <= 75) _pHddProg[i].Color = cColorHDDBar75; if (_hddBar[i].Value > 75) _pHddProg[i].Color = cColorHDDBar100; _hddBar[i].Text = sLetter + " " + CalcSize(iFS.ToString(), 1) + " " + sFSType; _hddBar[i].Name = _hddBar[i].Text + "\r\n" + "Size: " + CalcSize(iSize.ToString(), 1); //used for tooltip text i++; } } oReturnCollection.Dispose(); seeker.Dispose(); lTemp.Text = s; _pHddBack.Color = cColorHDDBack; for (int k = 0; k < 10; k++) { if (k < i) { if (bColorGlobal) { _hddBar[k].Font = fFontGlobal; lTemp.Font = fFontGlobal; } else { _hddBar[k].Font = fTitleFont[3]; lTemp.Font = fTitleFont[3]; } _hddBar[k].Height = Convert.ToInt16(_hddBar[k].Font.GetHeight()) + 2; _hddBar[k].Width = lTemp.PreferredWidth + 10; //size all bars to max necessary size _hddBar[k].Top = _hddBar[k].Height * k; //position the bar _hddBar[k].ForeColor = cColorHDDText; _hddBar[k].Visible = true; _hddBar[k].BringToFront(); _hddBar[k].Update(); } else _hddBar[k].Visible = false; } lTemp.Dispose(); lTemp = null; return s; }
internal void FreeEverything() { FileNameComboBox.Dispose(); FileNameLabel.Dispose(); }
private void OnReceive(IAsyncResult ar) { try { clientSocket.EndReceive(ar); if (byteData[0] == 8) { EviData data = new EviData(byteData); Evidence evi = new Evidence(); evi.name = data.strName; evi.desc = data.strDesc; evi.note = data.strNote; evi.index = data.index; using (MemoryStream ms = new MemoryStream(data.dataBytes)) { evi.icon = Image.FromStream(ms, false, true); } bool found = false; foreach (Evidence item in eviList) { if (item.index == evi.index) { found = true; item.name = evi.name; item.note = evi.note; item.desc = evi.desc; item.icon = evi.icon; break; } } if (found == false) eviList.Add(evi); testimonyPB.Location = new Point(257, 3); testimonyPB.BringToFront(); PictureBox icon = new PictureBox(); icon.Image = evi.icon; icon.Location = new Point(6, 5); icon.Size = new Size(70, 70); icon.BringToFront(); testimonyPB.Invoke((MethodInvoker)delegate { //perform on the UI thread testimonyPB.Controls.Add(icon); }); Label name = new Label(); name.Text = evi.name; name.Location = new Point(91, 8); name.Size = new Size(155, 17); name.TextAlign = ContentAlignment.MiddleCenter; name.ForeColor = Color.DarkOrange; name.BackColor = Color.Transparent; //name.Font = new Font(fonts.Families[0], 12.0f, FontStyle.Bold); name.BringToFront(); testimonyPB.Invoke((MethodInvoker)delegate { //perform on the UI thread testimonyPB.Controls.Add(name); }); Label note = new Label(); note.Text = evi.note; note.Location = new Point(92, 26); note.Size = new Size(153, 44); //note.Font = new Font(fonts.Families[0], 12.0f); note.BackColor = Color.Transparent; note.BringToFront(); testimonyPB.Invoke((MethodInvoker)delegate { //perform on the UI thread testimonyPB.Controls.Add(note); }); Label desc = new Label(); desc.Text = evi.desc; desc.Location = new Point(9, 81); desc.Size = new Size(238, 45); //desc.Font = new Font(fonts.Families[0], 12.0f); desc.BackColor = Color.Transparent; desc.ForeColor = Color.White; desc.BringToFront(); testimonyPB.Invoke((MethodInvoker)delegate { //perform on the UI thread testimonyPB.Controls.Add(desc); }); testimonyPB.Size = new Size(256, 127); testimonyPB.Image = Image.FromFile("base/misc/inventory_update.png"); wr = new WaveFileReader("base/sounds/general/sfx-selectjingle.wav"); sfxPlayer.Initialize(wr); if (!mute) sfxPlayer.Play(); for (int x = 0; x <= 64; x++) { testimonyPB.Location = new Point(256 - (4 * x), 3); //icon.Location = new Point(256 + 6 - (2 * x), 3 + 5); //name.Location = new Point(256 + 91 - (2 * x), 3 + 8); //note.Location = new Point(256 + 92 - (2 * x), 3 + 26); //desc.Location = new Point(256 + 9 - (2 * x), 3 + 81); icon.Refresh(); name.Refresh(); note.Refresh(); desc.Refresh(); } System.Threading.Thread.Sleep(3000); for (int x = 0; x <= 64; x++) { testimonyPB.Location = new Point(0 - (4 * x), 3); //icon.Location = new Point(6 - (2 * x), 3 + 5); //name.Location = new Point(91 - (2 * x), 3 + 8); //note.Location = new Point(92 - (2 * x), 3 + 26); //desc.Location = new Point(9 - (2 * x), 3 + 81); icon.Refresh(); name.Refresh(); note.Refresh(); desc.Refresh(); } testimonyPB.Image = null; name.Dispose(); icon.Dispose(); desc.Dispose(); note.Dispose(); } else { Data msgReceived = new Data(byteData); //Accordingly process the message received switch (msgReceived.cmdCommand) { case Command.Login: break; case Command.Logout: break; case Command.ChangeMusic: if (msgReceived.strMessage != null && msgReceived.strMessage != "" & msgReceived.strName != null) { appendTxtLogSafe("<<<" + msgReceived.strName + " changed the music to " + msgReceived.strMessage + ">>>\r\n"); musicReader = new DmoMp3Decoder("base/sounds/music/" + msgReceived.strMessage); if (musicPlayer.PlaybackState != PlaybackState.Stopped) musicPlayer.Stop(); musicPlayer.Initialize(musicReader); if (!mute) musicPlayer.Play(); } break; case Command.ChangeHealth: if (msgReceived.strName == "def") { if (msgReceived.strMessage == "-1") defHealth--; else if (msgReceived.strMessage == "+1") defHealth++; } else if (msgReceived.strName == "pro") { if (msgReceived.strMessage == "-1") proHealth--; else if (msgReceived.strMessage == "+1") proHealth++; } updateHealth(); break; case Command.Message: case Command.Present: if (latestMsg != null && msgReceived.strName == latestMsg.strName) { newGuy = false; } else { newGuy = true; testimonyPB.Image = null; } latestMsg = msgReceived; objectLayerPB.Image = null; objectLayerPB.Location = new Point(0, 0); objectLayerPB.Size = new Size(256, 192); if (msgReceived.callout <= 3) { sendEnabled = false; curPreAnimTime = 0; curPreAnimTime = 0; curPreAnim = null; soundTime = 0; curSoundTime = 0; if (msgReceived.callout > 0) performCallout(); if (iniParser.GetSoundName(msgReceived.strName, msgReceived.anim) != "1" && iniParser.GetSoundTime(msgReceived.strName, msgReceived.anim) > 0 & File.Exists("base/sounds/general/" + iniParser.GetSoundName(latestMsg.strName, latestMsg.anim) + ".wav")) { sfxPlayer.Stop(); wr = new WaveFileReader("base/sounds/general/" + iniParser.GetSoundName(latestMsg.strName, latestMsg.anim) + ".wav"); sfxPlayer.Initialize(wr); soundTime = iniParser.GetSoundTime(msgReceived.strName, msgReceived.anim); } /* if (iniParser.GetSoundName(msgReceived.strName, msgReceived.anim) != "1" && iniParser.GetSoundTime(msgReceived.strName, msgReceived.anim) > 0 & (File.Exists("base/sounds/general/" + iniParser.GetSoundName(latestMsg.strName, latestMsg.anim) + ".wav") | File.Exists("base/characters/" + latestMsg.strName + "/" + iniParser.GetSoundName(latestMsg.strName, latestMsg.anim) + ".wav"))) { sfxPlayer.Stop(); if (File.Exists("base/characters/" + latestMsg.strName + "/" + iniParser.GetSoundName(latestMsg.strName, latestMsg.anim) + ".wav")) wr = new WaveFileReader("base/characters/" + latestMsg.strName + "/" + iniParser.GetSoundName(latestMsg.strName, latestMsg.anim) + ".wav"); else wr = new WaveFileReader("base/sounds/general/" + iniParser.GetSoundName(latestMsg.strName, latestMsg.anim) + ".wav"); sfxPlayer.Initialize(wr); soundTime = iniParser.GetSoundTime(msgReceived.strName, msgReceived.anim); } */ if (iniParser.GetAnimType(msgReceived.strName, msgReceived.anim) == 5) ChangeSides(true); else ChangeSides(); //If there is no pre-animation if (iniParser.GetAnimType(msgReceived.strName, msgReceived.anim) == 5 | iniParser.GetPreAnim(msgReceived.strName, msgReceived.anim) == null | iniParser.GetPreAnimTime(msgReceived.strName, msgReceived.anim) <= 0) { charLayerPB.Enabled = true; setCharSprite("base/characters/" + msgReceived.strName + "/(b)" + iniParser.GetAnim(msgReceived.strName, msgReceived.anim) + ".gif"); if (msgReceived.cmdCommand == Command.Present) { sfxPlayer.Stop(); wr = new WaveFileReader("base/sounds/general/sfx-shooop.wav"); sfxPlayer.Initialize(wr); if (!mute) sfxPlayer.Play(); switch (iniParser.GetSide(msgReceived.strName)) { case "def": testimonyPB.Image = Image.FromFile("base/misc/ani_evidenceRight.gif"); System.Threading.Thread.Sleep(100); testimonyPB.Location = new Point(173, 13); testimonyPB.Size = new Size(70, 70); testimonyPB.Image = eviList[Convert.ToInt32(msgReceived.strMessage.Split('|').Last())].icon; break; case "pro": testimonyPB.Image = Image.FromFile("base/misc/ani_evidenceLeft.gif"); System.Threading.Thread.Sleep(100); testimonyPB.Location = new Point(13, 13); testimonyPB.Size = new Size(70, 70); testimonyPB.Image = eviList[Convert.ToInt32(msgReceived.strMessage.Split('|').Last())].icon; break; case "hld": testimonyPB.Image = Image.FromFile("base/misc/ani_evidenceLeft.gif"); System.Threading.Thread.Sleep(100); testimonyPB.Location = new Point(13, 13); testimonyPB.Size = new Size(70, 70); testimonyPB.Image = eviList[Convert.ToInt32(msgReceived.strMessage.Split('|').Last())].icon; break; case "hlp": testimonyPB.Image = Image.FromFile("base/misc/ani_evidenceRight.gif"); System.Threading.Thread.Sleep(100); testimonyPB.Location = new Point(173, 13); testimonyPB.Size = new Size(70, 70); testimonyPB.Image = eviList[Convert.ToInt32(msgReceived.strMessage.Split('|').Last())].icon; break; default: testimonyPB.Image = Image.FromFile("base/misc/ani_evidenceRight.gif"); System.Threading.Thread.Sleep(100); testimonyPB.Location = new Point(173, 13); testimonyPB.Size = new Size(70, 70); testimonyPB.Image = eviList[Convert.ToInt32(msgReceived.strMessage.Split('|').Last())].icon; break; } msgReceived.strMessage = msgReceived.strMessage.Split('|')[0]; } prepWriteDispBoxes(msgReceived, msgReceived.textColor); } else //if there is a pre-animation { //charLayerPB.Enabled = false; setCharSprite("base/characters/" + msgReceived.strName + "/" + iniParser.GetPreAnim(msgReceived.strName, msgReceived.anim) + ".gif"); preAnimTime = iniParser.GetPreAnimTime(msgReceived.strName, msgReceived.anim); curPreAnim = iniParser.GetPreAnim(msgReceived.strName, msgReceived.anim); } //dispTextRedraw.Enabled = true; } else { performCallout(); } break; case Command.List: appendTxtLogSafe("<<<" + strName + " has entered the courtroom>>>\r\n"); break; case Command.DataInfo: //Do the stuff with the incoming server data here //The user has logged into the system so we now request the server to send //the names of all users who are in the chat room Data msgToSend = new Data(); msgToSend.cmdCommand = Command.Login; msgToSend.strName = strName; byteData = new byte[1048576]; byteData = msgToSend.ToByte(); clientSocket.BeginSend(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(OnSend), null); byteData = new byte[1048576]; break; case Command.PacketSize: break; } if (msgReceived.strMessage != null & msgReceived.cmdCommand == Command.Message | msgReceived.cmdCommand == Command.Login | msgReceived.cmdCommand == Command.Logout) { if (msgReceived.callout <= 3) appendTxtLogSafe(msgReceived.strMessage + "\r\n"); } if (msgReceived.cmdCommand != Command.PacketSize) byteData = new byte[1048576]; else byteData = new byte[Convert.ToInt32(msgReceived.strMessage)]; } clientSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(OnReceive), null); } catch (SocketException) { if (MessageBox.Show("You have been kicked from the server.", "AODXClient", MessageBoxButtons.OK) == DialogResult.OK) { Close(); } } catch (ObjectDisposedException) { } catch (Exception ex) { if (Program.debug) MessageBox.Show(ex.Message + ".\r\n" + ex.StackTrace.ToString(), "AODXClient: " + strName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Funcion que nos devuelve el tamaño para ajustar un comboBox al texto /// </summary> /// <param name="myCombo">Recice el comboBox del cual queremos saber el tamaño</param> /// <returns></returns> private int dropDownWidth(ComboBox myCombo) { int maxWidth = 0; int temp = 0; Label label1 = new Label(); foreach (KeyValuePair<String, String> item in myCombo.Items) { label1.Text = item.Value; temp = label1.PreferredWidth + 20; if (temp > maxWidth) { maxWidth = temp; } } label1.Dispose(); return maxWidth; }
private void lblStatus_Click(object sender, EventArgs e) { Form aboutForm = new Form() { FormBorderStyle = FormBorderStyle.FixedSingle, MinimizeBox = false, MaximizeBox = false }; aboutForm.StartPosition = FormStartPosition.CenterParent; aboutForm.Width = 400; aboutForm.Height = 200; aboutForm.Text = "About Internet Tester"; aboutForm.Icon = Internet_Tester.Properties.Resources.Internet_Tester; //Get the version number Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); Label aboutText = new Label() { Width = 400, Height = 130, Location = new Point(0, 0), ImageAlign = ContentAlignment.MiddleCenter, TextAlign = ContentAlignment.MiddleCenter, Text = "Internet Tester v" + fileVersionInfo.ProductMajorPart + "." + fileVersionInfo.ProductMinorPart + "." + fileVersionInfo.ProductBuildPart + "\n\n" + "A Simple Program to Quickly\n" + "Check the Internet Connection\n\n" + "Programmed and Designed by Coolcord" }; Font aboutFont = new Font("Microsoft Sans Serif", 8, FontStyle.Bold); aboutText.Font = aboutFont; Button btnOk = new Button() { Width = 100, Height = 30, Text = "OK", Location = new Point(150, 130), ImageAlign = ContentAlignment.MiddleCenter, TextAlign = ContentAlignment.MiddleCenter }; btnOk.Click += (btnSender, btnE) => aboutForm.Close(); //click ok to close aboutForm.AcceptButton = btnOk; aboutForm.Controls.Add(aboutText); aboutForm.Controls.Add(btnOk); aboutForm.ShowDialog(); aboutForm.Dispose(); btnOk.Dispose(); aboutText.Dispose(); aboutFont.Dispose(); }
private void Hauptfenster_Load(object sender, EventArgs e) { // Init script types comboBox_script_type.Items.AddRange(Info.ScriptTemplate); comboBox_script_type.SelectedIndex = 0; comboBox_script_type.DropDownStyle = ComboBoxStyle.DropDownList; // already done by selected index changed //Datastores.ReloadDB(); //UpdateNPCListBox(); // set width of the combo int maxWidth = 0; int temp = 0; Label label_test = new Label(); foreach (var obj in comboBox_script_type.Items) { label_test.Text = obj.ToString(); temp = label_test.PreferredWidth; if (temp > maxWidth) maxWidth = temp; } label_test.Dispose(); comboBox_script_type.DropDownWidth = maxWidth; }
public static DialogResult MessageShowAgain(string title, string promptText) { Form form = new Form(); System.Windows.Forms.Label label = new System.Windows.Forms.Label(); CheckBox chk = new CheckBox(); Controls.MyButton buttonOk = new Controls.MyButton(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2)); form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); form.Text = title; label.Text = promptText; chk.Tag = ("SHOWAGAIN_" + title.Replace(" ", "_")); chk.AutoSize = true; chk.Text = "Show me again?"; chk.Checked = true; chk.Location = new Point(9, 80); if (MainV2.config[(string)chk.Tag] != null && (string)MainV2.config[(string)chk.Tag] == "False") // skip it { form.Dispose(); chk.Dispose(); buttonOk.Dispose(); label.Dispose(); return DialogResult.OK; } chk.CheckStateChanged += new EventHandler(chk_CheckStateChanged); buttonOk.Text = "OK"; buttonOk.DialogResult = DialogResult.OK; buttonOk.Location = new Point(form.Right - 100, 80); label.SetBounds(9, 40, 372, 13); label.AutoSize = true; form.ClientSize = new Size(396, 107); form.Controls.AddRange(new Control[] { label, chk, buttonOk }); form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height); form.FormBorderStyle = FormBorderStyle.FixedDialog; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; ThemeManager.ApplyThemeTo(form); DialogResult dialogResult = form.ShowDialog(); form.Dispose(); form = null; return dialogResult; }
private void btnAbout_Click(object sender, EventArgs e) { Form aboutForm = new Form() { FormBorderStyle = FormBorderStyle.FixedSingle, MinimizeBox = false, MaximizeBox = false }; aboutForm.StartPosition = FormStartPosition.CenterParent; aboutForm.Width = 400; aboutForm.Height = 200; aboutForm.Text = "About Clicktastic"; aboutForm.Icon = Properties.Resources.clicktastic; aboutForm.BackColor = Color.Black; //Get the version number Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); Label aboutText = new Label() { Width = 400, Height = 130, Location = new Point(0, 0), ImageAlign = ContentAlignment.MiddleCenter, TextAlign = ContentAlignment.MiddleCenter, Text = "Clicktastic v" + fileVersionInfo.ProductMajorPart + "." + fileVersionInfo.ProductMinorPart + "." + fileVersionInfo.ProductBuildPart + "\n\n" + "Mass Click Mouse Buttons or\n" + "Mass Press Keyboard Keys\n\n" + "Programmed and Designed by Coolcord" }; Font aboutFont = new Font("Microsoft Sans Serif", 8, FontStyle.Bold); aboutText.Font = aboutFont; aboutText.ForeColor = Color.White; Button btnOk = new Button() { Width = 100, Height = 30, Text = "OK", Location = new Point(150, 130), ImageAlign = ContentAlignment.MiddleCenter, TextAlign = ContentAlignment.MiddleCenter }; btnOk.Click += (btnSender, btnE) => aboutForm.Close(); //click ok to close btnOk.BackColor = SystemColors.ButtonFace; btnOk.UseVisualStyleBackColor = true; aboutForm.AcceptButton = btnOk; aboutForm.Controls.Add(aboutText); aboutForm.Controls.Add(btnOk); //Easter Egg =D aboutForm.KeyPreview = true; CheatCode cheatCode = new CheatCode(); aboutForm.KeyDown += new KeyEventHandler(cheatCode.GetCheatCode); //All done with the about form aboutForm.ShowDialog(); aboutForm.Dispose(); btnOk.Dispose(); aboutText.Dispose(); aboutFont.Dispose(); }
// wrapper to handle the width of the combo box int DropDownWidth(ComboBox myCombo) { int maxWidth = 0; int temp = 0; Label label_test = new Label(); foreach (var obj in myCombo.Items) { label_test.Text = obj.ToString(); temp = label_test.PreferredWidth; if (temp > maxWidth) maxWidth = temp; } label_test.Dispose(); return maxWidth; }
// // GetKeyDialog(string message) // Asks the user to press a key and returns the key that the user pressed // private KEYCOMBO GetKeyDialog(string message) { //Construct the key dialog Form keyPrompt = new Form() { FormBorderStyle = FormBorderStyle.FixedSingle, MinimizeBox = false, MaximizeBox = false }; keyPrompt.StartPosition = FormStartPosition.CenterParent; keyPrompt.Width = 250; keyPrompt.Height = 100; keyPrompt.Text = "Clicktastic"; keyPrompt.KeyPreview = true; keyPrompt.Icon = Properties.Resources.clicktastic; keyPrompt.BackColor = Color.Black; Label lblKey = new Label() { Width = 250, Height = 65, ImageAlign = ContentAlignment.MiddleCenter, TextAlign = ContentAlignment.MiddleCenter, Text = message, ForeColor = Color.White }; lblKey.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Bold); keyPrompt.Controls.Add(lblKey); System.Timers.Timer timer = new System.Timers.Timer(750); int textState = 1; timer.AutoReset = true; timer.Enabled = true; timer.Elapsed += (sender, e) => { try { this.Invoke(new MethodInvoker(() => { switch (textState) { //add dots to the end of the message as time passes case 0: lblKey.Text = message; break; case 1: lblKey.Text = message + "."; break; case 2: lblKey.Text = message + ".."; break; case 3: lblKey.Text = message + "..."; break; } })); textState = (textState + 1) % 4; } catch { } }; KEYCOMBO key = new KEYCOMBO(); Keys lastKey = Keys.None; key.valid = false; //assume invalid unless otherwise stated string strKey = null; keyPrompt.PreviewKeyDown += (sender, e) => { timer.Stop(); //Determine the key pressed strKey = keyStringConverter.KeyToString(e.KeyCode); //Determine key modifiers if (e.Alt && e.KeyCode != Keys.Menu) strKey = "Alt + " + strKey; if (e.Shift && e.KeyCode != Keys.ShiftKey) strKey = "Shift + " + strKey; if (e.Control && e.KeyCode != Keys.ControlKey) strKey = "Ctrl + " + strKey; lblKey.Text = strKey; lastKey = e.KeyCode; }; keyPrompt.KeyDown += (sender, e) => { if (e.Modifiers.Equals(Keys.Alt)) { e.Handled = true; //don't open the menu with alt } }; keyPrompt.KeyUp += (sender, e) => { keyPrompt.Close(); }; lblKey.MouseClick += (sender, e) => { timer.Stop(); if (e.Button == MouseButtons.Left) strKey = "LeftClick"; else if (e.Button == MouseButtons.Right) strKey = "RightClick"; else if (e.Button == MouseButtons.Middle) strKey = "MiddleClick"; else return; //button not recognized string strLastKey = lblKey.Text.Split(' ').Last(); if (strLastKey == "Ctrl" || strLastKey == "Shift" || strLastKey == "Alt") strKey = lblKey.Text + " + " + strKey; lblKey.Text = strKey; lastKey = Keys.None; keyPrompt.Close(); }; keyPrompt.MouseWheel += (sender, e) => { timer.Stop(); if (e.Delta < 0) //negative is down strKey = "MouseWheelDown"; else //positive is up strKey = "MouseWheelUp"; string strLastKey = lblKey.Text.Split(' ').Last(); if (strLastKey == "Ctrl" || strLastKey == "Shift" || strLastKey == "Alt") strKey = lblKey.Text + " + " + strKey; lblKey.Text = strKey; lastKey = Keys.None; keyPrompt.Close(); }; keyPrompt.ShowDialog(); //All done with the dialog keyPrompt.Dispose(); lblKey.Dispose(); key = ParseKEYCOMBO(strKey, lastKey); return key; }
private void Filter_DropDown(object sender, EventArgs e) { var cb = sender as ComboBox; if (cb == null) return; int maxWidth = 0; int temp = 0; Label label1 = new Label(); foreach (var obj in cb.Items) { label1.Text = obj.ToString(); temp = label1.PreferredWidth; if (temp > maxWidth) maxWidth = temp; } label1.Dispose(); if (maxWidth > cb.Width) cb.DropDownWidth = maxWidth; }
/// <summary> /// remove label if exist, optionally find label by tag /// </summary> public void RemoveLabel(Label label, TagItem tag=null, bool redraw = true) { if (label == null) label = Labels.Find(x => x.Text == tag.Name); if (label == null) return; f.splitContainer1.Panel2.Controls.Remove(label); label.Dispose(); Labels.Remove(label); if(redraw) drawTags(); //not used in del last label }