Beispiel #1
0
        public async void Start()
        {
            _ctoken = new CancellationTokenSource();

            WriteLine("Testing is started");
            _testedCount = 0;

            await Task.Run(() => {
                string test;
                while (_ctoken != null && !_ctoken.Token.IsCancellationRequested &&
                       _testQueue.TryDequeue(out test))
                {
                    var task = DoTest(test);
                    task.Wait();

                    Interlocked.Increment(ref _testedCount);
                }

                _ctoken = null;
            },
                           _ctoken.Token
                           );

            TestingCompleted?.Invoke(this, $"{Name} finished job");
        }
Beispiel #2
0
        private void MemoryTestView_TestingCompleted(object sender, EventArgs e)
        {
            if (sender is MemoryTestView memoryTestView && memoryTestView.Tag is Button button)
            {
                TraingViewCotnentControl.Content = null;
                button.IsEnabled = false;

                //记录
                if (button == Test1Button)
                {
                    MemoryPicturesExcelHelper.SaveMemoryTestData(UserDetailTestRecord.UserInfo, UserDetailTestRecord.Group1TestInfo);
                }
                else if (button == Test2Button)
                {
                    MemoryPicturesExcelHelper.SaveMemoryTestData(UserDetailTestRecord.UserInfo, UserDetailTestRecord.Group2TestInfo);
                }
                else
                {
                    MemoryPicturesExcelHelper.SaveMemoryTestData(UserDetailTestRecord.UserInfo, UserDetailTestRecord.Group3TestInfo);
                }
            }

            if (Test1Button.IsEnabled == false && Test2Button.IsEnabled == false && Test3Button.IsEnabled == false)
            {
                TestingCompleted?.Invoke(this, EventArgs.Empty);
            }
        }
        private void MemoryPictureList_OnPictureLocationComfirmed(object sender, LocationMemoryPictureItem item)
        {
            try
            {
                _selectedLocationTestingPictureList.Add(item);
                //提示结果
                var resultTipText = _memorizedPictureList.Any(i => i.PictureItem == item.PictureItem && i.Location == item.Location) ? "正确" : "错误";
                SetResultTip(resultTipText);

                if (sender is MemoryPictureListControl memoryPictureListControl &&
                    _selectedLocationTestingPictureList.Count >= memoryPictureListControl.TrainingStageSetting.ClickMaxLimit)
                {
                    TestingCompleted?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    var memorizedPictureList = _memorizedPictureList;
                    var random = new Random();
                    MemoryPictureItem visibileRandomPictureItem = null;
                    while (visibileRandomPictureItem == null)
                    {
                        var visibileRandomIndex = random.Next(memorizedPictureList.Count);
                        var randomPictureItem   = memorizedPictureList[visibileRandomIndex].PictureItem;
                        if (_selectedLocationTestingPictureList.All(i => i.PictureItem != randomPictureItem))
                        {
                            visibileRandomPictureItem = randomPictureItem;
                        }
                    }

                    visibileRandomPictureItem.IsPictureVisibile = true;
                }
            }
        private void MemoryPictureList_OnPictureLocationComfirmed(object sender, LocationMemoryPictureItem item)
        {
            //TODO 记录
            _selectedLocationTestingPictureList.Add(item);
            //提示结果
            var resultTipText = _memorizedPictureList.Any(i => i.PictureItem == item.PictureItem && i.Location == item.Location) ? "正确" : "错误";

            SetResultTip(resultTipText);

            if (sender is FamiliarMemoryListControl memoryPictureListControl &&
                _selectedLocationTestingPictureList.Count >= memoryPictureListControl.TrainingStageSetting.ClickMaxLimit)
            {
                TestingCompleted?.Invoke(this, EventArgs.Empty);
            }