Esempio n. 1
0
 public MainWindow()
 {
     _commandSender = new ArduinoCommand();
     InitializeComponent();
     ApplicationState state = new ApplicationState();
     this.DataContext = state;
     _listener = new ArduinoUpdater(state);
 }
Esempio n. 2
0
        internal StaticUpdateHandler(ApplicationState state)
        {
            _state = state;
            _commander = new ArduinoCommand();
            _commander.UpdateColorValue(ArduinoCommand.Colors.Red, _state.Red);
            _commander.UpdateColorValue(ArduinoCommand.Colors.Green, _state.Green);
            _commander.UpdateColorValue(ArduinoCommand.Colors.Blue, _state.Blue);

            _state.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(state_PropertyChanged);
        }
Esempio n. 3
0
 internal static UpdateHandler GetHandler(ApplicationState state)
 {
     switch (state.CurrentMode)
     {
         case ApplicationState.Mode.Random:
             return new RandomUpdateHandler(state);
          case ApplicationState.Mode.Keyboard:
             return new KeyboardUpdateHandler(state);
          default:
             return new StaticUpdateHandler(state);
     }
 }
Esempio n. 4
0
        internal KeyboardUpdateHandler(ApplicationState state)
        {
            // Listen for name change changes across all processes/threads on current desktop...
            IntPtr hhook = SetWinEventHook(EVENT_OBJECT_NAMECHANGE, EVENT_OBJECT_NAMECHANGE, IntPtr.Zero,
                    procDelegate, 0, 0, WINEVENT_OUTOFCONTEXT);

            _state = state;
            _instance = this;
            _commander = new ArduinoCommand();
            _dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            _dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            _dispatcherTimer.Interval = new TimeSpan(0, 0, 0,0,50);
            _dispatcherTimer.Start();
        }
Esempio n. 5
0
        internal RandomUpdateHandler(ApplicationState state)
        {
            _state = state;
            _commander = new ArduinoCommand();
            _commander.UpdateColorValue(ArduinoCommand.Colors.Red, _state.Red);
            _commander.UpdateColorValue(ArduinoCommand.Colors.Green, _state.Green);
            _commander.UpdateColorValue(ArduinoCommand.Colors.Blue, _state.Blue);

            _dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            _dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 50);
            _dispatcherTimer.Start();

            _targetRed = _rand.Next(0, 256);
            _targetBlue = _rand.Next(0, 256);
            _targetGreen = _rand.Next(0, 256);
        }
Esempio n. 6
0
 public ArduinoUpdater(ApplicationState state)
 {
     _state = state;
     _state.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(state_PropertyChanged);
 }