public static void DrawTextBox(Graphics g, Rectangle bounds, string textBoxText, Font font, Rectangle textBounds, TextFormatFlags flags, TextBoxState state) { InitializeRenderer((int) state); DrawBackground(g, bounds, state); Color foreColor = visualStyleRenderer.GetColor(ColorProperty.TextColor); TextRenderer.DrawText(g, textBoxText, font, textBounds, foreColor, flags); }
public static void DrawTextBox(Graphics g, Rectangle bounds, string textBoxText, Font font, TextFormatFlags flags, TextBoxState state) { InitializeRenderer((int) state); Rectangle backgroundContentRectangle = visualStyleRenderer.GetBackgroundContentRectangle(g, bounds); backgroundContentRectangle.Inflate(-2, -2); DrawTextBox(g, bounds, textBoxText, font, backgroundContentRectangle, flags, state); }
public void Click(Vector2 mousePosition) { switch (LayoutAlign) { case LayoutAlign.TopRight: mousePosition.Y = WindowHeight - mousePosition.Y; break; case LayoutAlign.TopLeft: mousePosition.X = WindowWidth - mousePosition.X; mousePosition.Y = WindowHeight - mousePosition.Y; break; case LayoutAlign.BottomRight: break; case LayoutAlign.BottomLeft: mousePosition.X = WindowWidth - mousePosition.X; break; default: break; } bool isHovering = PointInRectangle(Vertices[0].Position.Xy, Vertices[1].Position.Xy, Vertices[2].Position.Xy, Vertices[3].Position.Xy, mousePosition); if (isHovering && State == TextBoxState.Unfocused) { State = TextBoxState.Focused; } else { State = TextBoxState.Unfocused; } }
/// <summary> /// Leitet einen Zustand für eine Textbox an den Editor weiter /// </summary> /// <param name="e"></param> public void ReceiveLiveFeed(TextBoxState state) { if (EditorView != null) { EditorView.ReceiveLiveData(state); } }
public TextBoxBackup(ShaderProgram program, string text, Color4 colour, Color4 highlightColour, int x, int y, int width, int height, int windowWidth, int windowHeight, Matrix4 projection, LayoutAlign layoutAlign = LayoutAlign.TopRight, string fontLocation = "arial") : base(program, text, colour, highlightColour, x, y, width, height, windowWidth, windowHeight, projection, layoutAlign, fontLocation) { State = TextBoxState.Unfocused; }
public void Focus() { textBoxState = TextBoxState.Focus; foreach (TextBox tb in Global.textBoxes) { if (tb != this) tb.Unfocus(); } }
/// <summary> /// Inhalte aus dem Netzwerk an die entsprechende textbox weiterleiten /// </summary> /// <param name="state"></param> public void ReceiveLiveData(TextBoxState state) { Network.NetworkTextbox ntb = editorFields[state.TextBoxType]; if (ntb != null) { ntb.UpdateState(state); } }
/// <summary> /// Übermittelt Textbox-Zustände, die aus dem Netzwerk kommen, weiter an /// die entsprechende Darstellung /// </summary> /// <param name="state"></param> public void ProcessLiveData(TextBoxState state) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { foreach (ItemControl ctrl in Representations) { ctrl.ReceiveLiveFeed(state); } })); }
public void Focus() { textBoxState = TextBoxState.Focus; foreach (TextBox tb in Global.textBoxes) { if (tb != this) { tb.Unfocus(); } } }
private static void DrawBackground(Graphics g, Rectangle bounds, TextBoxState state) { visualStyleRenderer.DrawBackground(g, bounds); if ((state != TextBoxState.Disabled) && (visualStyleRenderer.GetColor(ColorProperty.FillColor) != SystemColors.Window)) { Rectangle backgroundContentRectangle = visualStyleRenderer.GetBackgroundContentRectangle(g, bounds); using (SolidBrush brush = new SolidBrush(SystemColors.Window)) { g.FillRectangle(brush, backgroundContentRectangle); } } }
private static void DrawBackground(Graphics g, Rectangle bounds, TextBoxState state) { visualStyleRenderer.DrawBackground(g, bounds); if (state != TextBoxState.Disabled) { Color windowColor = visualStyleRenderer.GetColor(ColorProperty.FillColor); if (windowColor != SystemColors.Window) { Rectangle fillRect = visualStyleRenderer.GetBackgroundContentRectangle(g, bounds); //then we need to re-fill the background. using(SolidBrush brush = new SolidBrush(SystemColors.Window)) { g.FillRectangle(brush, fillRect); } } } }
private static void DrawBackground(Graphics g, Rectangle bounds, TextBoxState state) { t_visualStyleRenderer.DrawBackground(g, bounds); if (state != TextBoxState.Disabled) { Color windowColor = t_visualStyleRenderer.GetColor(ColorProperty.FillColor); if (windowColor != SystemColors.Window) { Rectangle fillRect = t_visualStyleRenderer.GetBackgroundContentRectangle(g, bounds); g.FillRectangle(SystemBrushes.Window, fillRect); } } }
private static void DrawBackground(Graphics g, Rectangle bounds, TextBoxState state) { visualStyleRenderer.DrawBackground(g, bounds); if (state != TextBoxState.Disabled) { Color windowColor = visualStyleRenderer.GetColor(ColorProperty.FillColor); if (windowColor != SystemColors.Window) { Rectangle fillRect = visualStyleRenderer.GetBackgroundContentRectangle(g, bounds); //then we need to re-fill the background. using (SolidBrush brush = new SolidBrush(SystemColors.Window)) { g.FillRectangle(brush, fillRect); } } } }
private void SaveState(ActionType actionType) { if (lastActionType != actionType) { lastActionType = actionType; if (actionType != ActionType.Undefined) { undoLog.AddLast(state); while (undoLog.Count > MaxLogLength) { undoLog.RemoveFirst(); } redoLog.Clear(); state = state.Copy(); } } }
static void Main(string[] args) { ScrumTouchkit.Utilities.Serializer.JSONSerializer json = new ScrumTouchkit.Utilities.Serializer.JSONSerializer(); TextBoxState tbst = new TextBoxState { Text = "Beispieltext wird gerade verä", TextBoxType = 0, SelectionStart = 10, SelectionLength = 0, HorizontalOffset = 15, VerticalOffset = 0 }; Console.WriteLine(json.ObjectToString(tbst)); System.Windows.Forms.Clipboard.SetText(json.ObjectToString(tbst)); Console.Read(); }
/// <summary> /// Verarbeitet ankommende SMLP-Nachrichten /// </summary> /// <param name="sender"></param> /// <param name="msg"></param> private void Connection_SMLPMessageReceived(object sender, Protocol.SMLPMessage msg) { if (msg.LocalReceiver == SMLPMessage.AUDIO) { Audio.BufferAudio(msg.Data); } else { /** * Wenn es sich nicht um ein Audio-Sample handelt, wird die Nachricht an das lokale * Objekt weitergeleitet. Es handelt sich folglich um einen Zustand einer Textbox zur * Liveverfolgung von Änderungen **/ TextBoxState state = Connection.Serializer.ConvertToObject <TextBoxState>(msg.Data); ItemBase item = Surface.Database.GetItem(msg.LocalReceiver); if (item != null) { item.ProcessLiveData(state); } } }
public static void DrawTextBox (Graphics g, Rectangle bounds, string textBoxText, Font font, Rectangle textBounds, TextFormatFlags flags, TextBoxState state) { if (!IsSupported) throw new InvalidOperationException (); VisualStyleRenderer vsr; switch (state) { case TextBoxState.Assist: vsr = new VisualStyleRenderer (VisualStyleElement.TextBox.TextEdit.Assist); break; case TextBoxState.Disabled: vsr = new VisualStyleRenderer (VisualStyleElement.TextBox.TextEdit.Disabled); break; case TextBoxState.Hot: vsr = new VisualStyleRenderer (VisualStyleElement.TextBox.TextEdit.Hot); break; case TextBoxState.Normal: case TextBoxState.Readonly: default: vsr = new VisualStyleRenderer (VisualStyleElement.TextBox.TextEdit.Normal); break; case TextBoxState.Selected: vsr = new VisualStyleRenderer (VisualStyleElement.TextBox.TextEdit.Selected); break; } vsr.DrawBackground (g, bounds); if (textBounds == Rectangle.Empty) textBounds = new Rectangle (bounds.Left + 3, bounds.Top + 3, bounds.Width - 6, bounds.Height - 6); if (textBoxText != String.Empty) if (state == TextBoxState.Disabled) TextRenderer.DrawText (g, textBoxText, font, textBounds, SystemColors.GrayText, flags); else TextRenderer.DrawText (g, textBoxText, font, textBounds, SystemColors.ControlText, flags); }
private void SetTextBoxStatus(TextBox field, TextBoxState state) { var controlName = field.Name; var validationControl = Controls.Find(controlName.Replace('f', 'v'), true); if (validationControl != null && validationControl.Length > 0) { if (state == TextBoxState.Valid) { (validationControl[0] as Label).Text = "✔"; (validationControl[0] as Label).ForeColor = Color.Green; } else if (state == TextBoxState.Edited) { (validationControl[0] as Label).Text = "🖉"; (validationControl[0] as Label).ForeColor = Color.Orange; } else if (state == TextBoxState.Invalid) { (validationControl[0] as Label).Text = "!"; (validationControl[0] as Label).ForeColor = Color.Red; } } }
/// <summary> /// Draws a TextBox in the specified state, on the specified graphics /// surface, and within the specified bounds /// </summary> /// <param name="g">The Graphics to draw on</param> /// <param name="textRect">The Rectangle that represents the dimensions /// of the TextBox</param> /// <param name="state">A TextBoxState value that specifies the /// state to draw the TextBox in</param> public static void DrawTextBox(Graphics g, Rectangle textRect, TextBoxState state) { ThemeManager.DrawTextBox(g, textRect, textRect, state); }
/// <include file='doc\TextBoxRenderer.uex' path='docs/doc[@for="TextBoxRenderer.DrawTextBox1"]/*' /> /// <devdoc> /// <para> /// Renders a TextBox control. /// </para> /// </devdoc> public static void DrawTextBox(Graphics g, Rectangle bounds, string textBoxText, Font font, Rectangle textBounds, TextBoxState state) { DrawTextBox(g, bounds, textBoxText, font, textBounds, TextFormatFlags.TextBoxControl, state); }
public static void DrawTextBox(Graphics g, Rectangle bounds, TextBoxState state) { InitializeRenderer((int)state); DrawBackground(g, bounds, state); }
void OnCharTyped(object sender, TextInputEventArgs e) { TextBoxState.OnCharTyped(this, e); }
public void Unfocus() { textBoxState = TextBoxState.Unfocused; }
public void InitTextBox() { textBoxState = TextBoxState.Unfocused; ResetCharacter(); }
/// <include file='doc\TextBoxRenderer.uex' path='docs/doc[@for="TextBoxRenderer.DrawTextBox2"]/*' /> /// <devdoc> /// <para> /// Renders a TextBox control. /// </para> /// </devdoc> public static void DrawTextBox(Graphics g, Rectangle bounds, string textBoxText, Font font, TextFormatFlags flags, TextBoxState state) { InitializeRenderer((int)state); Rectangle textBounds = visualStyleRenderer.GetBackgroundContentRectangle(g, bounds); textBounds.Inflate(-2, -2); DrawTextBox(g, bounds, textBoxText, font, textBounds, flags, state); }
public void DrawTextField(Graphics g, Rectangle rect, string text, Font font, Color textColor, Color backColor, TextBoxState state, TextBoxStyle style, int scroll = 0, int cursorPos = -1, int selLength = 0) { if (rect.Width < 4 || rect.Height < 4) return; GraphicsState oldState = g.Save(); // Draw Background Rectangle textRect = DrawTextBoxBorder(g, rect, state, style, backColor); Rectangle textRectScrolled = new Rectangle( textRect.X - scroll, textRect.Y, textRect.Width + scroll, textRect.Height); if (text == null) return; RectangleF clipRect = g.ClipBounds; clipRect = textRect; g.SetClip(clipRect); // Draw Selection if ((state & TextBoxState.Focus) == TextBoxState.Focus && cursorPos >= 0 && selLength != 0) { int selPos = Math.Min(cursorPos + selLength, cursorPos); CharacterRange[] charRanges = new [] { new CharacterRange(selPos, Math.Abs(selLength)) }; Region[] charRegions = MeasureStringLine(g, text, charRanges, font, textRectScrolled); RectangleF selectionRect = charRegions.Length > 0 ? charRegions[0].GetBounds(g) : RectangleF.Empty; selectionRect.Inflate(0, 2); selectionRect.Y += GetFontYOffset(font); if (selPos == 0) { selectionRect.X -= 2; selectionRect.Width += 2; } if (selPos + Math.Abs(selLength) == text.Length) { selectionRect.Width += 2; } if ((state & TextBoxState.ReadOnlyFlag) == TextBoxState.ReadOnlyFlag) g.FillRectangle(new SolidBrush(Color.FromArgb(128, this.ColorGrayText)), selectionRect); else g.FillRectangle(new SolidBrush(Color.FromArgb(128, this.ColorHightlight)), selectionRect); } // Draw Text if ((state & TextBoxState.Disabled) == TextBoxState.Disabled || (state & TextBoxState.ReadOnlyFlag) == TextBoxState.ReadOnlyFlag) textColor = Color.FromArgb(128, textColor); DrawStringLine(g, text, font, textRectScrolled, textColor); // Draw Cursor if ((state & TextBoxState.ReadOnlyFlag) != TextBoxState.ReadOnlyFlag && cursorPos >= 0 && selLength == 0) { CharacterRange[] charRanges = new [] { new CharacterRange(0, cursorPos) }; Region[] charRegions = MeasureStringLine(g, text, charRanges, font, textRectScrolled); RectangleF textRectUntilCursor = charRegions.Length > 0 ? charRegions[0].GetBounds(g) : RectangleF.Empty; int curPixelPos = textRectScrolled.X + (int)textRectUntilCursor.Width + 2; DrawCursor(g, new Rectangle(curPixelPos, textRectScrolled.Top + 1, 1, textRectScrolled.Height - 2)); } g.Restore(oldState); }
private static bool DrawThemedTextBoxBorderNative(IntPtr hWnd, Graphics g, Rectangle bounds, TextBoxState style) { if (!VisualStyleRenderer.IsSupported) { return(false); } using (var themeData = CreateSafeThemeDataHandle(hWnd, VisualStyle.CLASS.EDIT)) { if (themeData.IsInvalid) { return(false); } var part = VisualStyle.EDITPARTS.EP_EDITBORDER_NOSCROLL; var state = style == TextBoxState.Disabled ? VisualStyle.EDITBORDER_NOSCROLLSTATES.EPSN_DISABLED : style == TextBoxState.Hot ? VisualStyle.EDITBORDER_NOSCROLLSTATES.EPSN_HOT : style == TextBoxState.Focused ? VisualStyle.EDITBORDER_NOSCROLLSTATES.EPSN_FOCUSED : VisualStyle.EDITBORDER_NOSCROLLSTATES.EPSN_NORMAL; using (var graphicsDeviceContext = new SafeGraphicsDeviceContextHandle(g)) { DrawThemeBackground(themeData, graphicsDeviceContext, part, state, bounds); } } return(true); }
public static void DrawTextBox (Graphics g, Rectangle bounds, TextBoxState state) { DrawTextBox (g, bounds, String.Empty, null, Rectangle.Empty, TextFormatFlags.Default, state); }
public static void DrawTextBox (Graphics g, Rectangle bounds, string textBoxText, Font font, TextFormatFlags flags, TextBoxState state) { DrawTextBox (g, bounds, textBoxText, font, Rectangle.Empty, flags, state); }
/// <summary> /// Draws a TextBox in the specified state, on the specified graphics /// surface, and within the specified bounds /// </summary> /// <param name="g">The Graphics to draw on</param> /// <param name="textRect">The Rectangle that represents the dimensions /// of the TextBox</param> /// <param name="clipRect">The Rectangle that represents the clipping area</param> /// <param name="state">A TextBoxState value that specifies the /// state to draw the TextBox in</param> public static void DrawTextBox(Graphics g, Rectangle textRect, Rectangle clipRect, TextBoxState state) { if (g == null || textRect.Width <= 0 || textRect.Height <= 0 || clipRect.Width <= 0 || clipRect.Height <= 0) { return; } if (ThemeManager.VisualStylesEnabled) { //ThemeManager.DrawThemeBackground(g, ThemeClasses.TextBox, (int) TextBoxParts.EditText, (int) state, textRect, clipRect); VisualStyleRenderer renderer; switch (state) { case TextBoxState.Disabled: renderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Disabled); break; case TextBoxState.Hot: renderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Hot); break; case TextBoxState.Readonly: renderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.ReadOnly); break; case TextBoxState.Selected: renderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Selected); break; case TextBoxState.Normal: renderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Normal); break; default: renderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Focused); break; } renderer.DrawBackground(g, textRect, clipRect); } else { ControlPaint.DrawBorder3D(g, textRect, Border3DStyle.Sunken); } }
public static void DrawTextBox(Graphics g, Rectangle bounds, string textBoxText, Font font, Rectangle textBounds, TextFormatFlags flags, TextBoxState state) { throw null; }
private static void DrawThemedTextBoxBorderManaged(Graphics g, Rectangle bounds, TextBoxState state) { var theme = Windows8Theme; var color = (state == TextBoxState.Disabled) ? theme.BorderColorDisabled : (state == TextBoxState.Hot) ? theme.BorderColorHot : (state == TextBoxState.Focused) ? theme.BorderColorFocused : theme.BorderColorNormal; ControlPaint.DrawBorder(g, bounds, color, ButtonBorderStyle.Solid); }
private void textBox1_Enter(object sender, EventArgs e) { State = TextBoxState.FOCUSED; //MessageBox.Show("hover"); this.Invalidate(); }
public static void DrawTextBox(Graphics g, Rectangle bounds, TextBoxState state) { throw null; }
private void textBox1_Leave(object sender, EventArgs e) { State = TextBoxState.NORMAL; //MessageBox.Show("leave"); this.Invalidate(); }
internal static VisualStyleRenderer CreateRenderer(TextBoxState state, bool focused, bool hasBorder) { if (!Application.RenderWithVisualStyles || !hasBorder) return null; VisualStyleElement element = null; if (focused) { element = VisualStyleElement.CreateElement(EDIT_CLASS, EP_EDITBORDER_NOSCROLL, EPSN_FOCUSED); if (!VisualStyleRenderer.IsElementDefined(element)) element = VisualStyleElement.TextBox.TextEdit.Focused; } else { switch (state) { case TextBoxState.Hot: element = VisualStyleElement.CreateElement(EDIT_CLASS, EP_EDITBORDER_NOSCROLL, EPSN_HOT); if (!VisualStyleRenderer.IsElementDefined(element)) element = VisualStyleElement.TextBox.TextEdit.Hot; break; case TextBoxState.Normal: element = VisualStyleElement.CreateElement(EDIT_CLASS, EP_EDITBORDER_NOSCROLL, EPSN_NORMAL); if (!VisualStyleRenderer.IsElementDefined(element)) element = VisualStyleElement.TextBox.TextEdit.Normal; break; case TextBoxState.Disabled: element = VisualStyleElement.CreateElement(EDIT_CLASS, EP_EDITBORDER_NOSCROLL, EPSN_DISABLED); if (!VisualStyleRenderer.IsElementDefined(element)) element = VisualStyleElement.TextBox.TextEdit.Disabled; break; } } return new VisualStyleRenderer(element); }
public static void DrawTextBox(Graphics g, Rectangle bounds, string textBoxText, Font font, Rectangle textBounds, TextFormatFlags flags, TextBoxState state) { InitializeRenderer((int)state); DrawBackground(g, bounds, state); Color textColor = visualStyleRenderer.GetColor(ColorProperty.TextColor); TextRenderer.DrawText(g, textBoxText, font, textBounds, textColor, flags); }
public static void DrawTextBox(Graphics g, Rectangle bounds, string textBoxText, Font font, Rectangle textBounds, TextBoxState state) { DrawTextBox(g, bounds, textBoxText, font, textBounds, TextFormatFlags.Default, state); }
public static void DrawTextBox(Graphics g, Rectangle bounds, string textBoxText, Font font, Rectangle textBounds, TextFormatFlags flags, TextBoxState state) { if (!IsSupported) { throw new InvalidOperationException(); } VisualStyleRenderer vsr; switch (state) { case TextBoxState.Assist: vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Assist); break; case TextBoxState.Disabled: vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Disabled); break; case TextBoxState.Hot: vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Hot); break; case TextBoxState.Normal: case TextBoxState.Readonly: default: vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Normal); break; case TextBoxState.Selected: vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Selected); break; } vsr.DrawBackground(g, bounds); if (textBounds == Rectangle.Empty) { textBounds = new Rectangle(bounds.Left + 3, bounds.Top + 3, bounds.Width - 6, bounds.Height - 6); } if (textBoxText != String.Empty) { if (state == TextBoxState.Disabled) { TextRenderer.DrawText(g, textBoxText, font, textBounds, SystemColors.GrayText, flags); } else { TextRenderer.DrawText(g, textBoxText, font, textBounds, SystemColors.ControlText, flags); } } }
/// <summary> /// Paints an OS-native background and border on the given control. /// </summary> /// <param name="hWnd"> /// Handle to a Windows Forms control. /// </param> /// <param name="g"> /// Graphics object to paint. /// </param> /// <param name="bounds"> /// The bounds of the control. /// </param> /// <param name="state"> /// The desired style of the text box. /// </param> public static void DrawThemedTextBoxBorder(IntPtr hWnd, Graphics g, Rectangle bounds, TextBoxState state = TextBoxState.Normal) { // TODO: Hover fade effect? // TODO: Create a general purpose wrapper method for P/Invoke calls that handles exceptions // and optionally calls a backup/fallback method if it fails try { if (DrawThemedTextBoxBorderNative(hWnd, g, bounds, state)) { return; } } catch (DllNotFoundException ex) { // Non-Windows OS LogNativeException("Probably non-Windows OS?", ex); } catch (EntryPointNotFoundException ex) { // Older version of Windows (pre-XP)? LogNativeException("Probably older version of Windows (pre-XP)?", ex); } DrawThemedTextBoxBorderManaged(g, bounds, state); }
private void CueTextBox_LostFocus(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(_mainBox.Text)) { _currentState = TextBoxState.Empty; _mainBox.Text = this.CueText; this.ActualTextBrush = this.CueTextBrush; } else { _currentState = TextBoxState.HasText; } }
public Rectangle DrawTextBoxBorder(Graphics g, Rectangle rect, TextBoxState state, TextBoxStyle style, Color backColor) { if (rect.Width < 4 || rect.Height < 4) return rect; Rectangle clientRect = rect; Color borderColor = this.ColorDarkBackground.ScaleBrightness(1.2f); Color borderColorDark = this.ColorDarkBackground.ScaleBrightness(0.85f); if (style == TextBoxStyle.Plain) { clientRect = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); Pen innerPen; if (state == TextBoxState.Normal) { innerPen = new Pen(Color.Transparent); } else if (state == TextBoxState.Hot) { innerPen = new Pen(Color.FromArgb(32, this.ColorHightlight)); } else if (state == TextBoxState.Focus) { innerPen = new Pen(Color.FromArgb(64, this.ColorHightlight)); } else //if (state == TextBoxState.Disabled) { innerPen = new Pen(Color.Transparent); } g.FillRectangle(new SolidBrush(backColor), rect); g.DrawRectangle(innerPen, rect.X, rect.Y, rect.Width - 1, rect.Height - 1); } else if (style == TextBoxStyle.Flat) { clientRect = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); Pen borderPen; Pen innerPen; if (state == TextBoxState.Normal) { borderPen = new Pen(borderColorDark); innerPen = new Pen(Color.Transparent); } else if (state == TextBoxState.Hot) { borderPen = new Pen(borderColorDark.MixWith(this.ColorHightlight, 0.25f, true)); innerPen = new Pen(Color.FromArgb(32, this.ColorHightlight)); } else if (state == TextBoxState.Focus) { borderPen = new Pen(borderColorDark.MixWith(this.ColorHightlight, 0.5f, true)); innerPen = new Pen(Color.FromArgb(48, this.ColorHightlight)); } else //if (state == TextBoxState.Disabled) { borderPen = new Pen(Color.FromArgb(128, borderColorDark)); innerPen = new Pen(Color.Transparent); } g.FillRectangle(new SolidBrush(backColor), rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); g.DrawRectangle(borderPen, rect.X, rect.Y, rect.Width - 1, rect.Height - 1); g.DrawRectangle(innerPen, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3); } else if (style == TextBoxStyle.Sunken) { clientRect = new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4); Pen borderPenDark; Pen borderPen; Pen innerPen; if (state == TextBoxState.Normal) { borderPenDark = new Pen(borderColorDark); borderPen = new Pen(borderColor); innerPen = new Pen(Color.Transparent); } else if (state == TextBoxState.Hot) { borderPenDark = new Pen(borderColorDark.MixWith(this.ColorHightlight, 0.25f, true)); borderPen = new Pen(borderColor.MixWith(this.ColorHightlight, 0.25f, true)); innerPen = new Pen(Color.FromArgb(32, this.ColorHightlight)); } else if (state == TextBoxState.Focus) { borderPenDark = new Pen(borderColorDark.MixWith(this.ColorHightlight, 0.5f, true)); borderPen = new Pen(borderColor.MixWith(this.ColorHightlight, 0.5f, true)); innerPen = new Pen(Color.FromArgb(48, this.ColorHightlight)); } else //if (state == TextBoxState.Disabled) { borderPenDark = new Pen(Color.FromArgb(128, borderColorDark)); borderPen = new Pen(Color.FromArgb(128, borderColor)); innerPen = new Pen(Color.Transparent); } g.FillRectangle(new SolidBrush(backColor), rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2); g.DrawLine(borderPenDark, rect.X + 1, rect.Y, rect.Right - 2, rect.Y); g.DrawLine(borderPen, rect.X, rect.Y + 1, rect.X, rect.Bottom - 2); g.DrawLine(borderPen, rect.Right - 1, rect.Y + 1, rect.Right - 1, rect.Bottom - 2); g.DrawLine(borderPen, rect.X + 1, rect.Bottom - 1, rect.Right - 2, rect.Bottom - 1); g.DrawRectangle(innerPen, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3); } return clientRect; }
public void textBoxClose() { tb_state = TextBoxState.Closed; state = State.NoMenu; }
protected override void OnKeyDown(NKeyCode keyCode, NModifierKey modifierKey, bool autoRepeat) { if (keyCode == NKeyCode.A && modifierKey == NModifierKey.Control) { state.SelectAll(); coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.Z && modifierKey == NModifierKey.Control) { if (undoLog.Count != 0) { redoLog.AddFirst(state); state = undoLog.Last.Value; undoLog.RemoveLast(); } lastActionType = ActionType.Undefined; coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.Z && modifierKey == (NModifierKey.Control | NModifierKey.Shift)) { if (redoLog.Count != 0) { undoLog.AddLast(state); state = redoLog.First.Value; redoLog.RemoveFirst(); } lastActionType = ActionType.Undefined; coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.LeftArrow && modifierKey == NModifierKey.None) { // todo: handle num-pad arrow keys SaveState(ActionType.Undefined); state.MoveCursorLeft(); coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.RightArrow && modifierKey == NModifierKey.None) { // todo: handle num-pad arrow keys SaveState(ActionType.Undefined); state.MoveCursorRight(); coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.LeftArrow && modifierKey == NModifierKey.Shift) { // todo: handle num-pad arrow keys SaveState(ActionType.Undefined); state.SelectLeft(); coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.RightArrow && modifierKey == NModifierKey.Shift) { // todo: handle num-pad arrow keys SaveState(ActionType.Undefined); state.SelectRight(); coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.Home && modifierKey == NModifierKey.None) { // todo: handle num-pad home key SaveState(ActionType.Undefined); state.GoHome(); coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.End && modifierKey == NModifierKey.None) { // todo: handle num-pad end key SaveState(ActionType.Undefined); state.GoEnd(); coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.Backspace && modifierKey == NModifierKey.None) { // todo: handle num-pad end key SaveState(ActionType.Deletion); state.DeleteLeft(); coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.Delete && modifierKey == NModifierKey.None) { // todo: handle num-pad end key SaveState(ActionType.Deletion); state.DeleteRight(); coordinatesCalculated = false; InvalidatePainting(); } else if (keyCode == NKeyCode.C && modifierKey == NModifierKey.Control) { if (state.HasSelection) { Application.Clipboard.PutText(state.SelectedText); } } else if (keyCode == NKeyCode.X && modifierKey == NModifierKey.Control) { if (state.HasSelection) { Application.Clipboard.PutText(state.SelectedText); SaveState(ActionType.Undefined); state.DeleteRight(); coordinatesCalculated = false; InvalidatePainting(); } } else if (keyCode == NKeyCode.V && modifierKey == NModifierKey.Control) { if (Application.Clipboard.TryGetText(out var text)) { SaveState(ActionType.Undefined); state.EnterText(text); coordinatesCalculated = false; InvalidatePainting(); } } }
public void textBoxOpen() { state = State.TextBox; tb_state = TextBoxState.Opening; }
public static void DrawTextBox(Graphics g, Rectangle bounds, TextBoxState state) { DrawTextBox(g, bounds, String.Empty, null, Rectangle.Empty, TextFormatFlags.Default, state); }
public void textBoxText(string text, bool more) { tb_more = more; tb_text = text; tb_state = TextBoxState.Waiting; }
public static void DrawTextBox(Graphics g, Rectangle bounds, string textBoxText, Font font, TextFormatFlags flags, TextBoxState state) { DrawTextBox(g, bounds, textBoxText, font, Rectangle.Empty, flags, state); }
public void update(int ticks) { PlayerInput input = cabedge.player1; switch(state) { case State.TextBox: if(input.Confirm) { input.Confirm.Unpress(); goto endPage; } if(input.Cancel) { input.Cancel.Unpress(); goto endPage; } break; endPage: tb_state = TextBoxState.Closed; state = State.NoMenu; goto case State.NoMenu; case State.NoMenu: break; case State.MainMenu: if(input.Confirm) { input.Confirm.Unpress(); mainMenuNavigator.activate(); } if (input.MenuX) { input.MenuX.Unpress(); state = State.NoMenu; goto case State.NoMenu; } if(input.Cancel) { input.Cancel.Unpress(); mainMenuNavigator.exit(); if(!mainMenuNavigator.IsInMenu) { state = State.NoMenu; goto case State.NoMenu; } } if(input.Down) { input.Down.Unpress(); mainMenuNavigator.next(); } else if(input.Up) { input.Up.Unpress(); mainMenuNavigator.prev(); } break; } for(int i=0;i<ticks;i++) tick(); }
private bool IsValidData() { if (ButtonRegister.Text == "Update") { if (string.IsNullOrEmpty(TextBoxSupId.Text)) { Globals.MessageBoxShow(this, "Please Choose a Customer to Edit"); TextBoxSupId.Focus(); return(false); } } if (string.IsNullOrEmpty(TextBoxSupName.Text)) { Globals.MessageBoxShow(this, "Please Enter Customer Name"); TextBoxSupName.Focus(); return(false); } if (string.IsNullOrEmpty(TextBoxZipCode.Text)) { Globals.MessageBoxShow(this, "Please Enter Zip Code"); TextBoxZipCode.Focus(); return(false); } else { string zipCodePattern = @"[0-9]{6}"; bool isZipValid = true; isZipValid = Regex.IsMatch(TextBoxZipCode.Text, zipCodePattern); if (!isZipValid) { Globals.MessageBoxShow(this, "Please Enter Valid Zip Code"); TextBoxZipCode.Focus(); return(false); } } if (string.IsNullOrEmpty(TextBoxSupPhno.Text)) { Globals.MessageBoxShow(this, "Please Enter Phone Number"); TextBoxSupPhno.Focus(); return(false); } else { string phnoPattern = @"[0-9]{10}"; bool isphnoValid = true; isphnoValid = Regex.IsMatch(TextBoxSupPhno.Text, phnoPattern); if (!isphnoValid) { Globals.MessageBoxShow(this, "Please Enter Valid Phone Number"); TextBoxSupPhno.Focus(); return(false); } } if (string.IsNullOrEmpty(TextBoxEmail.Text)) { Globals.MessageBoxShow(this, "Please Enter Email"); TextBoxEmail.Focus(); return(false); } else { string emailPattern = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; bool isemailValid = true; isemailValid = Regex.IsMatch(TextBoxEmail.Text, emailPattern); if (!isemailValid) { Globals.MessageBoxShow(this, "Please Enter Valid Email"); TextBoxEmail.Focus(); return(false); } } if (string.IsNullOrEmpty(TextBoxGSTNo.Text)) { Globals.MessageBoxShow(this, "Please Enter GST No"); TextBoxGSTNo.Focus(); return(false); } else { string gstPattern = @"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$"; bool isgstValid = true; isgstValid = Regex.IsMatch(TextBoxGSTNo.Text, gstPattern); if (!isgstValid) { Globals.MessageBoxShow(this, "Please Enter Valid GST No"); TextBoxGSTNo.Focus(); return(false); } } if (string.IsNullOrEmpty(TextBoxState.Text)) { Globals.MessageBoxShow(this, "Please Enter State"); TextBoxState.Focus(); return(false); } if (string.IsNullOrEmpty(TextBoxCity.Text)) { Globals.MessageBoxShow(this, "Please Enter City"); TextBoxCity.Focus(); return(false); } if (string.IsNullOrEmpty(TextBoxAddress.Text)) { Globals.MessageBoxShow(this, "Please Enter Address"); TextBoxAddress.Focus(); return(false); } if (DropDownListCountry.SelectedItem.Text == "Select Country") { Globals.MessageBoxShow(this, "Please Select Country"); DropDownListCountry.Focus(); return(false); } if (DropDownListGender.SelectedItem.Text == "Gender") { Globals.MessageBoxShow(this, "Please Select Gender"); DropDownListGender.Focus(); return(false); } return(true); }
private void CueTextBox_GotFocus(object sender, RoutedEventArgs e) { if (_currentState == TextBoxState.Empty) { _mainBox.Text = ""; this.ActualTextBrush = this.Foreground; } _currentState = TextBoxState.Typing; }