protected override void DoCommandAction()
        {
            AddToSelectionXY addCmd = new AddToSelectionXY(UpperLeftX, UpperLeftY, LowerRightX, LowerRightY);

            OutputManager.WriteOutput(addCmd.ToString());
        }
        protected override void DoCommandAction()
        {
            CommandExecuter.Instance.Execute(new Reset());
            // find horizontal placement
            int x1 = 0;
            int x2 = 0;

            for (int y = 0; y < FPGA.FPGA.Instance.MaxY; y++)
            {
                for (int x = 0; x < FPGA.FPGA.Instance.MaxX; x++)
                {
                    string currentResourceString = "";
                    int    i = 0;
                    while (currentResourceString.Length < ResourceString.Length)
                    {
                        // left FPGA
                        if (!FPGA.FPGA.Instance.Contains(x + i, y))
                        {
                            break;
                        }
                        Tile current = FPGA.FPGA.Instance.GetTile(x + i++, y);
                        // only cosider CLB, DSP, and BRAM
                        if (!(
                                IdentifierManager.Instance.IsMatch(current.Location, IdentifierManager.RegexTypes.CLB) ||
                                IdentifierManager.Instance.IsMatch(current.Location, IdentifierManager.RegexTypes.DSP) ||
                                IdentifierManager.Instance.IsMatch(current.Location, IdentifierManager.RegexTypes.BRAM))
                            )
                        {
                            continue;
                        }


                        currentResourceString += current.Location[0];
                        Console.WriteLine(currentResourceString);
                        if (currentResourceString.Equals(ResourceString))
                        {
                            x1 = x;
                            x2 = x + i - 1;
                        }
                    }
                }
            }
            int y1 = 0;
            int y2 = 0;

            for (int y = 0; y < FPGA.FPGA.Instance.MaxY; y++)
            {
                int hCount = 0;
                for (int h = y; y + h < FPGA.FPGA.Instance.MaxY; h++)
                {
                    Tile current = FPGA.FPGA.Instance.GetTile(x1, y);
                    if (
                        IdentifierManager.Instance.IsMatch(current.Location, IdentifierManager.RegexTypes.CLB) ||
                        IdentifierManager.Instance.IsMatch(current.Location, IdentifierManager.RegexTypes.DSP) ||
                        IdentifierManager.Instance.IsMatch(current.Location, IdentifierManager.RegexTypes.BRAM)
                        )
                    {
                        hCount++;
                    }

                    if (hCount == Height - 1)
                    {
                        y1 = y;
                        y2 = y + h;
                        break;
                    }
                }
                if (y1 != 0 && y2 != 0)
                {
                    break;
                }
            }
            AddToSelectionXY selectModuleArea = new AddToSelectionXY(x1, y1, x2, y2);
        }
        private void SelectedFromMouseDownToCurrent()
        {
            bool shiftDown      = ModifierKeys == Keys.Shift;
            bool ctrlDown       = ModifierKeys == Keys.Control;
            bool altDown        = ModifierKeys == Keys.Alt;
            bool altAndCtrlDown = ModifierKeys == (Keys.Control | Keys.Alt);

            if (!ctrlDown && !altAndCtrlDown)
            {
                CommandExecuter.Instance.Execute(new Commands.Selection.ClearSelection());
            }
            TileKey upperLeftTile  = null;
            TileKey lowerRightTile = null;

            if (shiftDown)
            {
                TileKey clickedKey = GetClickedKey(m_mouseDownPosition.X, m_mouseDownPosition.Y);
                if (m_lastClickedTile == null)
                {
                    return;
                }
                if (!FPGA.FPGA.Instance.Contains(clickedKey))
                {
                    return;
                }

                upperLeftTile  = m_lastClickedTile.TileKey;
                lowerRightTile = clickedKey;
            }
            else
            {
                int upperLeftX  = Math.Min(m_mouseDownPosition.X, m_currentMousePositionWithRectangleSelect.X);
                int upperLeftY  = Math.Min(m_mouseDownPosition.Y, m_currentMousePositionWithRectangleSelect.Y);
                int lowerRightX = Math.Max(m_mouseDownPosition.X, m_currentMousePositionWithRectangleSelect.X);
                int lowerRightY = Math.Max(m_mouseDownPosition.Y, m_currentMousePositionWithRectangleSelect.Y);

                upperLeftTile  = GetClickedKey(upperLeftX, upperLeftY);
                lowerRightTile = GetClickedKey(lowerRightX, lowerRightY);
            }

            if (!string.IsNullOrEmpty(GetTileFilter()))
            {
                AddToSelectionXY addCmd = new AddToSelectionXY();
                addCmd.Filter      = GetTileFilter();
                addCmd.LowerRightX = 0;
                addCmd.LowerRightY = 0;
                addCmd.UpperLeftX  = 0;
                addCmd.UpperLeftY  = 0;
                CommandExecuter.Instance.Execute(addCmd);
            }
            else if (altDown || altAndCtrlDown)
            {
                //Tile ult = FPGA.FPGA.Instance.GetTile(upperLeftTile);
                //Tile lrt = FPGA.FPGA.Instance.GetTile(lowerRightTile);
                try
                {
                    AddBlockToSelection addcmd = new AddBlockToSelection(upperLeftTile.X, upperLeftTile.Y, lowerRightTile.X, lowerRightTile.Y);
                    CommandExecuter.Instance.Execute(addcmd);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                CommandExecuter.Instance.Execute(new AddToSelectionXY(upperLeftTile.X, upperLeftTile.Y, lowerRightTile.X, lowerRightTile.Y));
            }

            if (StoredPreferences.Instance.ExecuteExpandSelection)
            {
                CommandExecuter.Instance.Execute(new Commands.Selection.ExpandSelection());
            }
        }