Пример #1
0
 void connection_changed(object sender, PropertyChangeArgs data)
 {
     if (bluetooth.Connected == true)
     {
         // Verbunden Status - evtl das Event in das Haupfenster einbinden für ein Symbol??
         Debug.WriteLine("Verbunden!");
         //Connection Detective aktivieren
         //bluetooth.connection_detective(true);
         Connect.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate
         {
             Connect.Content = "Trennen";
             Thread.Sleep(300);
             Close();
         });
     }
     else
     {
         //Gerät wurde getrennt -> Meldung ausgeben in allen Fenstern???
         Debug.WriteLine("Verbindung getrennt!");
         //bluetooth.connection_detective(false, 4000);
         Connect.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate
         {
             Connect.Content = "Verbinden";
         });
     }
 }
Пример #2
0
        //void commca(object sender, PropertyChangeArgs data)
        //{
        //    string command = data.mesg;
        //}

        void scan_finished(object sender, PropertyChangeArgs data)
        {
            found_devices = data.liste;

            //Clear Devices
            Devices.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate
            {
                Devices.Items.Clear();
            });

            //Found Devices
            foreach (String str in found_devices)
            {
                Devices.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate
                {
                    Devices.Items.Add(str);
                    Devices.SelectedItem = Devices.Items[0];
                });
            }
            ProgressRing.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate
            {
                ProgressRing.IsActive   = false;
                ProgressRing.Visibility = Visibility.Collapsed;
            });


            //Known Devices

            List <String> known_dev = bluetooth.get_known_devices();

            foreach (String str in known_dev)
            {
                Devices.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate
                {
                    Devices.Items.Add(str);
                    Devices.SelectedItem = Devices.Items[0];
                });
            }
        }
Пример #3
0
        private void Bluetooth_Command_Listener(object sender, PropertyChangeArgs command)
        {
            try
            {
                int    Mode = -1;
                string comm = command.mesg;
                System.Diagnostics.Debug.WriteLine("Command wurde übergeben: " + comm);
                switch (comm)
                {
                case "Paint":             //Paint
                {
                    Mode = 0;
                    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate
                        {
                            if (tetris != null)
                            {
                                tetris.Stop_Tetris();
                                monitor           = BitmapFactory.New(68, 42);
                                monitorImg.Source = monitor;
                            }

                            runningTask = RunningTask.Draw;
                            drawAccept  = true;
                            if (video != null)
                            {
                                video.RunVideo = false;
                            }
                            if (webcam != null)
                            {
                                webcam.closeWebcam();
                            }

                            try
                            {
                                draw = new Draw(drawlayer, monitorImg, monitor);
                            }
                            catch (Exception exc)
                            {
                            }
                            ex_eff = draw.Draw_execute;

                            draw.setColor    = Color.FromArgb(0, 200, 0, 255);
                            draw.setDrawtype = Drawtype.point;

                            Binding ColorBinding = new Binding("setColor");
                            ColorBinding.Source  = draw;
                            ColorBinding.Mode    = BindingMode.TwoWay;
                            DrawingColorPicker.SetBinding(Xceed.Wpf.Toolkit.ColorCanvas.SelectedColorProperty, ColorBinding);

                            SetUserControls();

                            //object GlassOfSugar = new  Object();
                            //Slider slider = new Slider();
                            //Binding AmountBinding = new Binding("Amount");
                            ////AmountBinding.Source = GlassOfSugar;
                            ////AmountBinding.Mode = BindingMode.TwoWay;
                            //slider.SetBinding(Slider.ValueProperty, AmountBinding);
                        });


                    break;
                }

                case "Fotobearbeitung":           //Pixelated Picture
                {
                    Mode = 1;

                    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate
                        {
                            if (tetris != null)
                            {
                                tetris.Stop_Tetris();
                                monitor           = BitmapFactory.New(68, 42);
                                monitorImg.Source = monitor;
                            }

                            runningTask = RunningTask.Draw;
                            drawAccept  = true;
                            if (video != null)
                            {
                                video.RunVideo = false;
                            }
                            if (webcam != null)
                            {
                                webcam.closeWebcam();
                            }

                            try
                            {
                                draw = new Draw(drawlayer, monitorImg, monitor);
                            }
                            catch (Exception exc)
                            {
                            }
                            ex_eff = draw.Draw_execute;

                            draw.setColor    = Color.FromArgb(0, 200, 0, 255);
                            draw.setDrawtype = Drawtype.point;

                            Binding ColorBinding = new Binding("setColor");
                            ColorBinding.Source  = draw;
                            ColorBinding.Mode    = BindingMode.TwoWay;
                            DrawingColorPicker.SetBinding(Xceed.Wpf.Toolkit.ColorCanvas.SelectedColorProperty, ColorBinding);

                            SetUserControls();

                            //object GlassOfSugar = new Object();
                            //Slider slider = new Slider();
                            //Binding AmountBinding = new Binding("Amount");
                            //AmountBinding.Source = GlassOfSugar;
                            //AmountBinding.Mode = BindingMode.TwoWay;
                            //slider.SetBinding(Slider.ValueProperty, AmountBinding);
                        });

                    break;
                }

                case "Tetris":           //Tetris
                {
                    Mode = 2;

                    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (ThreadStart) delegate
                        {
                            if (webcam != null)
                            {
                                webcam.closeWebcam();
                            }

                            runningTask = RunningTask.Tetris;
                            drawAccept  = false;
                            //Versuchsweise eingebaut -> dt_m.Tick ist fehlerquelle -.-  -> sollte eigentlich nicht sein
                            //dt_m.IsEnabled = false;

                            if (tetris == null)
                            {
                                monitor           = BitmapFactory.New(68, 42);
                                monitorImg.Source = monitor;
                                tetris            = new TetrisExecute(monitor, monitorTimer, AuroraWindow);
                                ex_eff            = tetris.tetris_exe;


                                Binding ScoreBinding = new Binding("Score");
                                ScoreBinding.Mode    = BindingMode.OneWay;
                                ScoreBinding.Source  = tetris.t;
                                Points.SetBinding(Label.ContentProperty, ScoreBinding);

                                Binding LevelBinding = new Binding("Level");
                                LevelBinding.Mode    = BindingMode.OneWay;
                                LevelBinding.Source  = tetris.t;
                                Level.SetBinding(Label.ContentProperty, LevelBinding);
                            }
                            else
                            {
                                tetris.Stop_Tetris();
                                tetris = new TetrisExecute(monitor, monitorTimer, AuroraWindow);
                                ex_eff = tetris.tetris_exe;

                                Binding ScoreBinding = new Binding("Score");
                                ScoreBinding.Mode    = BindingMode.TwoWay;
                                ScoreBinding.Source  = tetris.t;
                                Points.SetBinding(Label.ContentProperty, ScoreBinding);
                            }
                            SetUserControls();
                        });


                    break;
                }

                default:
                {
                    //hier wäre normalerweise ein switch(mode) -> unnötig?

                    break;
                }
                }
            }
            catch (Exception exc)
            {
            }
        }