예제 #1
0
        public void VerifySimpleCollectionScenario()
        {
            var objects = new Dictionary <string, WeakReference>();

            RunOnUIThread.Execute(() =>
            {
                var rating        = new RatingControl();
                objects["Rating"] = new WeakReference(rating);

                var colorPicker        = new ColorPicker();
                objects["ColorPicker"] = new WeakReference(colorPicker);

                var navigationView        = new NavigationView();
                objects["NavigationView"] = new WeakReference(navigationView);

                var parallaxView        = new ParallaxView();
                objects["ParallaxView"] = new WeakReference(parallaxView);

                var scrollPresenter        = new ScrollPresenter();
                objects["ScrollPresenter"] = new WeakReference(scrollPresenter);

                if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
                {
                    var scrollView        = new ScrollView();
                    objects["ScrollView"] = new WeakReference(scrollView);
                }
            });
            IdleSynchronizer.Wait();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            RunOnUIThread.Execute(() => CheckLeaks(objects));
        }
        public EventCycleTest(bool addToTree = true)
        {
            _rating = new RatingControl();
            _rating.ValueChanged += OnRatingValueChanged;
            if (addToTree)
            {
                Children.Add(_rating);
            }

            _colorPicker = new ColorPicker();
            _colorPicker.ColorChanged += OnColorPickerColorChanged;
            if (addToTree)
            {
                Children.Add(_colorPicker);
            }

            _navigationView = new NavigationView();
            _navigationView.SelectionChanged += OnNavigationViewSelectionChanged;
            if (addToTree)
            {
                Children.Add(_navigationView);
            }

            var item = new NavigationViewItem();

            _navigationView.MenuItems.Add(item);

            _scroller              = new Scroller();
            _scroller.ViewChanged += OnScrollerViewChanged;
            if (addToTree)
            {
                Children.Add(_scroller);
            }
        }
        private void TintColorButton_Checked(object sender, RoutedEventArgs e)
        {
            var colorPicker = new ColorPicker();

            colorPicker.ColorChanged += ColorPicker_ColorChanged;
            colorPicker.Color         = _acrylicBrush.TintColor;
            Viewbox.Child             = colorPicker;
        }
        private void ColorPicker_ColorChanged(ColorPicker sender, ColorChangedEventArgs args)
        {
            var colorItem = ColorList.SelectedItem as ColorItem;

            if (colorItem != null)
            {
                colorItem.ColorBrush.Color = args.NewColor;
            }
        }
예제 #5
0
        private void TintColorButton_Checked(object sender, RoutedEventArgs e)
        {
#if !BUILD_LEAN_MUX_FOR_THE_STORE_APP
            var colorPicker = new ColorPicker();
            colorPicker.ColorChanged += ColorPicker_ColorChanged;
            colorPicker.Color         = _acrylicBrush.TintColor;
            Viewbox.Child             = colorPicker;
#endif
        }
        private void ColorPicker_ColorChanged(Microsoft.UI.Xaml.Controls.ColorPicker sender, Microsoft.UI.Xaml.Controls.ColorChangedEventArgs args)
        {
            // In this case it is easier to deal with an event than the loopbacks that the ColorPicker creates with a two way binding
            var paletteEntry = ColorPaletteEntry;

            if (paletteEntry != null)
            {
                paletteEntry.ActiveColor = args.NewColor;
            }
        }
        private void ColorPicker_ColorChanged(Microsoft.UI.Xaml.Controls.ColorPicker sender, Microsoft.UI.Xaml.Controls.ColorChangedEventArgs args)
        {
            LightThemeIcon.Foreground = new SolidColorBrush(args.NewColor);
            DarkThemeIcon.Foreground  = new SolidColorBrush(args.NewColor);

            if (icon == null)
            {
                return;
            }
            CustomIconCode.Code = SampleTemplateProvider.GetXAMLCustomizedFontIconCode(icon.StringGlyph
                                                                                       , args.NewColor.ToString()
                                                                                       , ((int)CustomIconFontSize.Value).ToString());
        }
        public void VerifyVisualTree()
        {
            ColorPicker colorPicker = null;

            RunOnUIThread.Execute(() =>
            {
                colorPicker = new ColorPicker {
                    IsAlphaEnabled = true, Width = 300, Height = 600
                };
            });
            TestUtilities.SetAsVisualTreeRoot(colorPicker);

            VisualTreeTestHelper.VerifyVisualTree(root: colorPicker, masterFilePrefix: "ColorPicker");
        }
