Exemplo n.º 1
0
        private async void ColorPickerButton_Click(object sender, RoutedEventArgs e)
        {
            var eyedropper = new Eyedropper();

            eyedropper.PickCompleted += Eyedropper_PickCompleted;
            var color = await eyedropper.Open();
        }
Exemplo n.º 2
0
        private async void ColorPicker_Click(Microsoft.UI.Xaml.Controls.SplitButton sender, Microsoft.UI.Xaml.Controls.SplitButtonClickEventArgs args)
        {
            var eyedropper = new Eyedropper();

            eyedropper.ColorChanged  += Eyedropper_ColorChanged;
            eyedropper.PickCompleted += Eyedropper_PickCompleted;
            var color = await eyedropper.Open();
        }
Exemplo n.º 3
0
 private void Load()
 {
     SampleController.Current.RegisterNewCommand("Global Eyedropper", async(sender, args) =>
     {
         var eyedropper = new Eyedropper();
         var color      = await eyedropper.Open();
         InAppNotification.Show($"You get {color}.", 3000);
     });
 }
Exemplo n.º 4
0
        private void Eyedropper_PickCompleted(Eyedropper sender, EventArgs args)
        {
            ColorPicker.BorderThickness = new Thickness(0, 0, 0, 2);
            ColorPicker.BorderBrush     = new SolidColorBrush(sender.Color);
            Colors.Add(new PowerColor()
            {
                Brush = new SolidColorBrush(sender.Color), Hex = ToHex(sender.Color), Hsl = ToHSL(sender.Color), Hsv = ToHSV(sender.Color), RGB = ToRGB(sender.Color)
            });

            Colors.Reverse();
        }
Exemplo n.º 5
0
        private void UpdateEyedropper()
        {
            var activateEyedropper = ckbEyedropper.Checked;

            if (activateEyedropper != _eyedropperActive)
            {
                _eyedropperActive = activateEyedropper;
                Capture           = _eyedropperActive;
            }

            if (_eyedropperActive)
            {
                var color = Eyedropper.GetPixelColor(Cursor.Position);
                UpdateBackgroundProperties(color);
            }
        }
        public async Task Eyedropper_DoesntCrash()
        {
            Eyedropper eyedropper = null;
            Color?     color      = null;

            _ = App.Dispatcher.EnqueueAsync(async() =>
            {
                eyedropper = new Eyedropper
                {
                    XamlRoot = App.XamlRoot
                };
                color = await eyedropper.Open();
            });

            await App.Dispatcher.EnqueueAsync(async() =>
            {
                var xamlRoot = App.XamlRoot;

                var pos = new Point(xamlRoot.Size.Width / 2, xamlRoot.Size.Height / 2);
                uint id = 1;

                await eyedropper.InternalPointerPressedAsync(id, pos, PointerDeviceType.Mouse);

                await Task.Delay(1000);

                for (int i = 0; i < 50; i++)
                {
                    await Task.Delay(100);
                    eyedropper.InternalPointerMoved(id, pos);
                    pos.X += 5;
                    pos.Y += 5;
                }

                await eyedropper.InternalPointerReleasedAsync(id, pos);

                await Task.Delay(1000);

                Assert.AreEqual(Colors.CornflowerBlue, color);
            });
        }
Exemplo n.º 7
0
 public MainWindow()
 {
     InitializeComponent();
     globalEyedropper = new Eyedropper();
     globalEyedropper.ColorChanged += (s, e) => { TargetSolidColorBrush.Color = e.NewColor; };
 }
Exemplo n.º 8
0
 private void Eyedropper_PickCompleted(Eyedropper sender, EventArgs args)
 {
     AddColor(sender.Color);
 }
Exemplo n.º 9
0
 private void Eyedropper_ColorChanged(Eyedropper sender, EyedropperColorChangedEventArgs args)
 {
 }