Пример #1
0
        public static unsafe int Start(string name, DR2API.OnDeviceStateChanged onState)
        {
            int ret = 0;

            if (Program.IsRun)
            {
                ret = DR2API.DR2_Start(ApiHandle, name, onState, _onBuffer);
            }
            if (ret == 0)
            {
                Started = true;
            }
            else
            {
                Trace.WriteLine("start failed");
                string           errtring   = App.GetString("WifiError");
                string           captionstr = App.GetString("WifiWaring");
                MessageBoxButton button     = MessageBoxButton.OK;
                MessageBoxImage  icon       = MessageBoxImage.Warning;
                MessageBox.Show(errtring, captionstr, button, icon);
                System.Environment.Exit(0);
            }
            //ximu***
            Thread regThread = new Thread(startReg);

            regThread.IsBackground = true;
            regThread.Start();
            //ximu***
            return(ret);
        }
Пример #2
0
 protected override void OnRender(DrawingContext dc)
 {
     if (ActualHeight > 0 && ActualWidth > 0 && ViewModelBase.ApiHandle != IntPtr.Zero)
     {
         if (_bitmap == null)
         {
             _bitmap = new Bitmap((int)ActualWidth, (int)ActualHeight, PixelFormat.Format24bppRgb);
         }
         if (_bitmap != null && (_bitmap.Height != ActualHeight || _bitmap.Width != ActualWidth))
         {
             _bitmap.Dispose();
             _bitmap = new Bitmap((int)ActualWidth, (int)ActualHeight, PixelFormat.Format24bppRgb);
         }
         using (var g = Graphics.FromImage(_bitmap))
         {
             if (Program.IsRun)
             {
                 DR2API.DR2_Draw(ViewModelBase.ApiHandle, WindowHandle, g.GetHdc(), new RECT(0, 0, (int)ActualWidth, (int)ActualHeight),
                                 ActualWidth == Window.GetWindow(this).ActualWidth ? 1 : 0);
             }
         }
         dc.DrawImage(ToBitmapSource(_bitmap), new Rect(0, 0, ActualWidth, ActualHeight));
         GC.Collect();
     }
 }
Пример #3
0
 public static void Create()
 {
     if (Program.IsRun)
     {
         ApiHandle = DR2API.DR2_Create();
     }
 }
Пример #4
0
 private void OnMenuClickHelp(object sender, RoutedEventArgs e)
 {
     if (Program.IsRun)
     {
         DR2API.DR2_Click(ViewModelBase.ApiHandle, 4, _isLangUS);
     }
 }
Пример #5
0
 private void OnHowToConnectCommand2()
 {
     if (Program.IsRun)
     {
         DR2API.DR2_Click(ApiHandle, 4, _view._isLangUS);
     }
 }
Пример #6
0
 private void OnDisconnectCommand()
 {
     if (Program.IsRun)
     {
         DR2API.DR2_Click(ApiHandle, 2);
     }
 }
Пример #7
0
 private void OnHowToConnectCommand()
 {
     if (Program.IsRun)
     {
         DR2API.DR2_Click(ApiHandle, 1, m_MainWindow._isLangUS);
     }
 }
Пример #8
0
 private void OnDisConnectClick(object sender, EventArgs e)
 {
     if (Program.IsRun)
     {
         DR2API.DR2_Click(ViewModelBase.ApiHandle, 2);
     }
 }
Пример #9
0
 public void OnText(string text)
 {
     Trace.WriteLine("OnText:" + text);
     if (Program.IsRun)
     {
         DR2API.DR2_OnText(ViewModelBase.ApiHandle, text);
     }
 }
Пример #10
0
 private void OnCloseCommand()
 {
     if (Program.IsRun)
     {
         // DR2API.DR2_SetFullscreen(ApiHandle, false);
         DR2API.DR2_Click(ApiHandle, 2);
     }
 }
Пример #11
0
 public static void Stop()
 {
     if (Program.IsRun)
     {
         DR2API.DR2_Click(ApiHandle, 2);
         DR2API.DR2_Stop(ApiHandle);
     }
     Started = false;
 }