예제 #9
0
        private void ColorPicker_ColorChanged(ColorPicker sender, ColorChangedEventArgs args)
        {
            this.ColorFromEventRectangle.Fill = new SolidColorBrush(args.NewColor);

            this.RedTextBlock.Text   = args.NewColor.R.ToString();
            this.GreenTextBlock.Text = args.NewColor.G.ToString();
            this.BlueTextBlock.Text  = args.NewColor.B.ToString();
            this.AlphaTextBlock.Text = args.NewColor.A.ToString();

            this.OldRedTextBlock.Text   = args.OldColor.R.ToString();
            this.OldGreenTextBlock.Text = args.OldColor.G.ToString();
            this.OldBlueTextBlock.Text  = args.OldColor.B.ToString();
            this.OldAlphaTextBlock.Text = args.OldColor.A.ToString();
        }
        public void ColorPickerEventsTest()
        {
            RunOnUIThread.Execute(() =>
            {
                ColorPicker colorPicker = new ColorPicker();

                colorPicker.ColorChanged += (ColorPicker sender, ColorChangedEventArgs args) =>
                {
                    Verify.AreEqual(args.OldColor, Colors.White);
                    Verify.AreEqual(args.NewColor, Colors.Green);
                };

                colorPicker.Color = Colors.Green;
            });
        }
        public void ValidateHueRange()
        {
            RunOnUIThread.Execute(() =>
            {
                var colorPicker = new ColorPicker();
                try
                {
                    colorPicker.MinHue = -1;
                    Verify.Fail("Invalid argument exception wasn't raised.");
                }
                catch (Exception e)
                {
                    Verify.IsTrue(e.Message.Contains("MinHue must be between 0 and 359."));
                }
            });

            IdleSynchronizer.Wait();
        }
        public void VerifyClearingAlphaChannelInputFieldDoesNotCrash()
        {
            ColorPicker colorPicker = null;

            RunOnUIThread.Execute(() =>
            {
                colorPicker = new ColorPicker();
                colorPicker.IsAlphaEnabled = true;

                Content = colorPicker;
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                var alphaChannelTextBox = VisualTreeUtils.FindVisualChildByName(colorPicker, "AlphaTextBox") as TextBox;

                Verify.IsGreaterThan(alphaChannelTextBox.Text.Length, 0, "Alpha channel TextBox should have not been empty.");

                // Clearing the alpha channel input field should not crash the app.
                alphaChannelTextBox.Text = "";
            });
        }
예제 #13
0
 private void OnColorPickerColorChanged(ColorPicker sender, ColorChangedEventArgs args)
 {
 }
 private void ColorPicker_ColorChanged(Microsoft.UI.Xaml.Controls.ColorPicker sender, Microsoft.UI.Xaml.Controls.ColorChangedEventArgs args)
 {
     SelectedColor = args.NewColor;
 }
