//Amennyiben pozitív a ladderBoxes változó, csökkentti, és eltávolítja és törli a ladderInputBoxes lista utolsó két elemét. private void deleteLastLadderButton_Click(object sender, EventArgs e) { if (ladderBoxes > 0) { System.Windows.Forms.TextBox remove = ladderInputBoxes[ladderInputBoxes.Count - 1]; ladderInputBoxes.RemoveAt(ladderInputBoxes.Count - 1); remove.Dispose(); remove = ladderInputBoxes[ladderInputBoxes.Count - 1]; ladderInputBoxes.RemoveAt(ladderInputBoxes.Count - 1); remove.Dispose(); ladderBoxes = ladderBoxes - 1; } }
//Amennyiben pozitív a snakeBoxes változó, csökkenti, és eltávolítja és törli a snakeInputBoxes lista utolsó két elemét. private void deleteLastSnakeButton_Click(object sender, EventArgs e) { if (snakeBoxes > 0) { System.Windows.Forms.TextBox remove = snakeInputBoxes[snakeInputBoxes.Count - 1]; snakeInputBoxes.RemoveAt(snakeInputBoxes.Count - 1); remove.Dispose(); remove = snakeInputBoxes[snakeInputBoxes.Count - 1]; snakeInputBoxes.RemoveAt(snakeInputBoxes.Count - 1); remove.Dispose(); snakeBoxes = snakeBoxes - 1; } }
/// <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); } }
//Amennyiben pozitív a diceBoxes változó, csökkenti, és eltávolítja és törli a diceInputBoxes lista utolsó elemét. private void deleteLastDice_Click(object sender, EventArgs e) { if (diceBoxes > 0) { System.Windows.Forms.TextBox remove = diceInputBoxes[diceInputBoxes.Count - 1]; diceInputBoxes.RemoveAt(diceInputBoxes.Count - 1); remove.Dispose(); diceBoxes = diceBoxes - 1; } }
//Amennyiben pozitív a patternABoxes változó, csökkenti, és eltávolítja és törli a patternAInputBoxes lista utolsó elemét. private void deleteLastPatternAElementButton_Click(object sender, EventArgs e) { if (patternABoxes > 0) { System.Windows.Forms.TextBox remove = patternAInputBoxes[patternAInputBoxes.Count - 1]; patternAInputBoxes.RemoveAt(patternAInputBoxes.Count - 1); remove.Dispose(); patternABoxes = patternABoxes - 1; } }
public static Image createLongTwitImage(TextBox tbWeibo) { //获取图片长度 Graphics g = Graphics.FromHwnd(tbWeibo.Handle); int tmptbHeight; try { tmptbHeight = (int)g.MeasureString(tbWeibo.Text + "\r\n\r\n\t\t\tBy #SinaWeiboClient#", tbWeibo.Font, 440).Height; } catch { return null; } finally { g.Dispose(); } //生成文本框 TextBox tmptb = new TextBox(); tmptb.Multiline = true; tmptb.Width = 440; tmptb.Height = tmptbHeight; tmptb.Text = tbWeibo.Text + "\r\n\r\n\t\t\tBy #SinaWeiboClient#"; tmptb.BackColor = Color.White; tmptb.BorderStyle = BorderStyle.None; //转化为图片 Bitmap bmp = new Bitmap(tmptb.Width, tmptb.Height); Rectangle rect = new Rectangle(new Point(0, 0), tmptb.Size); tmptb.DrawToBitmap(bmp, rect); tmptb.Dispose(); //MeasureString方法不甚精准,消除底部空白 int lines = 0, pixels = 0, white = Color.White.ToArgb(); for (int i = bmp.Height; i > 0; i--, pixels = 0) { for (int j = 0; j < bmp.Width; j++) { if (bmp.GetPixel(j, i).ToArgb() == white) pixels++; else pixels = 0; } if (pixels == bmp.Width) lines++; else break; } return lines > 0 ? bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height - lines), System.Drawing.Imaging.PixelFormat.Format24bppRgb) : bmp; }
internal void FreeEverything() { menuStrip1.Dispose(); fileToolStripMenuItem.Dispose(); closeToolStripMenuItem.Dispose(); TopPanel.Dispose(); ThreeDPanel.Dispose(); MainElementHost.Dispose(); textBox1.Dispose(); // ViewPort.Dispose(); // Scene; }
/// <summary> /// Places the Actual TextBox on the owner so user can edit the text /// </summary> protected void PlaceActualTextBox() { if (_actualTextBox != null) { _actualTextBox.TextChanged -= new EventHandler(_actualTextbox_TextChanged); _actualTextBox.KeyDown -= new KeyEventHandler(_actualTextbox_KeyDown); _actualTextBox.LostFocus -= new EventHandler(_actualTextbox_LostFocus); _actualTextBox.VisibleChanged -= new EventHandler(_actualTextBox_VisibleChanged); Canvas.Controls.Remove(_actualTextBox); _actualTextBox.Dispose(); } _actualTextBox = new TextBox(); InitTextBox(_actualTextBox); _actualTextBox.TextChanged += new EventHandler(_actualTextbox_TextChanged); _actualTextBox.KeyDown += new KeyEventHandler(_actualTextbox_KeyDown); _actualTextBox.LostFocus += new EventHandler(_actualTextbox_LostFocus); _actualTextBox.VisibleChanged += new EventHandler(_actualTextBox_VisibleChanged); _actualTextBox.Visible = true; Canvas.Controls.Add(_actualTextBox); }
/// <summary> /// Removes the actual TextBox that edits the text /// </summary> protected void RemoveActualTextBox() { if (_actualTextBox == null || _removingTxt) { return; } _removingTxt = true; TextBoxText = _actualTextBox.Text; _actualTextBox.Visible = false; _actualTextBox.Parent.Controls.Remove(_actualTextBox); _actualTextBox.Dispose(); _actualTextBox = null; RedrawItem(); _removingTxt = false; }
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(); } } }
protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyData == System.Windows.Forms.Keys.Enter) { var obj = Diagram.SelectedFigure as GeometryFigure; if (obj != null) { System.Windows.Forms.TextBox v = new System.Windows.Forms.TextBox(); v.Parent = this; v.Size = new System.Drawing.Size(50, 25); v.Location = new System.Drawing.Point(100, 100); v.TextChanged += (ex, ev) => { obj.text.Value = v.Text; }; v.LostFocus += (ev, ex) => { v.Dispose(); v = null; }; } } _controller.KeyDownAction(e); Invalidate(); base.OnKeyDown(e); }
/// <summary> /// Removes the actual TextBox that edits the text /// </summary> protected void RemoveActualTextBox() { if (_actualTextBox == null || _removingTxt || isInStartEdit) { return; } _removingTxt = true; TextBoxText = _actualTextBox.Text; _actualTextBox.Visible = false; if (_actualTextBox.Parent != null) { _actualTextBox.Parent.Controls.Remove(_actualTextBox); } _actualTextBox.Dispose(); _actualTextBox = null; RedrawItem(); _removingTxt = false; Owner.ActiveTextBox = null; }
private void HandleLabelEditClick(DynamicList list) { if (this.allowLabelEdit) { TextBox txt = new TextBox(); txt.Text = this.Text; this.AssignControlUntilFocusChange(txt); if (this.BeginLabelEdit != null) { this.BeginLabelEdit(this, new DynamicListEventArgs(list)); } bool escape = false; txt.KeyDown += delegate (object sender2, KeyEventArgs e2) { if ((e2.KeyData == Keys.Return) || (e2.KeyData == Keys.Escape)) { e2.Handled = true; if (e2.KeyData == Keys.Escape) { if (this.CanceledLabelEdit != null) { this.CanceledLabelEdit(this, new DynamicListEventArgs(list)); } escape = true; } this.Control = null; txt.Dispose(); } }; txt.LostFocus += delegate { if (!escape) { this.Text = txt.Text; if (this.FinishLabelEdit != null) { this.FinishLabelEdit(this, new DynamicListEventArgs(list)); } } }; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Determine whether or not this control has been placed on a toolstrip control. /// </summary> /// ------------------------------------------------------------------------------------ protected override void OnParentChanged(EventArgs e) { base.OnParentChanged(e); Control parent = Parent; // Determine whether or not the control is hosted on a toolstrip. while (parent != null) { if (parent is ToolStrip) { m_fParentIsToolstrip = true; DockPadding.All = 1; btnScrPsgDropDown.Width = kButtonWidthOnToolstrip; MouseEnter += txtScrRef_MouseEnter; MouseLeave += txtScrRef_MouseLeave; SizeChanged += HandleSizeChanged; return; } parent = parent.Parent; } m_fParentIsToolstrip = false; TextBox txtTmp = new TextBox(); txtScrRef.Font = txtTmp.Font.Clone() as Font; txtTmp.Dispose(); DockPadding.All = (Application.RenderWithVisualStyles ? SystemInformation.BorderSize.Width : SystemInformation.Border3DSize.Width); btnScrPsgDropDown.Dock = DockStyle.Right; }
//=========================================================================== // // 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 OnKeyPress(object sender, KeyPressEventArgs e) { string hexChars = "0123456789ABCDEF"; if (textBoxString1.ContainsFocus | textBoxString2.ContainsFocus | textBoxString3.ContainsFocus |textBoxString4.ContainsFocus) { // ignore typing in textboxes return; } // check for copy/cut if ((e.KeyChar == 3) || (e.KeyChar == 24)) { textBoxDisplay.Copy(); return; } if (radioButtonDisconnect.Checked) { // don't do anything else if not connected return; } textBoxDisplay.Focus(); if (radioButtonHex.Checked) { // hex mode string charTyped = e.KeyChar.ToString(); // get typed char charTyped = charTyped.ToUpper(); if (charTyped.IndexOfAny(hexChars.ToCharArray()) == 0) { // valid Hex character if (labelTypeHex.Visible) { // first nibble already typed - send byte string dataString = labelTypeHex.Text.Substring(11,1) + charTyped; labelTypeHex.Text = "Type Hex : "; labelTypeHex.Visible = false; byte[] hexByte = new byte[1]; hexByte[0] = (byte)Utilities.Convert_Value_To_Int("0x" + dataString); dataString = "TX: " + dataString + "\r\n"; textBoxDisplay.AppendText(dataString); textBoxDisplay.SelectionStart = textBoxDisplay.Text.Length; textBoxDisplay.ScrollToCaret(); if (logFile != null) { logFile.Write(dataString); } Pk2.DataDownload(hexByte, 0, hexByte.Length); } else { // show first nibble labelTypeHex.Text = "Type Hex : " + charTyped + "_"; labelTypeHex.Visible = true; } } else { // other char - clear typed hex labelTypeHex.Text = "Type Hex : "; labelTypeHex.Visible = false; } } else { // ASCII mode // check for paste if (e.KeyChar == 22) { textBoxDisplay.SelectionStart = textBoxDisplay.Text.Length; //cursor at end TextBox tempBox = new TextBox(); tempBox.Multiline = true; tempBox.Paste(); do { int pasteLength = tempBox.Text.Length; if (pasteLength > 60) { pasteLength = 60; } sendString(tempBox.Text.Substring(0, pasteLength), false); tempBox.Text = tempBox.Text.Substring(pasteLength); // wait according to the baud rate so we don't overflow the download buffer float baud = float.Parse((comboBoxBaud.SelectedItem.ToString())); baud = (1F / baud) * 12F * (float)pasteLength; // to ensure we don't overflow, give each byte 12 bits baud *= 1000F; // baud is now in ms. Thread.Sleep((int)baud); } while (tempBox.Text.Length > 0); tempBox.Dispose(); return; } string charTyped = e.KeyChar.ToString(); if (charTyped == "\r") { charTyped = "\r\n"; } sendString(charTyped, false); } }
private List<Control> GetControls(GUIDField field, Size canvasSize) { TextBox textBox = new TextBox(); MaskedTextBox maskedTextBox = new MaskedTextBox(); if (field is IPatternable && !(string.IsNullOrEmpty(((IPatternable)field).Pattern))) { textBox.Dispose(); maskedTextBox.HidePromptOnLeave = true; maskedTextBox.Text = string.Empty; maskedTextBox.BorderStyle = borderStyle; //maskedTextBox.MaskInputRejected += new MaskInputRejectedEventHandler(maskedTextBox_MaskInputRejected); maskedTextBox.Mask = AppData.Instance.DataPatternsDataTable.GetMaskByPattern(((IPatternable)field).Pattern); SetControlProperties(maskedTextBox, field, canvasSize); Label maskedPrompt = GetPrompt(maskedTextBox, field, canvasSize); List<Control> maskedControls = new List<Control>(); maskedControls.Add(maskedPrompt); maskedControls.Add(maskedTextBox); if (!fieldControls.ContainsKey(field)) { fieldControls.Add(field, maskedControls); } else { fieldControls.Remove(field); fieldControls.Add(field, maskedControls); } return maskedControls; } else { maskedTextBox.Dispose(); if (field is GUIDField) { if (field.CurrentRecordValueString.Equals(string.Empty)) { //textBox.Text = field.NewGuid().ToString(); } else { textBox.Text = field.CurrentRecordValueString.Replace(StringLiterals.CURLY_BRACE_LEFT,string.Empty).Replace(StringLiterals.CURLY_BRACE_RIGHT, string.Empty); } textBox.ReadOnly = ((GUIDField)field).IsReadOnly; textBox.MaxLength = ((GUIDField)field).MaxLength; } SetControlProperties(textBox, field, canvasSize); textBox.ReadOnly = true; textBox.BorderStyle = borderStyle; Label prompt = GetPrompt(textBox, field, canvasSize); List<Control> controls = new List<Control>(); controls.Add(prompt); controls.Add(textBox); if (!fieldControls.ContainsKey(field)) { fieldControls.Add(field, controls); } else { fieldControls.Remove(field); fieldControls.Add(field, controls); } return controls; } }
void HandleLabelEditClick(DynamicList list) { if (!allowLabelEdit) return; TextBox txt = new TextBox(); txt.Text = this.Text; AssignControlUntilFocusChange(txt); if (BeginLabelEdit != null) BeginLabelEdit(this, new DynamicListEventArgs(list)); bool escape = false; txt.KeyDown += delegate(object sender2, KeyEventArgs e2) { if (e2.KeyData == Keys.Enter || e2.KeyData == Keys.Escape) { e2.Handled = true; if (e2.KeyData == Keys.Escape) { if (CanceledLabelEdit != null) CanceledLabelEdit(this, new DynamicListEventArgs(list)); escape = true; } this.Control = null; txt.Dispose(); } }; txt.LostFocus += delegate { if (!escape) { this.Text = txt.Text; if (FinishLabelEdit != null) FinishLabelEdit(this, new DynamicListEventArgs(list)); } }; }
internal void FreeEverything() { SearchTextBox.Dispose(); }
public void RefreshAll_TriggersRetrieveHotSpotEventForAllEnabled() { TextBox textBox1 = new TextBox(); TextBox textBox2 = new TextBox(); TextBox textBox3 = new TextBox(); TextBox textBox4 = new TextBox(); _hotSpotProvider.SetEnableHotSpots(textBox1, true); _hotSpotProvider.SetEnableHotSpots(textBox2, false); _hotSpotProvider.SetEnableHotSpots(textBox3, false); _hotSpotProvider.SetEnableHotSpots(textBox4, true); bool retrieveHotSpots1Called = false; bool retrieveHotSpots2Called = false; bool retrieveHotSpots3Called = false; bool retrieveHotSpots4Called = false; _hotSpotProvider.RetrieveHotSpots += delegate(object sender, RetrieveHotSpotsEventArgs e) { if (e.Control == textBox1) { retrieveHotSpots1Called = true; return; } if (e.Control == textBox2) { retrieveHotSpots2Called = true; return; } if (e.Control == textBox3) { retrieveHotSpots3Called = true; return; } if (e.Control == textBox4) { retrieveHotSpots4Called = true; return; } throw new InvalidOperationException(); }; // reset since installing the handler causes it to fire. retrieveHotSpots1Called = false; retrieveHotSpots2Called = false; retrieveHotSpots3Called = false; retrieveHotSpots4Called = false; // force hotSpotProvider to retrieve HotSpots _hotSpotProvider.RefreshAll(); Assert.IsTrue(retrieveHotSpots1Called); Assert.IsFalse(retrieveHotSpots2Called); Assert.IsFalse(retrieveHotSpots3Called); Assert.IsTrue(retrieveHotSpots4Called); textBox1.Dispose(); textBox2.Dispose(); textBox3.Dispose(); textBox4.Dispose(); }
private void checkDuplicateName(TextBox txtName) { Regex testName = new Regex("^[A-z][0-9A-z]*$"); if (!testName.Match(txtName.Text).Success) { DevExpress.XtraEditors.XtraMessageBox.Show("Please enter valid name for this object\nThe name must be alphanumeric", "Warning"); txtName.Focus(); txtName.SelectAll(); return; } bool isDuplicate = false; foreach (Control c in parentPanel.Controls) { //Kiểm tra tên đối với những Notation cùng loại if (c.GetType().Name == namingShape.GetType().Name && c != namingShape) if (((ShapeBase)c).sName.ToLower() == txtName.Text.ToLower()) { isDuplicate = true; break; } } if (!isDuplicate) { //nếu nó là attribute (viết tạm ở đây) if (this is AttributeShape) { AttributeShape att = this as AttributeShape; if (att.attributeChilds.Count == 0) { att.dataType = ucDataDescription.cboDataType.SelectedItem.ToString(); if (ucDataDescription.txtLength.Text != "") { try { int length = int.Parse(ucDataDescription.txtLength.Text); //if ((att.dataType == "nvarchar" || att.dataType == "nchar") && (length < 1 || length > 4000)) //{ // DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length between 1 and 4000.", "Warning"); // return; //} //if (length < 1 || length > 8000) //{ // DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length between 1 and 8000.", "Warning"); // return; //} if (length < 1) { DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length greater than 0", "Warning"); return; } att.dataLength = length; } catch { DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length as positive number.", "Warning"); return; } } else att.dataLength = 0; att.allowNull = ucDataDescription.chkNull.Checked; att.description = ucDataDescription.txtDescription.Text; ucDataDescription.Dispose(); } } this.sName = txtName.Text; //auto size to bound name Graphics g = CreateGraphics(); SizeF nameSize = g.MeasureString(sName, ThongSo.JFont); if (nameSize.Width + 30 > ThongSo.ShapeW) this.Width = (int)nameSize.Width + 30; txtName.Dispose(); parentPanel.isNaming = false; parentPanel.Refresh(); this.Invalidate(); } else { DevExpress.XtraEditors.XtraMessageBox.Show("Object " + txtName.Text + " already exist", "Warning"); txtName.Focus(); txtName.SelectAll(); } }
private void cancelbutton_click (object sender, EventArgs e, WebClient client,PictureBox cancelbutton, ProgressBar progressbar,string filename,TextBox episode = null) { const string message = "确定取消下载么?"; const string caption = "取消下载"; if (cancelbutton.Name.StartsWith("batch")) { client.CancelAsync(); client.Dispose(); //without it, deleting file would fail. batchpanel.Controls.Remove(episode); batchpanel.Controls.Remove(cancelbutton); batchpanel.Controls.Remove(progressbar); cancelbutton.Dispose(); progressbar.Dispose(); episode.Dispose(); File.Delete(filename); } else { var result = System.Windows.Forms.MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { client.CancelAsync(); client.Dispose(); infopanel.Controls.Remove(cancelbutton); infopanel.Controls.Remove(progressbar); cancelbutton.Dispose(); progressbar.Dispose(); File.Delete(filename); } } }