Exemple #1
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {

			if (mode == EButtonMode.PushButton && pushed) {
				SkinLayer l = Skin.Layers[lrButton];
				renderer.DrawLayer(l, rect, l.States.Pressed.Color, l.States.Pressed.Index);
				if (l.States.Pressed.Overlay) {
					renderer.DrawLayer(l, rect, l.Overlays.Pressed.Color, l.Overlays.Pressed.Index);
				}
			} else {
				base.DrawControl(renderer, rect, gameTime);
			}

			SkinLayer layer = Skin.Layers[lrButton];
			SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
			Color col = Color.White;
			int ox = 0;
			int oy = 0;

			if (ControlState == EControlState.Pressed) {
				if (layer.Text != null)
					col = layer.Text.Colors.Pressed;
				ox = 1;
				oy = 1;
			}
			if (glyph != null) {
				Margins cont = layer.ContentMargins;
				Rectangle r = new Rectangle(rect.Left + cont.Left,
											rect.Top + cont.Top,
											rect.Width - cont.Horizontal,
											rect.Height - cont.Vertical);
				renderer.DrawGlyph(glyph, r);
			} else {
				renderer.DrawString(this, layer, Text, rect, true, ox, oy);
			}
		}
Exemple #2
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			//base.DrawControl(renderer, rect, gameTime);

			SkinLayer s = new SkinLayer(Skin.Layers[0]);
			s.Text.Alignment = alignment;
			renderer.DrawString(this, s, Text, rect, true, 0, 0, ellipsis);
		}
Exemple #3
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			SkinLayer l1 = Skin.Layers["Control"];
			SkinLayer l2 = Skin.Layers["Selection"];
			rs = new Rectangle[Items.Count];

			renderer.DrawLayer(this, l1, rect, EControlState.Enabled);

			int prev = l1.ContentMargins.Left;
			for (int i = 0; i < Items.Count; i++) {
				MenuItem mi = Items[i];

				int tw = (int)l1.Text.Font.Resource.MeasureString(mi.Text).X + l1.ContentMargins.Horizontal;
				rs[i] = new Rectangle(rect.Left + prev, rect.Top + l1.ContentMargins.Top, tw, Height - l1.ContentMargins.Vertical);
				prev += tw;

				if (ItemIndex != i) {
					if (mi.Enabled && Enabled) {
						renderer.DrawString(this, l1, mi.Text, rs[i], EControlState.Enabled, false);
					} else {
						renderer.DrawString(this, l1, mi.Text, rs[i], EControlState.Disabled, false);
					}
				} else {
					if (Items[i].Enabled && Enabled) {
						renderer.DrawLayer(this, l2, rs[i], EControlState.Enabled);
						renderer.DrawString(this, l2, mi.Text, rs[i], EControlState.Enabled, false);
					} else {
						renderer.DrawLayer(this, l2, rs[i], EControlState.Disabled);
						renderer.DrawString(this, l2, mi.Text, rs[i], EControlState.Disabled, false);
					}
				}
			}
		}
Exemple #4
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			if (Border != EBevelBorder.None && Style != EBevelStyle.None) {
				if (Border != EBevelBorder.All) {
					DrawPart(renderer, rect, Border, Style, false);
				} else {
					DrawPart(renderer, rect, EBevelBorder.Left, Style, true);
					DrawPart(renderer, rect, EBevelBorder.Top, Style, true);
					DrawPart(renderer, rect, EBevelBorder.Right, Style, true);
					DrawPart(renderer, rect, EBevelBorder.Bottom, Style, true);
				}
			}
		}
Exemple #5
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			SkinLayer layer = Skin.Layers["Control"];
			SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
			Color col = (layer.Text != null) ? layer.Text.Colors.Enabled : Color.White;
			Point offset = new Point(layer.Text.OffsetX, layer.Text.OffsetY);

			renderer.DrawLayer(this, layer, rect);

			if (font != null && Text != null && Text != "") {
				renderer.DrawString(this, layer, Text, new Rectangle(rect.Left, rect.Top + layer.ContentMargins.Top, rect.Width, Skin.ClientMargins.Top - layer.ContentMargins.Horizontal), false, offset.X, offset.Y, false);
			}
		}
