public bool Delete(DynamicEquation o) { if (o == null) { return(false); } var old_value = values; var new_value = new List <DynamicEquation>(values); new_value.Remove(o); var cmd = new Command.DelegateCommand( () => { values = new_value; if (OnChanged != null) { OnChanged(this, null); } }, () => { values = old_value; if (OnChanged != null) { OnChanged(this, null); } }); Command.CommandManager.Execute(cmd); return(true); }
public int GetIndex(DynamicEquation vector) { if (vector == null) { return(-1); } return(Values.IndexOf(vector)); }
public static void LoadFromElement(XmlElement e, Data.DynamicEquationCollection collection, bool isClip) { collection.Values.Clear(); for (var i = 0; i < e.ChildNodes.Count; i++) { var e_child = e.ChildNodes[i] as XmlElement; var element = new DynamicEquation(DynamicEquation.DefaultName, collection); LoadFromElement(e_child, element, isClip); collection.Values.Add(element); } }
public bool Delete(DynamicEquation o) { if (o == null) { return(false); } var old_index = values.IndexOf(o); var old_value = values; var new_value = new List <DynamicEquation>(values); new_value.Remove(o); var cmd = new Command.DelegateCommand( () => { values = new_value; if (old_index < values.Count) { selected = new_value[old_index]; } else if (old_index > 0 && values.Count > 0) { selected = new_value[old_index - 1]; } else { selected = null; } if (OnChanged != null) { OnChanged(this, null); } }, () => { values = old_value; selected = o; if (OnChanged != null) { OnChanged(this, null); } }); Command.CommandManager.Execute(cmd); return(true); }
public bool Add() { if (values.Count >= 16) { return(false); } var old_selected = selected; var old_value = values; var new_value = new List <DynamicEquation>(values); var value = new DynamicEquation(this); value.Name.SetValue("New Expression"); value.Code.SetValue("@O.x = @In0\[email protected] = @In1"); new_value.Add(value); var cmd = new Command.DelegateCommand( () => { values = new_value; selected = new_value[new_value.Count - 1]; if (OnChanged != null) { OnChanged(this, null); } }, () => { values = old_value; selected = old_selected; if (OnChanged != null) { OnChanged(this, null); } }); Command.CommandManager.Execute(cmd); return(true); }