protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) { base.DrawControl(renderer, rect, gameTime); if (ReadOnly && (Focused || lstCombo.Focused) && drawSelection) { SkinLayer lr = Skin.Layers[0]; Rectangle rc = new Rectangle(rect.Left + lr.ContentMargins.Left, rect.Top + lr.ContentMargins.Top, Width - lr.ContentMargins.Horizontal - btnDown.Width, Height - lr.ContentMargins.Vertical); renderer.Draw(Manager.Skin.Images["ListBox.Selection"].Resource, rc, Color.FromNonPremultiplied(255, 255, 255, 128)); } }
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) { if (image != null) { if (sizeMode == SizeMode.Normal) renderer.Draw(image, rect.X, rect.Y, sourceRect, Color); else if (sizeMode == SizeMode.Auto) renderer.Draw(image, rect.X, rect.Y, sourceRect, Color); else if (sizeMode == SizeMode.Stretched) renderer.Draw(image, rect, sourceRect, Color); else if (sizeMode == SizeMode.Centered) { int x = (rect.Width / 2) - (image.Width / 2); int y = (rect.Height / 2) - (image.Height / 2); renderer.Draw(image, x, y, sourceRect, Color); } } }
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) { SkinLayer l1 = captionVisible ? Skin.Layers[lrCaption] : Skin.Layers[lrFrameTop]; SkinLayer l2 = Skin.Layers[lrFrameLeft]; SkinLayer l3 = Skin.Layers[lrFrameRight]; SkinLayer l4 = Skin.Layers[lrFrameBottom]; SkinLayer l5 = Skin.Layers[lrIcon]; LayerStates s1, s2, s3, s4; SpriteFont f1 = l1.Text.Font.Resource; Color c1 = l1.Text.Colors.Enabled; if ((Focused || (Manager.FocusedControl != null && Manager.FocusedControl.Root == this.Root)) && ControlState != ControlState.Disabled) { s1 = l1.States.Focused; s2 = l2.States.Focused; s3 = l3.States.Focused; s4 = l4.States.Focused; c1 = l1.Text.Colors.Focused; } else if (ControlState == ControlState.Disabled) { s1 = l1.States.Disabled; s2 = l2.States.Disabled; s3 = l3.States.Disabled; s4 = l4.States.Disabled; c1 = l1.Text.Colors.Disabled; } else { s1 = l1.States.Enabled; s2 = l2.States.Enabled; s3 = l3.States.Enabled; s4 = l4.States.Enabled; c1 = l1.Text.Colors.Enabled; } renderer.DrawLayer(Skin.Layers[lrWindow], rect, Skin.Layers[lrWindow].States.Enabled.Color, Skin.Layers[lrWindow].States.Enabled.Index); if (borderVisible) { renderer.DrawLayer(l1, new Rectangle(rect.Left, rect.Top, rect.Width, l1.Height), s1.Color, s1.Index); renderer.DrawLayer(l2, new Rectangle(rect.Left, rect.Top + l1.Height, l2.Width, rect.Height - l1.Height - l4.Height), s2.Color, s2.Index); renderer.DrawLayer(l3, new Rectangle(rect.Right - l3.Width, rect.Top + l1.Height, l3.Width, rect.Height - l1.Height - l4.Height), s3.Color, s3.Index); renderer.DrawLayer(l4, new Rectangle(rect.Left, rect.Bottom - l4.Height, rect.Width, l4.Height), s4.Color, s4.Index); if (iconVisible && (icon != null || l5 != null) && captionVisible) { Texture2D i = (icon != null) ? icon : l5.Image.Resource; renderer.Draw(i, GetIconRect(), Color.White); } int icosize = 0; if (l5 != null && iconVisible && captionVisible) icosize = l1.Height - l1.ContentMargins.Vertical + 4 + l5.OffsetX; int closesize = 0; if (btnClose.Visible) closesize = btnClose.Width - (btnClose.Skin.Layers[lrButton].OffsetX); Rectangle r = new Rectangle(rect.Left + l1.ContentMargins.Left + icosize, rect.Top + l1.ContentMargins.Top, rect.Width - l1.ContentMargins.Horizontal - closesize - icosize, l1.Height - l1.ContentMargins.Top - l1.ContentMargins.Bottom); int ox = l1.Text.OffsetX; int oy = l1.Text.OffsetY; renderer.DrawString(f1, Text, r, c1, l1.Text.Alignment, ox, oy, true); } }
private void DrawSelection(Renderer renderer, Rectangle rect) { if (!selection.IsEmpty) { int s = selection.Start; int e = selection.End; int sl = GetPosY(s); int el = GetPosY(e); int sc = GetPosX(s); int ec = GetPosX(e); int hgt = font.LineSpacing; int start = sl; int end = el; if (start < vert.Value) start = vert.Value; if (end > vert.Value + linesDrawn) end = vert.Value + linesDrawn; for (int i = start; i <= end; i++) { Rectangle r = Rectangle.Empty; if (mode == TextBoxMode.Normal) { int m = ClientArea.Height - font.LineSpacing; r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + m / 2, (int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt); } else if (sl == el) { r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt); } else { if (i == sl) r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i]).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt); else if (i == el) r = new Rectangle(rect.Left - horz.Value, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X, hgt); else r = new Rectangle(rect.Left - horz.Value, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i]).X, hgt); } renderer.Draw(Manager.Skin.Images["Control"].Resource, r, Color.FromNonPremultiplied(160, 160, 160, 128)); } } }
private void DrawPart(Renderer renderer, Rectangle rect, BevelBorder pos, BevelStyle style, bool all) { SkinLayer layer = Skin.Layers["Control"]; Color c1 = Utilities.ParseColor(layer.Attributes["LightColor"].Value); Color c2 = Utilities.ParseColor(layer.Attributes["DarkColor"].Value); Color c3 = Utilities.ParseColor(layer.Attributes["FlatColor"].Value); if (Color != UndefinedColor) c3 = Color; Texture2D img = Skin.Layers["Control"].Image.Resource; int x1 = 0; int y1 = 0; int w1 = 0; int h1 = 0; int x2 = 0; int y2 = 0; int w2 = 0; int h2 = 0; if (style == BevelStyle.Bumped || style == BevelStyle.Etched) { if (all && (pos == BevelBorder.Top || pos == BevelBorder.Bottom)) rect = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height); else if (all && (pos == BevelBorder.Left)) rect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - 1); switch (pos) { case BevelBorder.Left: { x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height; x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1; break; } case BevelBorder.Top: { x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1; x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1; break; } case BevelBorder.Right: { x1 = rect.Left + rect.Width - 2; y1 = rect.Top; w1 = 1; h1 = rect.Height; x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1; break; } case BevelBorder.Bottom: { x1 = rect.Left; y1 = rect.Top + rect.Height - 2; w1 = rect.Width; h1 = 1; x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1; break; } } } else { switch (pos) { case BevelBorder.Left: { x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height; break; } case BevelBorder.Top: { x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1; break; } case BevelBorder.Right: { x1 = rect.Left + rect.Width - 1; y1 = rect.Top; w1 = 1; h1 = rect.Height; break; } case BevelBorder.Bottom: { x1 = rect.Left; y1 = rect.Top + rect.Height - 1; w1 = rect.Width; h1 = 1; break; } } } switch (Style) { case BevelStyle.Bumped: { renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c1); renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c2); break; } case BevelStyle.Etched: { renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c2); renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c1); break; } case BevelStyle.Raised: { Color c = c1; if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c1; else c = c2; renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c); break; } case BevelStyle.Lowered: { Color c = c1; if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c2; else c = c1; renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c); break; } default: { renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c3); break; } } }