Beispiel #1
0
        /*
         * @brief 更新組件
         * @param id [in] 組件編號
         */
        private void UpdateComponentInner(int id, IComponent component)
        {
            var old = components[id];

            if (component != null)
            {
                components[id]  = component;
                componentsCache = null;

                if (component != null)
                {
                    OnComponentUpdate?.Invoke(this, id, old, component);
                }
                else
                {
                    toStrCache          = null;
                    componentsFlags[id] = false;

                    OnComponentRemove?.Invoke(this, id, old);
                }

                GetComponentsPool(id).Push(old);
            }
            else
            {
                OnComponentUpdate?.Invoke(this, id, old, component);
            }
        }
Beispiel #2
0
 private void RemoveComponents(IEnumerable <NodeComponent> components)
 {
     using (Document.Current.History.BeginTransaction()) {
         foreach (var c in components)
         {
             if (c.Owner != null)
             {
                 DeleteComponent.Perform(c.Owner, c);
             }
             OnComponentRemove?.Invoke(c);
         }
         Document.Current.History.CommitTransaction();
     }
 }