本文整理汇总了C#中LinearGradientBrush.RotateTransform方法的典型用法代码示例。如果您正苦于以下问题:C# LinearGradientBrush.RotateTransform方法的具体用法?C# LinearGradientBrush.RotateTransform怎么用?C# LinearGradientBrush.RotateTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinearGradientBrush
的用法示例。
在下文中一共展示了LinearGradientBrush.RotateTransform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillGradientBeam
public void FillGradientBeam(Graphics g, Color Col1, Color Col2, Rectangle rect, GradientAlignment align)
{
SmoothingMode stored = g.SmoothingMode;
ColorBlend Blend = new ColorBlend();
g.SmoothingMode = SmoothingMode.HighQuality;
LinearGradientBrush PathGradient;
switch (align)
{
case GradientAlignment.Vertical:
PathGradient = new LinearGradientBrush(new Point(rect.X, rect.Y), new Point(rect.X + rect.Width - 1, rect.Y), Color.Black, Color.Black);
Blend.Positions = new[] { 0, 1 / 2f, 1 };
Blend.Colors = new[]{Col1,Col2,Col1};
PathGradient.InterpolationColors = Blend;
g.FillRectangle(PathGradient, rect);
break;
case GradientAlignment.Horizontal:
PathGradient = new LinearGradientBrush(new Point(rect.X, rect.Y), new Point(rect.X, rect.Y + rect.Height), Color.Black, Color.Black);
Blend.Positions = new[]{0,1 / 2f,1 };
Blend.Colors = new[]{
Col1,
Col2,
Col1
};
PathGradient.InterpolationColors = Blend;
PathGradient.RotateTransform(0);
g.FillRectangle(PathGradient, rect);
break;
}
g.SmoothingMode = stored;
}
示例2: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
Graphics G = e.Graphics;
base.OnPaint(e);
TopGrip = TopSize + TopSpace;
this.Padding = new Padding(BorderSize + InsideBorderSize, TopSize + TopSpace + InsideBorderSize, BorderSize + InsideBorderSize, BorderSize + InsideBorderSize);
this.ParentForm.TransparencyKey = Color.Fuchsia;
this.ParentForm.MinimumSize = MinimumSize;
if (!(this.ParentForm.FormBorderStyle == FormBorderStyle.None))
{
this.ParentForm.FormBorderStyle = FormBorderStyle.None;
}
G.Clear(this.ParentForm.TransparencyKey);
//| Drawing the main rectangle base.
Rectangle MainRect = new Rectangle(0, TopSpace, Width - 1, Height - (1 + TopSpace));
Rectangle MainHighlightRect = new Rectangle(1, 1 + TopSpace, Width - 3, Height - (3+ TopSpace));
TextureBrush BGTextureBrush = new TextureBrush(D.CodeToImage(D.BGTexture), WrapMode.TileFlipXY);
G.FillRectangle(BGTextureBrush, MainRect);
G.DrawRectangle(new Pen(Color.FromArgb(40, Pal.ColHighest)), MainHighlightRect);
G.DrawRectangle(Pens.Black, MainRect);
//| Detail to the main rect's top grip
Rectangle ShineRect = new Rectangle(0, TopSpace, Width, Height);
//G.FillRectangle(new SolidBrush(Color.FromArgb(40, Pal.ColMed)), ShineRect);
LinearGradientBrush SubShineLGB1 = new LinearGradientBrush(ShineRect, Color.Black, Color.Black, 0, false);
LinearGradientBrush SubShineLGB2 = new LinearGradientBrush(ShineRect, Color.Black, Color.Black, 0, false);
ColorBlend Blend = new ColorBlend();
Blend.Positions = new[]{0,1 / 3f,2 / 3f,1};
Blend.Colors = new[]{
Color.FromArgb(50, Color.Black),
Color.FromArgb(150, Color.Black),
Color.FromArgb(50, Color.Black),
Color.Transparent
};
SubShineLGB1.InterpolationColors = Blend;
SubShineLGB1.RotateTransform(45);
Blend.Colors = new[]{
Color.FromArgb(50, Pal.ColHighest),
Color.FromArgb(150, Pal.ColHighest),
Color.FromArgb(50, Pal.ColHighest),
Color.Transparent
};
SubShineLGB2.InterpolationColors = Blend;
SubShineLGB2.RotateTransform(45);
//|
//D.FillGradientBeam(G, Color.Transparent, Color.FromArgb(80, Pal.ColHighest), ShineRect, GradientAlignment.Vertical);
//G.DrawLine(new Pen(SubShineLGB1), new Point(1, ShineRect.Height), new Point(Width - 2, ShineRect.Height));
//G.DrawLine(new Pen(SubShineLGB2), new Point(1, ShineRect.Height + 1), new Point(Width - 2, ShineRect.Height + 1));
//| Goind back through and making the rect below the detail darker
Rectangle DarkRect = new Rectangle(2, TopSpace + 2, Width - 4, Height - 4 - TopSpace);
LinearGradientBrush DarkLGB = new LinearGradientBrush(DarkRect, Color.FromArgb(100, Color.Black), Color.FromArgb(100, Color.Black), 90);
if (Darker) {
G.FillRectangle(DarkLGB, DarkRect);
}
//Lighter
//G.FillRectangle(new SolidBrush(Color.FromArgb(80, Pal.ColHigh)), DarkRect);
//| The inner and slightly brigher rectangle of the form
Rectangle InnerRect = new Rectangle(BorderSize-1, TopSpace + TopSize-1, Width - (BorderSize*2)+1, Height - BorderSize - TopSize - TopSpace+1);
Rectangle InnerHighlightRect = new Rectangle(BorderSize + 1, TopSpace + TopSize + 1, Width - (BorderSize * 2) - 1, Height - BorderSize - TopSize - TopSpace - 1);
Rectangle InnerHighlightRect2 = new Rectangle(BorderSize + InsideBorderSize, TopSpace + TopSize + InsideBorderSize, Width - (BorderSize * 2) - (InsideBorderSize*2), Height - BorderSize - TopSize - TopSpace - (InsideBorderSize*2));
// G.FillRectangle(BGTextureBrush, InnerRect);
// G.FillRectangle(new SolidBrush(Color.FromArgb(45, Pal.ColHigh)), InnerRect);
G.FillRectangle(new SolidBrush(D.ColorFromHex("#33373B")), InnerRect);
G.FillRectangle(new SolidBrush(BackColor), InnerHighlightRect2);
G.DrawRectangle(new Pen(Color.FromArgb(65, Pal.ColHighest)), InnerRect);
//G.DrawRectangle(new Pen(Color.FromArgb(40, Pal.ColHighest)), MainHighlightRect);
//G.DrawRectangle(Pens.Black, MainRect);
//G.FillRectangle(new SolidBrush(D.ColorFromHex("#33373B")), InnerHighlightRect);
//G.FillRectangle(new SolidBrush(BackColor), InnerHighlightRect2);
//G.DrawRectangle(new Pen(Color.FromArgb(80, Pal.ColHighest)), InnerHighlightRect);
//G.DrawRectangle(Pens.Black, InnerRect);
int textPad = 0;
if (this.ParentForm.ShowIcon)
{
G.DrawIcon(this.ParentForm.Icon, new Rectangle(BorderSize-4, TopSpace + 3, TopSize - 4, TopSize - 4));
textPad = BorderSize + TopSize - 5 + 4;
}
if(TitleAlignment == HorizontalAlignment.Center) {
textPad = 0;
}else if(TitleAlignment == HorizontalAlignment.Left && this.ParentForm.ShowIcon == false){
textPad = BorderSize + 1;
}
D.DrawTextWithShadow(G, new Rectangle(textPad, TopSpace, Width, TopSize + TitleYOffset), Text, TitleFont, TitleAlignment, TitleColor, Color.Black);
if (Sizable == true)
{
Rectangle SizeRect = new Rectangle(Width - BorderSize+1, Height - BorderSize+1, BorderSize-3, BorderSize-3);
LinearGradientBrush SizeLGB = new LinearGradientBrush(DarkRect, Color.FromArgb(10, Color.LightGray), Color.FromArgb(10, Color.LightGray), 90);
G.FillRectangle(SizeLGB, SizeRect);
G.FillRectangle(SizeLGB, SizeRect);
}
}