Пример #1
0
        private void AssembleSiblings(SingleBlock block)
        {
            checkedlist.Clear();
            CommonTypes.BlockColor checkcolor = block.BlockColor;

            // left:    row, col - 1
            // right:   row, col + 1
            // up:      row+1, col
            //down:     row-1, col
            if (openlist.Count != 0)
            {
                for (int i = 0; i < openlist.Count; i++)
                {
                    SingleBlock item = openlist[i];
                    uint        row  = item.Rowpos;
                    uint        col  = item.Columnpos;
                    if (!checkedlist.Contains(item))
                    {
                        var foundblock = FindBlock(row, col - 1);
                        if (foundblock != null && !checkedlist.Contains(foundblock) && !openlist.Contains(foundblock) && foundblock.BlockColor == checkcolor)
                        {
                            openlist.Add(foundblock);
                        }
                        foundblock = FindBlock(row, col + 1);
                        if (foundblock != null && !checkedlist.Contains(foundblock) && !openlist.Contains(foundblock) && foundblock.BlockColor == checkcolor)
                        {
                            openlist.Add(foundblock);
                        }
                        foundblock = FindBlock(row + 1, col);
                        if (foundblock != null && !checkedlist.Contains(foundblock) && !openlist.Contains(foundblock) && foundblock.BlockColor == checkcolor)
                        {
                            openlist.Add(foundblock);
                        }
                        foundblock = FindBlock(row - 1, col);
                        if (foundblock != null && !checkedlist.Contains(foundblock) && !openlist.Contains(foundblock) && foundblock.BlockColor == checkcolor)
                        {
                            openlist.Add(foundblock);
                        }
                        checkedlist.Add(item);
                    }
                }
            }
        }
Пример #2
0
        public object Convert(object value, Type targetType,
                              object parameter, CultureInfo culture)
        {
            CommonTypes.BlockColor color = (CommonTypes.BlockColor)value;
            var brush = new SolidColorBrush();

            switch (color)
            {
            case CommonTypes.BlockColor.BlockColorRed:
                brush = Brushes.Red;
                break;

            case CommonTypes.BlockColor.BlockColorGreen:
                brush = Brushes.Green;
                break;

            case CommonTypes.BlockColor.BlockColorBlue:
                brush = Brushes.Blue;
                break;

            case CommonTypes.BlockColor.BlockColorYellow:
                brush = Brushes.Orange;
                break;

            case CommonTypes.BlockColor.BlockColorPurple:
                brush = Brushes.Purple;
                break;

            //  for hittest
            case CommonTypes.BlockColor.BlockColorBlack:
                brush = Brushes.Black;
                break;

            default:
                break;
            }

            return(brush);
        }