예제 #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
        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);
            }
        }
예제 #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
        // 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);
                    }
                }
            }
        }