Exemple #6
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			SkinLayer layer = Skin.Layers[lrChecked];
			SkinText font = Skin.Layers[lrChecked].Text;

			if (!state) {
				layer = Skin.Layers[lrCheckBox];
				font = Skin.Layers[lrCheckBox].Text;
			}

			rect.Width = layer.Width;
			rect.Height = layer.Height;
			Rectangle rc = new Rectangle(rect.Left + rect.Width + 4, rect.Y, Width - (layer.Width + 4), rect.Height);

			renderer.DrawLayer(this, layer, rect);
			renderer.DrawString(this, layer, Text, rc, false, 0, 0);
		}
Exemple #7
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			SkinLayer layer = type == EGroupBoxType.Normal ? Skin.Layers["Control"] : Skin.Layers["Flat"];
			SpriteFont font = (layer.Text != null && layer.Text.Font != null) ? layer.Text.Font.Resource : null;
			Color col = (layer.Text != null) ? layer.Text.Colors.Enabled : Color.White;
			Point offset = new Point(layer.Text.OffsetX, layer.Text.OffsetY);
			Vector2 size = font.MeasureString(Text);
			size.Y = font.LineSpacing;
			Rectangle r = new Rectangle(rect.Left, rect.Top + (int)(size.Y / 2), rect.Width, rect.Height - (int)(size.Y / 2));

			renderer.DrawLayer(this, layer, r);

			if (font != null && Text != null && Text != "") {
				Rectangle bg = new Rectangle(r.Left + offset.X, (r.Top - (int)(size.Y / 2)) + offset.Y, (int)size.X + layer.ContentMargins.Horizontal, (int)size.Y);
				renderer.DrawLayer(Manager.Skin.Controls["Control"].Layers[0], bg, new Color(64, 64, 64), 0);
				renderer.DrawString(this, layer, Text, new Rectangle(r.Left, r.Top - (int)(size.Y / 2), (int)(size.X), (int)size.Y), true, 0, 0, false);
			}
		}
Exemple #8
0
		private void DrawDetached(Control control, Renderer renderer, GameTime gameTime) {
			if (control.Controls != null) {
				foreach (Control c in control.Controls) {
					if (c.Detached && c.Visible) {
						c.DrawControls(renderer, new Rectangle(c.OriginLeft, c.OriginTop, c.OriginWidth, c.OriginHeight), gameTime, true);
					}
				}
			}
		}
Exemple #9
0
		private void DrawControls(Renderer renderer, Rectangle rect, GameTime gameTime, bool firstDetach) {
			renderer.Begin(EBlendingMode.Default);

			DrawingRect = rect;
			DrawControl(renderer, rect, gameTime);

			DrawEventArgs args = new DrawEventArgs();
			args.Rectangle = rect;
			args.Renderer = renderer;
			args.GameTime = gameTime;
			OnDraw(args);

			renderer.End();

			DrawChildControls(renderer, gameTime, firstDetach);
		}
Exemple #10
0
		private void DrawChildControls(Renderer renderer, GameTime gameTime, bool firstDetachedLevel) {
			if (controls != null) {
				foreach (Control c in controls) {
					// We skip detached controls for first level after root (they are rendered separately in Draw() method)
					if (((c.Root == c.Parent && !c.Detached) || c.Root != c.Parent) && AbsoluteRect.Intersects(c.AbsoluteRect) && c.visible) {
						Manager.GraphicsDevice.ScissorRectangle = GetClippingRect(c);

						Rectangle rect = new Rectangle(c.OriginLeft - root.AbsoluteLeft, c.OriginTop - root.AbsoluteTop, c.OriginWidth, c.OriginHeight);
						if (c.Root != c.Parent && ((!c.Detached && CheckDetached(c)) || firstDetachedLevel)) {
							rect = new Rectangle(c.OriginLeft, c.OriginTop, c.OriginWidth, c.OriginHeight);
							Manager.GraphicsDevice.ScissorRectangle = rect;
						}

						renderer.Begin(EBlendingMode.Default);
						c.DrawingRect = rect;
						c.DrawControl(renderer, rect, gameTime);

						DrawEventArgs args = new DrawEventArgs();
						args.Rectangle = rect;
						args.Renderer = renderer;
						args.GameTime = gameTime;
						c.OnDraw(args);
						renderer.End();

						c.DrawChildControls(renderer, gameTime, firstDetachedLevel);

						c.DrawOutline(renderer, true);
					}
				}
			}
		}
