void Add(string s, PenSave ps) { PenValue pv = Transform(ps); save[s] = ps; pens[s] = pv; }
PenValue Transform(PenSave ps) { PenValue pv = new PenValue(); pv.pen = new Pen(ps.color); pv.min = ps.min; pv.max = ps.max; pv.scale = 1 / (ps.max - ps.min); return(pv); }
/// <summary> /// Deserialization constructor /// </summary> /// <param name="info">Serialization info</param> /// <param name="context">Streaming context</param> protected DictionaryPerformer(SerializationInfo info, StreamingContext context) { save = SerializationPerformer.GetObject <Dictionary <string, PenSave> >(info, "Pens"); foreach (string s in save.Keys) { PenSave ps = save[s]; PenValue pv = Transform(ps); pens[s] = pv; } init(); }
/// <summary> /// Access to function by name /// </summary> /// <param name="name">Function name</param> /// <returns>The function</returns> public Tuple <Pen, bool, double[], Func <object, double> > this[string name] { set { dictionary[name] = value; PenSave ps = new PenSave(); save[name] = ps; pens[name] = Transform(ps); SetPen(name, value.Item1); double[] d = value.Item3; SetScale(name, d[0], d[1]); converters[name] = value.Item4; } }
/// <summary> /// Sets scale /// </summary> /// <param name="s">Series name</param> /// <param name="min">Minimal value</param> /// <param name="max">Maximal value</param> void SetScale(string s, double min, double max) { if (!save.ContainsKey(s)) { return; } lock (this) { PenSave ps = save[s]; ps.min = min; ps.max = max; pens[s] = Transform(ps); init(); } }
/// <summary> /// Sets series to active /// </summary> /// <param name="s">Series name</param> /// <param name="active">True if active and facle otherwise</param> void SetAcive(string s, bool active) { if (active & save.ContainsKey(s)) { return; } if (!active & !save.ContainsKey(s)) { return; } if (!active) { save.Remove(s); pens.Remove(s); return; } PenSave ps = new PenSave(); ps.color = Color.White; PenValue pv = Transform(ps); save[s] = ps; pens[s] = pv; }