Ejemplo n.º 1
0
        /// <summary>
        /// Handles the ModifierCloned event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.CloneModifierEventArgs"/> instance containing the event data.</param>
        public void Interface_ModifierCloned(object sender, CloneModifierEventArgs e)
        {
            Trace.WriteLine("Cloning emitter...", "CORE");

            try
            {
                Modifier clone = e.Prototype.DeepCopy();

                foreach (Emitter emitter in this.ParticleEffect)
                {
                    foreach (Modifier modifier in emitter.Modifiers)
                    {
                        if (Object.ReferenceEquals(modifier, e.Prototype))
                        {
                            emitter.Modifiers.Add(clone);

                            e.AddedModifier = clone;

                            e.Result = CoreOperationResult.OK;

                            return;
                        }
                    }
                }

                e.Result = new CoreOperationResult(new Exception("Could not find modifier prototype in effect hierarchy."));
            }
            catch (Exception error)
            {
                e.Result = new CoreOperationResult(error);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the uxCloneMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void uxCloneMenuItem_Click(object sender, EventArgs e)
        {
            var selectedNode = this.uxEffectTree.SelectedNode;

            if (selectedNode is EmitterTreeNode)
            {
                CloneEmitterEventArgs args = new CloneEmitterEventArgs((selectedNode as EmitterTreeNode).Emitter);

                this.OnEmitterCloned(args);

                if (args.AddedEmitter != null)
                {
                    EmitterTreeNode newNode = new EmitterTreeNode(args.AddedEmitter);

                    selectedNode.Parent.Nodes.Add(newNode);

                    newNode.Expand();

                    newNode.EnsureVisible();
                }
            }
            else if (selectedNode is ModifierTreeNode)
            {
                CloneModifierEventArgs args = new CloneModifierEventArgs((selectedNode as ModifierTreeNode).Modifier);

                this.OnModifierCloned(args);

                if (args.AddedModifier != null)
                {
                    ModifierTreeNode newNode = new ModifierTreeNode(args.AddedModifier);

                    selectedNode.Parent.Nodes.Add(newNode);

                    newNode.EnsureVisible();
                }
            }
            else if (selectedNode is ControllerTreeNode)
            {
                var args = new CloneControllerEventArgs((selectedNode as ControllerTreeNode).Controller);

                this.OnControllerCloned(args);

                if (args.AddedController != null)
                {
                    ControllerTreeNode newNode = new ControllerTreeNode(args.AddedController);

                    selectedNode.Parent.Nodes.Add(newNode);

                    newNode.Expand();

                    newNode.EnsureVisible();
                }
            }
        }
Ejemplo n.º 3
0
        protected virtual void OnModifierCloned(CloneModifierEventArgs e)
        {
            Trace.WriteLine("User requires cloning a modifier...", "UI");

            using (new HourglassCursor())
            {
                var handler = Interlocked.CompareExchange(ref this.ModifierCloned, null, null);

                if (handler != null)
                {
                    handler.Invoke(this, e);
                }
            }

            this.AssertOperationOK(e.Result);
        }
Ejemplo n.º 4
0
        protected virtual void OnModifierCloned(CloneModifierEventArgs e)
        {
            Trace.WriteLine("User requires cloning a modifier...", "UI");

            using (new HourglassCursor())
            {
                var handler = Interlocked.CompareExchange(ref this.ModifierCloned, null, null);

                if (handler != null)
                    handler.Invoke(this, e);
            }

            this.AssertOperationOK(e.Result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handles the Click event of the uxCloneMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void uxCloneMenuItem_Click(object sender, EventArgs e)
        {
            var selectedNode = this.uxEffectTree.SelectedNode;

            if (selectedNode is EmitterTreeNode)
            {
                CloneEmitterEventArgs args = new CloneEmitterEventArgs((selectedNode as EmitterTreeNode).Emitter);

                this.OnEmitterCloned(args);

                if (args.AddedEmitter != null)
                {
                    EmitterTreeNode newNode = new EmitterTreeNode(args.AddedEmitter);

                    selectedNode.Parent.Nodes.Add(newNode);

                    newNode.Expand();

                    newNode.EnsureVisible();
                }
            }
            else if (selectedNode is ModifierTreeNode)
            {
                CloneModifierEventArgs args = new CloneModifierEventArgs((selectedNode as ModifierTreeNode).Modifier);

                this.OnModifierCloned(args);

                if (args.AddedModifier != null)
                {
                    ModifierTreeNode newNode = new ModifierTreeNode(args.AddedModifier);

                    selectedNode.Parent.Nodes.Add(newNode);

                    newNode.EnsureVisible();
                }
            }
            else if (selectedNode is ControllerTreeNode)
            {
                var args = new CloneControllerEventArgs((selectedNode as ControllerTreeNode).Controller);

                this.OnControllerCloned(args);

                if (args.AddedController != null)
                {
                    ControllerTreeNode newNode = new ControllerTreeNode(args.AddedController);

                    selectedNode.Parent.Nodes.Add(newNode);

                    newNode.Expand();

                    newNode.EnsureVisible();
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles the ModifierCloned event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.CloneModifierEventArgs"/> instance containing the event data.</param>
        public void Interface_ModifierCloned(Object sender, CloneModifierEventArgs e)
        {
            Trace.WriteLine("Cloning emitter...", "CORE");

            try
            {
                AbstractModifier clone = e.Prototype.DeepCopy();

                foreach (AbstractEmitter emitter in this.ParticleEffect.Emitters)
                {
                    foreach (AbstractModifier modifier in emitter.Modifiers)
                    {
                        if (Object.ReferenceEquals(modifier, e.Prototype))
                        {
                            emitter.Modifiers.Add(clone);

                            e.AddedModifier = clone;

                            e.Result = CoreOperationResult.OK;

                            return;
                        }
                    }
                }

                e.Result = new CoreOperationResult(new Exception("Could not find modifier prototype in effect hierarchy."));
            }
            catch (Exception error)
            {
                e.Result = new CoreOperationResult(error);
            }
        }
Ejemplo n.º 7
0
 protected virtual void OnModifierCloned(CloneModifierEventArgs e)
 {
     if (this.ModifierCloned != null)
         this.ModifierCloned(this, e);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles the ModifierCloned event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.CloneModifierEventArgs"/> instance containing the event data.</param>
        public void Interface_ModifierCloned(object sender, CloneModifierEventArgs e)
        {
            Modifier clone = e.Prototype.DeepCopy();

            foreach (Emitter emitter in this.ParticleEffect)
            {
                foreach (Modifier modifier in emitter.Modifiers)
                {
                    if (Object.ReferenceEquals(modifier, e.Prototype))
                    {
                        emitter.Modifiers.Add(clone);

                        e.AddedModifier = clone;

                        return;
                    }
                }
            }

            throw new Exception("Could not find modifier prototype in effect hierarchy.");
        }