Esempio n. 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            actualFramerate.MeasureHere();

            if (isServerOnline)
            {
                string connected = isConnected ? "Kinect ready" : "Kinect unavailable";
                Text = "Server online, " + connected + " " + actualFramerate.FrameRate + "   fps, Target: " + targetedFramerate.FrameRate + " fps,   ↑" + service.GetCurrentUpload() + " KB/s   ↓" + service.GetCurrentDownload() + " KB/s"; // Window Title Text
                if (isConnected)
                {
                    Graphics g = Graphics.FromImage(bmp.Bitmap);
                    g.Clear(Color.Transparent);

                    IList <CloudPoint> cloudpoints = service.GetCloudpoints();

                    if (cloudpoints == null)
                    {
                        g.Clear(Color.Magenta);
                        Text = "Internal server error";
                    }
                    else
                    {
                        foreach (CloudPoint p in cloudpoints)
                        {
                            // Color
                            bmp.SetPixel((int)p.GetX(), (int)p.GetY(), Color.FromArgb((int)(p.GetR() * 256), (int)(p.GetG() * 256), (int)(p.GetB() * 256)));

                            // Depth
                            bmp.SetPixel((int)p.GetX() + 512, (int)p.GetY(), Color.FromArgb((byte)(p.GetZ() % 4096), (byte)(p.GetZ() % 4096), (byte)(p.GetZ() % 4096)));
                        }

                        e.Graphics.DrawImage(bmp.Bitmap, 0, 0);
                    }
                }
            }
            else
            {
                Text = "Server unreachable";
            }
        }