Exemple #11
0
		internal virtual void PrepareTexture(Renderer renderer, GameTime gameTime) {
			if (visible) {
				if (invalidated) {
					OnDrawTexture(new DrawEventArgs(renderer, new Rectangle(0, 0, OriginWidth, OriginHeight), gameTime));

					if (target == null || target.Width < OriginWidth || target.Height < OriginHeight) {
						if (target != null) {
							target.Dispose();
							target = null;
						}

						int w = OriginWidth + (Manager.TextureResizeIncrement - (OriginWidth % Manager.TextureResizeIncrement));
						int h = OriginHeight + (Manager.TextureResizeIncrement - (OriginHeight % Manager.TextureResizeIncrement));

						if (h > Manager.TargetHeight)
							h = Manager.TargetHeight;
						if (w > Manager.TargetWidth)
							w = Manager.TargetWidth;

						target = CreateRenderTarget(w, h);
					}

					if (target != null) {
						Manager.GraphicsDevice.SetRenderTarget(target);
						target.GraphicsDevice.Clear(backColor);

						Rectangle rect = new Rectangle(0, 0, OriginWidth, OriginHeight);
						DrawControls(renderer, rect, gameTime, false);

						Manager.GraphicsDevice.SetRenderTarget(null);
					}
					invalidated = false;
				}
			}
		}
Exemple #12
0
		/// <summary>
		/// Initializes the controls manager.
		/// </summary>    
		public override void Initialize() {
			base.Initialize();

			if (autoCreateRenderTarget) {
				if (renderTarget != null) {
					renderTarget.Dispose();
				}
				renderTarget = CreateRenderTarget();
			}

			GraphicsDevice.DeviceReset += new System.EventHandler<System.EventArgs>(GraphicsDevice_DeviceReset);

			input.Initialize();
			renderer = new Renderer(this);
			SetSkin(skinName);
		}
Exemple #13
0
		protected override void Dispose(bool disposing) {
			if (disposing) {
				this.disposing = true;

				// Recursively disposing all controls added to the manager and its child controls.
				if (controls != null) {
					int c = controls.Count;
					for (int i = 0; i < c; i++) {
						if (controls.Count > 0)
							controls[0].Dispose();
					}
				}

				// Disposing all components added to manager.
				if (components != null) {
					int c = components.Count;
					for (int i = 0; i < c; i++) {
						if (components.Count > 0)
							components[0].Dispose();
					}
				}

				if (content != null) {
					content.Unload();
					content.Dispose();
					content = null;
				}

				if (renderer != null) {
					renderer.Dispose();
					renderer = null;
				}
				if (input != null) {
					input.Dispose();
					input = null;
				}
			}
			base.Dispose(disposing);
		}
Exemple #14
0
		internal override void Render(Renderer renderer, GameTime gameTime) {
			if (Visible && Shadow) {
				SkinControl c = Manager.Skin.Controls[skShadow];
				SkinLayer l = c.Layers[lrShadow];

				Color cl = Color.FromNonPremultiplied(l.States.Enabled.Color.R, l.States.Enabled.Color.G, l.States.Enabled.Color.B, Alpha);

				renderer.Begin(EBlendingMode.Default);
				renderer.DrawLayer(l, new Rectangle(Left - c.OriginMargins.Left, Top - c.OriginMargins.Top, Width + c.OriginMargins.Horizontal, Height + c.OriginMargins.Vertical), cl, 0);
				renderer.End();
			}
			base.Render(renderer, gameTime);
		}
Exemple #15
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			base.DrawControl(renderer, rect, gameTime);
		}
Exemple #16
0
		public DrawEventArgs(Renderer renderer, Rectangle rectangle, GameTime gameTime) {
			Renderer = renderer;
			Rectangle = rectangle;
			GameTime = gameTime;
		}
