Пример #1
0
        private void OnRobotStateChange(Robot.RobotStateChangeEventArgs e)
        {
            switch (e.StateChange)
            {
            case Robot.RobotStateChange.CONNECTING:
                IsRunning = true;
                break;

            case Robot.RobotStateChange.CONNECTING_SUCCEEDED:
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new ThreadStart(delegate()
                {
                    DisplayedBaseName     = Robot.CurrentConfig.BaseName;
                    DisplayedFriendlyName = Robot.CurrentConfig.MyroConfiguration.FriendlyName;
                    DisplayedIcon         = Robot.CurrentConfig.IconFilePath == null ? null :
                                            new BitmapImage(new Uri("file://" + Robot.CurrentConfig.IconFilePath));
                }));

                IsRunning = false;

                // Call this to update the state of grayed-out controls
                // that depend on CurrentConfig being set to become ungrayed.
                CommandManager.InvalidateRequerySuggested();
                break;

            case Robot.RobotStateChange.CONNECTING_FAILED:
                IsRunning = false;
                break;
            }
        }
Пример #2
0
 private void OnRobotStateChange(Robot.RobotStateChangeEventArgs e)
 {
     switch (e.StateChange)
     {
     case Robot.RobotStateChange.CONNECTING_SUCCEEDED:
         controlPanel.SetRobot();
         Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                new ThreadStart(delegate()
         {
             controlPanel.IsEnabled = true;
         }));
         break;
     }
 }