Exemple #1
0
        /// <summary>
        /// Handles the ControllerCloned event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.CloneControllerEventArgs"/> instance containing the event data.</param>
        public void Interface_ControllerCloned(Object sender, CloneControllerEventArgs e)
        {
            Trace.WriteLine("Cloning controller...", "CORE");

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

                foreach (AbstractEmitter emitter in this.ParticleEffect.Emitters)
                {
                    foreach (AbstractController controller in emitter.Controllers)
                    {
                        if (Object.ReferenceEquals(controller, e.Prototype))
                        {
                            emitter.Controllers.Add(clone);

                            e.AddedController = clone;

                            e.Result = CoreOperationResult.OK;

                            return;
                        }
                    }
                }

                e.Result = new CoreOperationResult(new Exception("Could not find controller prototype in effect hierarchy."));
            }
            catch (Exception error)
            {
                e.Result = new CoreOperationResult(error);
            }
        }
Exemple #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();
                }
            }
        }
Exemple #3
0
        protected virtual void OnControllerCloned(CloneControllerEventArgs e)
        {
            Trace.WriteLine("User requires cloning a controller...", "UI");

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

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

            this.AssertOperationOK(e.Result);
        }
Exemple #4
0
        protected virtual void OnControllerCloned(CloneControllerEventArgs e)
        {
            Trace.WriteLine("User requires cloning a controller...", "UI");

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

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

            this.AssertOperationOK(e.Result);
        }
Exemple #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();
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Handles the ControllerCloned event of the Interface.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ProjectMercury.EffectEditor.CloneControllerEventArgs"/> instance containing the event data.</param>
        public void Interface_ControllerCloned(Object sender, CloneControllerEventArgs e)
        {
            Trace.WriteLine("Cloning controller...", "CORE");

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

                foreach (AbstractEmitter emitter in this.ParticleEffect.Emitters)
                {
                    foreach (AbstractController controller in emitter.Controllers)
                    {
                        if (Object.ReferenceEquals(controller, e.Prototype))
                        {
                            emitter.Controllers.Add(clone);

                            e.AddedController = clone;

                            e.Result = CoreOperationResult.OK;

                            return;
                        }
                    }
                }

                e.Result = new CoreOperationResult(new Exception("Could not find controller prototype in effect hierarchy."));
            }
            catch (Exception error)
            {
                e.Result = new CoreOperationResult(error);
            }
        }