Exemple #17
0
		protected virtual void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			if (backColor != UndefinedColor && backColor != Color.Transparent) {
				renderer.Draw(Manager.Skin.Images["Control"].Resource, rect, backColor);
			}
			renderer.DrawLayer(this, skin.Layers[0], rect);
		}
Exemple #18
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			SkinLayer l1 = Skin.Layers["Control"];
			SkinLayer l2 = Skin.Layers["Header"];
			Color col = this.Color != UndefinedColor ? this.Color : Color.White;

			Rectangle r1 = new Rectangle(rect.Left, rect.Top + l1.OffsetY, rect.Width, rect.Height - l1.OffsetY);
			if (tabPages.Count <= 0) {
				r1 = rect;
			}

			base.DrawControl(renderer, r1, gameTime);

			if (tabPages.Count > 0) {

				Rectangle prev = new Rectangle(rect.Left, rect.Top + l2.OffsetY, 0, l2.Height);
				for (int i = 0; i < tabPages.Count; i++) {
					SpriteFont font = l2.Text.Font.Resource;
					Margins margins = l2.ContentMargins;
					Point offset = new Point(l2.OffsetX, l2.OffsetY);
					if (i > 0)
						prev = tabPages[i - 1].HeaderRect;

					tabPages[i].CalcRect(prev, font, margins, offset, i == 0);
				}

				for (int i = tabPages.Count - 1; i >= 0; i--) {
					int li = tabPages[i].Enabled ? l2.States.Enabled.Index : l2.States.Disabled.Index;
					Color lc = tabPages[i].Enabled ? l2.Text.Colors.Enabled : l2.Text.Colors.Disabled;
					if (i == hoveredIndex) {
						li = l2.States.Hovered.Index;
						lc = l2.Text.Colors.Hovered;
					}


					Margins m = l2.ContentMargins;
					Rectangle rx = tabPages[i].HeaderRect;
					Rectangle sx = new Rectangle(rx.Left + m.Left, rx.Top + m.Top, rx.Width - m.Horizontal, rx.Height - m.Vertical);
					if (i != selectedIndex) {
						renderer.DrawLayer(l2, rx, col, li);
						renderer.DrawString(l2.Text.Font.Resource, tabPages[i].Text, sx, lc, l2.Text.Alignment);
					}
				}

				Margins mi = l2.ContentMargins;
				Rectangle ri = tabPages[selectedIndex].HeaderRect;
				Rectangle si = new Rectangle(ri.Left + mi.Left, ri.Top + mi.Top, ri.Width - mi.Horizontal, ri.Height - mi.Vertical);
				renderer.DrawLayer(l2, ri, col, l2.States.Focused.Index);
				renderer.DrawString(l2.Text.Font.Resource, tabPages[selectedIndex].Text, si, l2.Text.Colors.Focused, l2.Text.Alignment, l2.Text.OffsetX, l2.Text.OffsetY, false);
			}
		}
Exemple #19
0
		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));
			}
		}
