Beispiel #1
0
        /// <summary>
        /// Create a new Linked Parameter with the given name
        /// </summary>
        /// <param name="name">The name of the linked parameter</param>
        /// <param name="error">If an error occurs this will contain a message to describe it.</param>
        /// <returns>True if it executed successfully</returns>
        public bool NewLinkedParameter(string name, ref string error)
        {
            var lp = new LinkedParameterChange();

            return(_Session.RunCommand(
                       XTMFCommand.CreateCommand("New Linked Parameter", (ref string e) =>
            {
                LinkedParameter linkedParameter = new LinkedParameter(name);
                LinkedParameterModel newModel = new LinkedParameterModel(linkedParameter, _Session, _ModelSystem);
                _RealLinkedParameters.Add(linkedParameter);
                LinkedParameters.Add(newModel);
                lp.Model = newModel;
                lp.Index = LinkedParameters.Count - 1;
                return true;
            },
                                                 (ref string e) =>
            {
                LinkedParameters.RemoveAt(lp.Index);
                _RealLinkedParameters.RemoveAt(lp.Index);
                InvokeRemoved(lp);
                return true;
            },
                                                 (ref string e) =>
            {
                LinkedParameters.Insert(lp.Index, lp.Model);
                _RealLinkedParameters.Insert(lp.Index, lp.Model.RealLinkedParameter);
                return true;
            }),
                       ref error
                       ));
        }
Beispiel #2
0
        /// <summary>
        /// Remove a linked parameter from the linked parameters
        /// </summary>
        /// <param name="linkedParameter">The linked parameter to remove</param>
        /// <param name="error">If an error occurs this will contain a message to describe it.</param>
        /// <returns>If the command was successful or not.</returns>
        public bool RemoveLinkedParameter(LinkedParameterModel linkedParameter, ref string error)
        {
            var lp = new LinkedParameterChange();

            return(this.Session.RunCommand(
                       XTMFCommand.CreateCommand((ref string e) =>
            {
                if ((lp.Index = this.LinkedParameters.IndexOf(linkedParameter)) < 0)
                {
                    e = "The linked parameter was not found!";
                    return false;
                }
                lp.Model = this.LinkedParameters[lp.Index];
                LinkedParameters.RemoveAt(lp.Index);
                RealLinkedParameters.RemoveAt(lp.Index);
                return true;
            },
                                                 (ref string e) =>
            {
                LinkedParameters.Insert(lp.Index, lp.Model);
                RealLinkedParameters.Insert(lp.Index, lp.Model.RealLinkedParameter);
                return true;
            },
                                                 (ref string e) =>
            {
                LinkedParameters.RemoveAt(lp.Index);
                RealLinkedParameters.RemoveAt(lp.Index);
                return true;
            }),
                       ref error
                       ));
        }
