public ClockItemIsCheckedConverter(Func<DateTime> currentTimeGetter, ClockDisplayMode displayMode)
        {
            if (currentTimeGetter == null) throw new ArgumentNullException("currentTimeGetter");

            _currentTimeGetter = currentTimeGetter;
            _displayMode = displayMode;
        }
Example #2
0
        private void GenerateButtons(Panel canvas, ICollection <int> range, double radiusRatio, IValueConverter isCheckedConverter, Func <int, string> stylePropertySelector,
                                     string format, ClockDisplayMode clockDisplayMode)
        {
            var anglePerItem   = 360.0 / range.Count;
            var radiansPerItem = anglePerItem * (Math.PI / 180);

            //nothing fancy with sizing/measuring...we are demanding a height
            if (canvas.Width < 10.0 || Math.Abs(canvas.Height - canvas.Width) > 0.0)
            {
                return;
            }

            _centreCanvas = new Point(canvas.Width / 2, canvas.Height / 2);
            var hypotenuseRadius = _centreCanvas.X * radiusRatio;

            foreach (var i in range)
            {
                var button = new ClockItemButton();
                button.SetBinding(StyleProperty, GetBinding(stylePropertySelector(i)));

                var adjacent = Math.Cos(i * radiansPerItem) * hypotenuseRadius;
                var opposite = Math.Sin(i * radiansPerItem) * hypotenuseRadius;

                button.CentreX = _centreCanvas.X + opposite;
                button.CentreY = _centreCanvas.Y - adjacent;

                button.SetBinding(ToggleButton.IsCheckedProperty, GetBinding("Time", converter: isCheckedConverter, converterParameter: i));
                button.SetBinding(Canvas.LeftProperty, GetBinding("X", button));
                button.SetBinding(Canvas.TopProperty, GetBinding("Y", button));

                button.Content = (i == 60 ? 0 : (i == 24 && clockDisplayMode == ClockDisplayMode.Hours ? 0 : i)).ToString(format);
                canvas.Children.Add(button);
            }
        }
		public ClockItemIsCheckedConverter(Func<DateTime> currentTimeGetter, ClockDisplayMode displayMode, bool is24Hours)
		{
			if (currentTimeGetter == null) throw new ArgumentNullException(nameof(currentTimeGetter));

			_currentTimeGetter = currentTimeGetter;
			_displayMode = displayMode;
		    _is24Hours = is24Hours;
		}
Example #4
0
        private static void OnClockChoiceMade(DependencyObject d, ClockDisplayMode displayMode)
        {
            var instance = (Clock)d;
            var dragCompletedEventArgs = new ClockChoiceMadeEventArgs(displayMode)
            {
                RoutedEvent = ClockChoiceMadeEvent,
            };

            instance.RaiseEvent(dragCompletedEventArgs);
        }
Example #5
0
        public ClockItemIsCheckedConverter(Func <DateTime> currentTimeGetter, ClockDisplayMode displayMode)
        {
            if (currentTimeGetter == null)
            {
                throw new ArgumentNullException("currentTimeGetter");
            }

            _currentTimeGetter = currentTimeGetter;
            _displayMode       = displayMode;
        }
        public ClockItemIsCheckedConverter(Func <DateTime> currentTimeGetter, ClockDisplayMode displayMode, bool is24Hours)
        {
            if (currentTimeGetter == null)
            {
                throw new ArgumentNullException(nameof(currentTimeGetter));
            }

            _currentTimeGetter = currentTimeGetter;
            _displayMode       = displayMode;
            _is24Hours         = is24Hours;
        }
		private static void OnClockChoiceMade(DependencyObject d, ClockDisplayMode displayMode)
		{
			var instance = (Clock)d;
			var dragCompletedEventArgs = new ClockChoiceMadeEventArgs(displayMode)
			{
				RoutedEvent = ClockChoiceMadeEvent,				
			};

			instance.RaiseEvent(dragCompletedEventArgs);
		}      
 public ClockChoiceMadeEventArgs(ClockDisplayMode displayMode, RoutedEvent routedEvent, object source) : base(routedEvent, source)
 {
     _displayMode = displayMode;
 }
 public ClockChoiceMadeEventArgs(ClockDisplayMode displayMode, RoutedEvent routedEvent) : base(routedEvent)
 {
     _displayMode = displayMode;
 }
 public ClockChoiceMadeEventArgs(ClockDisplayMode displayMode)
 {
     _displayMode = displayMode;
 }
		public ClockChoiceMadeEventArgs(ClockDisplayMode displayMode, RoutedEvent routedEvent, object source) : base(routedEvent, source)
		{
			_displayMode = displayMode;
		}
		public ClockChoiceMadeEventArgs(ClockDisplayMode displayMode, RoutedEvent routedEvent) : base(routedEvent)
		{
			_displayMode = displayMode;
		}
		public ClockChoiceMadeEventArgs(ClockDisplayMode displayMode)
		{
			_displayMode = displayMode;
		}