private static void Main(string[] args) { ColorPoint cPoint = new ColorPoint(); Console.WriteLine(cPoint.Sum()); //30 // вызов методов по типу ссылки }
/// <summary> ///Рисуем карту рисков /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void draw_risk_Click(object sender, EventArgs e) { try { DataSender ds = new DataSender(); ds.n = 1; ds.points = new List <ColorPoint>(); double scalecoeff = 50; // проходимся по дереву выбранных атрибутов, берем значение вероятности и влияния для выбранного элемента for (int ns = 10; ns < dataGridView1.Rows.Count; ns++) // перебираем столбцы (перебирая системы) { double x = (double)dataGridView1.Rows[ns].Cells[5].Value; // вероятность double y = (double)dataGridView1.Rows[ns].Cells[6].Value; // влияние string name = $"{dataGridView1.Rows[ns].Cells[1].Value}\r\n{dataGridView1.Rows[ns].Cells[2].Value}\r\n{dataGridView1.Rows[ns].Cells[3].Value}\r\n{dataGridView1.Rows[ns].Cells[4].Value}\r\n"; // $"Система - {rsk[ns - 1]}, \r\nЭлемент - {(string)dataGridView3.Rows[oldrowindex].Cells[0].Value}, \r\nАтрибут - {(string)dataGridView3.Rows[i + oldrowindex].Cells[0].Value}"; ColorPoint cp = new ColorPoint(x, y, 10 /*Радиус точки для отрисовки*/, name, dataGridView1.Rows[ns].DefaultCellStyle.BackColor, scalecoeff); ds.points.Add(cp); } FormGraphics fr = new FormGraphics(ds, $"Карта рисков\"{""}\"", own: this); fr.Show(); } catch (Exception ex) { } }
public static void Main() { string path = @"..\..\..\..\MyTest.dat"; int N = 10; List<ColorPoint> list = new List<ColorPoint>(); ColorPoint one; for (int i = 0; i < N; i++) { one = new ColorPoint(); one.x = gen.NextDouble(); one.y = gen.NextDouble(); int j = gen.Next(0, ColorPoint.colors.Length); one.color = ColorPoint.colors[j]; list.Add(one); } // Запись массива стpок в бинарный файл файл: var fs = new FileStream(path, FileMode.Open); using (BinaryWriter bw = new BinaryWriter(fs)) { foreach (var obj in list) { bw.Write(obj.color); bw.Write(obj.x); bw.Write(obj.y); } } Console.WriteLine("Записаны {0} строк в бинарный файл: \n{1}", N, path); }
private byte[] GetImageData(ColorPoint[] points) { ColorPoint last = points.Last(); int size = last.Position + 1; using (var ms = new MemoryStream()) { using (var bmp = new Bitmap(1, size, PixelFormat.Format32bppArgb)) { using (Graphics g = Graphics.FromImage(bmp)) { for (int i = 1; i < points.Length; i++) { var rect = new Rectangle(0, points[i - 1].Position, 1, points[i].Position); var brush = new LinearGradientBrush( rect, points[i - 1].Color, points[i].Color, LinearGradientMode.Vertical); g.FillRectangle(brush, rect); } bmp.SetPixel(0, last.Position, last.Color); bmp.Save(ms, ImageFormat.Png); } } return(ms.ToArray()); } }
private void _deletePoint_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; _editingColorPoint = b.DataContext as ColorPoint; Points.Remove(_editingColorPoint); }
public Colorf Linear(float t) { if (t <= points[0].t) { return(points[0].c); } int N = points.Count; if (t >= points[N - 1].t) { return(points[N - 1].c); } for (int k = 1; k < points.Count; ++k) { if (points[k].t > t) { ColorPoint prev = points[k - 1], next = points[k]; float a = (t - prev.t) / (next.t - prev.t); return((1.0f - a) * prev.c + (a) * next.c); } } return(points[N - 1].c); // should never get here... }
static void Main(string[] args) { ColorPoint startPoint = new ColorPoint(); Console.WriteLine(startPoint); Console.WriteLine(startPoint.Sum()); //0 }
static void Main(string[] args) { string path = @"../../../MyTest.txt"; if (!File.Exists(path)) { Console.WriteLine("Файл \"{0}\" не найден!", path); Console.ReadLine(); return; } // Таймер для профилирования фрагмента кода: System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); timer.Start(); string[] arrData = File.ReadAllLines(path); List <ColorPoint> list = new List <ColorPoint>(); int N = arrData.Length; // Количество строк в файле for (int i = 0; i < N; i++) { string s = arrData[i]; // list.Add(ColorPoint.GetObj(s)); // TODO: разработать GetObj(s) - // статический метод разбора строки и создания объекта ColorPoint: } timer.Stop(); foreach (ColorPoint l in list) { Console.WriteLine(l.ToString()); } Console.WriteLine("Прочитаны {0} строк из файла: \n{1}", N, path); Console.WriteLine("Метод: ReadAllLines \nВремя обработки: {0}", timer.Elapsed); Console.WriteLine("Время в миллисекундах: {0}", timer.ElapsedMilliseconds); Console.ReadKey(); }
public static void Main() { string path = @"..\..\..\..\MyTest.txt"; int N; // Количество создаваемых объектов (число строк в файле) // TODO: Определить значение N N = int.Parse(Console.ReadLine()); List<ColorPoint> list = new List<ColorPoint>(); ColorPoint one; for (int i = 0; i < N; i++) { one = new ColorPoint(); one.x = gen.NextDouble(); one.y = gen.NextDouble(); int j = gen.Next(0, ColorPoint.colors.Length); one.color = ColorPoint.colors[j]; list.Add(one); } string[] arrData = Array.ConvertAll(list.ToArray(), (ColorPoint cp) => cp.ToString()); // Запись массива стpок в текстовый файл: using(BinaryWriter bw = new BinaryWriter(File.Open(path, FileMode.OpenOrCreate))) { foreach(ColorPoint cp in list) { bw.Write(cp.color); bw.Write(cp.x); bw.Write(cp.y); } } Console.WriteLine("Записаны {0} строк в текстовый файл: \n{1}", N, path); }
private void ReloadPoints() { //Logging.Debug("Enter Reload"); if (GetColorGradientValue() != null) { ClearPoints(); var value = GetColorGradientValue(); List <ColorPoint> sortedColors = new List <ColorPoint>(value.Colors.SortedArray()); // we'll assume they're sorted, so any colorpoints at the same position are contiguous in the array for (int i = 0; i < sortedColors.Count; i++) { ColorPoint currentPoint = sortedColors[i]; double currentPos = currentPoint.Position; List <int> indexes = new List <int>(); indexes.Add(value.Colors.IndexOf(currentPoint)); while (i + 1 < sortedColors.Count && sortedColors[i + 1].Position == currentPos) { indexes.Add(value.Colors.IndexOf(sortedColors[i + 1])); i++; } var point = AddPoint(currentPos); point.Tag = indexes; } } //Logging.Debug("Exit Reload"); }
private void DeletePoint() { var selectedIndex = SelectedIndex; if (selectedIndex >= 0) { var selectedPoint = _points[selectedIndex]; List <int> colorPointIndexes = (List <int>)selectedPoint.Tag; var holdValue = new ColorGradient(GetColorGradientValue()); List <ColorPoint> colorPoints = new List <ColorPoint>(); foreach (int index in colorPointIndexes) { ColorPoint pt = holdValue.Colors[index]; if (pt == null) { continue; } colorPoints.Add(pt); } foreach (var colorpoint in colorPoints) { holdValue.Colors.Remove(colorpoint); } SetColorGradientValue(holdValue); } }
private void Button_Click(object sender, RoutedEventArgs e) { double maxValue = Points.Count > 0 ? Points.Max(o => o.Value) : -1; ColorPoint col = new ColorPoint { Value = maxValue + 1, LowColor = Colors.Black, HiColor = Colors.White }; Points.Add(col); _lister.SelectedItem = col; }
private double GetChannelFactor(ColorPoint[] channelPoints, double position) { if (channelPoints.Length < 1) { throw new ArgumentException("channelPoints must have any elements"); } ColorPoint startPoint = channelPoints[0]; ColorPoint endPoint = channelPoints[channelPoints.Length - 1]; foreach (ColorPoint point in channelPoints) { if (position > point.position) { startPoint = point; } else { endPoint = point; break; } } double positionFactor = (position - startPoint.position) / (endPoint.position - startPoint.position); return(Lerp(startPoint.factor, endPoint.factor, positionFactor)); }
private void PickHighColor_Click(object sender, RoutedEventArgs e) { Button b = sender as Button; _editingColorPoint = b.DataContext as ColorPoint; PopupColorPicker.Instance.SelectedColor = _editingColorPoint.HiColor; PopupColorPicker.Instance.ColorChanged += new PopupColorPicker.ColorChangedEventHandler(HighColorChanged); PopupColorPicker.Instance.Show(); }
/// <summary> /// Get the item in the specific index /// </summary> /// <param name="index">The index</param> /// <returns>The item in the specific index</returns> public ColorPoint this[int index] { get { ColorPoint result = new ColorPoint(); VectorOfColorPointGetItem(_ptr, index, ref result); return(result); } }
private static void Main(string[] args) { Point a12 = new Point(); Console.WriteLine(a12.Sum()); //30 ColorPoint ca100 = new ColorPoint(); a12 = ca100; Console.WriteLine(a12.Sum());//30 // вызов методов по типу ссылки }
/// <summary> /// Convert the standard vector to an array of ColorPoint /// </summary> /// <returns>An array of ColorPoint</returns> public ColorPoint[] ToArray() { ColorPoint[] res = new ColorPoint[Size]; if (res.Length > 0) { GCHandle handle = GCHandle.Alloc(res, GCHandleType.Pinned); VectorOfColorPointCopyData(_ptr, handle.AddrOfPinnedObject()); handle.Free(); } return(res); }
public void Equals_ColorPointEqualsPoint() { // Arrange Point P = new Point(1, 2); ColorPoint cp1 = new ColorPoint(1, 2, Color.Red); bool expected = true; // Act bool actual = ((Point)cp1).Equals(P); // Assert Assert.Equal(expected, actual); }
public void Equals_ColorPointDoesNotEqualDifferentColorPoint() { // Arrange ColorPoint cp1 = new ColorPoint(1, 2, Color.Red); ColorPoint cp2 = new ColorPoint(1, 2, Color.Blue); bool expected = false; // Act bool actual = cp1.Equals(cp2); // Assert Assert.Equal(expected, actual); }
public static void Main(String[] args) { Point <String> p1 = new Point <String>(5, 117, "home"), p2 = new Point <String>(2, 3, "work"); Point <double> p3 = new Point <double>(10, 100, 3.1415); ColorPoint <String, uint> p4 = new ColorPoint <String, uint>(20, 30, "foo", 0x0000FF); ColorPoint <String, Color> p5 = new ColorPoint <String, Color>(40, 50, "bar", Color.Blue); IMovable[] movables = { p1, p2, p3, p4, p5 }; Point <String>[] stringpoints = { p1, p4, p5 }; }
/// <summary> /// Get points. /// </summary> /// <param name="amount"> amount of points </param> /// <returns> List of points </returns> private static IEnumerable <ColorPoint> GetPoints(int amount) { var points = new List <ColorPoint>(); for (var i = 0; i < amount; i++) { ColorPoint point = GetPoint(); points.Add(point); } return(points); }
/// <summary> /// Get point. /// </summary> /// <returns> Color point </returns> private static ColorPoint GetPoint() { var point = new ColorPoint { X = Rnd.NextDouble(), Y = Rnd.NextDouble() }; int typeColorIndex = Rnd.Next(0, ColorPoint.Colors.Count); point.Color = ColorPoint.Colors[typeColorIndex]; return(point); }
/// <summary> /// 压缩位图文件 /// </summary> /// <param name="image"></param> /// <param name="fileName"></param> public static void Compress(Bitmap image, string fileName) { int x, y; int index; //建立颜色表 Dictionary<Color, int> colorTable = new Dictionary<Color, int>(); //象素点队列 List<ColorPoint> pointTable = new List<ColorPoint>(); index = 0; //获取第一点的象素颜色 ColorPoint point = new ColorPoint(image.GetPixel(0, 0), 0, 0); for (y = 0; y < image.Height; y++) { for (x = 0; x < image.Width; x++) { Color color = image.GetPixel(x, y); //将新颜色添加到颜色表中 if (!colorTable.ContainsKey(color)) { colorTable.Add(color, index++); } //判断颜色出现的次数 if (point.Color == color && point.Count < byte.MaxValue) { point.Count++; } else { //取得当前象素颜色所在颜色表的位置 point.Index = colorTable[point.Color]; pointTable.Add(point); //处理下一个颜色 point = new ColorPoint(color, 0, 1); } } } //处理最后的数据 if (point.Count > 0) { point.Index = colorTable[point.Color]; pointTable.Add(point); } WriteCompressPictureToStream(image, colorTable, pointTable, fileName); }
public SettingsWindow() { InitializeComponent(); _textBox.Text = Settings.Default.ProcessName; _colorTolerBox.Text = Settings.Default.ColorTolerance.ToString(); if (!string.IsNullOrWhiteSpace(Settings.Default.BattleConditions)) { var parts = ColorPoint.ParseCollection(Settings.Default.BattleConditions).ToList(); _tb1.Text = parts[0].ToString(); _tb2.Text = parts[1].ToString(); } }
public async Task AddColorPoint(double hue, double x, double y) { var point = new ColorPoint { hue = hue, x = x, y = y }; Console.WriteLine(point.ToString()); await displayClients.Do(async displays => { foreach (var client in displays) { await client.SendAsync("RecieveColorPoint", point); } }); }
public Vector3 GetValue(float t) { ColorPoint min = colorPoints[0]; for (int i = 0; i < colorPoints.Length; i++) { ColorPoint p = colorPoints[i]; if (p.position > t) { float frac = (t - min.position) / (p.position - min.position); return(min.color * (1 - frac) + p.color * frac); } min = p; } return(colorPoints[colorPoints.Length - 1].color); }
private void button1_Click(object sender, EventArgs e) { ColorPoint[] masColorPoint = new ColorPoint[5]; masColorPoint[0] = new ColorPoint(200, 100, "Green"); masColorPoint[1] = new ColorPoint(300, 200, "Blue"); masColorPoint[2] = new ColorPoint(200, 300, "Red"); masColorPoint[3] = new ColorPoint(100, 100, "Black"); masColorPoint[4] = new ColorPoint(200, 200, "Aqua"); Graphics g = panel1.CreateGraphics(); foreach (var item in masColorPoint) { Pen p = new Pen(Color.FromName(item.Color), 5); g.DrawEllipse(p, item.X, item.Y, 200, 100); } }
protected override Node Evaluate(Env env) { ColorPoint[] points = GetColorPoints(); WarnNotSupportedByLessJS("gradientImage(color, color[, position])"); string colorDefs = ColorPoint.Stringify(points); string imageUrl = GetFromCache(colorDefs); if (imageUrl == null) { imageUrl = "data:image/png;base64," + Convert.ToBase64String(GetImageData(points)); AddToCache(colorDefs, imageUrl); } return(new Url(new TextNode(imageUrl))); }
/// <summary> /// Get point. /// </summary> /// <param name="line"> Line for processing </param> /// <returns> ColorPoint </returns> private static ColorPoint GetPoint(string line) { string[] colorPointData = line.Split(); var x = Convert.ToDouble(colorPointData[0]); var y = Convert.ToDouble(colorPointData[1]); string color = colorPointData[2]; // Create new point. var colorPoint = new ColorPoint { X = x, Y = y, Color = color }; return(colorPoint); }
static void Main(string[] args) { int x, y, red, blue, green; Console.Write("Enter x coordinates: "); x = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter y coordinates: "); y = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter coordinates of red color: "); red = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter coordinates of blue color: "); blue = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter coordinates of green color: "); green = Convert.ToInt32(Console.ReadLine()); Point point = new ColorPoint(x, y, red, blue, green); Console.WriteLine(point.ToString()); Console.ReadLine(); }
private void Form1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ColorPoint p = new ColorPoint(e.X, e.Y, false); this.coordinates.Add(p); this.Invalidate(); } if (e.Button == MouseButtons.Right) { int i = 0; while (true) { ColorPoint cpoint = (ColorPoint)coordinates[i]; Point point = cpoint.p; if ((e.X < (point.X + (WIDTH / 2))) && (e.X > (point.X - (WIDTH / 2))) && (e.Y > (point.Y - (HEIGHT / 2))) && (e.Y < (point.Y + (HEIGHT / 2)))) { if (!cpoint.isRed) { cpoint.setIsRed(true); this.Invalidate(); i++; } else { coordinates.RemoveAt(i); this.Invalidate(); } } else { i++; } if (i == coordinates.Count) { break; } } } }
public void AddPoint(float t, Colorf c) { var cp = new ColorPoint() { t = t, c = c }; if (points.Count == 0) { points.Add(cp); validRange.Contain(t); } else if (t < points[0].t) { points.Insert(0, cp); validRange.Contain(t); } else { for (int k = 0; k < points.Count; ++k) { if (points[k].t == t) { points[k] = cp; return; } else if (points[k].t > t) { points.Insert(k, cp); return; } } points.Add(cp); validRange.Contain(t); } }
// edits the selected color in the 'edit' control private void editSelectedPoints() { if (edit.Gradient == null || edit.FocusSelection) return; if (DiscreteColors) { List<Color> selectedColors = new List<Color>(); foreach (ColorGradient.Point point in edit.Selection) { ColorPoint pt = point as ColorPoint; if (pt == null) continue; selectedColors.Add(pt.Color.ToRGB().ToArgb()); } using (DiscreteColorPicker picker = new DiscreteColorPicker()) { picker.ValidColors = ValidDiscreteColors; picker.SelectedColors = selectedColors; if (picker.ShowDialog() == DialogResult.OK) { if (picker.SelectedColors.Count() == 0) { DeleteColor(); } else if (picker.SelectedColors.Count() == selectedColors.Count) { int i = 0; foreach (Color selectedColor in picker.SelectedColors) { ColorPoint pt = edit.Selection[i] as ColorPoint; pt.Color = XYZ.FromRGB(selectedColor); } } else { double position = edit.Selection.First().Position; foreach (ColorGradient.Point point in edit.Selection) { edit.Gradient.Colors.Remove(point as ColorPoint); } foreach (Color selectedColor in picker.SelectedColors) { ColorPoint newPoint = new ColorPoint(selectedColor, position); edit.Gradient.Colors.Add(newPoint); } } } } } else { if (edit.Selection.Count > 1) MessageBox.Show("Non-discrete color gradient, >1 selected point. oops! please report it."); ColorPoint pt = edit.Selection.FirstOrDefault() as ColorPoint; if (pt == null) return; using (ColorPicker frm = new ColorPicker(_mode, _fader)) { frm.LockValue_V = LockColorEditorHSV_Value; frm.Color = _xyz; if (frm.ShowDialog(this.FindForm()) == DialogResult.OK) { pt.Color = _xyz = frm.Color; lblColorSelect.Color = _xyz.ToRGB().ToArgb(); _mode = frm.SecondaryMode; _fader = frm.PrimaryFader; } } } }
/// <summary> /// Finds the true and false representaions and dets the /// gradient stop colors for them /// </summary> /// <param name="el">The framework element</param> /// <param name="colorPoint">The colorPoint for the current value</param> /// <param name="id">The number of the element to set the color for</param> private static void UpdateColorsFromXaml(FrameworkElement el, ColorPoint colorPoint, string id) { if (el == null || colorPoint.HiColor == null || colorPoint.LowColor == null) { return; } GradientStop highStop = el.FindName(id + "HighColor") as GradientStop; GradientStop lowStop = el.FindName(id + "LowColor") as GradientStop; if (highStop != null && lowStop != null) { highStop.Color = colorPoint.HiColor; lowStop.Color = colorPoint.LowColor; } }
//select or add faders protected override void OnMouseDown(MouseEventArgs e) { if (_blend != null && e.Button == MouseButtons.Left && !ReadOnly) { bool foc; Selection = GetFadersUnderMouse(e.Location, ref _offset, out foc); FocusSelection = foc; if (_selection == null || _selection.Count == 0) { //create new color or alpha point Rectangle area = Rectangle.Inflate(this.ClientRectangle, -BORDER, -BORDER); double pos = PointToPos(e.Location); _offset = Point.Empty; // if (_orientation == Orientation.Horizontal ? e.Y > area.Bottom : e.X > area.Right) { List<ColorGradient.Point> newColorPoints; if (DiscreteColors) { List<Color> newColors = new List<Color>(); double targetPos = -1; foreach (ColorPoint colorPoint in _blend.Colors.SortedArray()) { if (targetPos < 0 || (colorPoint.Position < pos && colorPoint.Position != targetPos)) { targetPos = colorPoint.Position; newColors = new List<Color>(); } if (colorPoint.Position == targetPos) newColors.Add(colorPoint.Color.ToRGB()); if (colorPoint.Position > targetPos) break; } newColorPoints = new List<ColorGradient.Point>(); foreach (Color newColor in newColors) { ColorPoint point = new ColorPoint(newColor, targetPos); newColorPoints.Add(point); } } else { newColorPoints = new List<ColorGradient.Point> {new ColorPoint(_blend.GetColorAt((float) pos), pos)}; } _selection = newColorPoints; foreach (ColorPoint newColorPoint in newColorPoints) { _blend.Colors.Add(newColorPoint); } } else if (_orientation == Orientation.Horizontal ? e.Y < area.Y : e.X < area.X) { // MS: 25/09/11: disable drawing alpha points, we don't want to use them (yet). //AlphaPoint pnt = new AlphaPoint(_blend.GetColorAt((float)pos).A, pos); //_selection = pnt; //_blend.Alphas.Add(pnt); } } } base.OnMouseDown(e); }
//select or add faders protected override void OnMouseDown(MouseEventArgs e) { if (_blend != null && e.Button == MouseButtons.Left && !ReadOnly) { bool foc; Selection = GetFaderUnderMouse(e.Location, ref _offset, out foc); FocusSelection = foc; if (_selection == null) { //create new color or alpha point Rectangle area = Rectangle.Inflate(this.ClientRectangle, -BORDER, -BORDER); double pos = PointToPos(e.Location); _offset = Point.Empty; // if (_orientation == Orientation.Horizontal ? e.Y > area.Bottom : e.X > area.Right) { ColorPoint pnt = new ColorPoint(_blend.GetColorAt((float)pos), pos); _selection = pnt; _blend.Colors.Add(pnt); } else if (_orientation == Orientation.Horizontal ? e.Y < area.Y : e.X < area.X) { // MS: 25/09/11: disable drawing alpha points, we don't want to use them (yet). //AlphaPoint pnt = new AlphaPoint(_blend.GetColorAt((float)pos).A, pos); //_selection = pnt; //_blend.Alphas.Add(pnt); } } } base.OnMouseDown(e); }
// edits the selected color in the 'edit' control private void editSelectedPoints() { if (edit.Gradient == null || edit.FocusSelection) return; if (DiscreteColors) { List<Color> selectedColors = new List<Color>(); foreach (ColorGradient.Point point in edit.Selection) { ColorPoint pt = point as ColorPoint; if (pt == null) continue; selectedColors.Add(pt.Color.ToRGB().ToArgb()); } using (DiscreteColorPicker picker = new DiscreteColorPicker()) { picker.ValidColors = ValidDiscreteColors; picker.SelectedColors = selectedColors; if (picker.ShowDialog() == DialogResult.OK) { if (picker.SelectedColors.Count() == 0) { DeleteColor(); } else if (picker.SelectedColors.Count() == selectedColors.Count) { int i = 0; foreach (Color selectedColor in picker.SelectedColors) { ColorPoint pt = edit.Selection[i] as ColorPoint; pt.Color = XYZ.FromRGB(selectedColor); } } else { double position = edit.Selection.First().Position; foreach (ColorGradient.Point point in edit.Selection) { edit.Gradient.Colors.Remove(point as ColorPoint); } foreach (Color selectedColor in picker.SelectedColors) { ColorPoint newPoint = new ColorPoint(selectedColor, position); edit.Gradient.Colors.Add(newPoint); } } } } } else { if (edit.Selection.Count > 1) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Non-discrete color gradient, >1 selected point. oops! please report it.", "Delete library gradient?", false, false); messageBox.ShowDialog(); } ColorPoint pt = edit.Selection.FirstOrDefault() as ColorPoint; if (pt == null) return; using (ColorPicker frm = new ColorPicker(_mode, _fader)) { frm.LockValue_V = LockColorEditorHSV_Value; frm.Color = _xyz; if (frm.ShowDialog(this.FindForm()) == DialogResult.OK) { pt.Color = _xyz = frm.Color; lblColorSelect.Color = _xyz.ToRGB().ToArgb(); _mode = frm.SecondaryMode; _fader = frm.PrimaryFader; } } } }
private byte[] GetImageData(ColorPoint[] points) { ColorPoint last = points.Last(); int size = last.Position + 1; using (var ms = new MemoryStream()) { using (var bmp = new Bitmap(1, size, PixelFormat.Format32bppArgb)) { using (Graphics g = Graphics.FromImage(bmp)) { for (int i = 1; i < points.Length; i++) { var rect = new Rectangle(0, points[i - 1].Position, 1, points[i].Position); var brush = new LinearGradientBrush( rect, points[i - 1].Color, points[i].Color, LinearGradientMode.Vertical); g.FillRectangle(brush, rect); } bmp.SetPixel(0, last.Position, last.Color); bmp.Save(ms, ImageFormat.Png); } } return ms.ToArray(); } }