Exemple #1
0
        internal void Update()
        {
            var parameters           = Parameters;
            var modelSystemStructure = ModelSystemStructure;

            if (modelSystemStructure.RealModelSystemStructure.Parameters == null)
            {
                return;
            }
            var realParameters = modelSystemStructure.RealModelSystemStructure.Parameters.Parameters;

            if (realParameters == null)
            {
                return;
            }
            if (Parameters != null)
            {
                Parameters.Clear();
            }
            else
            {
                Parameters = parameters = new List <ParameterModel>(realParameters.Count);
            }
            for (int i = 0; i < realParameters.Count; i++)
            {
                parameters.Add(new ParameterModel(realParameters[i] as ModuleParameter, Session));
            }
            ModelHelper.PropertyChanged(PropertyChanged, this, "Parameters");
        }
Exemple #2
0
 private void UpdateAll()
 {
     UpdateChildren();
     if (!IsCollection)
     {
         Parameters.Update();
     }
     ModelHelper.PropertyChanged(PropertyChanged, this, "Type");
     ModelHelper.PropertyChanged(PropertyChanged, this, "Name");
     ModelHelper.PropertyChanged(PropertyChanged, this, "Description");
 }
Exemple #3
0
        /// <summary>
        /// Removes a collection member at the given index
        /// </summary>
        /// <param name="index">The index to remove from.</param>
        /// <param name="error">If an error happens it will contain a text representation of the error.</param>
        /// <returns>If the index was able to be removed</returns>
        /// <exception cref="InvalidOperationException">This operation is only allowed on Collections.</exception>
        public bool RemoveCollectionMember(int index, ref string error)
        {
            if (index < 0)
            {
                throw new InvalidOperationException("Indexes must be greater than or equal to zero!");
            }

            if (!IsCollection)
            {
                throw new InvalidOperationException("You can not add collection members to a module that is not a collection!");
            }
            CollectionChangeData data = new CollectionChangeData();

            return(Session.RunCommand(XTMFCommand.CreateCommand(
                                          (ref string e) =>
            {
                var children = RealModelSystemStructure.Children;
                if (children.Count <= index)
                {
                    e = "There is no collection member at index " + index + "!";
                    return false;
                }
                data.Index = index;
                data.StructureInQuestion = RealModelSystemStructure.Children[data.Index] as ModelSystemStructure;
                data.ModelInQuestion = Children[data.Index];
                RealModelSystemStructure.Children.RemoveAt(data.Index);
                Children.RemoveAt(data.Index);
                ModelHelper.PropertyChanged(PropertyChanged, this, "Children");
                return true;
            },
                                          (ref string e) =>
            {
                RealModelSystemStructure.Children.Insert(data.Index, data.StructureInQuestion);
                Children.Insert(data.Index, data.ModelInQuestion);
                ModelHelper.PropertyChanged(PropertyChanged, this, "Children");
                return true;
            },
                                          (ref string e) =>
            {
                RealModelSystemStructure.Children.RemoveAt(data.Index);
                Children.RemoveAt(data.Index);
                ModelHelper.PropertyChanged(PropertyChanged, this, "Children");
                return true;
            }),
                                      ref error));
        }
Exemple #4
0
 /// <summary>
 /// Commit the changes into the underlying data
 /// </summary>
 /// <param name="error">If there is a problem</param>
 /// <returns></returns>
 public bool Save(ref string error)
 {
     if (Children != null)
     {
         foreach (var child in Children)
         {
             if (!child.Save(ref error))
             {
                 return(false);
             }
         }
     }
     if (Dirty)
     {
         Dirty = false;
         ModelHelper.PropertyChanged(PropertyChanged, this, "IsDirty");
     }
     return(true);
 }
Exemple #5
0
        public bool SetName(string newName, ref string error)
        {
            var oldName = "";

            return(Session.RunCommand(XTMFCommand.CreateCommand((ref string e) =>
            {
                oldName = this.RealModelSystemStructure.Name;
                this.RealModelSystemStructure.Name = newName;
                ModelHelper.PropertyChanged(PropertyChanged, this, "Name");
                return true;
            }, (ref string e) =>
            {
                this.RealModelSystemStructure.Name = oldName;
                ModelHelper.PropertyChanged(PropertyChanged, this, "Name");
                return true;
            },
                                                                (ref string e) =>
            {
                this.RealModelSystemStructure.Name = newName;
                ModelHelper.PropertyChanged(PropertyChanged, this, "Name");
                return true;
            }), ref error));
        }
Exemple #6
0
 internal void SignalIsLinkedChanged()
 {
     ModelHelper.PropertyChanged(PropertyChanged, this, "IsLinked");
 }
Exemple #7
0
 private void UpdateChildren()
 {
     Children = CreateChildren(Session, RealModelSystemStructure);
     ModelHelper.PropertyChanged(PropertyChanged, this, "Children");
 }