本文整理汇总了C#中GradientStopCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# GradientStopCollection.Add方法的具体用法?C# GradientStopCollection.Add怎么用?C# GradientStopCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GradientStopCollection
的用法示例。
在下文中一共展示了GradientStopCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
public static GradientBrush Convert(System.Windows.Media.Color color)
{
var scrgb = color.ToScRGBColor();
var xyz = KnownColorSpaces.scRGB.ToXYZColor(scrgb);
var lab = KnownColorSpaces.Lab.FromXYZColor(xyz) as LabColor;
var l_base = lab.L;
var gradientStops = new GradientStopCollection();
var _lab = new LabColor(0xff, l_base * 1.07, lab.a, lab.b);
var _c = _lab.ToWindowsMediaColor();
gradientStops.Add(new GradientStop(_c, 0.5));
_lab = new LabColor(0xff, l_base * .93, lab.a, lab.b);
_c = _lab.ToWindowsMediaColor();
gradientStops.Add(new GradientStop(_c, 1));
var result = new LinearGradientBrush(gradientStops, 90);
result.Freeze();
return result;
}
示例2: DrawSquares
private void DrawSquares()
{
if (Row >= 3)
{
startx += 5;
}
if (Row >= 6)
{
startx += 5;
}
int x = startx + (Row * 40);
if (Column >= 3)
{
starty += 5;
}
if (Column >= 6)
{
starty += 5;
}
int y = starty + (Column * 37);
SetValue(Canvas.LeftProperty, Convert.ToDouble(x));
SetValue(Canvas.TopProperty, Convert.ToDouble(y));
GradientStopCollection gradients = new GradientStopCollection();
if (Value != 0)
{
gradients.Add(new GradientStop(Colors.LightBlue, 1));
gradients.Add(new GradientStop(Color.FromArgb(38, 255, 255, 255), 0.448));
gradients.Add(new GradientStop(Color.FromArgb(90, 73, 73, 73), 0.076));
SudokuTextBox.Text = Value.ToString();
SudokuTextBox.IsEnabled = false;
}
else
{
gradients.Add(new GradientStop(Colors.LightGreen, 0.9));
gradients.Add(new GradientStop(Colors.White, 0.448));
gradients.Add(new GradientStop(Colors.LightGreen, 0.076));
}
SudokuTextBox.BorderThickness = new Thickness(0);
SudokuTextBox.TextAlignment = TextAlignment.Center;
LinearGradientBrush brush = new LinearGradientBrush(gradients);
brush.StartPoint = new Point(0.5, 0);
brush.EndPoint = new Point(0.5, 1);
SudokuRectangle.Fill = brush;
SudokuRectangle.Stroke = Brushes.Gray;
SudokuRectangle.StrokeThickness = 1;
SudokuRectangle.RadiusX = 8;
SudokuRectangle.RadiusY = 8;
SudokuTextBox.TextChanged += new TextChangedEventHandler(SudokuTextBox_TextChanged);
}
示例3: SaveGradient
public override void SaveGradient()
{
double rate = DataManager.Instance.MainData.PixelWidth / _bokehData.Width;
GradientStopCollection collection = new GradientStopCollection();
collection.Add(new GradientStop() { Color = Colors.Transparent, Offset = _bokehData.Rate });
collection.Add(new GradientStop() { Color = Color.FromArgb(128, 0, 0, 0), Offset = _bokehData.Rate });
collection.Add(new GradientStop() { Color = Color.FromArgb(255, 0, 0, 0), Offset = 1 });
RadialGradientBrush brush = new RadialGradientBrush()
{
GradientOrigin = _bokehData.StarPoint,
Center = _bokehData.StarPoint,
RadiusX = _bokehData.RadiusX,
RadiusY = _bokehData.RadiusY,
GradientStops = collection,
};
Rectangle rectangle = new Rectangle()
{
Width = DataManager.Instance.MainData.PixelWidth,
Height = DataManager.Instance.MainData.PixelHeight,
Fill = _bokehData.MaskBrush,
OpacityMask = brush
};
Canvas saveCanvas = new Canvas()
{
Width = rectangle.Width,
Height = rectangle.Height,
Background = new ImageBrush() { ImageSource = DataManager.Instance.MainData },
};
saveCanvas.Children.Add(rectangle);
WriteableBitmap bmp = new WriteableBitmap(saveCanvas, null);
DataManager.Instance.SaveToFile(bmp);
}
示例4: BGBarListBoxItem
public BGBarListBoxItem(RecFolderInfo item)
{
InitializeComponent();
labelFolder.Content = item.recFolder;
progressBar.Value = item.freeBytes;
progressBar.Maximum = item.totalBytes;
GradientStopCollection stops = new GradientStopCollection();
stops.Add(new GradientStop(Colors.Red, 0.1));
stops.Add(new GradientStop(Colors.Yellow, 0.3));
stops.Add(new GradientStop(Colors.Lime, 0.4));
LinearGradientBrush brush = new LinearGradientBrush(stops, new Point(0, 0), new Point(1, 0));
brush.ColorInterpolationMode = ColorInterpolationMode.SRgbLinearInterpolation;
progressBar.Background = brush;
if (item.freeBytes > 0 && item.totalBytes > 0)
{
List<string> units = new List<string> { "Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };
int unit_base = 1024;
int n = (int)Math.Floor(Math.Min(Math.Log(item.freeBytes) / Math.Log(unit_base), units.Count - 1));
int m = (int)Math.Floor(Math.Min(Math.Log(item.totalBytes) / Math.Log(unit_base), units.Count - 1));
ToolTip = "空き容量: " + Math.Round(item.freeBytes / Math.Pow(unit_base, n), 1).ToString() + " " + units[n]
+ "/" + Math.Round(item.totalBytes / Math.Pow(unit_base, m), 1).ToString() + " " + units[m];
}
}
示例5: CreateGradientBrush
protected Brush CreateGradientBrush(Color baseColor)
{
const byte brightness = 60;
var gradientStops = new GradientStopCollection();
gradientStops.Add(new GradientStop() { Color = LightenColor(baseColor, brightness), Offset = 0.0 });
gradientStops.Add(new GradientStop() { Color = baseColor, Offset = 1.0 });
return new LinearGradientBrush(gradientStops, 90);
}
示例6: OnMouseLeave
private void OnMouseLeave(object sender, RoutedEventArgs e)
{
GradientStopCollection stopCollection = new GradientStopCollection();
stopCollection.Add(new GradientStop(Colors.Blue, 0.05));
stopCollection.Add(new GradientStop(Colors.LightBlue, 0.95));
RadialGradientBrush brush = new RadialGradientBrush(stopCollection);
circle.Fill = brush;
}
示例7: OnOneClick
private void OnOneClick(object sender, RoutedEventArgs e)
{
RadialGradientBrush brush = this.Resources["redBrush"] as RadialGradientBrush;
var gradientStops = new GradientStopCollection();
gradientStops.Add(new GradientStop(Colors.LightBlue, 0));
gradientStops.Add(new GradientStop(Colors.DarkBlue, 1));
LinearGradientBrush newBrush = new LinearGradientBrush(gradientStops);
this.Resources["redBrush"] = newBrush;
}
示例8: BrushEditor
public BrushEditor()
{
GradientStopCollection stops = new GradientStopCollection();
stops.Add(new GradientStop(Colors.Black, 0));
stops.Add(new GradientStop(Colors.White, 1));
linearGradientBrush = new LinearGradientBrush(stops);
linearGradientBrush.EndPoint = new Point(1, 0);
radialGradientBrush = new RadialGradientBrush(stops);
}
示例9: SetGradient
private void SetGradient(Color topColor, Color bottomColor)
{
GradientStopCollection gradients = new GradientStopCollection();
gradients.Add(new GradientStop(topColor, 0.9));
gradients.Add(new GradientStop(Colors.WhiteSmoke, 0.448));
gradients.Add(new GradientStop(bottomColor, 0.076));
LinearGradientBrush brush = new LinearGradientBrush(gradients);
brush.StartPoint = new Point(0.5, 0);
brush.EndPoint = new Point(0.5, 1);
SudokuRectangle.Fill = brush;
}
示例10: AssocColor
public void AssocColor(string seriesId, Color b)
{
Color bTransparent = b;
bTransparent.A = 0;
GradientStopCollection gs = new GradientStopCollection();
gs.Add(new GradientStop(bTransparent, 0));
gs.Add(new GradientStop(b, 0.1));
LinearGradientBrush g = new LinearGradientBrush(gs, new Point(0,0), new Point(ActualWidth, 0));
g.MappingMode = BrushMappingMode.Absolute;
g.Freeze();
brushes[seriesId] = g;
}
示例11: BtnSnowflake_Click
/// <summary>
/// Handles the click event on the Koch Snowflake button
/// </summary>
/// <param name="sender">The object generating the event</param>
/// <param name="e">RoutedEventArgs event arguments</param>
private void BtnSnowflake_Click(object sender, RoutedEventArgs e)
{
// set up the canvas background brush and instantiate the window with it
GradientStopCollection gradStop = new GradientStopCollection();
gradStop.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF88ADD8"), 0.947));
gradStop.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF235087"), 0.992));
gradStop.Add(new GradientStop(Colors.White, 0));
RadialGradientBrush brushBG = new RadialGradientBrush(gradStop);
FractalWindow winFrac = new FractalWindow(brushBG);
// setup the fractal we're going to draw and put it in the FractalWindow object
LineBendingFractal fractal = new LineBendingFractal();
winFrac.HostedFractal = fractal;
winFrac.Show();
}
示例12: Convert
/// <summary>
/// Converts the color of the supplied brush changing its luminosity by the given factor.
/// </summary>
/// <param name="value">The value that is produced by the binding target.</param>
/// <param name="targetType">The type to convert to.</param>
/// <param name="parameter">The factor used to adjust the luminosity (0..1).</param>
/// <param name="culture">The culture to use in the converter (unused).</param>
/// <returns>A converted value.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
#endif
{
if (value == null) return null;
if (parameter == null) return null;
var factor = double.Parse(parameter.ToString(), CultureInfo.InvariantCulture);
if (value is SolidColorBrush)
{
var color = ((SolidColorBrush)value).Color;
var hlsColor = HlsColor.FromRgb(color);
hlsColor.L *= factor;
return new SolidColorBrush(hlsColor.ToRgb());
}
else if (value is LinearGradientBrush)
{
var gradientStops = new GradientStopCollection();
foreach (var stop in ((LinearGradientBrush)value).GradientStops)
{
var hlsColor = HlsColor.FromRgb(stop.Color);
hlsColor.L *= factor;
gradientStops.Add(new GradientStop() { Color = hlsColor.ToRgb(), Offset = stop.Offset });
}
var brush = new LinearGradientBrush(gradientStops, 0.0);
return brush;
}
return value;
}
示例13: HeatMapLayer
/// <summary>
/// Initializes a new instance of the <see cref="HeatMapLayer"/> class.
/// </summary>
public HeatMapLayer()
{
GradientStopCollection stops = new GradientStopCollection();
stops.Add(new GradientStop() { Color = Colors.Transparent, Offset = 0 });
stops.Add(new GradientStop() { Color = Colors.Blue, Offset = .5 });
stops.Add(new GradientStop() { Color = Colors.Red, Offset = .75 });
stops.Add(new GradientStop() { Color = Colors.Yellow, Offset = .8 });
stops.Add(new GradientStop() { Color = Colors.White, Offset = 1 });
Gradient = stops;
HeatMapPoints = new ESRI.ArcGIS.Client.Geometry.PointCollection();
//Create a separate thread for rendering the heatmap layer.
renderThread = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true };
renderThread.ProgressChanged += new ProgressChangedEventHandler(renderThread_ProgressChanged);
renderThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(renderThread_RunWorkerCompleted);
renderThread.DoWork += new DoWorkEventHandler(renderThread_DoWork);
}
示例14: Tank
//public override double Temperature
//{
// set
// {
// base.Temperature = value;
// Canvas.SetTop(fillRect, 85.0 - base.Temperature);
// fillRect.Height = base.Temperature;
// bool flag = !MinTemperature;
// if (!flag)
// {
// fillRect.Fill = Brushes.Blue;
// }
// else
// {
// flag = !MaxTemperature;
// if (!flag)
// fillRect.Fill = Brushes.Red;
// else
// fillRect.Fill = Brushes.Green;
// }
// }
//}
public Tank()
: base(new Dictionary<String, Parameter>()
{
{ "Temperature", new Parameter(0.0, 0.0, 100.0, ".T") },
{ "Level", new Parameter(0.0, 0.0, 60.0, ".L") }
})
{
ellipseTop = new Ellipse();
ellipseBottom = new Ellipse();
backRect = new Rectangle();
fillRect = new Rectangle();
Canvas.SetLeft(ellipseTop, 0.0);
Canvas.SetTop(ellipseTop, 0.0);
ellipseTop.Width = 100.0;
ellipseTop.Height = 20.0;
GradientStopCollection gradientStopCollection = new GradientStopCollection();
gradientStopCollection.Add(new GradientStop(Color.FromArgb(255, 200, 190, 160), 0.0));
gradientStopCollection.Add(new GradientStop(Color.FromArgb(255, 100, 90, 60), 1.0));
ellipseTop.Fill = new LinearGradientBrush(gradientStopCollection);
Canvas.SetLeft(ellipseBottom, 0.0);
Canvas.SetTop(ellipseBottom, 80.0);
ellipseBottom.Width = 100.0;
ellipseBottom.Height = 20.0;
gradientStopCollection = new GradientStopCollection();
gradientStopCollection.Add(new GradientStop(Color.FromArgb(255, 200, 190, 160), 0.0));
gradientStopCollection.Add(new GradientStop(Color.FromArgb(255, 100, 90, 60), 1.0));
ellipseBottom.Fill = new LinearGradientBrush(gradientStopCollection);
Canvas.SetLeft(backRect, 0.0);
Canvas.SetTop(backRect, 10.0);
backRect.Width = 100.0;
backRect.Height = 80.0;
gradientStopCollection = new GradientStopCollection();
gradientStopCollection.Add(new GradientStop(Color.FromArgb(255, 200, 190, 160), 0.0));
gradientStopCollection.Add(new GradientStop(Color.FromArgb(255, 100, 90, 60), 1.0));
backRect.Fill = new LinearGradientBrush(gradientStopCollection);
Canvas.SetLeft(fillRect, 5.0);
fillRect.Width = 90.0;
Children.Add(ellipseTop);
Children.Add(ellipseBottom);
Children.Add(backRect);
Children.Add(fillRect);
Update();
}
示例15: Convert
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
double value = double.Parse(values[0].ToString());
double maxValue = double.Parse(values[1].ToString());
if (value <= 0) return new SolidColorBrush(TRANSPARENT);
if (value >= maxValue) return new SolidColorBrush(OPAQUE);
double percentage = value / maxValue;
GradientStopCollection gradientStops = new GradientStopCollection();
gradientStops.Add(new GradientStop(OPAQUE, 0.0));
gradientStops.Add(new GradientStop(OPAQUE, percentage - 0.01));
gradientStops.Add(new GradientStop(TRANSPARENT, percentage + 0.01));
gradientStops.Add(new GradientStop(TRANSPARENT, 1.0));
return new LinearGradientBrush(gradientStops, new Point(0.5, 1.0), new Point(0.5, 0.0));
}