Exemplo n.º 1
0
            /// <summary>
            /// Adds a pixel to the grid. It assignes the specified cell with the
            /// specified pixel value by adding a colored rectangle in that cell.
            /// </summary>
            /// <param name="pixel"></param>
            /// <param name="location"></param>
            /// <param name="grid"></param>
            public static void AddPixelToGrid(Int32 pixel, Prefab.Point location, Grid grid)
            {
                Rectangle rect = new Rectangle();

                if (pixel == Feature.TRANSPARENT_VALUE)
                {
                    rect.Fill = Brushes.Transparent;
                }
                else
                {
                    rect.Fill = new SolidColorBrush(Color.FromArgb((byte)Bitmap.Alpha(pixel),
                                                                   (byte)Bitmap.Red(pixel), (byte)Bitmap.Green(pixel), (byte)Bitmap.Blue(pixel)));
                }

                rect.Stroke          = Brushes.Black;
                rect.StrokeThickness = 0.5;
                grid.Children.Add(rect);

                Grid.SetRow(rect, location.Y);
                Grid.SetColumn(rect, location.X);
            }