private void AddPrefeb()
        {
            if (AddButtonClick == null)
            {
                return;
            }

            if (textBox_interval.Text.Equals("") || textBox_Tag.Text.Equals(""))
            {
                MessageBox.Show("유효한 모든 필드를 채워넣으십시오.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (curList.Contains(textBox_Tag.Text))
            {
                MessageBox.Show("중복된 Tag의 이벤트을 저장할 수 없습니다.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            /* 프 리 펩 저 장*/
            NewNode          = new MacroNode();
            NewNode.x        = int.Parse(textBox_PositionX.Text);
            NewNode.y        = int.Parse(textBox_PositionY.Text);
            NewNode.interval = int.Parse(textBox_interval.Text);
            NewNode.tag      = textBox_Tag.Text;
            if (comboBox_Type.SelectedIndex == 0)
            {
                NewNode.state = NodeStates.마우스_이동;
            }
            else
            {
                NewNode.state = NodeStates.마우스_이동_후_왼쪽클릭;
            }
            Invoke(AddButtonClick, null);
        }
 public void setEditor(MacroNode selectedNode)
 {
     textBox_PositionX.Text      = selectedNode.x.ToString();
     textBox_PositionY.Text      = selectedNode.y.ToString();
     textBox_interval.Text       = selectedNode.interval.ToString();
     textBox_Tag.Text            = selectedNode.tag.ToString();
     textBox_Keyborad.Text       = selectedNode.inputString;
     comboBox_Type.SelectedIndex = (int)selectedNode.state;
 }
        private ListViewItem GenerateItem(MacroNode macroNode)
        {
            ListViewItem listViewItem = new ListViewItem
            {
                ImageIndex = (int)macroNode.state,
                Text       = NodeSetter.NodeName(macroNode.state, false)
            };

            listViewItem.SubItems.Add(NodeSetter.NodeName(macroNode.state, true));
            listViewItem.SubItems.Add(macroNode.x.ToString() + ", " + macroNode.y.ToString());
            return(listViewItem);
        }
        public object Clone()
        {
            MacroNode macroNode = new MacroNode();

            macroNode.state       = state;
            macroNode.tag         = tag;
            macroNode.x           = x;
            macroNode.y           = y;
            macroNode.interval    = interval;
            macroNode.inputString = inputString;
            return(macroNode);
        }
 private void listView_Prefabs_ItemDragDrop(object sender, ListViewItemDragEventArgs e)
 {
     if (!e.Cancel)
     {
         int before = ((DragableListView.DragableListView)sender).Before;
         int after  = e.InsertionIndex;
         Console.WriteLine(string.Format("Before : {0}, After : {1}", before, after));
         MacroNode beforeNode = Prefabs[before];
         Prefabs.RemoveAt(before);
         Prefabs.Insert(after, beforeNode);
     }
 }
 private void button_PrefabToNode_Click(object sender, EventArgs e)
 {
     if (listView_Prefabs.SelectedIndices.Count > 0)
     {
         int selectedIndex = listView_Prefabs.SelectedIndices[0];
         Console.WriteLine("== Prefab to Node {0}", selectedIndex.ToString());
         MacroNode mn = (MacroNode)Prefabs[selectedIndex].Clone();
         Nodes.Add(mn);
         listView_Main.Items.Add(GenerateItem(mn, false));
         isModified = true;
         SetListIndex();
     }
     else
     {
         Console.WriteLine("== Fail Prefab to Node");
     }
 }
        /// <summary>
        /// MacroNode로 리스트뷰 형식에 맞는 ListViewItem을 반환해줍니다.
        /// </summary>
        /// <param name="macroNode"></param>
        /// <returns></returns>
        private ListViewItem GenerateItem(MacroNode macroNode, bool isPrefab)
        {
            if (isPrefab)
            {
                ListViewItem listViewItem = new ListViewItem
                {
                    ImageIndex = (int)macroNode.state,
                    Text       = NodeSetter.NodeName(macroNode.state, false)
                };
                listViewItem.SubItems.Add(NodeSetter.NodeName(macroNode.state, true));
                listViewItem.SubItems.Add(macroNode.tag);
                return(listViewItem);
            }
            else
            {
                ListViewItem listViewItem = new ListViewItem
                {
                    ImageIndex = (int)macroNode.state,
                    Text       = ""
                };
                listViewItem.SubItems.Add(NodeSetter.NodeName(macroNode.state, false));
                listViewItem.SubItems.Add(NodeSetter.NodeName(macroNode.state, true));

                if ((MainListColumnFlag & ColumnFlag.Tag) != 0)
                {
                    listViewItem.SubItems.Add(macroNode.tag);
                }

                if ((MainListColumnFlag & ColumnFlag.Point) != 0)
                {
                    listViewItem.SubItems.Add(string.Format("{0}, {1}", macroNode.x, macroNode.y));
                }

                if ((MainListColumnFlag & ColumnFlag.Interval) != 0)
                {
                    listViewItem.SubItems.Add(macroNode.interval.ToString());
                }

                if ((MainListColumnFlag & ColumnFlag.InputString) != 0)
                {
                    listViewItem.SubItems.Add(macroNode.inputString);
                }
                return(listViewItem);
            }
        }
        private void AddNode()
        {
            NodeStates ns = (NodeStates)comboBox_Type.SelectedIndex;

            if (IsInvaild(ns == NodeStates.마우스_이동 || ns == NodeStates.마우스_이동_후_왼쪽클릭))
            {
                if (Type == PopType.NewPrefab)
                {
                    MessageBox.Show("유효한 모든 필드를 채워넣으십시오.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Tag를 제외한 모든 필드를 채워넣으십시오.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }
            if (Type == PopType.NewPrefab && curKey.Contains(textBox_Tag.Text))
            {
                MessageBox.Show("중복된 Tag의 이벤트을 저장할 수 없습니다.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            /* 프 리 펩 저 장*/
            NewNode = new MacroNode();
            if (ns == NodeStates.마우스_이동 || ns == NodeStates.마우스_이동_후_왼쪽클릭)
            {
                NewNode.x = int.Parse(textBox_PositionX.Text);
                NewNode.y = int.Parse(textBox_PositionY.Text);
            }
            NewNode.interval    = int.Parse(textBox_interval.Text);
            NewNode.tag         = textBox_Tag.Text;
            NewNode.state       = ns;
            NewNode.inputString = textBox_Keyborad.Text;
            ((MainForm)this.Owner).addSuccess = true;

            if (Type == PopType.EditNode)
            {
                Invoke(AddButtonClick, null);
            }
            else
            {
                this.Visible = false;
            }
        }
 private void button_NodeToPrefab_Click(object sender, EventArgs e)
 {
     if (listView_Main.SelectedIndices.Count > 0)
     {
         int selectedIndex = listView_Main.SelectedIndices[0];
         if (listView_Main.Items[selectedIndex].SubItems[2].Text.Equals("") || PrefabsDupCheckSet.Contains(listView_Main.Items[selectedIndex].SubItems[2].Text))
         {
             MessageBox.Show("중복되거나 빈 Tag입니다.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         MacroNode mn = (MacroNode)Nodes[selectedIndex].Clone();
         PrefabsDupCheckSet.Add(mn.tag);
         Prefabs.Add(mn);
         listView_Prefabs.Items.Add(GenerateItem(mn, true));
     }
     else
     {
         Console.WriteLine("== Fail Prefab to Node");
     }
 }
        private void pictureBox_ImageArea_MouseDown(object sender, MouseEventArgs e)
        {
            if (!isMouseDown && isImageLoad)
            {
                int X = (int)(e.Location.X * (originalWidth / pictureBox_ImageArea.Size.Width));
                int Y = (int)(e.Location.Y * (originalHeight / pictureBox_ImageArea.Size.Height));
                CurMouseType = e.Button;
                MacroNode newNode = new MacroNode
                {
                    state = NodeStates.마우스_이동,
                    x     = X,
                    y     = Y
                };
                listView_WorkFlow.Items.Add(GenerateItem(newNode));
                Nodes.Add(newNode);

                DownPoint = new Point(e.Location.X, e.Location.Y);
                pictureBox_ImageArea.Refresh();
                DrawCross(e.Location.X, e.Location.Y, Color.Red, (PictureBox)sender);
                isMouseDown = true;
            }
        }
        private void pictureBox_ImageArea_MouseUp(object sender, MouseEventArgs e)
        {
            if (CurMouseType == e.Button && isImageLoad)
            {
                if (isDoubleClick)
                {
                    isDoubleClick = false;
                }
                else
                {
                    MacroNode newNode = new MacroNode();
                    int       X       = (int)(e.Location.X * (originalWidth / pictureBox_ImageArea.Size.Width));
                    int       Y       = (int)(e.Location.Y * (originalHeight / pictureBox_ImageArea.Size.Height));
                    if (DownPoint.Equals(new Point(e.Location.X, e.Location.Y)))
                    {
                        switch (e.Button)
                        {
                        case MouseButtons.Left:
                            RemoveLastNode();
                            AddNodeLast(new MacroNode()
                            {
                                state = NodeStates.마우스_이동_후_왼쪽클릭, x = X, y = Y
                            });
                            break;

                        case MouseButtons.Right:
                            AddNodeLast(new MacroNode()
                            {
                                state = NodeStates.마우스_오른쪽클릭
                            });
                            break;

                        case MouseButtons.Middle:
                            AddNodeLast(new MacroNode()
                            {
                                state = NodeStates.마우스_휠클릭
                            });
                            break;
                        }
                    }
                    else
                    {
                        switch (e.Button)
                        {
                        case MouseButtons.Left:
                            AddNodeLast(new MacroNode()
                            {
                                state = NodeStates.마우스_누르기_왼쪽
                            });
                            AddNodeLast(new MacroNode {
                                state = NodeStates.마우스_이동, x = X, y = Y
                            });
                            AddNodeLast(new MacroNode {
                                state = NodeStates.마우스_떼기_왼쪽
                            });
                            break;

                        case MouseButtons.Right:
                            AddNodeLast(new MacroNode()
                            {
                                state = NodeStates.마우스_누르기_오른쪽
                            });
                            AddNodeLast(new MacroNode {
                                state = NodeStates.마우스_이동, x = X, y = Y
                            });
                            AddNodeLast(new MacroNode {
                                state = NodeStates.마우스_떼기_오른쪽
                            });
                            break;

                        case MouseButtons.Middle:
                            AddNodeLast(new MacroNode()
                            {
                                state = NodeStates.마우스_누르기_휠
                            });
                            AddNodeLast(new MacroNode {
                                state = NodeStates.마우스_이동, x = X, y = Y
                            });
                            AddNodeLast(new MacroNode {
                                state = NodeStates.마우스_떼기_휠
                            });
                            break;
                        }
                        DrawCross(e.Location.X, e.Location.Y, Color.Aqua, (PictureBox)sender);
                    }
                    Console.WriteLine();
                }
                isMouseDown = false;
            }
        }
 private void AddNodeLast(MacroNode macronode)
 {
     macronode.interval = 800;
     listView_WorkFlow.Items.Add(GenerateItem(macronode));
     Nodes.Add(macronode);
 }
            public static void Run(MacroNode macroNode, bool clickTest)
            {
                try
                {
                    ManualResetEvent stoppeing_event_ = new ManualResetEvent(false);
                    stoppeing_event_.Reset();

                    switch (macroNode.state)
                    {
                    case NodeStates.마우스_이동:
                        SetCursorPos(macroNode.x, macroNode.y);
                        break;

                    case NodeStates.마우스_왼쪽클릭:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.마우스_오른쪽클릭:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
                            mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.마우스_더블클릭:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.마우스_휠클릭:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0);
                            mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.마우스_이동_후_왼쪽클릭:
                        SetCursorPos(macroNode.x, macroNode.y);
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                        }
                        break;

                    /*
                     * case NodeStates.마우스_휠_내리기:
                     * mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 0, 2);
                     * break;
                     *
                     * case NodeStates.마우스_휠_올리기:
                     * mouse_event(MOUSEEVENTF_HWHEEL, 0, 0, 0, 2);
                     * break;
                     */
                    case NodeStates.마우스_누르기_왼쪽:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.마우스_떼기_왼쪽:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.마우스_누르기_오른쪽:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.마우스_떼기_오른쪽:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.마우스_누르기_휠:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.마우스_떼기_휠:
                        if (clickTest)
                        {
                            mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0);
                        }
                        break;

                    case NodeStates.시스템_대기:
                        break;

                    case NodeStates.시스템_스크린샷찍기:
                        break;

                    case NodeStates.키보드_키입력:
                        SendKeyInterval(macroNode.inputString);
                        break;
                    }
                    stoppeing_event_.WaitOne(macroNode.interval);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Send Event \r\n" + e.Message);
                }
            }