Пример #12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            IntPtr hdc = e.Graphics.GetHdc();

            if (Program.IsRun)
            {
                DR2API.DR2_Draw(ViewModelBase.ApiHandle, Handle, hdc, new RECT(0, 0, (int)Width, (int)Height), 0);
            }
            e.Graphics.ReleaseHdc(hdc);
        }
Пример #13
0
        private void OnCloseCommand()
        {
            Window.GetWindow(_client as DependencyObject).Close();

            if (Program.IsRun)
            {
                //DR2API.DR2_SetFullscreen(ApiHandle, false);
                DR2API.DR2_Click(ApiHandle, 2);
            }
        }
Пример #14
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            var pt = e.GetPosition(this);

            //Debug.WriteLine("OnMouseMove: width:{0}, height:{1}, x:{2}, y{3}", ActualWidth, ActualHeight, pt.X, pt.Y);
            if (Program.IsRun)
            {
                DR2API.DR2_OnMouseMove(ViewModelBase.ApiHandle, (int)ActualWidth, (int)ActualHeight, (int)pt.X, (int)pt.Y);
            }
        }
Пример #15
0
        void VideoPlayer_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2)
            {
                if (_vm != null)
                {
                    _vm.FullScreenCommand.Execute(null);
                    return;
                }
            }
            var pt = e.GetPosition(this);

            //Debug.WriteLine("OnMouseLeftButtonDown: width:{0}, height:{1}, x:{2}, y{3}", ActualWidth, ActualHeight, pt.X, pt.Y);
            if (Program.IsRun)
            {
                DR2API.DR2_OnMouseLeftButtonDown(ViewModelBase.ApiHandle, e.ClickCount, (int)ActualWidth, (int)ActualHeight, (int)pt.X, (int)pt.Y);
            }
            e.Handled = true;
        }
Пример #16
0
        public VideoPlayerForm(VideoPlayerHost host)
        {
            if (Program.IsRun)
            {
                InitializeComponent();
            }
            _host = host;
            if (Program.IsRun)
            {
                DR2API.DR2_SetDrawWnd(ViewModelBase.ApiHandle, Handle);
            }

            //设置定时器  3 秒一次
            _mainTimer           = new DispatcherTimer();
            _mainTimer.Interval  = TimeSpan.FromSeconds(3);
            _mainTimer.Tick     += new EventHandler(dTimer_Tick);
            _mainTimer.IsEnabled = true;
            _mainTimer.Start();
        }
Пример #17
0
        private void VideoPlayerForm_MouseMove(object sender, MouseEventArgs e)
        {
            var pt = e.Location;

            //Debug.WriteLine("OnMouseMove: width:{0}, height:{1}, x:{2}, y{3}", Width, Height, pt.X, pt.Y);
            if (Program.IsRun)
            {
                DR2API.DR2_OnMouseMove(ViewModelBase.ApiHandle, Width, Height, pt.X, pt.Y);

                if (_host._lft != null && m_x != pt.X && m_y != pt.Y)
                {
                    m_x = pt.X;
                    m_y = pt.Y;

                    _mainTimer.Start();
                    _host._lft.ftbname.Opacity = 1.0;
                    _host._lft.Show();
                }
            }
        }
Пример #18
0
        public PhoneViewModel(IClientView client)
            : base(client as FrameworkElement)
        {
            _llft   = null;
            _client = client;

            // _client.FullScreen(true);

            int isQp = DR2API.DR2_GetISQP(ViewModelBase.ApiHandle);

            if (isQp == 1)
            {
                OnFullScreenCommand();
            }

            //string isQP = System.Configuration.ConfigurationManager.AppSettings["ISQP"];
            //if (string.Compare(isQP, "true", true) == 0)
            //  OnFullScreenCommand();
            //DR2.Views.PhoneView sss = _client;
        }
Пример #19
0
 private void OnFullScreenCommand()
 {
     if (Program.IsRun)
     {
         DR2API.DR2_SetWndChanging(ApiHandle, true);
     }
     _fulling    = true;
     _fullScreen = !_fullScreen;
     if (_client != null)
     {
         _client.FullScreen(_fullScreen);
     }
     _fulling = false;
     if (Program.IsRun)
     {
         DR2API.DR2_SetFullscreen(ApiHandle, _fullScreen);
     }
     if (Program.IsRun)
     {
         DR2API.DR2_SetWndChanging(ApiHandle, false);
     }
 }
