Ejemplo n.º 1
0
        /// <summary>
        /// 外部调用,开始进行推屏
        /// </summary>
        /// <param name="IP"></param>
        public void StartPushScreen(string IP)
        {
            if (m_updatetimer != null)
            {
                m_updatetimer.Stop();
                m_updatetimer.Dispose();
                m_updatetimer = null;
            }

            timerlock         = false;
            m_mainimg         = null;
            m_framebufferdata = null;
            m_truedrawrect    = new Rectangle(0, 0, 0, 0);
            m_IP = IP;
            //将需要推屏的IP传递进入DLL
            SetIP(m_IP);

            StartVNCClient();

            //启动timer事件,准备刷新屏幕数据
            if (m_updatetimer == null)
            {
                m_updatetimer           = new System.Timers.Timer(300);
                m_updatetimer.Elapsed  += new System.Timers.ElapsedEventHandler(UpdateImage);
                m_updatetimer.AutoReset = true;
                m_updatetimer.Enabled   = true;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 回调的屏幕刷新函数,对关键数据进行赋值
        /// </summary>
        /// <param name="date"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="right"></param>
        /// <param name="bottom"></param>
        private void GetUpdateDate(IntPtr date, int length, int w, int h, int left, int top, int right, int bottom)
        {
            if (m_framebufferdata == null)
            {
                m_framebufferdata = new FrameBufferData();
            }

            m_framebufferdata.data   = date;
            m_framebufferdata.length = length;
            m_framebufferdata.w      = w;
            m_framebufferdata.h      = h;
            m_framebufferdata.left   = left;
            m_framebufferdata.top    = top;
            m_framebufferdata.right  = right;
            m_framebufferdata.bottom = bottom;
        }
Ejemplo n.º 3
0
        private void Update(FrameBufferData fb)
        {
            IntPtr date   = fb.data;
            int    length = fb.length;
            int    w      = fb.w;
            int    h      = fb.h;
            int    left   = fb.left;
            int    top    = fb.top;
            int    right  = fb.right;
            int    bottom = fb.bottom;

            //lock (locker)
            try
            {
                if (m_mainimg == null)
                {
                    m_mainimg = new Bitmap(w, h, PixelFormat.Format32bppRgb);
                }

                if (m_truedrawrect.Width == 0)
                {
                    if ((w * OSPictureBox.Height) >= (OSPictureBox.Width * h))
                    {
                        m_truedrawrect.Width  = OSPictureBox.Width;
                        m_truedrawrect.Height = (OSPictureBox.Width * h) / w;
                        m_truedrawrect.X      = 0;
                        m_truedrawrect.Y      = (OSPictureBox.Height - m_truedrawrect.Height) / 2;
                    }
                    else
                    {
                        m_truedrawrect.Height = OSPictureBox.Height;
                        m_truedrawrect.Width  = (OSPictureBox.Height * w) / h;
                        m_truedrawrect.X      = (OSPictureBox.Width - m_truedrawrect.Width) / 2;
                        m_truedrawrect.Y      = 0;
                    }

                    m_maing = OSPictureBox.CreateGraphics();
                    m_maing.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.Low;
                    m_maing.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
                    m_maing.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                }

                byte[] m_imgData = new byte[length];

                try
                {
                    Marshal.Copy(date, m_imgData, 0, length);
                    BitmapData bitdata = m_mainimg.LockBits(
                        new Rectangle(0, 0, m_mainimg.Width, m_mainimg.Height),
                        ImageLockMode.WriteOnly,
                        PixelFormat.Format32bppRgb);
                    Marshal.Copy(m_imgData, 0, bitdata.Scan0, m_imgData.Length);
                    m_mainimg.UnlockBits(bitdata);
                    m_maing.DrawImage(m_mainimg,
                                      m_truedrawrect,
                                      new Rectangle(0, 0, w, h),
                                      GraphicsUnit.Pixel);
                }
                catch (AccessViolationException)
                {
                    Trace.WriteLine("内存托管错误");
                }
            }
            catch (Exception)
            {
            }
        }