当前位置: 首页>>代码示例>>C#>>正文


C# GradientStopCollection.Add方法代码示例

本文整理汇总了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;
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:30,代码来源:ColorToGradientBrushConverter.cs

示例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);
        }
开发者ID:amomsen,项目名称:projects,代码行数:60,代码来源:SudokuSquare.xaml.cs

示例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);
        }
开发者ID:onionstyle,项目名称:BokehDemo,代码行数:35,代码来源:EllipseGradient.cs

示例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];
            }
        }
开发者ID:xceza7,项目名称:EDCB,代码行数:27,代码来源:BGBarListBoxItem.xaml.cs

示例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);
 }
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:8,代码来源:ExtendedDataToSeriesConverterBase.cs

示例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;		
		}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:8,代码来源:PlaybackButton.xaml.cs

示例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;
        }
开发者ID:CNinnovation,项目名称:WPFWorkshopFeb2016,代码行数:10,代码来源:MainWindow.xaml.cs

示例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);
		}
开发者ID:modulexcite,项目名称:WpfDesigner,代码行数:10,代码来源:BrushEditor.cs

示例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;
 }
开发者ID:amomsen,项目名称:projects,代码行数:11,代码来源:SudokuSquare.xaml.cs

示例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;
        }
开发者ID:23119841,项目名称:FERA-2015,代码行数:13,代码来源:AVPlot.xaml.cs

示例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();
        }
开发者ID:delve,项目名称:WpfFractals,代码行数:20,代码来源:MainWindow.xaml.cs

示例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;
        }
开发者ID:alykhaled,项目名称:facebook-winclient-sdk,代码行数:39,代码来源:ColorLuminosityConverter.cs

示例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);
		}
开发者ID:Esri,项目名称:arcgis-toolkit-sl-wpf,代码行数:19,代码来源:HeatMapLayer.cs

示例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();
    }
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:68,代码来源:Tank.cs

示例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));
        }
开发者ID:DarthAffe,项目名称:HikariLauncher,代码行数:18,代码来源:ProgressToOpacityMaskConverter.cs


注:本文中的GradientStopCollection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。