Пример #1
0
    public void GridPressed(GridItem item)
    {
        #region GridPressed
        if (!IsSimulating && !IsUIOpen)
        {
            for (int i = 0; i < GridItem.ITEM_TYPE.ITEMS.Length; i++)
            {
                GridItem.ITEM_TYPE.Item type = GridItem.ITEM_TYPE.ITEMS[i];
                if (item.itemType.Equals(type))
                {
                    bool foundNext = false;
                    GridItem.ITEM_TYPE.Item nextItem = null;
                    if (item == startItem)
                    {
                        startItem = null;
                    }
                    if (item == endItem)
                    {
                        endItem = null;
                    }

                    while (!foundNext)
                    {
                        int next = i + 1;
                        if (next >= GridItem.ITEM_TYPE.ITEMS.Length)
                        {
                            next = 0;
                        }
                        nextItem = GridItem.ITEM_TYPE.ITEMS[next];
                        if (nextItem.Equals(GridItem.ITEM_TYPE.START))
                        {
                            if (startItem != null)
                            {
                                i++;
                                continue;
                            }
                            else
                            {
                                startItem = item;
                                foundNext = true;
                                break;
                            }
                        }
                        else if (nextItem.Equals(GridItem.ITEM_TYPE.END))
                        {
                            if (endItem != null)
                            {
                                i++;
                                continue;
                            }
                            else
                            {
                                endItem   = item;
                                foundNext = true;
                                break;
                            }
                        }
                        else
                        {
                            foundNext = true;
                            break;
                        }
                    }
                    item.itemType = nextItem;
                    item.Invalidate();
                    break;
                }
            }
        }
        #endregion
    }