Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public int GetIndex(DynamicEquation vector)
 {
     if (vector == null)
     {
         return(-1);
     }
     return(Values.IndexOf(vector));
 }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }