예제 #1
0
        private void RotationTimer_Tick(object sender, EventArgs e)
        {
            var increasingAngle = MathHelper.Map(-wheelRotationAngle, 0, targetRotationAngle, 0, 5);

            wheelRotationAngle -= (5 - increasingAngle);

            nonFlickerPanel.Refresh();

            var index = (int)(-wheelRotationAngle / step);

            if (index >= StudentsReadyInClass.Count)
            {
                //index = 0; bunu yorum yapıp aşağıyı ekledim..
                index = index % StudentsReadyInClass.Count;
            }
            //index = index - StudentsReadyInClass.Count; // bu satır orijinal de yorumdu. index = 0 yanlış çalışıyordu. Ben modu ekledim. Bu da mod ile aynı çalışıyor..

            OnStudentSelected?.Invoke(this, new StudentSelectedEventArgs()
            {
                Student = StudentsReadyInClass[index]
            });

            if (wheelRotationAngle.ToInt() <= -targetRotationAngle.ToInt() ||
                (int)wheelRotationAngle <= (int)-targetRotationAngle)
            {
                rotationTimer.Stop();

                OnStudentSelected?.Invoke(this, new StudentSelectedEventArgs()
                {
                    Student = StudentsReadyInClass[selectedIndex]
                });



                Application.DoEvents();

                System.Threading.Thread.Sleep(AnimationEndWaitDuration);

                BtnRoundSpin.Enabled = true;

                // çark dönmeyi tamamlayınca seçilen öğrencinin ismini kurada çıkanlar listesine yazar..
                var ListBoxItem = this.StudentsReadyInClass[selectedIndex].FirstName + " " + this.StudentsReadyInClass[selectedIndex].LastName;
                var parent      = this.Parent as FormMain;
                parent.AddItemToListBoxSelectedStudents(ListBoxItem); // Ana formdaki methoda LİstBox ı gönderip yazdıracağız.


                //if (!StudentReelectionInSession)
                //{
                //    StudentsReadyInClass.RemoveAt(selectedIndex);
                //}

                Application.DoEvents();

                wheelRotationAngle = 0; // hep aynı yereden başlar

                nonFlickerPanel.Invalidate();
            }
        }
예제 #2
0
        private void RotationTimer_Tick(object sender, EventArgs e)
        {
            var increasingAngle = MathHelper.Map(-wheelRotationAngle, 0, targetRotationAngle, 0, 5);

            wheelRotationAngle -= (5 - increasingAngle);

            nonFlickerPanel.Refresh();

            var index = (int)(-wheelRotationAngle / step);

            if (index >= Students.Count)
            {
                index = index - Students.Count;
            }

            OnStudentSelected?.Invoke(this, new StudentSelectedEventArgs()
            {
                Student = Students[index]
            });

            if (wheelRotationAngle.ToInt() <= -targetRotationAngle.ToInt() ||
                (int)wheelRotationAngle <= (int)-targetRotationAngle)
            {
                rotationTimer.Stop();

                OnStudentSelected?.Invoke(this, new StudentSelectedEventArgs()
                {
                    Student = Students[selectedIndex]
                });

                Application.DoEvents();

                System.Threading.Thread.Sleep(AnimationEndWaitDuration);

                buttonSpinWheel.Enabled = true;
                Application.DoEvents();

                wheelRotationAngle = 0;
                nonFlickerPanel.Invalidate();
            }
        }