public MovementWindow(MainWindow mainWindow , string mode , int complexity , int Speed, System.Windows.Media.Color color1 , System.Windows.Media.Color color2 , System.Windows.Media.Color color3 ) { InitializeComponent(); Pointer1.Stroke = new SolidColorBrush(color1); this.color1 = new SolidColorBrush(color1); Pointer1.DataContext = model; Pointer2.Stroke = new SolidColorBrush(color2); this.color2 = new SolidColorBrush(color2); StimulyEllipse1.Stroke = this.color1; CheckPointEllipse.Stroke = this.color2; Pointer2.DataContext = model; lineBrush = new SolidColorBrush(color3); CourseSpeed = Speed; this.queue1 = new AnimationQueue(StimulyEllipse1, Canvas.LeftProperty, Canvas.TopProperty); this.mainWindow = mainWindow; recorder = coordinateRecorder.getInstance(this); holder = CoordinateDataBuffer.GetInstance(); t = new System.Timers.Timer(); t.Elapsed += new ElapsedEventHandler(SendInfo); t.Interval += 100; this.SetBinding(Window.WidthProperty, new Binding("RezolutionX") { Source = model, Mode = BindingMode.OneWayToSource }); this.SetBinding(Window.HeightProperty, new Binding("RezolutionY") { Source = model, Mode = BindingMode.OneWayToSource }); if (complexity == 0) { CourseSpeed += 4; // Lowest complexity trajectory has too many coordinates and the animation moves to slow. For this increment the course speed more . } if (mode == "Asynchronous") { generate = Asynchronous; checkPointTimer = new System.Timers.Timer(); checkPointTimer.Interval = 1000.0 / CourseSpeed * 50; checkPointTimer.Elapsed += new ElapsedEventHandler(ShowNextCheckPoint); queue1.checkPointHandler += new EventHandler(ShowNextCheckPoint); StimulyEllipse1.Visibility = Visibility.Visible; CheckPointEllipse.Visibility = Visibility.Visible; } if (mode == "Synchronous") { generate = Synchronous; StimulyEllipse1.Visibility = Visibility.Visible; } CourseComplexity = complexity; }
private Service(MainWindow observer) { this.observer = observer; microphones = new MicrophoneHandler(this); WMHandler = new WiimoteHandler(); stimuly_data_context = MovementWindowViewModel.GetInstance(); wm1_data_context = new WiimoteDataContext(); wm2_data_context = new WiimoteDataContext(); mic_data_context = new MicrophoneViewModel(); try { port = PortAccessHandler.GetIntance(); } catch (Exception ex) { Xceed.Wpf.Toolkit.MessageBox.Show( "A paralel port could not be detected on the given address. Please make sure you have a paralel port on the machine. \r\n"+ ex.Message); port = null; } }
//Make two threads to test if that improves the GUI responsiveness of the led points. Theoretically it should as there would be way less calls to the OnNext method . Ideally //it would have a frequence of around 60 to 100 fps. //Made service as a Singleton public static Service getInstance(MainWindow observer) { if (instance == null) instance = new Service(observer); return instance; }
public MovementWindow(MainWindow mainWindow , System.Windows.Media.Color color1, System.Windows.Media.Color color2, System.Windows.Media.Color color3 , int StrokeThickness) { InitializeComponent(); Pointer1.Stroke = new SolidColorBrush(color1); Pointer1.DataContext = model; Pointer2.Stroke = new SolidColorBrush(color2); Pointer2.DataContext = model; lineBrush = new SolidColorBrush(color3); this.StrokeThickness = StrokeThickness; this.mainWindow = mainWindow; recorder = coordinateRecorder.getInstance(this); holder = CoordinateDataBuffer.GetInstance(); this.queue1 = new AnimationQueue(StimulyEllipse1, Canvas.LeftProperty, Canvas.TopProperty); t = new System.Timers.Timer(); t.Elapsed += new ElapsedEventHandler(SendInfo); t.Interval += 100; this.SetBinding(Window.WidthProperty, new Binding("RezolutionX") { Source = model, Mode = BindingMode.OneWayToSource }); this.SetBinding(Window.HeightProperty, new Binding("RezolutionY") { Source = model, Mode = BindingMode.OneWayToSource }); generate = Self_Paced; CourseComplexity = 0; StimulyEllipse1.Visibility = Visibility.Visible; }