Beispiel #1
0
 // เมื่อแก้วถูกคลิก
 private void OnClickAnswer(object sender, CupAnswerEventArgs objName)
 {
     _lastClickedCup = (CupUI)sender;
     var temp = ClickAnswer;
     if (temp != null)
     {
         temp(sender, objName);
     }
     _lastClickedCup.Sb_Correct.Completed -= new EventHandler(Sb_Correct_Completed);
     _lastClickedCup.Sb_Correct.Completed += new EventHandler(Sb_Correct_Completed);
 }
Beispiel #2
0
        /// <summary>
        /// กำหนดคำถาม
        /// </summary>
        /// <param name="question">คำถาม</param>
        /// <param name="cupStyleName">ชนิดรูปทรงของแก้ว</param>
        /// <param name="cupLevel">ชนิดระดับความยากของแก้ว</param>
        public void SetQuestionRow(QuestionRow question, string cupStyleName, string cupLevel)
        {
            if (_lastClickedCup != null) _lastClickedCup.StopCupIncorrect();

            _lastClickedCup = null;
            _cupStyleName = cupStyleName;
            _cupLevel = cupLevel;
            _question = question;

            Storyboard1.SpeedRatio = question.SwapSpeed;
            Storyboard2.SpeedRatio = question.SwapSpeed;

            // กำหนด state เริ่มต้นจากจำนวนแก้ว
            const int VeryEasy = 2;
            const int Easy = 3;
            const int Normal = 4;
            const int Hard = 5;
            switch (question.CupCount)
            {
                case VeryEasy: _cupRowState = "twoCup"; break;
                case Easy: _cupRowState = "threeCup"; break;
                case Normal: _cupRowState = "fourCup"; break;
                case Hard: _cupRowState = "fiveCup"; break;
                default: break;
            }

            // กำหนดการใช้งานของ state manager เพื่อกำหนดการแสดงผลของแก้วที่จะนำไปใช้งาน
            VisualStateManager.GoToState(this, _cupRowState, false);

            // เคลียแก้ว
            foreach (var canvas in _cupCanvases) (canvas.Children[ElementCupIndex] as CupUI).ResetState();

            // กำหนดลายแก้ว และวัตถุภายในแก้ว
            for (int canvasIndex = 0; canvasIndex < _cupCanvases.Count(); canvasIndex++)
            {
                if (canvasIndex < question.BeforeCup.Count)
                {
                    // กำหนดข้อมูลของแก้วที่นำไปแสดงผล
                    (_cupCanvases[canvasIndex].Children[ElementCupIndex] as CupUI)
                        .Initialize(_question.BeforeCup[canvasIndex], getCupStyleName());
                }
                else
                {
                    // กำหนดวัตถุที่ไม่ได้ถูกนำมาแสดงผลให้ไม่สามารถเปิดแก้วได้
                    (_cupCanvases[canvasIndex].Children[ElementCupIndex] as CupUI).HasOpened = true;
                }
            }

            // ทำการเปิดแสดงวัตถุที่อยู่ภายในแก้ว
            foreach (var canvas in _cupCanvases) (canvas.Children[ElementCupIndex] as CupUI).Sb_ShowItem.Begin();
        }