public static void InitScrollbarImage() { Image[] tmpImages = ImageHelper.CutImage(HScrollbarImage, 4, true); Image[] tmpRightImages = ImageHelper.CutImage(tmpImages[0], 3, false); Image[] tmpLeftImages = ImageHelper.CutImage(tmpImages[1], 3, false); Image[] tmpScrollButtonImages = ImageHelper.CutImage(tmpImages[2], 3, false); Rectangle[] srcLeftButtonRect = ShapeHelper.GetRectangles(new Rectangle(new Point(0, 0), tmpLeftImages[0].Size), LeftBorderWidth, RightBorderWidth, TopBorderHeight, BottomBorderHeight); Rectangle[] srcRightButtonRect = ShapeHelper.GetRectangles(new Rectangle(new Point(0, 0), tmpRightImages[0].Size), LeftBorderWidth, RightBorderWidth, TopBorderHeight, BottomBorderHeight); Rectangle[] srcScrollButtonRect = ShapeHelper.GetRectangles(new Rectangle(new Point(0, 0), tmpScrollButtonImages[0].Size), LeftBorderWidth, RightBorderWidth, TopBorderHeight, BottomBorderHeight); for (int i = 0; i <= tmpLeftImages.Length - 1; i++) { for (int j = 0; j <= srcLeftButtonRect.Length - 1; j++) { SourceRightButtonImages[i, j] = ImageHelper.GetImage(tmpRightImages[i], srcRightButtonRect[j]); SourceLeftButtonImages[i, j] = ImageHelper.GetImage(tmpLeftImages[i], srcLeftButtonRect[j]); SourceScrollButtonImages[i, j] = ImageHelper.GetImage(tmpScrollButtonImages[i], srcScrollButtonRect[j]); //加边框 SourceRightButtonImages[i, j] = ImageHelper.AddBorder(SourceRightButtonImages[i, j]); SourceLeftButtonImages[i, j] = ImageHelper.AddBorder(SourceLeftButtonImages[i, j]); SourceScrollButtonImages[i, j] = ImageHelper.AddBorder(SourceScrollButtonImages[i, j]); } } SourceBackImage = tmpImages[3]; SourceBackImage = ImageHelper.AddBorder(SourceBackImage); }
public static void InitButtonImage() { Image tmpButtonImage = (Bitmap)ButtonImage.Clone(); //设置透明 tmpButtonImage = ImageHelper.ReplaceColor(tmpButtonImage, Color.FromArgb(255, 0, 255), Color.Transparent); //切分图片 Image[] SrcButtonImages = ImageHelper.CutImage(tmpButtonImage, 3, true); if (SrcButtonImages.Length == 3) { Image[] tmpImages = new Image[4]; SrcButtonImages.CopyTo(tmpImages, 0); tmpImages[3] = ImageHelper.ReplaceColor(SrcButtonImages[0], Color.DarkGray); SrcButtonImages = tmpImages; } //原始矩形划分 Rectangle[] tmpRects = ShapeHelper.GetRectangles(new Rectangle(new Point(0, 0), SrcButtonImages[0].Size), LeftBorderWidth, RightBorderWidth, TopBorderHeight, BottomBorderHeight); for (int i = 0; i <= SrcButtonImages.Length - 1; i++) { Image tmpImage = SrcButtonImages[i]; //切分出九个部分的图片 SrcLeftTopImages[i] = ImageHelper.GetImage(tmpImage, tmpRects[0]); SrcTopImages[i] = ImageHelper.GetImage(tmpImage, tmpRects[1]); SrcRightTopImages[i] = ImageHelper.GetImage(tmpImage, tmpRects[2]); SrcLeftImages[i] = ImageHelper.GetImage(tmpImage, tmpRects[3]); SrcCenterImages[i] = ImageHelper.GetImage(tmpImage, tmpRects[4]); SrcRightImages[i] = ImageHelper.GetImage(tmpImage, tmpRects[5]); SrcLeftBottomImages[i] = ImageHelper.GetImage(tmpImage, tmpRects[6]); SrcBottomImages[i] = ImageHelper.GetImage(tmpImage, tmpRects[7]); SrcRightBottomImages[i] = ImageHelper.GetImage(tmpImage, tmpRects[8]); //加边框 SrcLeftTopImages[i] = ImageHelper.AddBorder(SrcLeftTopImages[i]); SrcTopImages[i] = ImageHelper.AddBorder(SrcTopImages[i]); SrcRightTopImages[i] = ImageHelper.AddBorder(SrcRightTopImages[i]); SrcLeftImages[i] = ImageHelper.AddBorder(SrcLeftImages[i]); SrcCenterImages[i] = ImageHelper.AddBorder(SrcCenterImages[i]); SrcRightImages[i] = ImageHelper.AddBorder(SrcRightImages[i]); SrcLeftBottomImages[i] = ImageHelper.AddBorder(SrcLeftBottomImages[i]); SrcBottomImages[i] = ImageHelper.AddBorder(SrcBottomImages[i]); SrcRightBottomImages[i] = ImageHelper.AddBorder(SrcRightBottomImages[i]); } }