Exemple #20
0
		private void DrawPart(Renderer renderer, Rectangle rect, EBevelBorder pos, EBevelStyle 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 == EBevelStyle.Bumped || style == EBevelStyle.Etched) {
				if (all && (pos == EBevelBorder.Top || pos == EBevelBorder.Bottom)) {
					rect = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height);
				} else if (all && (pos == EBevelBorder.Left)) {
					rect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - 1);
				}
				switch (pos) {
					case EBevelBorder.Left: {
							x1 = rect.Left;
							y1 = rect.Top;
							w1 = 1;
							h1 = rect.Height;
							x2 = x1 + 1;
							y2 = y1;
							w2 = w1;
							h2 = h1;
							break;
						}
					case EBevelBorder.Top: {
							x1 = rect.Left;
							y1 = rect.Top;
							w1 = rect.Width;
							h1 = 1;
							x2 = x1;
							y2 = y1 + 1;
							w2 = w1;
							h2 = h1;
							break;
						}
					case EBevelBorder.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 EBevelBorder.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 EBevelBorder.Left: {
							x1 = rect.Left;
							y1 = rect.Top;
							w1 = 1;
							h1 = rect.Height;
							break;
						}
					case EBevelBorder.Top: {
							x1 = rect.Left;
							y1 = rect.Top;
							w1 = rect.Width;
							h1 = 1;
							break;
						}
					case EBevelBorder.Right: {
							x1 = rect.Left + rect.Width - 1;
							y1 = rect.Top;
							w1 = 1;
							h1 = rect.Height;
							break;
						}
					case EBevelBorder.Bottom: {
							x1 = rect.Left;
							y1 = rect.Top + rect.Height - 1;
							w1 = rect.Width;
							h1 = 1;
							break;
						}
				}
			}

			switch (Style) {
				case EBevelStyle.Bumped: {
						renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c1);
						renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c2);
						break;
					}
				case EBevelStyle.Etched: {
						renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c2);
						renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c1);
						break;
					}
				case EBevelStyle.Raised: {
						Color c = c1;
						if (pos == EBevelBorder.Left || pos == EBevelBorder.Top)
							c = c1;
						else
							c = c2;

						renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c);
						break;
					}
				case EBevelStyle.Lowered: {
						Color c = c1;
						if (pos == EBevelBorder.Left || pos == EBevelBorder.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;
					}
			}
		}
Exemple #21
0
		internal virtual void Render(Renderer renderer, GameTime gameTime) {
			if (visible && target != null) {
				bool draw = true;

				if (draw) {
					renderer.Begin(EBlendingMode.Default);
					renderer.Draw(target, OriginLeft, OriginTop, new Rectangle(0, 0, OriginWidth, OriginHeight), Color.FromNonPremultiplied(255, 255, 255, Alpha));
					renderer.End();

					DrawDetached(this, renderer, gameTime);

					DrawOutline(renderer, false);
				}
			}
		}
Exemple #22
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			RecalcParams();

			SkinLayer bg = Skin.Layers[strRail];
			renderer.DrawLayer(bg, rect, Color.White, bg.States.Enabled.Index);
		}
Exemple #23
0
		private void DrawOutline(Renderer renderer, bool child) {
			if (!OutlineRect.IsEmpty) {
				Rectangle r = OutlineRect;
				if (child) {
					r = new Rectangle(OutlineRect.Left + (parent.AbsoluteLeft - root.AbsoluteLeft), OutlineRect.Top + (parent.AbsoluteTop - root.AbsoluteTop), OutlineRect.Width, OutlineRect.Height);
				}

				Texture2D t = Manager.Skin.Controls["Control.Outline"].Layers[0].Image.Resource;

				int s = resizerSize;
				Rectangle r1 = new Rectangle(r.Left + leftModifier, r.Top + topModifier, r.Width, s);
				Rectangle r2 = new Rectangle(r.Left + leftModifier, r.Top + s + topModifier, resizerSize, r.Height - (2 * s));
				Rectangle r3 = new Rectangle(r.Right - s + leftModifier, r.Top + s + topModifier, s, r.Height - (2 * s));
				Rectangle r4 = new Rectangle(r.Left + leftModifier, r.Bottom - s + topModifier, r.Width, s);

				Color c = Manager.Skin.Controls["Control.Outline"].Layers[0].States.Enabled.Color;

				renderer.Begin(EBlendingMode.Default);
				if ((ResizeEdge & EAnchors.Top) == EAnchors.Top || !partialOutline)
					renderer.Draw(t, r1, c);
				if ((ResizeEdge & EAnchors.Left) == EAnchors.Left || !partialOutline)
					renderer.Draw(t, r2, c);
				if ((ResizeEdge & EAnchors.Right) == EAnchors.Right || !partialOutline)
					renderer.Draw(t, r3, c);
				if ((ResizeEdge & EAnchors.Bottom) == EAnchors.Bottom || !partialOutline)
					renderer.Draw(t, r4, c);
				renderer.End();
			} else if (DesignMode && Focused) {
				Rectangle r = ControlRect;
				if (child) {
					r = new Rectangle(r.Left + (parent.AbsoluteLeft - root.AbsoluteLeft), r.Top + (parent.AbsoluteTop - root.AbsoluteTop), r.Width, r.Height);
				}

				Texture2D t = Manager.Skin.Controls["Control.Outline"].Layers[0].Image.Resource;

				int s = resizerSize;
				Rectangle r1 = new Rectangle(r.Left + leftModifier, r.Top + topModifier, r.Width, s);
				Rectangle r2 = new Rectangle(r.Left + leftModifier, r.Top + s + topModifier, resizerSize, r.Height - (2 * s));
				Rectangle r3 = new Rectangle(r.Right - s + leftModifier, r.Top + s + topModifier, s, r.Height - (2 * s));
				Rectangle r4 = new Rectangle(r.Left + leftModifier, r.Bottom - s + topModifier, r.Width, s);

				Color c = Manager.Skin.Controls["Control.Outline"].Layers[0].States.Enabled.Color;

				renderer.Begin(EBlendingMode.Default);
				renderer.Draw(t, r1, c);
				renderer.Draw(t, r2, c);
				renderer.Draw(t, r3, c);
				renderer.Draw(t, r4, c);
				renderer.End();
			}
		}