예제 #15
0
 private void ColorPicker_ColorChanged(ColorPicker sender, ColorChangedEventArgs args)
 {
     ((SolidColorBrush)Application.Current.Resources["CustomReaderBackground"]).Color = args.NewColor;
 }
        public void ColorPickerTest()
        {
            RunOnUIThread.Execute(() =>
            {
                ColorPicker colorPicker = new ColorPicker();
                Verify.IsNotNull(colorPicker);

                Verify.AreEqual(Colors.White, colorPicker.Color);
                Verify.IsNull(colorPicker.PreviousColor);
                Verify.IsFalse(colorPicker.IsAlphaEnabled);
                Verify.IsTrue(colorPicker.IsColorSpectrumVisible);
                Verify.IsTrue(colorPicker.IsColorPreviewVisible);
                Verify.IsTrue(colorPicker.IsColorSliderVisible);
                Verify.IsTrue(colorPicker.IsAlphaSliderVisible);
                Verify.IsFalse(colorPicker.IsMoreButtonVisible);
                Verify.IsTrue(colorPicker.IsColorChannelTextInputVisible);
                Verify.IsTrue(colorPicker.IsAlphaTextInputVisible);
                Verify.IsTrue(colorPicker.IsHexInputVisible);
                Verify.AreEqual(0, colorPicker.MinHue);
                Verify.AreEqual(359, colorPicker.MaxHue);
                Verify.AreEqual(0, colorPicker.MinSaturation);
                Verify.AreEqual(100, colorPicker.MaxSaturation);
                Verify.AreEqual(0, colorPicker.MinValue);
                Verify.AreEqual(100, colorPicker.MaxValue);
                Verify.AreEqual(ColorSpectrumShape.Box, colorPicker.ColorSpectrumShape);
                Verify.AreEqual(ColorSpectrumComponents.HueSaturation, colorPicker.ColorSpectrumComponents);

                // Clamping the min and max properties changes the color value,
                // so let's test this new value before we change those.
                colorPicker.Color = Colors.Green;
                Verify.AreEqual(Colors.Green, colorPicker.Color);

                colorPicker.PreviousColor                  = Colors.Red;
                colorPicker.IsAlphaEnabled                 = true;
                colorPicker.IsColorSpectrumVisible         = false;
                colorPicker.IsColorPreviewVisible          = false;
                colorPicker.IsColorSliderVisible           = false;
                colorPicker.IsAlphaSliderVisible           = false;
                colorPicker.IsMoreButtonVisible            = true;
                colorPicker.IsColorChannelTextInputVisible = false;
                colorPicker.IsAlphaTextInputVisible        = false;
                colorPicker.IsHexInputVisible              = false;
                colorPicker.MinHue                  = 10;
                colorPicker.MaxHue                  = 300;
                colorPicker.MinSaturation           = 10;
                colorPicker.MaxSaturation           = 90;
                colorPicker.MinValue                = 10;
                colorPicker.MaxValue                = 90;
                colorPicker.ColorSpectrumShape      = ColorSpectrumShape.Ring;
                colorPicker.ColorSpectrumComponents = ColorSpectrumComponents.HueValue;

                Verify.AreNotEqual(Colors.Green, colorPicker.Color);
                Verify.AreEqual(Colors.Red, colorPicker.PreviousColor);
                Verify.IsTrue(colorPicker.IsAlphaEnabled);
                Verify.IsFalse(colorPicker.IsColorSpectrumVisible);
                Verify.IsFalse(colorPicker.IsColorPreviewVisible);
                Verify.IsFalse(colorPicker.IsColorSliderVisible);
                Verify.IsFalse(colorPicker.IsAlphaSliderVisible);
                Verify.IsTrue(colorPicker.IsMoreButtonVisible);
                Verify.IsFalse(colorPicker.IsColorChannelTextInputVisible);
                Verify.IsFalse(colorPicker.IsAlphaTextInputVisible);
                Verify.IsFalse(colorPicker.IsHexInputVisible);
                Verify.AreEqual(10, colorPicker.MinHue);
                Verify.AreEqual(300, colorPicker.MaxHue);
                Verify.AreEqual(10, colorPicker.MinSaturation);
                Verify.AreEqual(90, colorPicker.MaxSaturation);
                Verify.AreEqual(10, colorPicker.MinValue);
                Verify.AreEqual(90, colorPicker.MaxValue);
                Verify.AreEqual(ColorSpectrumShape.Ring, colorPicker.ColorSpectrumShape);
                Verify.AreEqual(ColorSpectrumComponents.HueValue, colorPicker.ColorSpectrumComponents);
            });
        }
예제 #17
0
 private void ColorPicker_ColorChanged(ColorPicker sender, ColorChangedEventArgs args)
 {
     _acrylicBrush.TintColor = args.NewColor;
 }