protected override Line CreateLine(FillDirection direction, int extentOffset, int breadthOffset, int availableBreadth, RecyclerView.Recycler recycler, RecyclerView.State state, IndexPath nextVisibleItem, bool isNewGroup ) { var item = GetFlatItemIndex(nextVisibleItem); var view = recycler.GetViewForPosition(item, state); Debug.Assert(view is SelectorItem, "view is SelectorItem (we should never be given a group header)"); var size = AddViewAtOffset(view, direction, extentOffset, breadthOffset, availableBreadth); var physicalSize = size.LogicalToPhysicalPixels(); var breadth = (int)(ScrollOrientation == Orientation.Vertical ? physicalSize.Width : physicalSize.Height); return(new Line { NumberOfViews = 1, Extent = (int)(ScrollOrientation == Orientation.Vertical ? physicalSize.Height : physicalSize.Width), FirstItem = nextVisibleItem, LastItem = nextVisibleItem, Breadth = breadth }); }
void InitWholeFilledRange() { int row = 0; int rowCount = 0; int column = 0; int columnCount = 0; FillDirection fillDirection = _dragFillExtent.FillDirection; CellRange startRange = _dragFillExtent.StartRange; CellRange fillRange = _dragFillExtent.FillRange; switch (fillDirection) { case FillDirection.Left: case FillDirection.Right: row = startRange.Row; rowCount = startRange.RowCount; column = (fillDirection == FillDirection.Left) ? fillRange.Column : startRange.Column; columnCount = startRange.ColumnCount + fillRange.ColumnCount; break; default: row = (fillDirection == FillDirection.Up) ? fillRange.Row : startRange.Row; rowCount = startRange.RowCount + fillRange.RowCount; column = startRange.Column; columnCount = startRange.ColumnCount; break; } _wholeFillRange = new CellRange(row, column, rowCount, columnCount); }
public RptExportTemplateCell GetBeginHeaderCell(FillDirection direction) { if (Cells == null || Cells.Count == 0) { return(null); } RptExportTemplateCell cell = Cells[0]; if (direction == FillDirection.Vertical) { for (int i = 1; i < Cells.Count; i++) { if (Cells[i].ColumnIdx < cell.ColumnIdx) { cell = Cells[i]; } } return(cell); } for (int i = 1; i < Cells.Count; i++) { if (Cells[i].RowIdx < cell.RowIdx) { cell = Cells[i]; } } return(cell); }
public static bool Fill( Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { if (System.Environment.OSVersion.Platform != PlatformID.WinCE) { using (SolidBrush br = new SolidBrush(startColor)) { gr.FillRectangle(br, rc); } return true; } // 頂点の座標と色を指定 Win32Helper.TRIVERTEX[] tva = new Win32Helper.TRIVERTEX[2]; tva[0] = new Win32Helper.TRIVERTEX(rc.X, rc.Y, startColor); tva[1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Bottom, endColor); // どのTRIVERTEXの値を使用するかインデックスを指定 Win32Helper.GRADIENT_RECT[] gra = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1) }; // GradientFill関数の呼び出し IntPtr hdc = gr.GetHdc(); bool b = Win32Helper.GradientFill( hdc, tva, (uint)tva.Length, gra, (uint)gra.Length, (uint)fillDir); gr.ReleaseHdc(hdc); return b; }
/// <summary> /// This method wraps the PInvoke to GradientFill /// </summary> /// <param name="gr">The Graphics object we are filling</param> /// <param name="rc">The rectangle to fill</param> /// <param name="startColor">The starting color for the fill</param> /// <param name="endColor">The ending color for the fill</param> /// <param name="fillDir">The direction to fill</param> /// <returns>Returns true if the call to GradientFill succeeded; false otherwise.</returns> public static bool Fill( IntPtr hdc, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { // Initialize the data to be used in the call to GradientFill. Win32.TRIVERTEX[] tva = new Win32.TRIVERTEX[2]; tva[0] = new Win32.TRIVERTEX(rc.X, rc.Y, startColor); tva[1] = new Win32.TRIVERTEX(rc.Right, rc.Bottom, endColor); Win32.GRADIENT_RECT[] gra = new Win32.GRADIENT_RECT[] { new Win32.GRADIENT_RECT(0, 1) }; // PInvoke to GradientFill. bool b = Win32.GradientFill( hdc, tva, (uint)tva.Length, gra, (uint)gra.Length, (uint)fillDir); System.Diagnostics.Debug.Assert(b, string.Format( "GradientFill failed: {0}", System.Runtime.InteropServices.Marshal.GetLastWin32Error())); return(b); }
/// <summary> /// This method wraps the PInvoke to GradientFill /// </summary> /// <param name="gr">The Graphics object we are filling</param> /// <param name="rc">The rectangle to fill</param> /// <param name="startColor">The starting color for the fill</param> /// <param name="endColor">The ending color for the fill</param> /// <param name="fillDir">The direction to fill</param> /// <returns>Returns true if the call to GradientFill succeeded; false otherwise.</returns> public static bool Fill( IntPtr hdc, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { // Initialize the data to be used in the call to GradientFill. Win32.TRIVERTEX[] tva = new Win32.TRIVERTEX[2]; tva[0] = new Win32.TRIVERTEX(rc.X, rc.Y, startColor); tva[1] = new Win32.TRIVERTEX(rc.Right, rc.Bottom, endColor); Win32.GRADIENT_RECT[] gra = new Win32.GRADIENT_RECT[] { new Win32.GRADIENT_RECT(0, 1)}; // PInvoke to GradientFill. bool b = Win32.GradientFill( hdc, tva, (uint)tva.Length, gra, (uint)gra.Length, (uint)fillDir); System.Diagnostics.Debug.Assert(b, string.Format( "GradientFill failed: {0}", System.Runtime.InteropServices.Marshal.GetLastWin32Error())); return b; }
protected override Line CreateLine(FillDirection direction, int extentOffset, int breadthOffset, int availableBreadth, RecyclerView.Recycler recycler, RecyclerView.State state, IndexPath nextVisibleItem, bool isNewGroup ) { var item = GetFlatItemIndex(nextVisibleItem); var view = recycler.GetViewForPosition(item, state); if (!(view is SelectorItem)) { throw new InvalidOperationException($"Expected {nameof(SelectorItem)} but received {view?.GetType().ToString() ?? "<null>"}"); } var size = AddViewAtOffset(view, direction, extentOffset, breadthOffset, availableBreadth); var physicalSize = size.LogicalToPhysicalPixels(); var breadth = (int)(ScrollOrientation == Orientation.Vertical ? physicalSize.Width : physicalSize.Height); return(new Line { NumberOfViews = 1, Extent = (int)(ScrollOrientation == Orientation.Vertical ? physicalSize.Height : physicalSize.Width), FirstItem = nextVisibleItem, LastItem = nextVisibleItem, Breadth = breadth }); }
// This method wraps the PInvoke to GradientFill. // Parmeters: // gr - The Graphics object we are filling // rc - The rectangle to fill // startColor - The starting color for the fill // endColor - The ending color for the fill // fillDir - The direction to fill // // Returns true if the call to GradientFill succeeded; false // otherwise. internal static bool Fill( Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { // Initialize the data to be used in the call to GradientFill. user32.TRIVERTEX[] tva = new user32.TRIVERTEX[2]; tva[0] = new user32.TRIVERTEX(rc.X, rc.Y, startColor); tva[1] = new user32.TRIVERTEX(rc.Right, rc.Bottom, endColor); user32.GRADIENT_RECT[] gra = new user32.GRADIENT_RECT[] { new user32.GRADIENT_RECT(0, 1) }; // Get the hDC from the Graphics object. IntPtr hdc = gr.GetHdc(); // PInvoke to GradientFill. bool b; b = user32.GradientFill( hdc, tva, (uint)tva.Length, gra, (uint)gra.Length, (uint)fillDir); System.Diagnostics.Debug.Assert(b, string.Format( "GradientFill failed: {0}", System.Runtime.InteropServices.Marshal.GetLastWin32Error())); // Release the hDC from the Graphics object. gr.ReleaseHdc(hdc); return(b); }
public MarketPrices ReplaceNanFill(FillDirection method) { foreach (StockPrices stockprices in allPrices) stockprices.ReplaceNanFill(method); return this; }
public static void DrawVistaGradient(Graphics gr, Color aColor, Rectangle aRect, FillDirection aDir) { Rectangle dstrc = aRect; if (aDir == FillDirection.Vertical) { dstrc.Height /= 2; } else { dstrc.Width /= 2; } Rectangle rectangle2 = dstrc; if (aDir == FillDirection.Vertical) { rectangle2.Location = new Point(aRect.X, aRect.Y + (aRect.Height / 2)); } else { rectangle2.Location = new Point(aRect.X + (aRect.Width / 2), aRect.Y); } Color colorA = GetColorA(aColor); Color colorB = GetColorB(aColor); Color colorC = GetColorC(aColor); Color colorD = GetColorD(aColor); GradientColor gradientColor = new GradientColor(colorA, colorB, aDir); Fill(gr, dstrc, dstrc, gradientColor); GradientColor color6 = new GradientColor(colorC, colorD, aDir); Fill(gr, rectangle2, rectangle2, color6); }
public static bool Fill(Graphics gr, Rectangle rc, Color startColor, Color middleColor1, Color middleColor2, Color endColor, FillDirection fillDirection) { bool flag = (middleColor1 != Color.Transparent) | (middleColor2 != Color.Transparent); if (Environment.OSVersion.Platform != PlatformID.WinCE) { return FillManagedWithMiddle(gr, rc, startColor, middleColor1, middleColor2, endColor, fillDirection); } int num = 2; if (flag) { num += 2; } Win32Helper.TRIVERTEX[] pVertex = new Win32Helper.TRIVERTEX[num]; pVertex[0] = new Win32Helper.TRIVERTEX(rc.X, rc.Y, startColor); if (flag) { if (middleColor1 == Color.Transparent) { middleColor1 = middleColor2; } if (middleColor2 == Color.Transparent) { middleColor2 = middleColor1; } if (fillDirection == FillDirection.Horizontal) { pVertex[1] = new Win32Helper.TRIVERTEX(rc.X + (rc.Width / 2), rc.Bottom, middleColor1); pVertex[2] = new Win32Helper.TRIVERTEX(rc.X + (rc.Width / 2), rc.Y, middleColor2); } else { pVertex[1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Y + (rc.Height / 2), middleColor1); pVertex[2] = new Win32Helper.TRIVERTEX(rc.X, rc.Y + (rc.Height / 2), middleColor2); } } pVertex[num - 1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Bottom, endColor); Win32Helper.GRADIENT_RECT[] pMesh = null; if (flag) { pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1), new Win32Helper.GRADIENT_RECT(2, 3) }; } else { pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1) }; } IntPtr hdc = gr.GetHdc(); bool flag2 = false; try { flag2 = Win32Helper.GradientFill(hdc, pVertex, (uint) pVertex.Length, pMesh, (uint) pMesh.Length, (uint) fillDirection); gr.ReleaseHdc(hdc); } catch (Exception) { gr.ReleaseHdc(hdc); flag2 = FillManagedWithMiddle(gr, rc, startColor, middleColor1, middleColor2, endColor, fillDirection); } return flag2; }
public static void DrawVistaGradient(Graphics gr, Color aColor, Rectangle aRect, FillDirection aDir) { Color colorA = GetColorA(aColor); Color colorB = GetColorB(aColor); Color colorC = GetColorC(aColor); Color colorD = GetColorD(aColor); Fill(gr, aRect, colorA, colorB, colorC, colorD, aDir); }
protected void FillLine(FillDirection direction, string childKey, int y, int margina, int marginb) { if (FillDirection.LEFT == direction) { margina += childKey.Length - 1; } this.Buffer.FillLine(this.Parser.LineChar, y, margina, marginb); }
public void AddLine(Line newLine, FillDirection fillDirection) { if (fillDirection == FillDirection.Forward) { _lines.AddToBack(newLine); } else { _lines.AddToFront(newLine); Start -= newLine.Extent; } }
public StockPrices ReplaceNanFill(FillDirection method) { switch (method) { case FillDirection.Forward: return ForwardFill(); case FillDirection.Backward: return BackwardFill(); default: return this; } }
public static bool Fill( Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { // Get the hDC from the Graphics object. IntPtr hdc = gr.GetHdc(); bool b = Fill(hdc, rc, startColor, endColor, fillDir); // Release the hDC from the Graphics object. gr.ReleaseHdc(hdc); return b; }
public void RemoveTrailingLine(FillDirection fillDirection) { if (fillDirection == FillDirection.Forward) { var removed = _lines.RemoveFromFront(); //Move Start forward because we are removing a line from the start Start += removed.Extent; } else { _lines.RemoveFromBack(); } }
public static bool Fill( Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { // Get the hDC from the Graphics object. IntPtr hdc = gr.GetHdc(); bool b = Fill(hdc, rc, startColor, endColor, fillDir); // Release the hDC from the Graphics object. gr.ReleaseHdc(hdc); return(b); }
public void RemoveTrailingLine(FillDirection fillDirection) { if (fillDirection == FillDirection.Forward) { //Note: the Deque implementation used (https://github.com/StephenCleary/Deque/blob/master/src/Nito.Collections.Deque/Deque.cs) //doesn't appear to actually release the reference to the item on calling the RemoveFrom_() methods. //This isn't really a problem here, but precludes its use for storing, eg, views. var removed = _lines.RemoveFromFront(); //Move Start forward because we are removing a line from the start Start += removed.Extent; } else { _lines.RemoveFromBack(); } }
/// <summary> /// This method wraps the PInvoke to GradientFill. /// Returns true if the call to GradientFill succeeded; false /// otherwise. /// </summary> /// <param name="gr">The Graphics object we are filling</param> /// <param name="rc">The rectangle to fill</param> /// <param name="startColor">The starting color for the fill</param> /// <param name="endColor">The ending color for the fill</param> /// <param name="fillDir">The direction to fill</param> /// <returns>Returns true if the call to GradientFill succeeded</returns> public static bool Fill( Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { if (Environment.OSVersion.Platform == PlatformID.WinCE) { // Initialize the data to be used in the call to GradientFill. NativeMethods.TRIVERTEX[] tva = new NativeMethods.TRIVERTEX[2]; tva[0] = new NativeMethods.TRIVERTEX(rc.X, rc.Y, startColor); tva[1] = new NativeMethods.TRIVERTEX(rc.Right, rc.Bottom, endColor); NativeMethods.GRADIENT_RECT[] gra = new NativeMethods.GRADIENT_RECT[] { new NativeMethods.GRADIENT_RECT(0, 1) }; // Get the hDC from the Graphics object. IntPtr hdc = gr.GetHdc(); // PInvoke to GradientFill. bool b; b = NativeMethods.GradientFill( hdc, tva, (uint)tva.Length, gra, (uint)gra.Length, (uint)fillDir); System.Diagnostics.Debug.Assert(b, string.Format( "GradientFill failed: {0}", System.Runtime.InteropServices.Marshal.GetLastWin32Error())); // Release the hDC from the Graphics object. gr.ReleaseHdc(hdc); return(b); } else { using (SolidBrush brush = new SolidBrush(startColor)) gr.FillRectangle(brush, rc); return(false); } }
private Vector2Int GetFillMatrixIndex(Vector2Int position, FillDirection verticleDirection, FillDirection horizontalDirection) { Vector2Int matrixIndex = ConvertPositionToMatrixIndex(position); bool isTileEmpty = LevelController.instance.IsTileEmpty(matrixIndex); // for matrixIndex change int matrixVerticleChange = (verticleDirection == FillDirection.FillUp) ? -1 : 1; int matrixHorizontalChange = (horizontalDirection == FillDirection.FillRight) ? 1 : -1; //to prevent the infinite loop int maxLoopCount = 10; while (!isTileEmpty && maxLoopCount > 0) { //Check for no out of range if (matrixIndex.x == 1 && matrixVerticleChange == -1) { matrixVerticleChange = 1; } else if (matrixIndex.x == M - 2 && matrixVerticleChange == 1) { matrixVerticleChange = -1; } if (matrixIndex.y == 1 && matrixHorizontalChange == -1) { matrixHorizontalChange = 1; } else if (matrixIndex.y == N - 2 && matrixHorizontalChange == 1) { matrixHorizontalChange = -1; } matrixIndex.x += matrixVerticleChange; matrixIndex.y += matrixHorizontalChange; isTileEmpty = LevelController.instance.IsTileEmpty(matrixIndex); --maxLoopCount; } return(matrixIndex); }
public static bool Fill( Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { // 頂点の座標と色を指定 Win32Helper.TRIVERTEX[] tva = new Win32Helper.TRIVERTEX[2]; tva[0] = new Win32Helper.TRIVERTEX(rc.X, rc.Y, startColor); tva[1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Bottom, endColor); // どのTRIVERTEXの値を使用するかインデックスを指定 Win32Helper.GRADIENT_RECT[] gra = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1) }; // GradientFill関数の呼び出し IntPtr hdc = gr.GetHdc(); bool b = Win32Helper.GradientFill( hdc, tva, (uint)tva.Length, gra, (uint)gra.Length, (uint)fillDir); gr.ReleaseHdc(hdc); return b; }
/// <summary> /// Sets the direction of this StatBar, optionally changing the layout as well. /// </summary> /// <param name="direction">The direction of the StatBar</param> /// <param name="includeRectLayouts">Should the layout be flipped together with the StatBar direction</param> public void SetDirection(FillDirection direction, bool includeRectLayouts) { Axis oldAxis = axis; bool oldReverse = reverseValue; this.Direction = direction; if (!includeRectLayouts) { return; } if (axis != oldAxis) { RectTransformUtility.FlipLayoutAxes(transform as RectTransform, true, true); } if (reverseValue != oldReverse) { RectTransformUtility.FlipLayoutOnAxis(transform as RectTransform, (int)axis, true, true); } }
public static bool GradientFill(this Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { if (DesignMode.IsTrue) { using (var pen = new Pen(startColor)) { if (fillDir == FillDirection.LeftToRight) { for (var x = rc.Left; x < rc.Right; x++) { pen.Color = ColorEx.InterpolateLinear(startColor, endColor, x, 0, rc.Width); gr.DrawLine(pen, x, rc.Top, x, rc.Bottom - 1); } } if (fillDir == FillDirection.TopToBottom) { for (var y = rc.Top; y < rc.Bottom; y++) { pen.Color = ColorEx.InterpolateLinear(startColor, endColor, y, 0, rc.Height); gr.DrawLine(pen, rc.Left, y, rc.Right - 1, y); } } } return false; } var tva = new TRIVERTEX[2]; tva[0] = new TRIVERTEX(rc.X, rc.Y, startColor); tva[1] = new TRIVERTEX(rc.Right, rc.Bottom, endColor); var gra = new[] { new GRADIENT_RECT(0, 1) }; var hdc = gr.GetHdc(); var ret = NativeMethods.GradientFill(hdc, tva, (uint)tva.Length, gra, (uint)gra.Length, (uint)fillDir); gr.ReleaseHdc(hdc); return ret; }
public static void GradientFill(Graphics g, Rectangle rect, Color startColor, Color endColor, FillDirection fillDir) { TRIVERTEX[] vertex = new TRIVERTEX[] { new TRIVERTEX(rect.X, rect.Y, startColor), new TRIVERTEX(rect.Right, rect.Bottom, endColor) }; GRADIENT_RECT[] grect = new GRADIENT_RECT[] { new GRADIENT_RECT(0, 1) }; IntPtr hdc = g.GetHdc(); GradientFill(hdc, vertex, (uint)vertex.Length, grect, (uint)grect.Length, (uint)fillDir); g.ReleaseHdc(hdc); }
public Line GetLeadingLine(FillDirection fillDirection) { return(fillDirection == FillDirection.Forward ? GetLastLine() : GetFirstLine()); }
public static bool Fill(Graphics gr, Rectangle rc, Color startColor, Color middleColor1, Color middleColor2, Color endColor, int middleColor1Offset, int middleColor2Offset, FillDirection fillDirection) { bool flag = (middleColor1 != Color.Transparent) | (middleColor2 != Color.Transparent); if (Environment.OSVersion.Platform != PlatformID.WinCE) { return FillManagedWithMiddle(gr, rc, startColor, middleColor1, middleColor2, endColor, middleColor1Offset, middleColor2Offset, fillDirection); } int num = 2; if (flag) { if (middleColor1 == Color.Transparent) { middleColor1 = middleColor2; middleColor1Offset = middleColor2Offset; } if (middleColor2 == Color.Transparent) { middleColor2 = middleColor1; middleColor2Offset = middleColor1Offset; } if (middleColor1Offset == middleColor2Offset) { num += 2; } else { num += 4; } } Win32Helper.TRIVERTEX[] pVertex = new Win32Helper.TRIVERTEX[num]; int index = 0; pVertex[index++] = new Win32Helper.TRIVERTEX(rc.X, rc.Y, startColor); if (flag) { if (fillDirection == FillDirection.Horizontal) { int num3 = (rc.Width * middleColor1Offset) / 100; int num4 = (rc.Width * middleColor2Offset) / 100; pVertex[index++] = new Win32Helper.TRIVERTEX(rc.X + num3, rc.Bottom, middleColor1); if (middleColor1Offset != middleColor2Offset) { pVertex[index++] = new Win32Helper.TRIVERTEX(rc.X + num3, rc.Y, middleColor1); pVertex[index++] = new Win32Helper.TRIVERTEX(rc.X + num4, rc.Bottom, middleColor2); } pVertex[index++] = new Win32Helper.TRIVERTEX(rc.X + num4, rc.Y, middleColor2); } else { int num5 = (rc.Height * middleColor1Offset) / 100; int num6 = (rc.Height * middleColor2Offset) / 100; pVertex[index++] = new Win32Helper.TRIVERTEX(rc.Right, rc.Y + num5, middleColor1); if (middleColor1Offset != middleColor2Offset) { pVertex[index++] = new Win32Helper.TRIVERTEX(rc.X, rc.Y + num5, middleColor1); pVertex[index++] = new Win32Helper.TRIVERTEX(rc.Right, rc.Y + num6, middleColor2); } pVertex[index++] = new Win32Helper.TRIVERTEX(rc.X, rc.Y + num6, middleColor2); } } pVertex[index] = new Win32Helper.TRIVERTEX(rc.Right, rc.Bottom, endColor); Win32Helper.GRADIENT_RECT[] pMesh = null; if (flag) { if (middleColor1Offset != middleColor2Offset) { pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1), new Win32Helper.GRADIENT_RECT(2, 3), new Win32Helper.GRADIENT_RECT(4, 5) }; } else { pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1), new Win32Helper.GRADIENT_RECT(2, 3) }; } } else { pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1) }; } IntPtr hdc = gr.GetHdc(); bool flag2 = false; try { flag2 = Win32Helper.GradientFill(hdc, pVertex, (uint) pVertex.Length, pMesh, (uint) pMesh.Length, (uint) fillDirection); gr.ReleaseHdc(hdc); } catch (Exception) { gr.ReleaseHdc(hdc); FillManagedWithMiddle(gr, rc, startColor, middleColor1, middleColor2, endColor, middleColor1Offset, middleColor2Offset, fillDirection); flag2 = true; } return flag2; }
/// <summary> /// 渐变填充 /// </summary> /// <param name="gr"></param> /// <param name="rc"></param> /// <param name="startColor"></param> /// <param name="endColor"></param> /// <param name="fillDir"></param> /// <returns></returns> public static bool Fill(Graphics g, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { TRIVERTEX[] tva = new TRIVERTEX[2]; tva[0] = new TRIVERTEX(rc.X, rc.Y, startColor); tva[1] = new TRIVERTEX(rc.Right, rc.Bottom, endColor); GRADIENT_RECT[] gra = new GRADIENT_RECT[] { new GRADIENT_RECT(0, 1) }; IntPtr hdc = g.GetHdc(); bool InvokeResult = Win32.GradientFill(hdc, tva, (uint)tva.Length, gra, (uint)gra.Length, (uint)fillDir); if (!InvokeResult) { System.Diagnostics.Debug.Assert( InvokeResult, string.Format("GradientFill failed: {0}", System.Runtime.InteropServices.Marshal.GetLastWin32Error())); } g.ReleaseHdc(hdc); return(InvokeResult); }
/// <summary> /// 使用指定的渐变色和方向填充一个矩形 Fills the rectagle with gradient colors /// </summary> /// <param name="gx">Destination graphics</param> /// <param name="rc">Desctination rectangle</param> /// <param name="startColorValue">Starting color for gradient</param> /// <param name="endColorValue">End color for gradient</param> /// <param name="fillDirection">The direction of the gradient</param> public static void FillGradientRectangle(this Graphics gx, Rectangle rc, Color startColorValue, Color endColorValue, FillDirection fillDirection) { GradientFill.Fill( gx, rc, startColorValue, endColorValue, fillDirection); }
public static bool FillManagedWithMiddle(Graphics gr, Rectangle rc, Color startColor, Color middleColor1, Color middleColor2, Color endColor, int middleColor1Offset, int middleColor2Offset, FillDirection fillDirection) { if ((middleColor1 != Color.Transparent) | (middleColor2 != Color.Transparent)) { if (middleColor1 == Color.Transparent) { middleColor1 = middleColor2; middleColor1Offset = middleColor2Offset; } if (middleColor2 == Color.Transparent) { middleColor2 = middleColor1; middleColor2Offset = middleColor1Offset; } if (fillDirection == FillDirection.Horizontal) { int width = (rc.Width * middleColor1Offset) / 100; int num2 = (rc.Width * middleColor2Offset) / 100; Rectangle rectangle = new Rectangle(rc.X, rc.Y, width, rc.Height); FillManaged(gr, rectangle, startColor, middleColor1, fillDirection); if (middleColor1Offset != middleColor2Offset) { Rectangle rectangle2 = new Rectangle(rc.X + width, rc.Y, num2 - width, rc.Height); FillManaged(gr, rectangle2, middleColor1, middleColor2, fillDirection); } Rectangle rectangle3 = new Rectangle(rc.X + num2, rc.Y, rc.Width - num2, rc.Height); FillManaged(gr, rectangle3, middleColor2, endColor, fillDirection); } else { int height = (rc.Height * middleColor1Offset) / 100; int num4 = (rc.Height * middleColor2Offset) / 100; Rectangle rectangle4 = new Rectangle(rc.X, rc.Y, rc.Width, height); FillManaged(gr, rectangle4, startColor, middleColor1, fillDirection); if (middleColor1Offset != middleColor2Offset) { Rectangle rectangle5 = new Rectangle(rc.X, rc.Y + height, rc.Width, num4 - height); FillManaged(gr, rectangle5, middleColor1, middleColor2, fillDirection); } Rectangle rectangle6 = new Rectangle(rc.X, rc.Y + num4, rc.Width, rc.Height - num4); FillManaged(gr, rectangle6, middleColor2, endColor, fillDirection); } } else { FillManaged(gr, rc, startColor, endColor, fillDirection); } return true; }
protected override Line CreateLine(FillDirection direction, int extentOffset, int breadthOffset, int availableBreadth, RecyclerView.Recycler recycler, RecyclerView.State state, IndexPath nextVisibleItem, bool isNewGroup ) { var itemsInLine = ResolveMaximumItemsInLine(availableBreadth); var firstItemInLine = nextVisibleItem; //Find first item in line, since the item we are passed is the last if (direction == FillDirection.Back) { // We are recreating the last line of the group - it may be truncated (if the total items are not an even multiple // of the items-per-line). if (isNewGroup) { itemsInLine = XamlParent.GetItemsOnLastLine(firstItemInLine.Section, itemsInLine); } for (int i = 0; i < itemsInLine - 1; i++) { firstItemInLine = GetNextUnmaterializedItem(FillDirection.Back, firstItemInLine).Value; var isCorrectGroup = firstItemInLine.Section == nextVisibleItem.Section; if (!isCorrectGroup) { //TODO: fix bug that makes this happen (#47229) } Debug.Assert(isCorrectGroup, GetAssertMessage("First item should not be from a different group")); } } IndexPath lastItemInLine = firstItemInLine; IndexPath?currentItem = firstItemInLine; var availableWidth = ResolveAvailableWidth(availableBreadth); var availableHeight = ResolveAvailableHeight(availableBreadth); int usedBreadth = 0; for (int i = 0; i < itemsInLine; i++) { var view = recycler.GetViewForPosition(GetFlatItemIndex(currentItem.Value), state); Debug.Assert(view is SelectorItem, "view is SelectorItem (we should never be given a group header)"); //Add view before we measure it, this ensures that DP inheritances are correctly applied AddView(view, direction); var slotSize = new Windows.Foundation.Size(availableWidth, availableHeight).PhysicalToLogicalPixels(); var measuredSize = _layouter.MeasureChild(view, slotSize); var physicalMeasuredSize = measuredSize.LogicalToPhysicalPixels(); var measuredWidth = (int)physicalMeasuredSize.Width; var measuredHeight = (int)physicalMeasuredSize.Height; if (_implicitItemWidth == null) { //Set these values to dimensions of first materialised item _implicitItemWidth = measuredWidth; _implicitItemHeight = measuredHeight; availableWidth = ResolveAvailableWidth(availableBreadth); availableHeight = ResolveAvailableHeight(availableBreadth); itemsInLine = ResolveMaximumItemsInLine(availableBreadth); } LayoutChild(view, FillDirection.Forward, //We always lay out view 'top down' so that it is aligned correctly if its height is less than the line height direction == FillDirection.Forward ? extentOffset : extentOffset - ResolveItemExtent().Value, breadthOffset + usedBreadth, new Foundation.Size(width: slotSize.Width, height: slotSize.Height) ); usedBreadth += ResolveItemBreadth().Value; lastItemInLine = currentItem.Value; currentItem = GetNextUnmaterializedItem(FillDirection.Forward, currentItem); if (currentItem == null || currentItem.Value.Section != firstItemInLine.Section) { itemsInLine = i + 1; break; } } return(new Line { NumberOfViews = itemsInLine, Extent = ResolveItemExtent().Value, Breadth = usedBreadth, FirstItem = firstItemInLine, LastItem = lastItemInLine }); }
public IndexPath GetTrailingMaterializedItem(FillDirection fillDirection) { return(fillDirection == FillDirection.Forward ? GetFirstLine().FirstItem : GetLastLine().LastItem); }
public int GetLeadingEdge(FillDirection fillDirection) { return(fillDirection == FillDirection.Forward ? End : Start); }
public static void GradientFill(Graphics g, Rectangle rect, Color startColor, Color endColor, FillDirection fillDir) { TRIVERTEX[] vertex = new TRIVERTEX[] { new TRIVERTEX(rect.X,rect.Y,startColor), new TRIVERTEX(rect.Right,rect.Bottom,endColor) }; GRADIENT_RECT[] grect = new GRADIENT_RECT[] { new GRADIENT_RECT(0,1) }; IntPtr hdc = g.GetHdc(); GradientFill(hdc, vertex, (uint)vertex.Length, grect, (uint)grect.Length, (uint)fillDir); g.ReleaseHdc(hdc); }
public static bool FillManagedWithMiddle(Graphics gr, Rectangle rc, Color startColor, Color middleColor1, Color middleColor2, Color endColor, FillDirection fillDirection) { if ((middleColor1 != Color.Transparent) | (middleColor2 != Color.Transparent)) { if (middleColor1 == Color.Transparent) { middleColor1 = middleColor2; } if (middleColor2 == Color.Transparent) { middleColor2 = middleColor1; } if (fillDirection == FillDirection.Horizontal) { Rectangle rectangle = new Rectangle(rc.X, rc.Y, rc.Width / 2, rc.Height); FillManaged(gr, rectangle, startColor, middleColor1, fillDirection); Rectangle rectangle2 = new Rectangle(rc.X + (rc.Width / 2), rc.Y, rc.Width / 2, rc.Height); FillManaged(gr, rectangle2, middleColor2, endColor, fillDirection); } else { Rectangle rectangle3 = new Rectangle(rc.X, rc.Y, rc.Width, rc.Height / 2); FillManaged(gr, rectangle3, startColor, middleColor1, fillDirection); Rectangle rectangle4 = new Rectangle(rc.X, rc.Y + (rc.Height / 2), rc.Width, rc.Height / 2); FillManaged(gr, rectangle4, middleColor2, endColor, fillDirection); } } else { FillManaged(gr, rc, startColor, endColor, fillDirection); } return true; }
private FillFlowContainer buildTest(FillDirection dir, Vector2 spacing) { ButtonsContainer.RemoveAll(btn => btn != selectionDropdown); FillFlowContainer fc; var cnt = new Container() { Padding = new MarginPadding(25f) { Top = 100f }, RelativeSizeAxes = Axes.Both, Children = new[] { fc = new FillFlowContainer() { RelativeSizeAxes = Axes.Both, AutoSizeAxes = Axes.None, Direction = dir, Spacing = spacing, } } }; Add(cnt); var rotateBtn = AddButton("Rotate Container", () => { if (fc.Rotation > 0) { fc.RotateTo(0f, 1000); } else { fc.RotateTo(45f, 1000); } }); AddButton("Scale Container", () => { if (fc.Scale.X == 1f) { fc.ScaleTo(1.2f, 1000); } else { fc.ScaleTo(1f, 1000); } }); AddButton("Shear Container", () => { if (fc.Shear.X == 0) { fc.Shear = new Vector2(0.5f, 0f); } else { fc.Shear = new Vector2(0f, 0f); } }); AddToggle("Center Container Anchor", (state) => { if (state) { fc.Anchor = Anchor.Centre; } else { fc.Anchor = Anchor.TopLeft; } }); AddToggle("Center Container Origin", (state) => { if (state) { fc.Origin = Anchor.Centre; } else { fc.Origin = Anchor.TopLeft; } }); AddToggle("Autosize Container", (state) => { if (state) { fc.RelativeSizeAxes = Axes.None; fc.AutoSizeAxes = Axes.Both; } else { fc.AutoSizeAxes = Axes.None; fc.RelativeSizeAxes = Axes.Both; fc.Width = 1; fc.Height = 1; } }); AddToggle("Anchor TopCenter children", (state) => { if (state) { foreach (var child in fc.Children) { child.Anchor = Anchor.TopCentre; } } else { foreach (var child in fc.Children) { child.Anchor = Anchor.TopLeft; } } }); AddToggle("Rotate children", (state) => { if (state) { foreach (var child in fc.Children) { child.RotateTo(45f, 1000); } } else { foreach (var child in fc.Children) { child.RotateTo(0f, 1000); } } }); AddToggle("Shear children", (state) => { if (state) { foreach (var child in fc.Children) { child.Shear = new Vector2(0.2f, 0.2f); } } else { foreach (var child in fc.Children) { child.Shear = Vector2.Zero; } } }); AddToggle("Scale children", (state) => { if (state) { foreach (var child in fc.Children) { child.ScaleTo(1.25f, 1000); } } else { foreach (var child in fc.Children) { child.ScaleTo(1f, 1000); } } }); AddToggle("Change children origin", (state) => { if (state) { foreach (var child in fc.Children) { child.Origin = Anchor.Centre; } } else { foreach (var child in fc.Children) { child.Origin = Anchor.TopLeft; } } }); var addChildrenBtn = AddToggle("Stop adding children", (state) => { }); cnt.Position = new Vector2(rotateBtn.Width, 0f); cnt.Padding = new MarginPadding(25f) { Top = cnt.Padding.Top, Right = 25f + cnt.Position.X }; Add(new Box { Colour = Color4.HotPink, Width = 3, Height = 3, Position = fc.Parent.ToSpaceOfOtherDrawable(fc.BoundingBox.TopLeft, this), Origin = Anchor.Centre }); Add(new Box { Colour = Color4.HotPink, Width = 3, Height = 3, Position = fc.Parent.ToSpaceOfOtherDrawable(fc.BoundingBox.TopRight, this), Origin = Anchor.Centre }); Add(new Box { Colour = Color4.HotPink, Width = 3, Height = 3, Position = fc.Parent.ToSpaceOfOtherDrawable(fc.BoundingBox.BottomLeft, this), Origin = Anchor.Centre }); Add(new Box { Colour = Color4.HotPink, Width = 3, Height = 3, Position = fc.Parent.ToSpaceOfOtherDrawable(fc.BoundingBox.BottomRight, this), Origin = Anchor.Centre }); ScheduledDelegate d = null; d = Scheduler.AddDelayed( () => { if (fc.Parent == null) { d.Cancel(); } if (addChildrenBtn.State) { fc.Invalidate(); } if (fc.Children.Count() < 1000 && !addChildrenBtn.State) { fc.Add(new Container { AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { Width = 50, Height = 50, Colour = new Color4(255, 255, 255, 255) }, new SpriteText { Colour = Color4.Black, RelativePositionAxes = Axes.Both, Position = new Vector2(0.5f, 0.5f), Origin = Anchor.Centre, Text = fc.Children.Count().ToString() } } }); } }, 100, true ); return(fc); }
/// <summary> /// /// </summary> /// <param name="stockItemList"></param> /// <param name="customerList"></param> /// <param name="fillDirection"></param> public void FillData(StockItemList stockItemList, CustomerList customerList, DateTime date, FillDirection fillDirection) { var idCounter = 1; const int step = 10; for (var j = 0; j < step; j++) { foreach (var oneCustomer in customerList) { foreach (var onestockItem in stockItemList) { Add(new StockTransaction(Session) { ID = idCounter++, Amount = j * 10 + idCounter + onestockItem.ID, stockItem = onestockItem, customer = oneCustomer, Date = fillDirection == FillDirection.Beforedate ? date.Date.AddHours(-(idCounter + oneCustomer.ID + onestockItem.ID)) : date.Date.AddHours(idCounter + oneCustomer.ID + onestockItem.ID) , TransactionNumber = GetTransactionNumber(oneCustomer.ID) }); } } } }
/// <summary> /// /// </summary> /// <param name="sesssion"></param> /// <param name="stockItemList"></param> /// <param name="customerList"></param> /// <returns></returns> public static StockTransactionList CreateNew(Session sesssion, StockItemList stockItemList, CustomerList customerList, DateTime date, FillDirection fillDirection) { var tmpStockTransaction = new StockTransactionList(sesssion); tmpStockTransaction.FillData(stockItemList, customerList, date, fillDirection); return(tmpStockTransaction); }
/// <summary> /// 返回指定渐变色和方向的填充矩形 /// </summary> /// <param name="rc">Destination rectangle</param> /// <param name="startColorValue">Starting color for gradient</param> /// <param name="endColorValue">End color for gradient</param> /// <param name="fillDirection">The direction of the gradient</param> /// <returns>Image of the rectanle</returns> public static Bitmap GetGradientRectangle(Rectangle rc, Color startColorValue, Color endColorValue, FillDirection fillDirection) { Bitmap outputImage = new Bitmap(rc.Width, rc.Height); // Create temporary graphics Graphics gx = Graphics.FromImage(outputImage); GradientFill.Fill( gx, rc, startColorValue, endColorValue, fillDirection); return(outputImage); }
public void DrawBar(Vector2 position, Vector2 size, float fraction, FillDirection fillDirection, Vector4 incompleteColor, Vector4 completeColor, float rounding = 5f) { if (fraction < 0) { fraction = 0; } if (fraction > 1) { fraction = 1; } var incompleteCorners = ImDrawCornerFlags.None; var completeCorners = ImDrawCornerFlags.None; var drawList = ImGui.GetWindowDrawList(); var topLeft = position; var bottomRight = position + size; var incompleteTopLeft = topLeft; var incompleteBottomRight = bottomRight; var completeTopLeft = topLeft; var completeBottomRight = bottomRight; switch (fillDirection) { case FillDirection.FromRight: incompleteCorners |= fraction <= 0 ? ImDrawCornerFlags.All : ImDrawCornerFlags.Left; completeCorners |= fraction >= 1 ? ImDrawCornerFlags.All : ImDrawCornerFlags.Right; incompleteBottomRight.X -= size.X * fraction; completeTopLeft.X += size.X * (1 - fraction); break; case FillDirection.FromLeft: incompleteCorners |= fraction <= 0 ? ImDrawCornerFlags.All : ImDrawCornerFlags.Right; completeCorners |= fraction >= 1 ? ImDrawCornerFlags.All : ImDrawCornerFlags.Left; incompleteTopLeft.X += size.X * fraction; completeBottomRight.X -= size.X * (1 - fraction); break; case FillDirection.FromTop: incompleteCorners |= fraction <= 0 ? ImDrawCornerFlags.All : ImDrawCornerFlags.Bot; completeCorners |= fraction >= 1 ? ImDrawCornerFlags.All : ImDrawCornerFlags.Top; incompleteTopLeft.Y += size.Y * fraction; completeBottomRight.Y -= size.Y * (1 - fraction); break; case FillDirection.FromBottom: incompleteCorners |= fraction <= 0 ? ImDrawCornerFlags.All : ImDrawCornerFlags.Top; completeCorners |= fraction >= 1 ? ImDrawCornerFlags.All : ImDrawCornerFlags.Bot; incompleteBottomRight.Y -= size.Y * fraction; completeTopLeft.Y += size.Y * (1 - fraction); break; default: throw new ArgumentOutOfRangeException(nameof(fillDirection), fillDirection, null); } if (fraction < 1) { drawList.AddRectFilled(incompleteTopLeft, incompleteBottomRight, ImGui.GetColorU32(incompleteColor), rounding, incompleteCorners); } if (fraction > 0) { drawList.AddRectFilled(completeTopLeft, completeBottomRight, ImGui.GetColorU32(completeColor), rounding, completeCorners); } ImGui.Dummy(size); }
private void buildTest(FillDirection dir, Vector2 spacing) { Add(new Container { Padding = new MarginPadding(25f), RelativeSizeAxes = Axes.Both, Children = new Drawable[] { fillContainer = new FillFlowContainer { RelativeSizeAxes = Axes.Both, AutoSizeAxes = Axes.None, Direction = dir, Spacing = spacing, }, new Box { Anchor = Anchor.CentreLeft, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Size = new Vector2(3, 1), Colour = Color4.HotPink, }, new Box { Anchor = Anchor.CentreRight, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Size = new Vector2(3, 1), Colour = Color4.HotPink, }, new Box { Anchor = Anchor.TopCentre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, Size = new Vector2(1, 3), Colour = Color4.HotPink, }, new Box { Anchor = Anchor.BottomCentre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, Size = new Vector2(1, 3), Colour = Color4.HotPink, } } }); AddToggleStep("Rotate Container", state => { fillContainer.RotateTo(state ? 45f : 0, 1000); }); AddToggleStep("Scale Container", state => { fillContainer.ScaleTo(state ? 1.2f : 1f, 1000); }); AddToggleStep("Shear Container", state => { fillContainer.Shear = state ? new Vector2(0.5f, 0f) : new Vector2(0f, 0f); }); AddToggleStep("Center Container Anchor", state => { fillContainer.Anchor = state ? Anchor.Centre : Anchor.TopLeft; }); AddToggleStep("Center Container Origin", state => { fillContainer.Origin = state ? Anchor.Centre : Anchor.TopLeft; }); AddToggleStep("Autosize Container", state => { if (state) { fillContainer.RelativeSizeAxes = Axes.None; fillContainer.AutoSizeAxes = Axes.Both; } else { fillContainer.AutoSizeAxes = Axes.None; fillContainer.RelativeSizeAxes = Axes.Both; fillContainer.Width = 1; fillContainer.Height = 1; } }); AddToggleStep("Rotate children", state => { if (state) { foreach (var child in fillContainer.Children) { child.RotateTo(45f, 1000); } } else { foreach (var child in fillContainer.Children) { child.RotateTo(0f, 1000); } } }); AddToggleStep("Shear children", state => { if (state) { foreach (var child in fillContainer.Children) { child.Shear = new Vector2(0.2f, 0.2f); } } else { foreach (var child in fillContainer.Children) { child.Shear = Vector2.Zero; } } }); AddToggleStep("Scale children", state => { if (state) { foreach (var child in fillContainer.Children) { child.ScaleTo(1.25f, 1000); } } else { foreach (var child in fillContainer.Children) { child.ScaleTo(1f, 1000); } } }); AddToggleStep("Randomly scale children", state => { if (state) { foreach (var child in fillContainer.Children) { child.ScaleTo(RNG.NextSingle(1, 2), 1000); } } else { foreach (var child in fillContainer.Children) { child.ScaleTo(1f, 1000); } } }); AddToggleStep("Randomly set child origins", state => { if (state) { foreach (var child in fillContainer.Children) { switch (RNG.Next(9)) { case 0: child.Origin = Anchor.TopLeft; break; case 1: child.Origin = Anchor.TopCentre; break; case 2: child.Origin = Anchor.TopRight; break; case 3: child.Origin = Anchor.CentreLeft; break; case 4: child.Origin = Anchor.Centre; break; case 5: child.Origin = Anchor.CentreRight; break; case 6: child.Origin = Anchor.BottomLeft; break; case 7: child.Origin = Anchor.BottomCentre; break; case 8: child.Origin = Anchor.BottomRight; break; } } } else { foreach (var child in fillContainer.Children) { child.Origin = originDropdown.Current; } } }); AddToggleStep("Stop adding children", state => { addChildren = state; }); scheduledAdder?.Cancel(); scheduledAdder = Scheduler.AddDelayed( () => { if (fillContainer.Parent == null) { scheduledAdder.Cancel(); } if (addChildren) { fillContainer.Invalidate(); } if (fillContainer.Children.Count() < 1000 && !addChildren) { fillContainer.Add(new Container { Anchor = childAnchor, Origin = childOrigin, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { Width = 50, Height = 50, Colour = Color4.White }, new SpriteText { Colour = Color4.Black, RelativePositionAxes = Axes.Both, Position = new Vector2(0.5f, 0.5f), Origin = Anchor.Centre, Text = fillContainer.Children.Count().ToString() } } }); } }, 100, true ); }
public static void DrawGradientRoundedRectangle(this Graphics g, Rectangle rect, Color startColor, Color endColor, FillDirection direction = FillDirection.TopToBottom, Color borderColor = default(Color), int radius = 8, RectangleEdgeFilter filter = RectangleEdgeFilter.All) { // 填充渐变背景 Rectangle gradientRect = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height); using (GraphicsPath path = g.GenerateRoundedRectangle(gradientRect, radius, filter)) using (LinearGradientBrush brush = new LinearGradientBrush(gradientRect, startColor, endColor, 90f)) { g.FillPath(brush, path); } // 画边框 using (Pen borderPen = new Pen(borderColor)) { GraphicsExtension.DrawRoundedRectangle(g, borderPen, rect, radius, filter); } }
public static bool Fill(Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { Win32.TRIVERTEX[] pVertex = new Win32.TRIVERTEX[] { new Win32.TRIVERTEX(rc.X, rc.Y, startColor), new Win32.TRIVERTEX(rc.Right, rc.Bottom, endColor) }; Win32.GRADIENT_RECT[] pMesh = new Win32.GRADIENT_RECT[] { new Win32.GRADIENT_RECT(0, 1) }; IntPtr hdc = gr.GetHdc(); bool flag = Win32.GradientFill(hdc, pVertex, (uint)pVertex.Length, pMesh, (uint)pMesh.Length, (uint)fillDir); gr.ReleaseHdc(hdc); return(flag); }
public static bool GradientFill( this Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { // Initialize the data to be used in the call to GradientFill. TRIVERTEX[] tva = new TRIVERTEX[2]; tva[0] = new TRIVERTEX(rc.X, rc.Y, startColor); tva[1] = new TRIVERTEX(rc.Right, rc.Bottom, endColor); GRADIENT_RECT[] gra = new GRADIENT_RECT[] { new GRADIENT_RECT(0, 1) }; // Get the hDC from the Graphics object. IntPtr hdc = gr.GetHdc(); // PInvoke to GradientFill. bool b; b = Win32Helper.GradientFill( hdc, tva, (uint)tva.Length, gra, (uint)gra.Length, (uint)fillDir); System.Diagnostics.Debug.Assert(b, string.Format( "GradientFill failed: {0}", System.Runtime.InteropServices.Marshal.GetLastWin32Error())); // Release the hDC from the Graphics object. gr.ReleaseHdc(hdc); return b; }
public void TestDifferentTypesSource(Visibility a, FillDirection b, bool c) { }
public static bool FillManaged(Graphics gr, Rectangle rc, Color startColor, Color endColor, FillDirection fillDirection) { if (fillDirection == FillDirection.Horizontal) { int num = endColor.R - startColor.R; int num2 = endColor.G - startColor.G; int num3 = endColor.B - startColor.B; int width = rc.Width; int right = rc.Right; int top = rc.Top; int num6 = rc.Bottom - 1; if (top == num6) { int num7 = 0; int left = rc.Left; while (num7 < width) { int red = startColor.R + ((num7 * num) / width); int green = startColor.G + ((num7 * num2) / width); int blue = startColor.B + ((num7 * num3) / width); Color c = Color.FromArgb(red, green, blue); DrawPixel(gr, c, left, top); left++; num7++; } } else { int num12 = 0; int num13 = rc.Left; while (num12 < width) { int num14 = startColor.R + ((num12 * num) / width); int num15 = startColor.G + ((num12 * num2) / width); int num16 = startColor.B + ((num12 * num3) / width); Color color2 = Color.FromArgb(num14, num15, num16); gr.DrawLine(GetPen(color2), num13, top, num13, num6); num13++; num12++; } } } else if (fillDirection == FillDirection.Vertical) { int num17 = endColor.R - startColor.R; int num18 = endColor.G - startColor.G; int num19 = endColor.B - startColor.B; int height = rc.Height; int x = rc.Left; int num22 = rc.Right - 1; int bottom = rc.Bottom; if (x == num22) { int num23 = 0; for (int i = rc.Top; num23 < height; i++) { int num25 = startColor.R + ((num23 * num17) / height); int num26 = startColor.G + ((num23 * num18) / height); int num27 = startColor.B + ((num23 * num19) / height); Color color3 = Color.FromArgb(num25, num26, num27); DrawPixel(gr, color3, x, i); num23++; } } else { int num28 = 0; for (int j = rc.Top; num28 < height; j++) { int num30 = startColor.R + ((num28 * num17) / height); int num31 = startColor.G + ((num28 * num18) / height); int num32 = startColor.B + ((num28 * num19) / height); Color color4 = Color.FromArgb(num30, num31, num32); gr.DrawLine(GetPen(color4), x, j, num22, j); num28++; } } } return true; }
public static bool Fill(Graphics gr, Rectangle rc, Color startColor, Color middleColor1, Color middleColor2, Color endColor, FillDirection fillDirection) { bool flag = (middleColor1 != Color.Transparent) | (middleColor2 != Color.Transparent); int num = 2; if (flag) { num += 2; } Win32Helper.TRIVERTEX[] pVertex = new Win32Helper.TRIVERTEX[num]; pVertex[0] = new Win32Helper.TRIVERTEX(rc.X, rc.Y, startColor); if (flag) { if (middleColor1 == Color.Transparent) { middleColor1 = middleColor2; } if (middleColor2 == Color.Transparent) { middleColor2 = middleColor1; } if (fillDirection == FillDirection.Horizontal) { pVertex[1] = new Win32Helper.TRIVERTEX(rc.X + (rc.Width / 2), rc.Bottom, middleColor1); pVertex[2] = new Win32Helper.TRIVERTEX(rc.X + (rc.Width / 2), rc.Y, middleColor2); } else { pVertex[1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Y + (rc.Height / 2), middleColor1); pVertex[2] = new Win32Helper.TRIVERTEX(rc.X, rc.Y + (rc.Height / 2), middleColor2); } } pVertex[num - 1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Bottom, endColor); Win32Helper.GRADIENT_RECT[] pMesh = null; if (flag) { pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1), new Win32Helper.GRADIENT_RECT(2, 3) }; } else { pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1) }; } IntPtr hdc = gr.GetHdc(); bool flag2 = false; try { flag2 = Win32Helper.GradientFill(hdc, pVertex, (uint) pVertex.Length, pMesh, (uint) pMesh.Length, (uint) fillDirection); gr.ReleaseHdc(hdc); } catch (Exception) { gr.ReleaseHdc(hdc); if (Environment.OSVersion.Platform == PlatformID.WinCE) { gr.FillRectangle(GetBrush(startColor), rc); return true; } try { try { Assembly.Load("Resco.AdvancedComboBox.Design, Version=" + GetAssemblyVersion() + ", Culture=neutral, PublicKeyToken=7444f602060105f9").GetType("Resco.Controls.AdvancedComboBox.Design.AdvancedComboBoxDesigner").GetMethod("DesignerGradientFill", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(Graphics), typeof(Rectangle), typeof(Color), typeof(Color), typeof(Color), typeof(Color), typeof(FillDirection) }, null).Invoke(null, new object[] { gr, rc, startColor, middleColor1, middleColor2, endColor, fillDirection }); } catch (Exception) { gr.FillRectangle(GetBrush(startColor), rc); } return flag2; } finally { flag2 = true; } } return flag2; }
/// <summary> /// Gradient fill /// </summary> public bool GradientFill(Rectangle rc, Color startColor, Color endColor, FillDirection fillDir) { return VKontakteWM.Components.GDI.GradientFill.Fill(_hdc, rc, startColor, endColor, fillDir); }