Beispiel #1
0
        public void UpdatePosition()
        {
            var textInputLayer = GetWindowTextInputLayer();

            if (_contentElement == null || _currentInputWidget == null || textInputLayer == null)
            {
                return;
            }

            var transformToRoot = _contentElement.TransformToVisual(Windows.UI.Xaml.Window.Current.Content);
            var point           = transformToRoot.TransformPoint(new Point(0, 0));

            if (textInputLayer.Children.Contains(_currentInputWidget))
            {
                WpfCanvas.SetLeft(_currentInputWidget, point.X);
                WpfCanvas.SetTop(_currentInputWidget, point.Y);
            }
        }
Beispiel #2
0
        public WpfSpinButton()
        {
            var width  = 25;
            var height = 25;

            Background = new SolidColorBrush(Colors.Transparent);
            Storyboard = new Storyboard {
                RepeatBehavior = RepeatBehavior.Forever, Duration = TimeSpan.FromMilliseconds(Duration)
            };

            for (int i = 0; i < 360; i += 30)
            {
                // Create the rectangle and centre it in our widget
                var rect = new WpfRectangle {
                    Width = 2, Height = 8, Fill = new SolidColorBrush(Colors.Black), RadiusX = 1, RadiusY = 1, Opacity = Values[0]
                };
                WpfCanvas.SetTop(rect, (height - rect.Height) / 2);
                WpfCanvas.SetLeft(rect, (width - rect.Width) / 2);

                // Rotate the element by 'i' degrees, creating a circle out of all the elements
                var group = new TransformGroup();
                group.Children.Add(new RotateTransform(i, 0.5, -6));
                group.Children.Add(new TranslateTransform(0, 10));
                rect.RenderTransform = group;

                // Set the animation
                var timeline = new DoubleAnimationUsingKeyFrames();
                Storyboard.SetTarget(timeline, rect);
                Storyboard.SetTargetProperty(timeline, new PropertyPath("Opacity"));

                var offset = Duration * (i / 360.0);
                for (int j = 0; j < StartTimes.Length; j++)
                {
                    var start = (StartTimes[j] + offset) % Duration;
                    timeline.KeyFrames.Add(new EasingDoubleKeyFrame {
                        KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(start)), Value = Values[j]
                    });
                }
                Storyboard.Children.Add(timeline);
                Children.Add(rect);
            }
        }