Exemplo n.º 1
0
        private bool CheckResult()
        {
            if (this.generatedCount == this.currentPass.TotalObjectCount)
            {
                if (this.generateTimer != null)
                {
                    this.generateTimer.Stop();
                }
            }

            if (this.generatedCount == this.currentPass.TotalObjectCount &&
                this.flyingDataList.Count == 0)
            {
                ResultWindow wnd = new ResultWindow();
                if (this.passCount >= this.currentPass.PassObjectCount)
                {
                    wnd.State = SoonLearning.AppCenter.Controls.ResultState.Pass;
                }
                else
                {
                    wnd.State = SoonLearning.AppCenter.Controls.ResultState.NotPass;
                }

                wnd.ShowMessage(MessageWindowCallback);

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private void Done()
        {
            if (this.drawNumberData.DrawNumberImageData != null &&
                this.drawNumberData.DrawNumberImageData.Length > 0)
            {
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.StreamSource = new MemoryStream(this.drawNumberData.DrawNumberImageData);
                bi.EndInit();

                if (this.numberImage == null)
                {
                    this.numberImage = new Image();
                }

                this.Children.Add(this.numberImage);
                this.numberImage.Source  = bi;
                this.numberImage.Stretch = Stretch.Uniform;
                this.numberImage.Width   = this.drawNumberData.DrawNumberItem.ForegroundWidth;  // bi.PixelWidth;// *bkScale;
                this.numberImage.Height  = this.drawNumberData.DrawNumberItem.ForegroundHeight; // bi.PixelHeight;// *bkScale;
                Canvas.SetTop(this.numberImage, this.drawNumberData.DrawNumberItem.NumberImagePoint.Y);
                Canvas.SetLeft(this.numberImage, this.drawNumberData.DrawNumberItem.NumberImagePoint.X);
                this.numberImage.Visibility = System.Windows.Visibility.Visible;
                this.Background.Opacity     = 1.0;
            }

            List <Line> lineList = new List <Line>();

            foreach (UIElement o in this.Children)
            {
                if (o is Line)
                {
                    lineList.Add(o as Line);
                }
            }

            foreach (Line line in lineList)
            {
                this.Children.Remove(line);
            }

            //   this.Children.Add(this.resultCtrl);

            //     this.resultCtrl.Show = true;
            //    Canvas.SetTop(this.resultCtrl, (this.Height - this.resultCtrl.ActualHeight) / 2);
            //    Canvas.SetLeft(this.resultCtrl, (this.Width - this.resultCtrl.ActualWidth) / 2);

            this.Dispatcher.BeginInvoke(new ThreadStart(() =>
            {
                Thread.Sleep(2000);

                ResultWindow resultWin = new ResultWindow();
                resultWin.State        = ResultState.Pass;
                resultWin.ShowMessage(MessageWindowCallback);
            }),
                                        DispatcherPriority.Background,
                                        null);
        }
        private void showStageFeedback()
        {
            Thread.Sleep(200);
            //    DoubleAnimation doubleAnimation = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromMilliseconds(300)));
            //    doubleAnimation.Completed += (sender, e) =>
            {
                this.Dispatcher.BeginInvoke(new ThreadStart(() =>
                                                            //    if (MemorizeDataMgr.Instance.Entry.StageFeedback == null)
                {
                    if (MemorizeDataMgr.Instance.IsLastStage)
                    {
                        MemorizeDataMgr.Instance.UsedTime = this.timeControl.Elapsed;
                        this.timeControl.Stop();
                        MemorizeResultWindow resultWnd = new MemorizeResultWindow();
                        resultWnd.ShowDialog();

                        MemorizeDataMgr.Instance.Restart();
                        this.timeControl.Start(60);
                        this.startStage();
                    }
                    else
                    {
                        ResultWindow resultWnd = new ResultWindow();
                        resultWnd.State        = ResultState.Pass;
                        if (MemorizeDataMgr.Instance.CurrentChanllengeMode == ChanllengeMode.VsPC)
                        {
                            if (this.memorizeItemGrid.UserCorrectCount < this.memorizeItemGrid.BotCorrectCount)
                            {
                                resultWnd.State = ResultState.NotPass;
                            }
                        }
                        else if (MemorizeDataMgr.Instance.CurrentChanllengeMode == ChanllengeMode.TwoPlayer)
                        {
                            StringBuilder message = new StringBuilder();
                            message.AppendLine(string.Format("{0}翻开了{1}组牌, {2}翻开了{3}组牌.", MemorizeDataMgr.Instance.PlayerAName,
                                                             this.memorizeItemGrid.PlayerACorrectCount,
                                                             MemorizeDataMgr.Instance.PlayerBName,
                                                             this.memorizeItemGrid.PlayerBCorrectCount));
                            if (this.memorizeItemGrid.PlayerACorrectCount > this.memorizeItemGrid.PlayerBCorrectCount)
                            {
                                message.AppendLine(string.Format("{0}战胜了{1}.", MemorizeDataMgr.Instance.PlayerAName,
                                                                 MemorizeDataMgr.Instance.PlayerBName));
                            }
                            else if (this.memorizeItemGrid.PlayerACorrectCount == this.memorizeItemGrid.PlayerBCorrectCount)
                            {
                                message.AppendLine(string.Format("{0}与{1}战成了平手.", MemorizeDataMgr.Instance.PlayerAName,
                                                                 MemorizeDataMgr.Instance.PlayerBName));
                            }
                            else
                            {
                                message.AppendLine(string.Format("{0}战胜了{1}.", MemorizeDataMgr.Instance.PlayerBName, MemorizeDataMgr.Instance.PlayerAName));
                            }
                            resultWnd.Message = message.ToString();
                        }
                        resultWnd.ShowMessage((ok) =>
                        {
                            if (ok)
                            {
                                MemorizeDataMgr.Instance.MoveToNextStage();
                            }
                            this.startStage();
                        });
                    }
                }),
                                            DispatcherPriority.Normal,
                                            null);
            };

            //   this.backgroundImage.BeginAnimation(Image.OpacityProperty, doubleAnimation);
        }
Exemplo n.º 4
0
        private void CreatePuzzle()
        {
            this.puzzleHostingPanel.Children.Clear();

            this.puzzleGrid            = new PuzzleGrid();
            this.puzzleGrid.PuzzleWon += delegate(object sender, EventArgs e)
            {
                this.getAnswerBtn.IsEnabled        = false;
                this.nextStepBtn.IsEnabled         = false;
                this.showNumbersCheckBox.IsEnabled = false;

                this.Dispatcher.BeginInvoke(new ThreadStart(() =>
                {
                    ResultWindow win = new ResultWindow();
                    win.State        = ResultState.Pass;
                    win.ShowMessage(MessageWindowCallback);
                }),
                                            DispatcherPriority.ApplicationIdle,
                                            null);
            };

            if (puzzleStream != null)
            {
                puzzleStream.Dispose();
                puzzleStream = null;
            }

            byte[] imageData = PuzzleData.LoadImageData(this.puzzleItem.ImageFile);

            if (this.puzzleStream != null)
            {
                this.puzzleStream.Dispose();
                this.puzzleStream = null;
            }

            this.puzzleStream = new System.IO.MemoryStream(imageData);

            BitmapImage bi = new BitmapImage();

            bi.BeginInit();
            bi.StreamSource = this.puzzleStream;
            bi.EndInit();

            Image image = new Image();

            image.Source = bi;

            image.Width  = puzzleSize.Width;
            image.Height = puzzleSize.Height;

            this.elementToChopUp = image;

            this.puzzleGrid.MoveMade += new EventHandler <HandledEventArgs>(OnMoveMade);

            this.puzzleGrid.IsApplyingStyle = true;
            this.puzzleGrid.NumRows         = PuzzleSetting.Instance.Rows;
            this.puzzleGrid.NumCols         = PuzzleSetting.Instance.Cols;

            this.puzzleGrid.ElementToChopUp = elementToChopUp;
            this.puzzleGrid.PuzzleSize      = puzzleSize;

            this.puzzleGrid.ShowNumbers(this.showNumbersCheckBox.IsChecked.Value);

            this.puzzleGrid.ShouldAnimateInteractions = true;

            this.showNumbersCheckBox.IsEnabled = true;

            puzzleHostingPanel.Children.Add(this.puzzleGrid);
        }