本文整理汇总了C#中System.Windows.Media.LinearGradientBrush类的典型用法代码示例。如果您正苦于以下问题:C# LinearGradientBrush类的具体用法?C# LinearGradientBrush怎么用?C# LinearGradientBrush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LinearGradientBrush类属于System.Windows.Media命名空间,在下文中一共展示了LinearGradientBrush类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Meter8
public Meter8()
{
var borderBrush = new LinearGradientBrush();
borderBrush.StartPoint = new Point();
borderBrush.EndPoint = new Point(1d, 1d);
borderBrush.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0d });
borderBrush.GradientStops.Add(new GradientStop() { Color = Colors.White, Offset = 0.4999d });
borderBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(0xff, 0x84, 0x7B, 0x6C), Offset = 0.5d });
borderBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(0xff, 0x84, 0x7B, 0x6C), Offset = 1d });
var border = new Rectangle();
border.Fill = borderBrush;
//border.Stroke = new SolidColorBrush(Colors.Black);
//border.StrokeThickness = 1d;
var background = new Rectangle();
background.Fill = new SolidColorBrush(Color.FromArgb(0xff, 0xAD, 0xA7, 0x9D));
background.Margin = new Thickness(4d);
var grid = new Grid();
grid.Children.Add(border);
grid.Children.Add(background);
grid.Children.Add(_canvas);
grid.Children.Add(_calibrationCanvas);
this.Content = grid;
_label.Text = Value.ToString();
_label.Foreground = new SolidColorBrush(ForeColor);
_pointLine.Stroke = new SolidColorBrush(Colors.Red);
_pointLine.StrokeThickness = 2d;
this.SizeChanged += Meter_SizeChanged;
}
示例2: SetCustomData
/// <summary>
/// Main windows에 적용 할 수 있는 간략한 Data 테스트
/// </summary>
private void SetCustomData()
{
// 제목
Title = "Display Some Text";
//// 현재 창에 나타날 data
//Content = "Content can be simple text!";
// font 지정
FontFamily = new FontFamily("Comic Sans MS");
FontSize = 48;
// gradient 효과가 적용된 Brush
Brush brush = new LinearGradientBrush(Colors.Black, Colors.White, new Point(0,0), new Point(1,1));
Background = brush;
Foreground = brush;
// 현재 창의 content 내용에 따라 창의 크기를 조절 할 수 있는 값
SizeToContent = SizeToContent.WidthAndHeight;
// 현재 창의 Resizing 방법 지정
ResizeMode = ResizeMode.CanMinimize;
}
示例3: CreateTestScrollViewer
/// <summary>
/// Create a ScrollViewer that can be used by the tests.
/// </summary>
/// <returns>A ScrollViewer that can be used by the tests.</returns>
private static ScrollViewer CreateTestScrollViewer()
{
LinearGradientBrush brush = new LinearGradientBrush
{
StartPoint = new Point(),
EndPoint = new Point(1, 1)
};
brush.GradientStops.Add(new GradientStop { Offset = 0, Color = Colors.Red });
brush.GradientStops.Add(new GradientStop { Offset = 1, Color = Colors.Blue });
Canvas panel = new Canvas
{
Height = 400,
Width = 400,
Background = brush
};
return new ScrollViewer
{
Height = 100,
Width = 100,
HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
Content = panel
};
}
示例4: ResizeChrome
static ResizeChrome()
{
TransparentBrush = Brushes.Transparent;
TransparentBrush.Freeze();
var borderBrush = new LinearGradientBrush()
{
Opacity = 0.7,
StartPoint = new Point(0, 0),
EndPoint = new Point(1, 0.3),
};
borderBrush.GradientStops.Add(new GradientStop(Colors.SlateBlue, 0));
borderBrush.GradientStops.Add(new GradientStop(Colors.LightBlue, 0.5));
borderBrush.GradientStops.Add(new GradientStop(Colors.SlateBlue, 1));
borderBrush.Freeze();
BorderBrush = borderBrush;
var thumbBrush = new RadialGradientBrush()
{
Center = new Point(0.3, 0.3),
GradientOrigin = new Point(0.3, 0.3),
RadiusX = 0.7,
RadiusY = 0.7,
};
thumbBrush.GradientStops.Add(new GradientStop(Colors.White, 0));
thumbBrush.GradientStops.Add(new GradientStop(Colors.DarkSlateBlue, 0.9));
thumbBrush.Freeze();
ThumbBrush = thumbBrush;
TransparentPen = new Pen(TransparentBrush, 3.5);
BorderPen = new Pen(BorderBrush, 2);
BorderPen.DashStyle = DashStyles.Dash;
ThumbGeometry = new EllipseGeometry();
UpdateZoom(1);
}
示例5: setgradient
public void setgradient(Panel elm)
{
LinearGradientBrush myBrush = new LinearGradientBrush();
Point startpoint = new Point();
int angle = CommunConfig.getInstance().Angle;
startpoint.X = System.Math.Cos(((double)angle / 180) * System.Math.PI)/2 + 0.5;
startpoint.Y = System.Math.Sin(((double)angle / 180) * System.Math.PI)/2 + 0.5;
angle -= 180;
Point endpoint = new Point();
endpoint.X = System.Math.Cos(((double)angle / 180) * System.Math.PI)/2 +0.5;
endpoint.Y = System.Math.Sin(((double)angle / 180) * System.Math.PI)/2 +0.5;
myBrush.StartPoint = startpoint;
myBrush.EndPoint = endpoint;
System.Windows.Media.Color c = new Color();
System.Drawing.Color drawingColor = CommunConfig.getInstance().StartColor;
c = System.Windows.Media.Color.FromRgb(drawingColor.R, drawingColor.G, drawingColor.B);
myBrush.GradientStops.Add(new GradientStop(c, 1));
drawingColor = CommunConfig.getInstance().EndColor;
c = System.Windows.Media.Color.FromRgb(drawingColor.R, drawingColor.G, drawingColor.B);
myBrush.GradientStops.Add(new GradientStop(c, 0));
elm.Background = myBrush;
}
示例6: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var color = (string) value;
try
{
TypeConverter colorConverter = new ColorConverter();
var baseColor = (Color) colorConverter.ConvertFromString(color);
var c2 = Color.FromArgb(25, baseColor.R, baseColor.G, baseColor.B);
var colorBrush = new LinearGradientBrush();
colorBrush.StartPoint = new Point(0, 0);
colorBrush.EndPoint = new Point(0, 1);
colorBrush.GradientStops.Add(new GradientStop(c2, 0.15));
colorBrush.GradientStops.Add(new GradientStop(baseColor, 0.85));
colorBrush.GradientStops.Add(new GradientStop(c2, 1));
return colorBrush;
}
catch (Exception)
{
return Brushes.DarkRed;
}
}
示例7: ProgressColorChanged
private static void ProgressColorChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
ProgressBarGame senderCast = sender as ProgressBarGame;
if (senderCast == null)
{
return; // this should never happen
}
Color color = (Color)e.NewValue;
// Turn the color into a slight gradient
LinearGradientBrush brush = new LinearGradientBrush();
brush.StartPoint = new Point(0, 0);
brush.EndPoint = new Point(0, 1);
GradientStopCollection gradients = new GradientStopCollection();
gradients.Add(new GradientStop(UtilityWPF.AlphaBlend(Colors.White, color, .5d), 0d));
gradients.Add(new GradientStop(UtilityWPF.AlphaBlend(Colors.White, color, .25d), .1d));
gradients.Add(new GradientStop(color, .4d));
gradients.Add(new GradientStop(UtilityWPF.AlphaBlend(Colors.Black, color, .2d), .9d));
gradients.Add(new GradientStop(UtilityWPF.AlphaBlend(Colors.Black, color, .25d), 1d));
brush.GradientStops = gradients;
// The progress bar is actually tied to this property
senderCast.ProgressBrush = brush;
}
示例8: ZomingAndPanningExample
public ZomingAndPanningExample()
{
InitializeComponent();
var gradientBrush = new LinearGradientBrush
{
StartPoint = new System.Windows.Point(0, 0),
EndPoint = new Point(0, 1)
};
gradientBrush.GradientStops.Add(new GradientStop(System.Windows.Media.Color.FromRgb(33, 148, 241), 0));
gradientBrush.GradientStops.Add(new GradientStop(Colors.Transparent, 1));
cartesianChart1.Series.Add(new LineSeries
{
Values = GetData(),
Fill = gradientBrush,
StrokeThickness = 1,
PointGeometry = null
});
cartesianChart1.Zoom = ZoomingOptions.X;
cartesianChart1.AxisX.Add(new Axis
{
LabelFormatter = val => new System.DateTime((long)val).ToString("dd MMM")
});
cartesianChart1.AxisY.Add(new Axis
{
LabelFormatter = val => val.ToString("C")
});
}
示例9: GradientTheBrush
public GradientTheBrush()
{
Title = "Gradient the Brush";
LinearGradientBrush brush = new LinearGradientBrush(Colors.Red, Colors.Blue, new Point(0, 0), new Point(1, 1));
Background = brush;
brush.SpreadMethod = GradientSpreadMethod.Reflect;
}
示例10: Convert
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var isKeyboardFocusWithin = (bool)value;
if (isKeyboardFocusWithin)
{
LinearGradientBrush linGrBrush = new LinearGradientBrush();
linGrBrush.StartPoint = new Point(0.5, 0);
linGrBrush.EndPoint = new Point(0.5, 1);
GradientStop firstGrStop = new GradientStop();
firstGrStop.Color = Color.FromArgb(255, 253, 211, 168);
GradientStop secondGrStop = new GradientStop();
secondGrStop.Color = Color.FromArgb(255, 252, 231, 159);
linGrBrush.GradientStops.Add(firstGrStop);
linGrBrush.GradientStops.Add(secondGrStop);
return linGrBrush;
}
else
{
return new SolidColorBrush(Colors.LightGray);
}
}
示例11: LinearGradientColorBrush
public static Brush LinearGradientColorBrush(string status)
{
LinearGradientBrush tempBrush = new LinearGradientBrush();
tempBrush.StartPoint = new Point(0, 0);
tempBrush.EndPoint = new Point(10, 10);
tempBrush.Opacity = .5;
tempBrush.MappingMode = BrushMappingMode.Absolute;
tempBrush.SpreadMethod = GradientSpreadMethod.Repeat;
GradientStop stop1 = new GradientStop();
stop1.Color = StatusStringToColorObject(status);
tempBrush.GradientStops.Add(stop1);
GradientStop stop2 = new GradientStop();
stop2.Color = StatusStringToColorObject(status);
stop2.Offset = 0.49;
tempBrush.GradientStops.Add(stop2);
GradientStop stop3 = new GradientStop();
stop3.Color = Colors.Transparent;
stop3.Offset = 0.51;
tempBrush.GradientStops.Add(stop3);
GradientStop stop4 = new GradientStop();
stop3.Color = Colors.Transparent;
stop3.Offset = 1;
tempBrush.GradientStops.Add(stop4);
return tempBrush;
}
示例12: GetLineBrush
public static LinearGradientBrush GetLineBrush()
{
//<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
//<GradientStop Color="#FFCCCCCC" Offset="0"/>
//<GradientStop Color="Black" Offset="1"/>
//<GradientStop Color="#FFABABAB" Offset="0.457"/>
//<GradientStop Color="Black" Offset="0.53"/>
//</LinearGradientBrush>
LinearGradientBrush brush = new LinearGradientBrush();
brush.EndPoint = new Point(0.5, 1);
brush.StartPoint = new Point(0.5, 0);
GradientStop gs = new GradientStop();
gs.Color = ConvertColor("#FFCCCCCC");
gs.Offset = 0;
brush.GradientStops.Add(gs);
gs = new GradientStop();
gs.Color = Colors.Black;
gs.Offset = 1;
brush.GradientStops.Add(gs);
gs = new GradientStop();
gs.Color = ConvertColor("#FFABABAB");
gs.Offset = 0.457;
brush.GradientStops.Add(gs);
gs = new GradientStop();
gs.Color = Colors.Black;
gs.Offset = 0.53;
brush.GradientStops.Add(gs);
return brush;
}
示例13: LinearGradientAnimation
public LinearGradientAnimation(LinearGradientBrush fromValue, LinearGradientBrush toValue, Duration duration)
: this()
{
this.From = fromValue;
this.To = toValue;
base.Duration = duration;
}
示例14: setBackground
public void setBackground()
{
Point p1 = new Point(0,0);
Point p2 = new Point(1.5,1);
switch (strFertigungsstatus)
{
case "Planung":
Background = new LinearGradientBrush(Colors.Orange,Colors.Transparent,p1,p2);
break;
case "Montage":
Background = new LinearGradientBrush(Colors.MediumTurquoise,Colors.Transparent,p1,p2);
break;
case "Prüfbereit":
Background = new LinearGradientBrush(Colors.Orchid,Colors.Transparent,p1,p2);
break;
case "Prüfung":
Background = new LinearGradientBrush(Colors.DeepSkyBlue,Colors.Transparent,p1,p2);
break;
case "Komplettierung":
Background = new LinearGradientBrush(Colors.LightSkyBlue,Colors.Transparent,p1,p2);
break;
case "Versendet":
Background = new LinearGradientBrush(Colors.GreenYellow,Colors.Transparent,p1,p2);
break;
default:
Background = new LinearGradientBrush(Colors.White,Colors.Transparent,p1,p2);
break;
}
}
示例15: PaintBackground
private void PaintBackground()
{
var backgroundSquare = new GeometryDrawing(Brushes.Black, null, new RectangleGeometry(new Rect(0, 0, 100, 100)));
var aGeometryGroup = new GeometryGroup();
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 50, 50)));
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(50, 50, 50, 50)));
var checkerBrush = new LinearGradientBrush();
checkerBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0));
checkerBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 22, 0), 1.0));
var checkers = new GeometryDrawing(checkerBrush, null, aGeometryGroup);
var checkersDrawingGroup = new DrawingGroup();
checkersDrawingGroup.Children.Add(backgroundSquare);
checkersDrawingGroup.Children.Add(checkers);
var myBrush = new DrawingBrush
{
Drawing = checkersDrawingGroup,
Viewport = new Rect(0, 0, 0.02, 0.02),
TileMode = TileMode.Tile,
Opacity = 0.5
};
LayoutRoot.Background = myBrush;
}