Example #1
0
        private void panel1_Click(object sender, EventArgs e)
        {
            Point mouseLocation = panel1.PointToClient(System.Windows.Forms.Control.MousePosition);

            //If a node has already been selected move it to the current mouse pos
            if (currentSelectedNode != null)
            {
                currentSelectedNode.setLocation(mouseLocation);
                currentSelectedNode.NodeLocation = mouseLocation;

                currentSelectedNode = null;
                panel1.Invalidate();
                return;
            }

            ImageNode temp = getCloestImageNode(mouseLocation);

            if (temp != null)
            {
                currentSelectedNode = temp;
            }
        }
Example #2
0
 public void addChild(ImageNode a_newChild)
 {
     m_children.Add(a_newChild);
     a_newChild.setLocation(new Point(this.m_location.X, this.m_location.Y + 45));
 }
Example #3
0
        private void panel1_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.StringFormat))
            {
                string str = (string)e.Data.GetData(DataFormats.StringFormat);

                Point mouseDropPos = panel1.PointToClient(System.Windows.Forms.Control.MousePosition);

                if (str == "Selector")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/selector.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("SelectorNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "Sequence")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/sequence.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("SequenceNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "Repeater")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/repeater.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("RepeaterNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "Maximum")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/maximum.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("MaximumNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "Wander")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/wander.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("WanderNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "Walk")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/walk.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("WalkNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "Run")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/run.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("RunNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "OpenDoor")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/openDoor.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("OpenDoorNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "Flee")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/flee.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("FleeNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "FindEntrance")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/findEntrance.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("FindEntranceNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                if (str == "Attack")
                {
                    Image temp;
                    using (FileStream stream = new FileStream("../../assets/attack.jpg", FileMode.Open, FileAccess.Read))
                    {
                        temp = Image.FromStream(stream);
                    }

                    ImageNode newNode = new ImageNode("AttackNode", mouseDropPos, temp, NodeCount);
                    NodeCount += 1;
                    newNode.setPicBoxParent(panel1);
                    newNode.getPicBox().BringToFront();
                    newNode.setLocation(mouseDropPos);
                    newNode.getPicBox().Location = newNode.NodeLocation;

                    imageNodeList.Add(newNode);
                }

                this.Invalidate();
                panel1.Invalidate();
            }
        }