public UIBigButton(bool green) : base() { CaptionStyle = CaptionStyle.Clone(); CaptionStyle.Size = 37; CaptionStyle.Color = (green)?UIStyle.Current.GreenBtnTxt:UIStyle.Current.BtnTxt; CaptionStyle.DisabledColor = UIStyle.Current.BtnDisable; Texture = Content.Get().CustomUI.Get(green ? "greenbutton.png" : "button.png").Get(GameFacade.GraphicsDevice); }
public static void DrawCaptionBackground(PaintEventArgs e , Rectangle rect , Color backColor , CaptionStyle backgroundStyle , int baseLineSize , Color baseLineColor) { if (rect.Width == 0 || rect.Height == 0) { return; } Brush brush; switch (backgroundStyle) { case CaptionStyle.HorizontalGradient: brush = new LinearGradientBrush(rect, backColor, PaintHelper.GetLightColor(backColor), 0.0f); e.Graphics.FillRectangle(brush, rect); break; case CaptionStyle.VerticalGradient: brush = new LinearGradientBrush(rect, backColor, PaintHelper.GetDarkColor(backColor), 90.0f); e.Graphics.FillRectangle(brush, rect); break; case CaptionStyle.BaseLine: if (baseLineSize > 0) { //brush = new LinearGradientBrush(rect, baseLineColor, Color.FromArgb(0, baseLineColor), 0.0f); brush = new SolidBrush(baseLineColor); e.Graphics.FillRectangle(brush, new Rectangle(rect.Left, rect.Bottom - baseLineSize, rect.Width, baseLineSize)); rect.Height -= baseLineSize; } break; default: break; } }
/// <summary> /// Highlights the word that the caret is in. /// </summary> private void HighlightCurrentWord() { int caret = SelectionStart; bool wordSelected = false; foreach (CaptionWord cw in Caption.Words) { //If the word contains the caret but hasn't been selected yet, highlight and then select it. if (cw.Contains(caret) && !cw.IsSelected) { SetTextBackgroundColour(cw, CaptionStyle.Highlighted); cw.IsSelected = true; } //If the word doesn't contain the caret but is selected, then unselect it. else if (!cw.Contains(caret) && cw.IsSelected) { //Return it to the original Caption colour SetTextBackgroundColour(cw, CaptionStyle.GetColourOf(cw)); cw.IsSelected = false; } //If cw is still selected after check if (cw.IsSelected) { SelectionMode = CaptionTextBoxSelectionMode.SingleWordSelection; OnCaptionWordSelected(new CaptionWordSelectedEventArgs(cw)); wordSelected = true; } } if (!wordSelected) { SelectionMode = CaptionTextBoxSelectionMode.NoSelection; OnNothingSelected(EventArgs.Empty); } }
public void AutoSize() { this.Size = CaptionStyle.MeasureString(Caption); }
public void NewStyle(Color color, int size) { CaptionStyle = CaptionStyle.Clone(); CaptionStyle.Color = color; CaptionStyle.Size = size; }
/// <summary> /// Sets the background colour of the text specified by the arguments. Preserves the previous /// selection, restoring it after highlighting is done. /// </summary> /// <param name="word">The CaptionWord to highlight.</param> /// <param name="style">The CaptionStyle to use.</param> public void SetTextBackgroundColour(CaptionWord word, CaptionStyle style) { this.SetTextBackgroundColour(word.BeginIndex, word.Length, style.TextColour, style.BackColour); }
private void m_btnChangeCaptionStyle_Click(object sender, EventArgs e) { if (this.m_captionStyle == CaptionStyle.Flat) { this.m_captionStyle = CaptionStyle.Normal; } else { this.m_captionStyle = CaptionStyle.Flat; } xPanderPanelList1.CaptionStyle = this.m_captionStyle; }