コード例 #1
0
ファイル: Form1.cs プロジェクト: SunRiver-NEU/DST
        private void PicturePrint(object sender, EventArgs e)
        {
            if (MainPicture.Tag == null || (bool)MainPicture.Tag == false)
            {
                return;
            }

            if (TEXT.Count >= 0) //与Print的相差一位
            {
                //画在picture上
                int        x = MainPicture.Location.X;
                int        y = MainPicture.Location.Y;
                int        h = MainPicture.Height;
                int        w = MainPicture.Width;
                Graphics   g = Graphics.FromImage(MainPicture.Image);
                SolidBrush mybrush;
                mybrush = new SolidBrush(Color.Lime); //设置默认画刷颜色
                Font myfont;
                myfont = new Font("黑体", 14);          //设置默认字体格式
                g.DrawString(TB_Dialogue.Text, myfont, mybrush, new Rectangle(x, y, h, w));
                MainPicture.Refresh();                //刷新图片

                if (TEXT.Count == 0)                  //最后
                {
                    timer_Dialogue.Tick -= PicturePrint;
                    MainPicture.Tag      = false;
                    if (ENTERFN != null)
                    {
                        ENTERFN(WHO);
                    }
                }
            }
        }
コード例 #2
0
        public void GetNextCard()
        {
            try
            {
                //Stop hint timer
                #region [ Spelling Mode ]
                if (Controller.Mode == FlashCardMode.Spelling)
                {
                    hintTimer.Enabled = false;
                    Debug.WriteLine("Timer Suspended");
                }
                #endregion

                Controller.Busy = true;
                SelectedCard    = Controller.GetNextCard();
                if (SelectedCard != null)
                {
                    CodeProfiler.Start("GetNextCard-LoadCard");
                    lbCardCounter.Text = Controller.Cards.IndexOf(SelectedCard).ToString() +
                                         " / " + Controller.Cards.Count.ToString();

                    MainPicture.Image = SelectedCard.Image;

                    //In Spelling mode, spell each characters
                    #region [ Spelling Mode Only ]
                    if (Controller.Mode == FlashCardMode.Spelling)
                    {
                        CardLabel.Text = String.Empty;
                        Cursor         = Cursors.WaitCursor;
                        if (SelectedCard.Audio != null)
                        {
                            SelectedCard.Audio.PlaySync();
                        }
                        else
                        {
                            Synth.Speak(SelectedCard.Text);
                        }

                        foreach (char ptrChar in SelectedCard.Text)
                        {
                            Controller.PlayCharSoundSync(ptrChar);
                        }
                        hintTimer.Interval = Controller.SpellingModeHintIntervalInitial;
                        Cursor             = Cursors.Default;
                    }
                    #endregion

                    if (Controller.CaseSensitive)
                    {
                        CardLabel.Text = SelectedCard.Text;
                        ExpectedText   = CardLabel.Text;
                        CurrentIndex   = 0;
                    }
                    else
                    {
                        CardLabel.Text = SelectedCard.Text.ToUpper();
                        ExpectedText   = CardLabel.Text;
                        CurrentIndex   = 0;
                    }

                    //Create puzzle hint
                    #region [ Puzzle Mode Only ]
                    if (Controller.Mode == FlashCardMode.Puzzle)
                    {
                        PuzzleHint.Text = CardLabel.Text;
                        PuzzleHint.Shuffle();
                        for (int x = 0; x < PuzzleHint.Text.Length; x++)
                        {
                            PuzzleHint.HighlightChar(x);
                        }
                    }
                    #endregion

                    MainPicture.Refresh();
                    CardLabel.Refresh();
                    CodeProfiler.Stop("GetNextCard-LoadCard");

                    //Read selected card
                    if (SelectedCard.Audio != null)
                    {
                        SelectedCard.Audio.PlaySync();
                    }
                    else
                    {
                        Synth.Speak(SelectedCard.Text);
                    }

                    //Start hint timer
                    #region [ Spelling Mode Only ]
                    if (Controller.Mode == FlashCardMode.Spelling)
                    {
                        hintTimer.Enabled = Controller.SpellingModePlayHint;
                    }
                    Debug.WriteLine("Timer Enabled");
                    #endregion
                }
            }
            finally { Controller.Busy = false; }
        }