Пример #1
0
 public static SKColor ToSKColor(BaseColorViewModel colorViewModel)
 {
     return(colorViewModel switch
     {
         ArgbColorViewModel argbColor => new SKColor(argbColor.R, argbColor.G, argbColor.B, argbColor.A),
         _ => throw new NotSupportedException($"The {colorViewModel.GetType()} color type is not supported."),
     });
Пример #2
0
 private static DXF.AciColor ToColor(BaseColorViewModel colorViewModel)
 {
     return(colorViewModel switch
     {
         ArgbColorViewModel argbColor => new DXF.AciColor(argbColor.R, argbColor.G, argbColor.B),
         _ => throw new NotSupportedException($"The {colorViewModel.GetType()} color type is not supported."),
     });
Пример #3
0
        private void InitializeComponent()
        {
            _ = this.WhenActivated((CompositeDisposable disposable) => { });
            AvaloniaXamlLoader.Load(this);

            _passwordSection     = this.FindControl <StackPanel>("PasswordSection");
            _reminderSection     = this.FindControl <StackPanel>("ReminderSection");
            _bankCartSection     = this.FindControl <StackPanel>("BankCartSection");
            _personalDataSection = this.FindControl <StackPanel>("PersonalDataSection");
            _txtPassword         = this.FindControl <TextBox>("txtPassword");
            _pbHard       = this.FindControl <ProgressBar>("pbHard");
            _txtStartTime = this.FindControl <TextBox>("tbStartTime");
            _cbType       = this.FindControl <ComboBox>("cbType");
            _bColor       = this.FindControl <Border>("bColor");
            _pColorPicker = this.FindControl <Popup>("pColorPicker");
            _colorPicker  = this.FindControl <ColorPicker>("colorPicker");
            _tbColor      = this.FindControl <TextBox>("tbColor");

            _txtPassword.GetObservable(TextBox.TextProperty).Subscribe(value => PasswordUtils.DeterminingPasswordComplexity(_pbHard, value));
            _cbType.SelectionChanged += SectionChanged;

            _tbColor.Text = ((Color)Application.Current.FindResource("ThemeSelectedControlColor")).ToString();

            _argbColorViewModel = new ArgbColorViewModel
            {
                Hex = _tbColor.Text
            };

            _pColorPicker.DataContext = _argbColorViewModel;

            _bColor.Background = new SolidColorBrush(ColorHelpers.FromHexColor(_tbColor.Text));

            _colorPicker.ChangeColor += _colorPicker_ChangeColor;
        }
Пример #4
0
        public void Parse_String_Using_Predefined_Color_Names()
        {
            var target = ArgbColorViewModel.Parse("Magenta");

            Assert.Equal(0xFF, target.A);
            Assert.Equal(0xFF, target.R);
            Assert.Equal(0x00, target.G);
            Assert.Equal(0xFF, target.B);
        }
Пример #5
0
        public void Parse_String_Statring_With_Hash_And_No_Alpha_Channel()
        {
            var target = ArgbColorViewModel.Parse("#ABCDEF");

            Assert.Equal(0xFF, target.A);
            Assert.Equal(0xAB, target.R);
            Assert.Equal(0xCD, target.G);
            Assert.Equal(0xEF, target.B);
        }
Пример #6
0
        public void FromUInt32_Should_Convert_From_UInit32()
        {
            var target = ArgbColorViewModel.FromUInt32(0x07ABCDEF);

            Assert.Equal(0x07, target.A);
            Assert.Equal(0xAB, target.R);
            Assert.Equal(0xCD, target.G);
            Assert.Equal(0xEF, target.B);
        }
    public override object Copy(IDictionary <object, object>?shared)
    {
        var copy = new ArgbColorViewModel(ServiceProvider)
        {
            Value = Value
        };

        return(copy);
    }
Пример #8
0
        private void OpenColorPicker(object sender, RoutedEventArgs e)
        {
            if (SearchViewModel.SelectedFolderItem.FolderContext.UseColor)
            {
                _argbColorViewModel = new ArgbColorViewModel
                {
                    Hex = SearchViewModel.SelectedFolderItem.FolderContext.Color
                };

                pColorPicker.DataContext = _argbColorViewModel;

                pColorPicker.Open();
            }
        }
Пример #9
0
 public static string ToHexString(this ArgbColorViewModel color)
 {
     return($"#{color.ToUint32():X8}");
 }
Пример #10
0
 public static uint ToUint32(this ArgbColorViewModel color)
 {
     return(((uint)color.A << 24) | ((uint)color.R << 16) | ((uint)color.G << 8) | (uint)color.B);
 }
Пример #11
0
 public static AM.Color ToColor(ArgbColorViewModel argbColorViewModelViewModel)
 {
     return(AM.Color.FromArgb(argbColorViewModelViewModel.A, argbColorViewModelViewModel.R, argbColorViewModelViewModel.G, argbColorViewModelViewModel.B));
 }
Пример #12
0
        public void ToSvgHex_Should_Return_Color_String_Statring_With_Hash()
        {
            var target = _factory.CreateArgbColor(0xFF, 0x7F, 0x5A, 0x45);

            Assert.Equal("#7F5A45", ArgbColorViewModel.ToSvgHex(target)); // NOTE: 0xFF Alpha value is not used in Svg
        }
Пример #13
0
        public void ToXamlHex_Should_Return_Color_String_Statring_With_Hash()
        {
            var target = _factory.CreateArgbColor(0xFF, 0x7F, 0x5A, 0x45);

            Assert.Equal("#FF7F5A45", ArgbColorViewModel.ToXamlHex(target));
        }
 public static string ToString(ArgbColorViewModel value)
 {
     return($"#{value.Value:X8}");
 }