本文整理汇总了C#中System.Windows.Media.GradientStop类的典型用法代码示例。如果您正苦于以下问题:C# GradientStop类的具体用法?C# GradientStop怎么用?C# GradientStop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GradientStop类属于System.Windows.Media命名空间,在下文中一共展示了GradientStop类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:37,代码来源:ColorExtensions.cs
示例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);
}
}
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:26,代码来源:BoolToColorConverter.cs
示例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;
}
开发者ID:dfberry,项目名称:WAZDash,代码行数:31,代码来源:StatusColor.cs
示例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;
}
开发者ID:quantumjockey,项目名称:TheseColorsDontRun,代码行数:40,代码来源:GradientStopCollectionExtensions.cs
示例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;
}
开发者ID:alexanderashe,项目名称:SouthportYouthBand,代码行数:30,代码来源:RSSFeed.xaml.cs
示例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;
}
开发者ID:noedelarosa,项目名称:SIC,代码行数:25,代码来源:ConvertEstadoHistoricoVisitas.cs
示例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);
}
开发者ID:pgordon,项目名称:NumberKill,代码行数:33,代码来源:Form1.cs
示例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;
}
开发者ID:dalinhuang,项目名称:my-un-code,代码行数:34,代码来源:Color.cs
示例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;
}
开发者ID:humra,项目名称:Practice,代码行数:9,代码来源:MainWindow.g.i.cs
示例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")));
}
开发者ID:SamuelToh,项目名称:Masters_Degree_Major_Project,代码行数:9,代码来源:IOGateComponent.g.i.cs
示例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")));
}
开发者ID:SamuelToh,项目名称:Masters_Degree_Major_Project,代码行数:9,代码来源:ParamIOGate.g.cs
示例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")));
}
开发者ID:karanthaker,项目名称:Windows-Phone-App---Tetris-Game,代码行数:9,代码来源:Block.g.i.cs
示例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));
}
开发者ID:CNinnovation,项目名称:WPFWorkshop,代码行数:10,代码来源:MainWindow.xaml.cs
示例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();
}
开发者ID:jiangguang5201314,项目名称:VMukti,代码行数:54,代码来源:Disposition_PopUp.cs
示例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;
}
开发者ID:duracellko,项目名称:WindowsApp-VisualAssets,代码行数:12,代码来源:SvgStopElement.cs
示例16: getGradientBrush
private Brush getGradientBrush(Color color1, Color color2, int stopColor1, int stopColor2)
{
Point startPoint = new Point(0.5, 0);
Point endPoint = new Point(0.5, 1);
GradientStop stop1 = new GradientStop(color1, stopColor1);
GradientStop stop2 = new GradientStop(color2, stopColor2);
GradientStopCollection stops = new GradientStopCollection() { stop1, stop2 };
return new LinearGradientBrush(stops, startPoint, endPoint);
}
开发者ID:hihack,项目名称:CRM.Mobile,代码行数:12,代码来源:CRMScrollViewer.cs
示例17: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var start = new GradientStop { Offset = 0.9, Color = ((Color) value) };
var stop = new GradientStop { Offset = 1, Color = Colors.Transparent };
var result = new RadialGradientBrush
{
GradientStops = new GradientStopCollection {start, stop}
};
return result;
}
开发者ID:eugenezinoviev,项目名称:UControl,代码行数:12,代码来源:ColorToOuterGlowConverter.cs
示例18: CreateGradientBrush
/// <summary>
/// Creates a gradient brush from a list of colors.
/// </summary>
/// <param name="colors">The colors.</param>
/// <param name="horizontal">if set to <c>true</c> [horizontal].</param>
/// <returns>A LinearGradientBrush.</returns>
public static LinearGradientBrush CreateGradientBrush(IList<Color> colors, bool horizontal = true)
{
var brush = new LinearGradientBrush { StartPoint = new Point(0, 0), EndPoint = horizontal ? new Point(1, 0) : new Point(0, 1) };
int n = colors.Count;
for (int i = 0; i < n; i++)
{
var gs = new GradientStop(colors[i], (double)i / (n - 1));
brush.GradientStops.Add(gs);
}
return brush;
}
开发者ID:chantsunman,项目名称:helix-toolkit,代码行数:18,代码来源:BrushHelper.cs
示例19: BasicLED
public BasicLED()
{
InitializeComponent();
ellipseRGB = ellipse.Fill as RadialGradientBrush;
ellipseRGB_GS1 = ellipseRGB.GradientStops[0];
ellipseRGB_GS2 = ellipseRGB.GradientStops[1];
lastIsActive = false;
lastActiveColor = lastInactiveColor = ellipseRGB_GS2.Color;
lastHighlightColor = ellipseRGB_GS1.Color;
lastBorderWidth = ellipse.StrokeThickness;
}
开发者ID:mosaicsys,项目名称:MosaicLibCS,代码行数:13,代码来源:BasicLED.xaml.cs
示例20: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
this.shadowOuterStop1 = (GradientStop)base.GetTemplateChild("PART_ShadowOuterStop1");
this.shadowOuterStop2 = (GradientStop)base.GetTemplateChild("PART_ShadowOuterStop2");
this.shadowVertical1 = (GradientStop)base.GetTemplateChild("PART_ShadowVertical1");
this.shadowVertical2 = (GradientStop)base.GetTemplateChild("PART_ShadowVertical2");
this.shadowHorizontal1 = (GradientStop)base.GetTemplateChild("PART_ShadowHorizontal1");
this.shadowHorizontal2 = (GradientStop)base.GetTemplateChild("PART_ShadowHorizontal2");
this.outerGlowBorder = (Border)base.GetTemplateChild("PART_OuterGlowBorder");
this.UpdateGlowSize(this.OuterGlowSize);
this.UpdateGlowColor(this.OuterGlowColor);
}
开发者ID:JuRogn,项目名称:OA,代码行数:13,代码来源:OuterGlowBorder.cs
注:本文中的System.Windows.Media.GradientStop类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论