Beispiel #1
0
 private void BtnConnect_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         wm.Connect();
         connected          = true;
         recording          = true;
         wm.WiimoteChanged += wm_WiimoteChanged;
         wm.SetLEDs(true, false, false, true);
         BtnConnect.IsEnabled = false;
     }
     catch (WiimoteNotFoundException ex)
     {
         Dialogs.ErrorDialog ed = new Dialogs.ErrorDialog();
         ed.SetMessage("A Wiimote could not be found, please connect it through Bluetooth and try again.");
         ed.ShowDialog();
     }
 }
Beispiel #2
0
        private void LoadImages()
        {
            var response = _imgService.ObatainSavedimages();

            if (response.Succesfull)
            {
                if (response.Data.ToList().Count <= 0)
                {
                    LBLMsg.Visibility = Visibility.Visible;
                }
                else
                {
                    lvImages.ItemsSource = new ObservableCollection <Dataimage>(response.Data);
                    LBLMsg.Visibility    = Visibility.Hidden;
                }
            }
            else
            {
                Dialogs.ErrorDialog ed = new Dialogs.ErrorDialog();
                ed.SetMessage("Cannot connect to the server");
                ed.ShowDialog();
            }
        }
Beispiel #3
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)canvas.Width, (int)canvas.Height, 96d, 69d, PixelFormats.Pbgra32);

            canvas.Measure(new System.Windows.Size((int)canvas.Width, (int)canvas.Height));
            canvas.Arrange(new Rect(new System.Windows.Size((int)canvas.Width, (int)canvas.Height)));
            renderBitmap.Render(canvas);
            PngBitmapEncoder encoder = new PngBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(renderBitmap));

            var imageName = string.Format("{0}{1}{2}{3}{4}{5}.png", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            var response  = new Response();

            using (MemoryStream memoryStream = new MemoryStream())
            {
                encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                encoder.Save(memoryStream);

                response = _imgService.SaveImage(memoryStream.ToArray(), imageName);
            }
            Application.Current.MainWindow.Height++;
            Application.Current.MainWindow.Height--;
            if (response.Succesfull)
            {
                Dialogs.ErrorDialog ed = new Dialogs.ErrorDialog();
                ed.SetMessage("Imagen guardada exitosamente");
                ed.SetTitle("Success!");
                ed.ShowDialog();
            }
            else
            {
                Dialogs.ErrorDialog ed = new Dialogs.ErrorDialog();
                ed.SetMessage("Cannot connect to the server");
                ed.ShowDialog();
            }
        }