public void AddPoint() { double val = 0; if (Points.Count != 0) val = Points[Points.Count - 1].Point + 1; GradientPoint point = new GradientPoint() { Point = val, color = Colors.Black }; Points.Add(point); point.PropertyChanged += new PropertyChangedEventHandler(point_PropertyChanged); RaisePropertyChanged("Points"); point.NeedDelete += new EventHandler<EventArgs>(point_NeedDelete); }
public void Load(StreamReader sr) { GradientDef g = new GradientDef(); String line; while ((line = sr.ReadLine()) != null) { if (line.Length == 0) { GradientDefs.Add(g); return; } string[] words = line.Split(seperator); if (words[0] == "Gradient") { string name = ""; for (int i = 1; i < words.Length; ++i) name += (i == 1 ? "" : " ") + words[i]; g.Name = name; } else if (words[0] == "Point") { try { GradientPoint point = new GradientPoint() { Point = Convert.ToDouble(words[1]), color = new Color() { R = Convert.ToByte(words[2]), G = Convert.ToByte(words[3]), B = Convert.ToByte(words[4]), A = 255 } }; g.Points.Add(point); } catch (Exception) { } } } }