Exemple #1
0
        /*************************************/

        protected void MarkAsModified(CallerUpdate update)
        {
            if (Modified != null)
            {
                Modified?.Invoke(this, update);
            }
        }
        /*******************************************/
        /**** Override Methods                  ****/
        /*******************************************/

        protected override void OnCallerModified(object sender, CallerUpdate update)
        {
            base.OnCallerModified(sender, update);

            // Adding a tag under the component
            Type type = Caller.SelectedItem as Type;

            if (type != null)
            {
                Message = type.ToText();
            }
        }
Exemple #3
0
        /*************************************/

        protected bool RestoreItem(object selectedItem, List <ParamInfo> inputParams, List <ParamInfo> outputParams)
        {
            // Finally Set the item
            SetItem(selectedItem, false);

            // Make sure that saved selection is copied over
            if (inputParams != null)
            {
                SelectInputs(inputParams.GroupBy(x => x.Name).Select(g => g.First()).ToDictionary(x => x.Name, x => x.IsSelected));
            }
            if (outputParams != null)
            {
                SelectOutputs(outputParams.GroupBy(x => x.Name).Select(g => g.First()).ToDictionary(x => x.Name, x => x.IsSelected));
            }

            // Look for changes
            CallerUpdate update = new CallerUpdate
            {
                Cause           = CallerUpdateCause.ReadFromSave,
                ComponentUpdate = new ComponentUpdate {
                    Name = Name, Description = Description
                },
                InputUpdates  = InputParams.Changes(inputParams).Where(x => x.Param.IsSelected).ToList(),
                OutputUpdates = OutputParams.Changes(outputParams).Where(x => x.Param.IsSelected).ToList()
            };

            // Record warnings if changes happened
            List <IParamUpdate> paramUpdates = update.InputUpdates.Concat(update.OutputUpdates).ToList();

            if (paramUpdates.Count > 0)
            {
                Engine.Reflection.Compute.RecordWarning("This component was upgraded. Here's the resulting changes: \n"
                                                        + paramUpdates.Select(x => "  - " + x.IToText()).Aggregate((a, b) => a + "\n" + b));
            }

            // Send the notification
            MarkAsModified(update);

            return(true);
        }
        /*******************************************/
        /**** Event Methods                     ****/
        /*******************************************/

        protected virtual void OnCallerModified(object sender, CallerUpdate update)
        {
            if (update == null)
            {
                return;
            }

            m_NotifyChanges = false;

            // Update the component details
            UpdateComponentDetails(update.ComponentUpdate);

            // Update the inputs
            update.InputUpdates.ForEach(x => UpdateInput(x as dynamic));

            // Update the outputs
            update.OutputUpdates.ForEach(x => UpdateOutput(x as dynamic));

            // Ask component to refresh
            Params.OnParametersChanged();
            ExpireSolution(true);

            m_NotifyChanges = true;
        }