public override void CreateShape() { base.CreateShape(); switch (buttonType) { default: case CaptionButtonType.Close: buttonDescriptor = ShapeDescriptor.ComputeShape(this, Shape.Rectangle); crossDescriptor = ShapeDescriptor.Join( Shapes.DrawLine(4, Color.AntiqueWhite, crossTopLeftAbsolutePosition, crossTopLeftAbsolutePosition + new Vector2(DefaultCrossWidth, DefaultCrossWidth)), Shapes.DrawLine(4, Color.AntiqueWhite, crossTopLeftAbsolutePosition + new Vector2(0, DefaultCrossWidth), crossTopLeftAbsolutePosition + new Vector2(DefaultCrossWidth, 0) ) ); buttonDescriptor.Depth = depth; crossDescriptor.Depth = Depth.AsChildOf(depth); shapeDescriptors[0] = buttonDescriptor; shapeDescriptors[1] = crossDescriptor; break; } }
public override void UpdateShape() { switch (buttonType) { default: case CaptionButtonType.Close: if (buttonDescriptor != null) { buttonDescriptor.UpdateShape(ShapeDescriptor.ComputeShape(this, Shape.Rectangle)); } if (crossDescriptor != null) { crossDescriptor.UpdateShape(ShapeDescriptor.Join( Shapes.DrawLine(4, Color.AntiqueWhite, crossTopLeftAbsolutePosition, crossTopLeftAbsolutePosition + new Vector2(DefaultCrossWidth, DefaultCrossWidth)), Shapes.DrawLine(4, Color.AntiqueWhite, crossTopLeftAbsolutePosition + new Vector2(0, DefaultCrossWidth), crossTopLeftAbsolutePosition + new Vector2(DefaultCrossWidth, 0) )) ); } break; } }
/// <summary> /// Draws a right trapezoidal outline. /// </summary> /// <param name="position">The position.</param> /// <param name="size">The size.</param> /// <param name="triangleWidth">Width of the triangle.</param> /// <param name="isTriangleUpside">Ff set to <c>true</c> the triangle will be upside.</param> /// <param name="color">The color.</param> /// <param name="borderSize">Size of the border.</param> /// <param name="borderColor">Color of the border.</param> /// <param name="style">The style.</param> /// <param name="rectangleBorders">The rectangle borders.</param> /// <param name="triangleBorders">The triangle borders.</param> /// <returns>A right trapezoidal outline ShapeDescriptor object.</returns> public static ShapeDescriptor DrawRightTrapezoidalOutline(Vector2 position, Size size, int triangleWidth, bool isTriangleUpside, Color color, int borderSize, Color borderColor, BorderStyle style, Border rectangleBorders, Border triangleBorders) { Vector2 topLeft = position; Size innerSize = new Size(size.Width - borderSize, size.Height - borderSize); ShapeDescriptor sTriangleSide = ShapeDescriptor.Empty; ShapeDescriptor sTriangleBase = ShapeDescriptor.Empty; ShapeDescriptor sRectangleOutline = DrawRectangularOutline(topLeft, size, borderSize, borderColor, style, rectangleBorders); if (isTriangleUpside) { if ((triangleBorders & Border.Right) == Border.Right) { sTriangleSide = DrawLine(borderSize, Color.FromArgb(255, ColorOperator.Scale(borderColor, lightShadeFactor)), new Vector2(topLeft.X + size.Width, position.Y + (borderSize / 2)), new Vector2(topLeft.X + size.Width + triangleWidth, topLeft.Y + size.Height - (borderSize / 2))); } if ((triangleBorders & Border.Bottom) == Border.Bottom) { sTriangleBase = DrawRectangle(new Vector2(topLeft.X + size.Width, topLeft.Y + size.Height - borderSize), new Size(triangleWidth, borderSize), Color.FromArgb(255, ColorOperator.Scale(borderColor, darkShadeFactor))); } } else { if ((triangleBorders & Border.Left) == Border.Left) { sTriangleSide = DrawLine(borderSize, Color.FromArgb(255, ColorOperator.Scale(borderColor, darkShadeFactor)), new Vector2(topLeft.X + innerSize.Width, position.Y + size.Height - (borderSize / 2)), new Vector2(topLeft.X + innerSize.Width + triangleWidth, position.Y + (borderSize / 2))); } if ((triangleBorders & Border.Top) == Border.Top) { sTriangleBase = DrawRectangle(new Vector2(topLeft.X + innerSize.Width - borderSize, topLeft.Y), new Size(triangleWidth, borderSize), Color.FromArgb(255, ColorOperator.Scale(borderColor, lightShadeFactor))); } } return(ShapeDescriptor.Join(sRectangleOutline, sTriangleSide, sTriangleBase)); }
public static ShapeDescriptor DrawFullRectangle(Vector2 position, Size size, Color color, ShadingMode shadeMode, int borderSize, Color borderColor, BorderStyle style, Border borders) { return(ShapeDescriptor.Join( DrawRectangle(new Vector2(position.X + borderSize, position.Y + borderSize), new Size(size.Width - borderSize * 2, size.Height - borderSize * 2), color, shadeMode), DrawRectangularOutline(position, size, borderSize, borderColor, style, borders))); }
/// <summary> /// This methods draws a trapezoid whose 90° angle is in the right side. /// </summary> /// <param name="position">The topLeft point of the trapezoid</param> /// <param name="size">The <b>whole size</b> of the trapezoid</param> /// <param name="triangleWidth">The extra width of the greater base side</param> /// <param name="isTriangleUpside">If the triangle part is to be drawn upside</param> /// <param name="isShaded">If shading is to be applied to the trapezoid polygons</param> /// <param name="color">Color of the trapezoid's inner area. The specified ShadeVertices /// delegate will then proceed to create a shaded version.</param> /// <param name="borderSize">Size in pixels of the border.</param> /// <param name="borderColor">Average color of the border.</param> /// <param name="rectangleBorders">Which borders of the rectangular part of the outline to draw.</param> /// <param name="triangleBorders">Which borders of the triangular part of the outline to draw.</param> /// <param name="shadeMode">ShadeVertices delegate used.</param> /// <returns>A Trapezoidal ShapeDescriptor object.</returns> public static ShapeDescriptor DrawFullRightTrapezoid(Vector2 position, Size size, int triangleWidth, bool isTriangleUpside, Color color, int borderSize, Color borderColor, BorderStyle style, Border rectangleBorders, Border triangleBorders, ShadingMode shadeMode) { ShapeDescriptor sTrapezoid = DrawRightTrapezoid(position, size, triangleWidth, isTriangleUpside, color, borderSize, shadeMode); ShapeDescriptor sOutline = DrawRightTrapezoidalOutline(position, size, triangleWidth, isTriangleUpside, color, borderSize, borderColor, style, rectangleBorders, triangleBorders); return(ShapeDescriptor.Join(sTrapezoid, sOutline)); }
public static ShapeDescriptor DrawRectangularOutline(Vector2 position, Size size, Color borderTopAndLeft, Color borderBottomAndRight, int borderSize, Border borders) { ShapeDescriptor vBorderTop = ShapeDescriptor.Empty; ShapeDescriptor vBorderSideL = ShapeDescriptor.Empty; ShapeDescriptor vBorderSideR = ShapeDescriptor.Empty; ShapeDescriptor vBorderBottom = ShapeDescriptor.Empty; Vector2 innerPositionTopLeft = new Vector2( position.X + borderSize, position.Y + borderSize); Vector2 borderPositionTopRight = new Vector2( position.X + size.Width - borderSize, position.Y); Vector2 borderPositionBottomLeft = new Vector2( position.X, position.Y + size.Height - borderSize); Size borderTop = new Size(size.Width, borderSize); Size borderSide = new Size(borderSize, size.Height); if ((borders & Border.Top) != 0) { vBorderTop = DrawRectangle( position, borderTop, borderTopAndLeft); } if ((borders & Border.Left) != 0) { vBorderSideL = DrawRectangle( position, borderSide, borderTopAndLeft); } if ((borders & Border.Right) != 0) { vBorderSideR = DrawRectangle( borderPositionTopRight, borderSide, borderBottomAndRight); } if ((borders & Border.Bottom) != 0) { vBorderBottom = DrawRectangle( borderPositionBottomLeft, borderTop, borderBottomAndRight); } return(ShapeDescriptor.Join(vBorderTop, vBorderSideL, vBorderSideR, vBorderBottom)); }
ShapeDescriptor PreCompute(ref List <ISpriteControl> newSprites) { List <ShapeDescriptor> shapeDescriptors = new List <ShapeDescriptor>(); foreach (BaseControl ctl in PreOrderVisible) { if (ctl.IsVisible) { if (ctl is ISpriteControl) { newSprites.Add(ctl as ISpriteControl); } if (ctl is IRenderableControl) { IRenderableControl rCtl = ctl as IRenderableControl; if (rCtl.Shape == Shape.None) { continue; } else { rCtl.CreateShape(); shapeDescriptors.AddRange(rCtl.ShapeDescriptors); } } } } GenerateRenderSteps(shapeDescriptors, newSprites); //foreach (ShapeDescriptor shapeDescriptor in vertexDescriptors) //{ // shapeDescriptor.ArrayOffset = vIndex; // vIndex += shapeDescriptor.Vertices.Length; // numPrimitives += shapeDescriptor.NumPrimitives; // sb.AppendLine(string.Format("{0}.{1}.{2}", shapeDescriptor.Depth.WindowLayer, // shapeDescriptor.Depth.ComponentLayer, shapeDescriptor.Depth.ZOrder)); //} return(ShapeDescriptor.Join(shapeDescriptors.ToArray())); }