コード例 #1
0
        private void minuteHand_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.clockHandState == ClockHandState.HourHandSelected)
            {
                return;
            }

            if (this.clockHandState == ClockHandState.MinuteHandSelected)
            {
                this.minuteHandBlinkStoryboard.Stop();
                this.clockHandState = ClockHandState.NotSelected;
            }
            else
            {
                this.minuteHandBlinkStoryboard.Begin();
                this.clockHandState = ClockHandState.MinuteHandSelected;
            }
        }
コード例 #2
0
        private void clockHandDispatcherTimer_Tick(object sender, EventArgs e)
        {
            if (this.clockHandState == ClockHandState.HourHandSelected)
            {
                if (this.isClockwise)
                {
                    this.hourHandRotation.Rotation = (this.hourHandRotation.Rotation + 30) % 720;
                }
                else
                {
                    this.hourHandRotation.Rotation = (this.hourHandRotation.Rotation + 690) % 720;
                }
                this.angleToGo -= 30;
            }
            else if (this.clockHandState == ClockHandState.MinuteHandSelected)
            {
                if (this.isClockwise)
                {
                    this.minuteHandRotation.Rotation = (this.minuteHandRotation.Rotation + 6) % 360;
                    this.hourHandRotation.Rotation   = (this.hourHandRotation.Rotation + 0.5) % 720;
                }
                else
                {
                    this.minuteHandRotation.Rotation = (this.minuteHandRotation.Rotation + 354) % 360;
                    this.hourHandRotation.Rotation   = (this.hourHandRotation.Rotation + 719.5) % 720;
                }
                this.angleToGo -= 6;
            }

            if (this.angleToGo <= 0)
            {
                int hours   = (int)((this.hourHandRotation.Rotation + 90) % 720) / 30;
                int minutes = (int)Math.Round(((this.minuteHandRotation.Rotation + 90) % 360) / 6);
                this.timePicker.Value = new DateTime(1, 1, 1, hours, minutes, 0);

                this.minuteHandBlinkStoryboard.Stop();
                this.hourHandBlinkStoryboard.Stop();
                this.clockHandDispatcherTimer.Stop();
                this.clockHandState = ClockHandState.NotSelected;
            }
        }
コード例 #3
0
        private void hourHand_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.clockHandState == ClockHandState.MinuteHandSelected)
            {
                return;
            }

            // Do not try to merge the code below as
            // "this.isHourHandSelected = !this.isHourHandSelected",
            // becuse the quoted code could theoretically cause a race condition.
            if (this.clockHandState == ClockHandState.HourHandSelected)
            {
                this.hourHandBlinkStoryboard.Stop();
                this.clockHandState = ClockHandState.NotSelected;
            }
            else if (this.clockHandState == ClockHandState.NotSelected)
            {
                this.hourHandBlinkStoryboard.Begin();
                this.clockHandState = ClockHandState.HourHandSelected;
            }
        }