Пример #20
0
        private void VideoPlayerForm_MouseDown(object sender, MouseEventArgs e)
        {
            Trace.WriteLine("MouseDown: X = " + e.X + "; Y = " + e.Y);
            // Trace.WriteLine("oriWidth: = " + oriWidth + " ; oriheight = " + oriheight);
            Trace.WriteLine("VideoPlayerFormWidth: = " + this.Width + " ; VideoPlayerFormHeight = " + this.Height);
            RECT in_rect  = new RECT(1, 1, 1, 1);
            RECT out_rect = new RECT(1, 1, 1, 1);

            DR2API.DR2_GetDrawRect(ViewModelBase.ApiHandle, ref in_rect, ref out_rect);


            Trace.WriteLine("in_rect:  " + in_rect.left + " " + in_rect.top + " " + in_rect.right + " " + in_rect.bottom + " ");
            Trace.WriteLine("out_rect: " + out_rect.left + " " + out_rect.top + " " + out_rect.right + " " + out_rect.bottom + " ");


            int in_X = (int)e.X;
            int in_Y = (int)e.Y;

            int isVertical = _host.getIsVertical();


            if (isVertical == 1)
            {
                VideoPlayerForm.PHONE_HEIGHT = VideoPlayerForm.PHONE_HEIGHT_FIRST_SCREEN;
                VideoPlayerForm.PHONE_WIDTH  = VideoPlayerForm.PHONE_WIDTH_FIRST_SCREEN;
            }
            else
            {
                VideoPlayerForm.PHONE_HEIGHT = VideoPlayerForm.PHONE_HEIGHT_SECOND_SCREEN;
                VideoPlayerForm.PHONE_WIDTH  = VideoPlayerForm.PHONE_WIDTH_SECOND_SCREEN;
            }


            var pt = e.Location;

            if (e.Button == MouseButtons.Left)
            {
                {
                    byte[] data = new byte[12];

                    data[0] = 0; // mouseDown
                    data[1] = 0;
                    data[2] = 0;
                    data[3] = 0;

                    int sendX = 0;
                    sendX = (int)((float)((in_X) - out_rect.left) * (VideoPlayerForm.PHONE_WIDTH / (float)(out_rect.Width)));

                    byte[] X = BitConverter.GetBytes(sendX);

                    X.CopyTo(data, 4);

                    int sendY = 0;
                    sendY = (int)((float)((in_Y) - out_rect.top) * (VideoPlayerForm.PHONE_HEIGHT / (float)(out_rect.Height)));;

                    byte[] Y = BitConverter.GetBytes(sendY);
                    Y.CopyTo(data, 8);

                    if ((sendX >= 0 && (sendX < VideoPlayerForm.PHONE_WIDTH)) && (sendY >= 0 && (sendY < VideoPlayerForm.PHONE_HEIGHT)))
                    {
                        Trace.WriteLine("send mouse down : X = " + sendX + "; Y = " + sendY);
                        DataManager.sendMouseData(data);
                    }
                    else
                    {
                        Trace.WriteLine(" invalid mouse down : X = " + sendX + "; Y = " + sendY);
                    }
                }

                //Debug.WriteLine("OnMouseLeftButtonDown: width:{0}, height:{1}, x:{2}, y{3}", Width, Height, pt.X, pt.Y);
                if (Program.IsRun)
                {
                    DR2API.DR2_OnMouseLeftButtonDown(ViewModelBase.ApiHandle, e.Clicks, Width, Height, pt.X, pt.Y);
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                //Debug.WriteLine("OnMouseRightButtonDown: width:{0}, height:{1}, x:{2}, y{3}", Width, Height, pt.X, pt.Y);
                if (Program.IsRun)
                {
                    DR2API.DR2_OnMouseRightButtonDown(ViewModelBase.ApiHandle, Width, Height, pt.X, pt.Y);
                }
            }
        }
Пример #21
0
 // open a new Thread to do this ,because this contain a while(true)
 static void startReg()
 {
     DR2API.DR2_registSocketFun(ApiHandle, ScreenCast.Program.dm.run); // regist the function.
 }