Exemplo n.º 1
0
        private void SaveColor_Click(object _, RoutedEventArgs _1)
        {
            var color = ColorPicker.GetColor();

            var currentColors = SavedColors.Colors.ToBuilder();

            currentColors[_saveColorIndex] = color;

            SavedColors.Colors = currentColors.ToImmutable();

            ThreadHelper.JoinableTaskFactory.Run(() => SavedColorsManager.SaveColorAsync(color, _saveColorIndex));

            if (++_saveColorIndex >= SavedColors.Colors.Length)
            {
                _saveColorIndex = 0;
            }
        }
        public ColorPickerWindow(
            Color foregroundColor,
            Color backgroundColor,
            bool useExtraContrastSuggestions,
            FontFamily sampleFontFamily,
            double sampleFontSize,
            bool editBackground = false)
        {
            InitializeComponent();

            ColorPicker.ForegroundColor      = foregroundColor;
            ColorPicker.BackgroundColor      = backgroundColor;
            ColorPicker.EditBackgroundColor  = editBackground;
            ColorPicker.SampleTextFontFamily = sampleFontFamily;
            ColorPicker.SampleTextFontSize   = sampleFontSize;

            SavedColors.Colors = ThreadHelper.JoinableTaskFactory.Run(() => SavedColorsManager.GetColorsAsync());

            // Focus the first tab item when the window loads
            Loaded += (s, e) => MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
        }