コード例 #1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            int index = 0;
            int count = 0;

            GlobalVariables.CountError = 0;

            string[] listLocalFile = Directory.GetFiles(GlobalFunction.GetSavedDir(), "*.mrb");
            var listMotionInfo = listLocalFile.Select(file => new MotionInfo(file)).ToList();
            listMotionInfo.Sort((x, y) => String.CompareOrdinal(x.Title, y.Title)); // Sort title

            while (count < 1000)
            {
                var motionID = listMotionInfo[index].MotionID;
                var transferRequest = new TransferMotionToRobot(motionID);
                var transferWindow = new Windows.TransferWindow(transferRequest, motionID.ToString());
                if (transferWindow.ShowDialog(StaticMainWindow.Window) == true)
                {
                }
                System.Threading.Thread.Sleep(5000);
                index++;
                if (index == listMotionInfo.Count) index = 0;
                count++;
                DebugHelper.WriteLine("Transfer count :" + count);
            }
        }
コード例 #2
0
ファイル: TransferWindow.xaml.cs プロジェクト: huucp/tuneRobo
        public TransferWindow(TransferMotionToRobot request, string motionTitle)
        {
            InitializeComponent();

            RobotRequest = request;
            RobotRequest.ProcessError += Request_ProcessError;
            RobotRequest.ProcessSuccessfully += RobotRequest_ProcessSuccessfully;
            RobotRequest.ProgressReport += Request_ProgressReport;

            ProgressBar.Maximum = 100;

            var viewModel = new TransferWindowViewModel();
            DataContext = viewModel;
            ViewModel = (TransferWindowViewModel)DataContext;
            ViewModel.Title = motionTitle;
            ViewModel.TransferText = (string)TryFindResource("TransferringText");
        }
コード例 #3
0
        // This method raises the CopyMotion event
        private void TransferButton_Click(object sender, RoutedEventArgs e)
        {
            if (!GlobalVariables.RoboOnline)
            {
                var title = string.Format("{0}!", TryFindResource("ConnectToRobotText"));
                WPFMessageBox.Show(StaticMainWindow.Window, "", title, MessageBoxButton.OK, MessageBoxImage.Warning,
                                   MessageBoxResult.OK);
            }
            else
            {
                if (CheckExistInRobot(GlobalVariables.CurrentListMotion, MotionID))
                {
                    var titleRecopy = (string)TryFindResource("ExistInRobotText");
                    var msgRecopy = (string)TryFindResource("WantRecopyMotionText");
                    var recopyResult = WPFMessageBox.Show(StaticMainWindow.Window, msgRecopy, titleRecopy,
                                                          MessageBoxButton.YesNo, MessageBoxImage.Question,
                                                          MessageBoxResult.No);
                    if (recopyResult == MessageBoxResult.No)
                    {
                        return;
                    }
                }

                if (GlobalVariables.CurrentRobotState.MusicState == RobotState.MusicStates.MusicPlaying)
                {
                    var titleStop = (string)TryFindResource("StopDanceToCopyText");
                    var msgStop = (string)TryFindResource("WantToStopDanceText");
                    var result = WPFMessageBox.Show(StaticMainWindow.Window, msgStop, titleStop, MessageBoxButton.YesNo,
                                                MessageBoxImage.Question, MessageBoxResult.Yes);
                    if (result == MessageBoxResult.Yes)
                    {

                        var musicStopRequest = new RemoteRequest(RobotPacket.PacketID.Stop);
                        musicStopRequest.ProcessSuccessfully += (data) =>
                        {
                            Dispatcher.BeginInvoke((Action)delegate
                            {
                                var transferRequest = new TransferMotionToRobot(MotionID);
                                var transferWindow = new Windows.TransferWindow(transferRequest, MotionID.ToString());
                                if (transferWindow.ShowDialog(StaticMainWindow.Window) == true)
                                {
                                    var newEventArgs = new RoutedEventArgs(CopyMotionEvent);
                                    RaiseEvent(newEventArgs);
                                }
                            });
                        };
                        musicStopRequest.ProcessError += (data, msg) => Debug.Fail(msg);
                        GlobalVariables.RobotWorker.AddJob(musicStopRequest);

                    }
                }
                else
                {
                    var transferRequest = new TransferMotionToRobot(MotionID);
                    var transferWindow = new Windows.TransferWindow(transferRequest, MotionID.ToString());
                    if (transferWindow.ShowDialog(StaticMainWindow.Window) == true)
                    {
                        var newEventArgs = new RoutedEventArgs(CopyMotionEvent);
                        RaiseEvent(newEventArgs);
                    }

                }
            }
        }
コード例 #4
0
ファイル: TransferWindow.xaml.cs プロジェクト: huucp/tuneRobo
 private void Request_ProcessError(TransferMotionToRobot.ErrorCode errorCode, string errorMessage)
 {
     //GlobalVariables.CountError++;
     //DebugHelper.WriteLine("Tranfer error count:" + GlobalVariables.CountError);
     Dispatcher.BeginInvoke((Action)delegate
                                         {
                                             DialogResult = false;
                                             Console.WriteLine(errorMessage);
                                             Close();
                                             var title = (string)TryFindResource("TransferErrorText");
                                             WPFMessageBox.Show(StaticMainWindow.Window, "", title, MessageBoxButton.OK, MessageBoxImage.Information,
                                                                MessageBoxResult.OK);
                                         });
 }