コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Menu_Mouse_Down(object sender, RoutedEventArgs e)
        {
            FrameworkElement feSource = e.Source as FrameworkElement;
            switch (feSource.Name)
            {
                case "Connect":
                    if(!init)
                        Init_Connect_Window();
                    else
                    {
                         portWindow.Visibility = Visibility.Visible;

                     }
                    break;
                case "Bluetooth":
                    BluetoothWindow b_w = new BluetoothWindow(this);
                    b_w.Show();
                    break;
                case "Draw":
                    if (tetris != null)
                    {
                        tetris.Stop_Tetris();

                    }
                    if (video != null)
                        video.RunVideo = false;
                    if (webcam != null)
                        webcam.closeWebcam();

                    runningTask = RunningTask.Draw;
                    drawAccept = true;

                    draw = new Draw(drawlayer,monitorImg,monitor);
                    ex_eff = draw.Draw_execute;

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

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

                    break;
                case "Effects":
                    if (tetris != null)
                    {
                        tetris.Stop_Tetris();

                    }
                    if (video != null)
                        video.RunVideo = false;
                    if (webcam != null)
                        webcam.closeWebcam();

                    runningTask = RunningTask.Effect;
                    drawAccept = false;
                    ex_eff = plasma.Plasma_execute;

                    monitorTimer.IsEnabled = true;

                    break;
                case "Images":
                    if (tetris != null)
                    {
                        tetris.Stop_Tetris();
                        monitor = BitmapFactory.New(68, 42);
                        monitorImg.Source = monitor;

                    }
                    if (webcam != null)
                        webcam.closeWebcam();
                    if (video != null)
                        video.RunVideo = false;

                    drawAccept = false;
                    monitorImg.Source = monitor;
                    runningTask = RunningTask.Image;

                    ip = new ImagePixelate(monitor);
                    ex_eff = ip.execute;

                    break;

                case "Video":
                    if (tetris != null)
                    {
                        tetris.Stop_Tetris();

                        monitorImg.Source = monitor;

                    }
                    if (webcam != null)
                        webcam.closeWebcam();
                    runningTask = RunningTask.Video;

                    CentralMonitor.IsEnabled = false;
                    drawAccept = false;

                    video = new Video(monitor);
                    ex_eff = video.video_execute;

                    video.RunVideo = true;

                    break;
                case "Tetris":

                    if (webcam != null)
                        webcam.closeWebcam();
                    if (video != null)
                        video.RunVideo = false;
                    runningTask = RunningTask.Tetris;
                    drawAccept = false;

                    if (tetris == null)
                    {

                        tetris = new TetrisExecute(monitor, monitorTimer, AuroraWindow);
                        ex_eff = tetris.tetris_exe;

                    }
                    else
                    {
                        tetris.Stop_Tetris();
                        tetris = new TetrisExecute(monitor, monitorTimer, AuroraWindow);
                        ex_eff = tetris.tetris_exe;

                    }
                    break;
                case "Webcam":
                    runningTask = RunningTask.Webcam;
                    CentralMonitor.IsEnabled = false;
                    drawAccept = false;

                    if (tetris != null)
                        tetris.Stop_Tetris();
                    if (webcam == null)
                    {
                        webcam = new Webcam(monitor);
                    }
                    if (video != null)
                        video.RunVideo = false;
                    webcam.resumeWebcam(monitor);
                    ex_eff = webcam.Webcam_execute;

                    break;

            }
            SetUserControls();
        }
コード例 #2
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)
            {

            }
        }