Beispiel #3
0
        internal void RemoveWithoutCommand(LinkedParameterModel newLP)
        {
            var index = LinkedParameters.IndexOf(newLP);

            if (index >= 0)
            {
                LinkedParameters.RemoveAt(index);
                _RealLinkedParameters.RemoveAt(index);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Add a new linked parameter without a command.  Only do this in another
        /// command where you will clean up afterwards.
        /// </summary>
        /// <param name="name">The name of the new linked parameter</param>
        /// <param name="value">The value to assign to it.</param>
        /// <returns>The newly created linked parameter</returns>
        internal LinkedParameterModel AddWithoutCommand(string name, string value)
        {
            LinkedParameter      linkedParameter = new LinkedParameter(name);
            LinkedParameterModel newModel        = new LinkedParameterModel(linkedParameter, _Session, _ModelSystem);

            AddWithoutCommand(newModel);
            string error = null;

            newModel.SetWithoutCommand(value, ref error);
            return(newModel);
        }
Beispiel #5
0
 internal void AddWithoutCommand(LinkedParameterModel linkedParameter)
 {
     _RealLinkedParameters.Add(linkedParameter.RealLinkedParameter);
     LinkedParameters.Add(linkedParameter);
 }
Beispiel #6
0
 internal void RemoveWithoutCommand(LinkedParameterModel newLP)
 {
     var index = LinkedParameters.IndexOf(newLP);
     if(index >= 0)
     {
         LinkedParameters.RemoveAt(index);
         RealLinkedParameters.RemoveAt(index);
     }
 }
Beispiel #7
0
 internal void AddWithoutCommand(LinkedParameterModel linkedParameter)
 {
     RealLinkedParameters.Add(linkedParameter.RealLinkedParameter);
     LinkedParameters.Add(linkedParameter);
 }
Beispiel #8
0
 /// <summary>
 /// Add a new linked parameter without a command.  Only do this in another
 /// command where you will clean up afterwards.
 /// </summary>
 /// <param name="name">The name of the new linked parameter</param>
 /// <param name="value">The value to assign to it.</param>
 /// <returns>The newly created linked parameter</returns>
 internal LinkedParameterModel AddWithoutCommand(string name, string value)
 {
     LinkedParameter linkedParameter = new LinkedParameter(name);
     LinkedParameterModel newModel = new LinkedParameterModel(linkedParameter, Session, ModelSystem);
     AddWithoutCommand(newModel);
     string error = null;
     newModel.SetWithoutCommand(value, ref error);
     return newModel;
 }
Beispiel #9
0
 /// <summary>
 /// Remove a linked parameter from the linked parameters
 /// </summary>
 /// <param name="linkedParameter">The linked parameter to remove</param>
 /// <param name="error">If an error occurs this will contain a message to describe it.</param>
 /// <returns>If the command was successful or not.</returns>
 public bool RemoveLinkedParameter(LinkedParameterModel linkedParameter, ref string error)
 {
     var lp = new LinkedParameterChange();
     return this.Session.RunCommand(
         XTMFCommand.CreateCommand((ref string e) =>
         {
             if((lp.Index = this.LinkedParameters.IndexOf(linkedParameter)) < 0)
             {
                 e = "The linked parameter was not found!";
                 return false;
             }
             lp.Model = this.LinkedParameters[lp.Index];
             LinkedParameters.RemoveAt(lp.Index);
             RealLinkedParameters.RemoveAt(lp.Index);
             return true;
         },
         (ref string e) =>
         {
             LinkedParameters.Insert(lp.Index, lp.Model);
             RealLinkedParameters.Insert(lp.Index, lp.Model.RealLinkedParameter);
             return true;
         },
         (ref string e) =>
         {
             LinkedParameters.RemoveAt(lp.Index);
             RealLinkedParameters.RemoveAt(lp.Index);
             return true;
         }),
         ref error
         );
 }
Beispiel #10
0
 /// <summary>
 /// Create a new Linked Parameter with the given name
 /// </summary>
 /// <param name="name">The name of the linked parameter</param>
 /// <param name="error">If an error occurs this will contain a message to describe it.</param>
 /// <returns>True if it executed successfully</returns>
 public bool NewLinkedParameter(string name, ref string error)
 {
     var lp = new LinkedParameterChange();
     return this.Session.RunCommand(
         XTMFCommand.CreateCommand((ref string e) =>
         {
             LinkedParameter linkedParameter = new LinkedParameter(name);
             LinkedParameterModel newModel = new LinkedParameterModel(linkedParameter, Session, ModelSystem);
             RealLinkedParameters.Add(linkedParameter);
             LinkedParameters.Add(newModel);
             lp.Model = newModel;
             lp.Index = this.LinkedParameters.Count - 1;
             return true;
         },
         (ref string e) =>
         {
             LinkedParameters.RemoveAt(lp.Index);
             RealLinkedParameters.RemoveAt(lp.Index);
             return true;
         },
         (ref string e) =>
         {
             LinkedParameters.Insert(lp.Index, lp.Model);
             RealLinkedParameters.Insert(lp.Index, lp.Model.RealLinkedParameter);
             return true;
         }),
         ref error
         );
 }