Beispiel #1
0
        //For Testing and Visualization Purposes
        public MainWindow()
        {
            InitializeComponent();
            WorldInterface.InitializeWorld(WorldSize);

            var pf        = PixelFormats.Bgr24;
            int rawStride = (WorldSize * pf.BitsPerPixel + 7) / 8;

            byte[] img = new byte[rawStride * WorldSize];
            int    p   = 0;

            foreach (var wc in WorldInterface.GetCells())
            {
                var c = CellToBrush(wc.WorldCellType);
                img[p]     = c.B;
                img[p + 1] = c.G;
                img[p + 2] = c.R;
                p         += 3;
            }
            BitmapSource b    = BitmapSource.Create(WorldSize, WorldSize, 96, 96, pf, null, img, rawStride);
            Image        disp = new Image()
            {
                Width  = 500,
                Source = b
            };

            drawCanvas.Children.Add(disp);
            theServer = new Server();;
            theServer.ClientStatusUpdate += ClientStatus;
        }