Inheritance: Windows.UI.Xaml.Controls.UserControl
Example #1
0
        private void Draw()
        {
            _pieSlices.Clear();

            gridRotateTransform.CenterX = this.RenderSize.Width / 2;
            gridRotateTransform.CenterY = this.RenderSize.Height / 2;

            var startAngle = 0;
            var color      = BackgroundColor;

            if (Slices != null)
            {
                foreach (var slice in Slices)
                {
                    var sliceSize = 360 / Slices.Count();

                    var pieSlice = new PieSlice
                    {
                        StartAngle      = startAngle,
                        Angle           = sliceSize,
                        Radius          = Size / 2,
                        BackgroundColor = color,
                        Label           = slice,
                        ForegroundColor = ForegroundColor,
                        HideLabel       = HideLabels,
                    };

                    _pieSlices.Add(pieSlice);

                    startAngle += sliceSize;
                    color       = color.Lighten();
                }
            }
        }
Example #2
0
        private void layoutRoot_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
        {
            var angleFromYAxis = 360 - Angle;

            SelectedItem = _pieSlices
                           .SingleOrDefault(p => p.StartAngle <= angleFromYAxis && (p.StartAngle + p.Angle) > angleFromYAxis);

            var finalAngle = SelectedItem.StartAngle + SelectedItem.Angle / 2;

            doubleAnimation.From = Angle;
            doubleAnimation.To   = 360 - finalAngle;
            storyBoard.Begin();

            Angle = 360 - finalAngle;
        }
Example #3
0
        public RotaryWheel()
        {
            DataContext = this;
            InitializeComponent();

            Loaded += (sender, args) =>
            {
                Draw();
                SelectedItem = _pieSlices.FirstOrDefault();

                if (SelectedItem != null)
                {
                    Angle = 360 - SelectedItem.Angle / 2;
                }
            };

            _pieSlices.CollectionChanged += (sender, args) =>
            {
                switch (args.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    foreach (PieSlice item in args.NewItems)
                    {
                        layoutSpinner.Children.Add(item);
                    }
                    break;

                case NotifyCollectionChangedAction.Remove:
                    foreach (PieSlice item in args.OldItems)
                    {
                        layoutSpinner.Children.Remove(item);
                    }
                    break;

                case NotifyCollectionChangedAction.Reset:
                    layoutSpinner.Children.Clear();
                    break;
                }
            };
        }