예제 #1
0
    private void LoadColors()
    {
        string response = Rest.GetColors();

        Debug.Log(response);
        List <CustomColor> customColors = JsonArrayHelper.getJsonList <CustomColor>(response);

        if (ColorNames == null || ColorNames.Count > 0)
        {
            ColorNames = new Dictionary <string, string>();
        }

        foreach (var customColor in customColors)
        {
            ColorNames.Add(customColor.color, customColor.name);
        }
    }
예제 #2
0
        private void RefreshCanvas()
        {
            CurrentStones.Clear();
            HistStones.Clear();
            ColorNames.Clear();
            CurrentBlock.Children.RemoveRange(0, CurrentBlock.Children.Count);

            stoneWidth = (((int)CurrentBlock.Bounds.Width) - (2 * 2 * space) - ((BlockSize - 1) * space)) / BlockSize;

            int firstBlockStone = BlockSize * (SelectedBlock - 1);

            for (int i = 0; i < BlockSize; i++)
            {
                if (firstBlockStone + i < stonesPerLine)
                {
                    if (ShowHistory && SelectedRow - 2 >= 0)
                    {
                        int oldStoneIndex = intField[firstBlockStone + i, SelectedRow - 2];
                        if (oldStoneIndex >= 0 && fParameters.colors.Length > oldStoneIndex)
                        {
                            HistStones.Add(new SolidColorBrush(fParameters.colors[oldStoneIndex].mediaColor));
                        }
                    }

                    int stoneindex = intField[firstBlockStone + i, SelectedRow - 1];
                    if (stoneindex < 0)
                    {
                        continue;
                    }

                    CurrentStones.Add(new SolidColorBrush(fParameters.colors[stoneindex].mediaColor));

                    if (ColorNames.Count == 0 || !ColorNames.LastOrDefault().ColorName.Equals(fParameters.colors[stoneindex].name))
                    {
                        ColorNames.Add(new ColorAmount(fParameters.colors[stoneindex].name, 1));
                    }
                    else
                    {
                        ColorNames.LastOrDefault().Amount++;
                    }
                }
            }
        }