Exemple #24
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			RecalcParams();

			SkinLayer p = Skin.Layers["Control"];
			SkinLayer l = Skin.Layers["Scale"];

			float ratio = 0.66f;
			int h = (int)(ratio * rect.Height);
			int t = rect.Top + (Height - h) / 2;

			float px = ((float)value / (float)range);
			int w = (int)Math.Ceiling(px * (rect.Width - p.ContentMargins.Horizontal - btnSlider.Width)) + 2;

			if (w < l.SizingMargins.Vertical)
				w = l.SizingMargins.Vertical;
			if (w > rect.Width - p.ContentMargins.Horizontal)
				w = rect.Width - p.ContentMargins.Horizontal;

			Rectangle r1 = new Rectangle(rect.Left + p.ContentMargins.Left, t + p.ContentMargins.Top, w, h - p.ContentMargins.Vertical);

			base.DrawControl(renderer, new Rectangle(rect.Left, t, rect.Width, h), gameTime);
			if (scale)
				renderer.DrawLayer(this, l, r1);
		}
Exemple #25
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			int x = rect.Left;
			int y = rect.Top;
			int w = rect.Width;
			int h = rect.Height;
			int s = bevelMargin;

			if (bevelBorder != EBevelBorder.None) {
				if (bevelStyle != EBevelStyle.Flat) {
					s += 2;
				} else {
					s += 1;
				}

				if (bevelBorder == EBevelBorder.Left || bevelBorder == EBevelBorder.All) {
					x += s;
					w -= s;
				}
				if (bevelBorder == EBevelBorder.Top || bevelBorder == EBevelBorder.All) {
					y += s;
					h -= s;
				}
				if (bevelBorder == EBevelBorder.Right || bevelBorder == EBevelBorder.All) {
					w -= s;
				}
				if (bevelBorder == EBevelBorder.Bottom || bevelBorder == EBevelBorder.All) {
					h -= s;
				}
			}

			base.DrawControl(renderer, new Rectangle(x, y, w, h), gameTime);
		}
Exemple #26
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			CheckLayer(Skin, "Control");
			CheckLayer(Skin, "Scale");

			base.DrawControl(renderer, rect, gameTime);

			if (Value > 0 || mode == EProgressBarMode.Infinite) {
				SkinLayer p = Skin.Layers["Control"];
				SkinLayer l = Skin.Layers["Scale"];
				Rectangle r = new Rectangle(rect.Left + p.ContentMargins.Left,
											rect.Top + p.ContentMargins.Top,
											rect.Width - p.ContentMargins.Vertical,
											rect.Height - p.ContentMargins.Horizontal);

				float perc = ((float)value / range) * 100;
				int w = (int)((perc / 100) * r.Width);
				Rectangle rx;
				if (mode == EProgressBarMode.Default) {
					if (w < l.SizingMargins.Vertical)
						w = l.SizingMargins.Vertical;
					rx = new Rectangle(r.Left, r.Top, w, r.Height);
				} else {
					int s = r.Left + w;
					if (s > r.Left + p.ContentMargins.Left + r.Width - (r.Width / 4))
						s = r.Left + p.ContentMargins.Left + r.Width - (r.Width / 4);
					rx = new Rectangle(s, r.Top, (r.Width / 4), r.Height);
				}

				renderer.DrawLayer(this, l, rx);
			}
		}
