本文整理汇总了C#中System.Windows.Media.GradientStop类的典型用法代码示例。如果您正苦于以下问题:C# GradientStop类的具体用法?C# GradientStop怎么用?C# GradientStop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GradientStop类属于System.Windows.Media命名空间,在下文中一共展示了GradientStop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToGradient
/// <summary>Creates a gradient brush with the given colors flowing in the specified direction.</summary>
/// <param name="direction">The direction of the gradient.</param>
/// <param name="start">The starting color.</param>
/// <param name="end">The ending color.</param>
public static LinearGradientBrush ToGradient(this Direction direction, Color start, Color end)
{
// Create the brush.
var brush = new LinearGradientBrush();
switch (direction)
{
case Direction.Down:
case Direction.Up:
brush.StartPoint = new Point(0.5, 0);
brush.EndPoint = new Point(0.5, 1);
break;
case Direction.Right:
case Direction.Left:
brush.StartPoint = new Point(0, 0.5);
brush.EndPoint = new Point(1, 0.5);
break;
}
// Configure colors.
var gradientStart = new GradientStop { Color = start };
var gradientEnd = new GradientStop { Color = end };
gradientStart.Offset = direction == Direction.Up || direction == Direction.Left ? 1 : 0;
gradientEnd.Offset = direction == Direction.Down || direction == Direction.Right ? 1 : 0;
// Insert colors.
brush.GradientStops.Add(gradientStart);
brush.GradientStops.Add(gradientEnd);
// Finish up.
return brush;
}
示例2: 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);
}
}
示例3: 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;
}
示例4: MatchOffsetToColor
/// <summary>
/// Retrieves the color that most closely represents what would be found on the scale offset.
/// </summary>
/// <param name="ramp">The color scale the return value is derived from.</param>
/// <param name="offset">The offset on the color scale for which a color is to be found..</param>
/// <param name="maxR">The maximum R-channel value.</param>
/// <param name="maxG">The maximum G-channel value.</param>
/// <param name="maxB">The maximum B-channel value.</param>
/// <param name="alphaEnabled">Whether or not value-matching for the alpha channel is enabled.</param>
/// <returns>The color closest to the specified offset on the specified color scale.</returns>
public static Color MatchOffsetToColor(this GradientStopCollection ramp, double offset, int maxR, int maxG, int maxB, bool alphaEnabled)
{
double startBoundaryOffset = 0.0;
double finishBoundaryOffset = 1.0;
GradientStop startBoundary = new GradientStop();
GradientStop finishBoundary = new GradientStop();
foreach (GradientStop boundary in ramp)
{
if (boundary.Offset <= offset && boundary.Offset > startBoundaryOffset)
{
startBoundary = boundary;
}
if (boundary.Offset > offset && boundary.Offset <= finishBoundaryOffset)
{
finishBoundary = boundary;
break;
}
}
var color = Color.FromScRgb(
(alphaEnabled) ? CalculateChannelValue(startBoundary, finishBoundary, "ScA", offset, 255) : (float)1.0,
CalculateChannelValue(startBoundary, finishBoundary, "ScR", offset, maxR),
CalculateChannelValue(startBoundary, finishBoundary, "ScG", offset, maxG),
CalculateChannelValue(startBoundary, finishBoundary, "ScB", offset, maxB)
);
return color;
}
示例5: RSSFeed
public RSSFeed()
{
InitializeComponent();
schoolInfo = new MySchoolInfo();
ApplicationBar.Opacity = 0.5;
Rectangle verticalFillRectangle = new Rectangle();
verticalFillRectangle.Width = 200;
verticalFillRectangle.Height = 100;
//'Create a vertical linear gradient
LinearGradientBrush myVerticalGradient = new LinearGradientBrush();
myVerticalGradient.StartPoint = new Point(0.5, 0);
myVerticalGradient.EndPoint = new Point(0.5, 1);
GradientStop stop1 = new GradientStop();
stop1.Color = schoolInfo.Color1.Color;
stop1.Offset = 0.33;
GradientStop stop2 = new GradientStop();
stop2.Color = schoolInfo.Color2.Color;
stop2.Offset = 0.66;
myVerticalGradient.GradientStops.Add(stop1);
myVerticalGradient.GradientStops.Add(stop2);
listboxRSSFeedItems.Background = myVerticalGradient;
}
示例6: Convert
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture){
int valor = (int)value;
LinearGradientBrush brocha = new LinearGradientBrush();
GradientStop color1 = new GradientStop();
GradientStop color2 = new GradientStop();
brocha.StartPoint.Offset(-0.041,-0.005);
brocha.EndPoint.Offset(0.782,1.123);
color1.Offset = 0;
if(valor == 0){
color1.Color = Colors.IndianRed;
}else {
color1.Color = Colors.LightBlue;
}
color2.Offset = 0.645;
brocha.GradientStops.Add(color1);
brocha.GradientStops.Add(color2);
return brocha;
}
示例7: drawPoint
private void drawPoint(Point p, Canvas testCanvas)
{
//create shape
System.Diagnostics.Debug.WriteLine("Creating shape");
Shape userShape;
Shape shape = new Ellipse();
shape.SetValue(Canvas.LeftProperty, p.X);
shape.SetValue(Canvas.TopProperty, p.Y);
//shape.HorizontalAlignment = HorizontalAlignment.Left;
//shape.VerticalAlignment = VerticalAlignment.Center;
shape.Width = 4;
shape.Height = 4;
shape.Stroke = new SolidColorBrush(Colors.Black);
shape.StrokeThickness = 3.0;
GradientBrush gb = new LinearGradientBrush();
gb.GradientStops = new GradientStopCollection();
GradientStop g1 = new GradientStop();
g1.Color = Colors.Red;
gb.GradientStops.Add(g1);
g1 = new GradientStop();
g1.Color = Colors.Blue;
g1.Offset = 2;
gb.GradientStops.Add(g1);
shape.Fill = gb;
shape.Visibility = System.Windows.Visibility.Visible;
shape.Opacity = 0.5;
testCanvas.Children.Add(shape);
}
示例8: 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;
}
示例9: switch
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.Animirani = ((System.Windows.Media.GradientStop)(target));
return;
}
this._contentLoaded = true;
}
示例10: InitializeComponent
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Windows.Application.LoadComponent(this, new System.Uri("/MQuter-eLabApp;component/View/Components/Activity/IOGateComponent.xaml", System.UriKind.Relative));
this.Gate = ((System.Windows.Shapes.Ellipse)(this.FindName("Gate")));
this.GateBrush = ((System.Windows.Media.GradientStop)(this.FindName("GateBrush")));
}
示例11: InitializeComponent
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Windows.Application.LoadComponent(this, new System.Uri("/MQuter-eLabApp;component/View/ParamIOGate.xaml", System.UriKind.Relative));
this.ParamConnecctor = ((System.Windows.Shapes.Rectangle)(this.FindName("ParamConnecctor")));
this.GateBrush = ((System.Windows.Media.GradientStop)(this.FindName("GateBrush")));
}
示例12: InitializeComponent
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Windows.Application.LoadComponent(this, new System.Uri("/Tetris7;component/Piece/Block.xaml", System.UriKind.Relative));
this.rectangle = ((System.Windows.Shapes.Rectangle)(this.FindName("rectangle")));
this.gradientStop = ((System.Windows.Media.GradientStop)(this.FindName("gradientStop")));
}
示例13: OnButtonClick
private void OnButtonClick(object sender, RoutedEventArgs e)
{
GradientStop[] gradientStops = new GradientStop[]
{
new GradientStop(Colors.DarkGreen, 0),
new GradientStop(Colors.White, 1)
};
this.Resources["myBrush"] = new LinearGradientBrush(
new GradientStopCollection(gradientStops));
}
示例14: ShowPopUp
public void ShowPopUp(UserControl abc, Point x)
{
LinearGradientBrush brush = new LinearGradientBrush();
GradientStop stop = new GradientStop(Colors.Azure, 0.0);
GradientStop stop2 = new GradientStop(Colors.Black, 1.0);
brush.GradientStops.Add(stop);
brush.GradientStops.Add(stop2);
this.g.Background = brush;
this.popUp = new Window();
this.popUp.Title = "Dispositon Render";
this.popUp.Name = "PopUp";
this.popUp.AllowsTransparency = true;
this.popUp.Background = Brushes.Transparent;
this.popUp.WindowStyle = WindowStyle.None;
this.popUp.ShowInTaskbar = true;
//this.popUp.Topmost = true;
this.popUp.Height = 400.0;
this.popUp.Width = 230.0;
this.popUp.MouseLeave += new MouseEventHandler(this.popUp_MouseLeave);
double primaryScreenWidth = SystemParameters.PrimaryScreenWidth;
double primaryScreenHeight = SystemParameters.PrimaryScreenHeight;
double num3 = primaryScreenWidth - x.X;
double num4 = primaryScreenHeight - x.Y;
if (num3 < this.popUp.Width)
{
this.popUp.Left = primaryScreenWidth - this.popUp.Width;
}
else
{
this.popUp.Left = x.X - 80.0;
if (this.popUp.Left < 0.0)
{
this.popUp.Left = 0.0;
}
}
if (num4 < this.popUp.Height)
{
this.popUp.Top = primaryScreenHeight - this.popUp.Height;
}
else
{
this.popUp.Top = x.Y - 30.0;
if (this.popUp.Top < 0.0)
{
this.popUp.Top = 0.0;
}
}
this.g.Children.Add(abc);
this.popUp.Content = this.g;
this.popUp.Show();
}
示例15: ToGradientStop
//==========================================================================
public GradientStop ToGradientStop()
{
Color color = Color.ToColor();
color.A = (byte)Math.Round(Opacity.ToDouble() * 255);
GradientStop stop = new GradientStop();
stop.Color = color;
stop.Offset = Offset.ToDouble();
return stop;
}