Exemplo n.º 1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            DesktopWindow tmp_wnd = ttclient.AcquireUserDesktopWindow(userid);

            if (tmp_wnd.nSessionID <= 0)
            {
                ttclient.ReleaseUserDesktopWindow(deskwnd);
                this.Close();
                return;
            }

            ttclient.ReleaseUserDesktopWindow(deskwnd);

            deskwnd = tmp_wnd;

            if (ClientSize.Height != deskwnd.nHeight || ClientSize.Width != deskwnd.nWidth)
            {
                ClientSize = new Size(deskwnd.nWidth, deskwnd.nHeight);
                //int width_diff = deskwnd.nWidth - ClientSize.Width;
                //int height_diff = deskwnd.nHeight - ClientSize.Height;
                //this.Size.Width += width_diff;
                //this.Size.Height += height_diff;
            }

            if (bmp != null)
            {
                bmp.Dispose();
            }
            bmp = null;

            switch (deskwnd.bmpFormat)
            {
            case BitmapFormat.BMP_RGB8_PALETTE:
                bmp = new Bitmap(deskwnd.nWidth, deskwnd.nHeight, deskwnd.nBytesPerLine,
                                 PixelFormat.Format8bppIndexed, deskwnd.frameBuffer);
                ColorPalette pal = bmp.Palette;
                for (int i = 0; i < 256; i++)
                {
                    pal.Entries[i] = TeamTalkBase.Palette_GetColorTable(BitmapFormat.BMP_RGB8_PALETTE, i);
                }
                bmp.Palette = pal;
                break;

            case BitmapFormat.BMP_RGB16_555:
                bmp = new Bitmap(deskwnd.nWidth, deskwnd.nHeight,
                                 deskwnd.nBytesPerLine, PixelFormat.Format16bppRgb555,
                                 deskwnd.frameBuffer);
                break;

            case BitmapFormat.BMP_RGB24:
                bmp = new Bitmap(deskwnd.nWidth, deskwnd.nHeight, deskwnd.nBytesPerLine,
                                 PixelFormat.Format24bppRgb, deskwnd.frameBuffer);
                break;

            case BitmapFormat.BMP_RGB32:
                bmp = new Bitmap(deskwnd.nWidth, deskwnd.nHeight, deskwnd.nBytesPerLine,
                                 PixelFormat.Format32bppRgb, deskwnd.frameBuffer);
                break;
            }

            Invalidate();
        }