Exemple #27
0
		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 != EControlState.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 == EControlState.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);
			}
		}
Exemple #28
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			int h = txtMain.Visible ? (txtMain.Height + 1) : 0;
			Rectangle r = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - h);
			base.DrawControl(renderer, r, gameTime);
		}
Exemple #29
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			base.DrawControl(renderer, rect, gameTime);

			SkinLayer l1 = Skin.Layers["Control"];
			SkinLayer l2 = Skin.Layers["Selection"];

			int vsize = LineHeight();
			Color col = Color.White;

			for (int i = 0; i < Items.Count; i++) {
				int mod = i > 0 ? 2 : 0;
				int left = rect.Left + l1.ContentMargins.Left + vsize;
				int h = vsize - mod - (i < (Items.Count - 1) ? 1 : 0);
				int top = rect.Top + l1.ContentMargins.Top + (i * vsize) + mod;


				if (Items[i].Separated && i > 0) {
					Rectangle r = new Rectangle(left, rect.Top + l1.ContentMargins.Top + (i * vsize), LineWidth() - vsize + 4, 1);
					renderer.Draw(Manager.Skin.Controls["Control"].Layers[0].Image.Resource, r, l1.Text.Colors.Enabled);
				}
				if (ItemIndex != i) {
					if (Items[i].Enabled) {
						Rectangle r = new Rectangle(left, top, LineWidth() - vsize, h);
						renderer.DrawString(this, l1, Items[i].Text, r, false);
						col = l1.Text.Colors.Enabled;
					} else {
						Rectangle r = new Rectangle(left + l1.Text.OffsetX,
													top + l1.Text.OffsetY,
													LineWidth() - vsize, h);
						renderer.DrawString(l1.Text.Font.Resource, Items[i].Text, r, l1.Text.Colors.Disabled, l1.Text.Alignment);
						col = l1.Text.Colors.Disabled;
					}
				} else {
					if (Items[i].Enabled) {
						Rectangle rs = new Rectangle(rect.Left + l1.ContentMargins.Left,
													 top,
													 Width - (l1.ContentMargins.Horizontal - Skin.OriginMargins.Horizontal),
													 h);
						renderer.DrawLayer(this, l2, rs);

						Rectangle r = new Rectangle(left,
													top, LineWidth() - vsize, h);

						renderer.DrawString(this, l2, Items[i].Text, r, false);
						col = l2.Text.Colors.Enabled;
					} else {
						Rectangle rs = new Rectangle(rect.Left + l1.ContentMargins.Left,
													 top,
													 Width - (l1.ContentMargins.Horizontal - Skin.OriginMargins.Horizontal),
													 vsize);
						renderer.DrawLayer(l2, rs, l2.States.Disabled.Color, l2.States.Disabled.Index);

						Rectangle r = new Rectangle(left + l1.Text.OffsetX,
													top + l1.Text.OffsetY,
													LineWidth() - vsize, h);
						renderer.DrawString(l2.Text.Font.Resource, Items[i].Text, r, l2.Text.Colors.Disabled, l2.Text.Alignment);
						col = l2.Text.Colors.Disabled;
					}

				}

				if (Items[i].Image != null) {
					Rectangle r = new Rectangle(rect.Left + l1.ContentMargins.Left + 3,
												rect.Top + top + 3,
												LineHeight() - 6,
												LineHeight() - 6);
					renderer.Draw(Items[i].Image, r, Color.White);
				}

				if (Items[i].Items != null && Items[i].Items.Count > 0) {
					renderer.Draw(Manager.Skin.Images["Shared.ArrowRight"].Resource, rect.Left + LineWidth() - 4, rect.Top + l1.ContentMargins.Top + (i * vsize) + 8, col);
				}
			}
		}
Exemple #30
0
		protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime) {
			renderer.DrawLayer(this, Skin.Layers[0], rect);
			renderer.DrawString(this, Skin.Layers[0], Text, rect, true);
		}