コード例 #1
0
ファイル: Window.cs プロジェクト: GodLesZ/svn-dump
		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);
			}
		}
コード例 #2
0
ファイル: ContextMenu.cs プロジェクト: GodLesZ/svn-dump
		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);
				}
			}
		}
コード例 #3
0
ファイル: Control.cs プロジェクト: GodLesZ/svn-dump
		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();
			}
		}
コード例 #4
0
ファイル: Control.cs プロジェクト: GodLesZ/svn-dump
		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);
		}
コード例 #5
0
ファイル: TextBox.cs プロジェクト: hakanaku2009/svn-dump
        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 == ETextBoxMode.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));
                }
            }
        }
コード例 #6
0
ファイル: Control.cs プロジェクト: GodLesZ/svn-dump
		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);
				}
			}
		}
コード例 #7
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);
            }
        }
コード例 #8
0
ファイル: ComboBox.cs プロジェクト: GodLesZ/svn-dump
		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));
			}
		}
コード例 #9
0
ファイル: ContextMenu.cs プロジェクト: hakanaku2009/svn-dump
        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);
                }
            }
        }
コード例 #10
0
ファイル: Bevel.cs プロジェクト: GodLesZ/svn-dump
		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;
					}
			}
		}
コード例 #11
0
ファイル: Bevel.cs プロジェクト: hakanaku2009/svn-dump
        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;
            }
            }
        }