Xaml.vb渐变颜色代码

时间:2018-06-26 13:38:26

标签: vb.net xaml gradient

公共类BotaoEmergencia

Private pressedcolorvermelho As SolidColorBrush = "#d73f3e".ToBrush()
Private pressedfundoamarelo As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("#FFF500"), SolidColorBrush)
Private pressedDisabledColor As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("#DA251D"), SolidColorBrush)
Private pressedcontornolinhas As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("#da251d"), SolidColorBrush)


Public Shared ReadOnly IsPressedProperty As DependencyProperty = DependencyProperty.Register("IsPressed", GetType(Boolean), GetType(BotaoEmergencia), New PropertyMetadata(False, AddressOf OnIsPressedChanged))
Public Property IsPressed() As Boolean
    Get
        Return DirectCast(GetValue(IsPressedProperty), Boolean)
    End Get
    Set(value As Boolean)
        SetValue(IsPressedProperty, value)
    End Set
End Property

Public Shared Sub OnIsPressedChanged(source As DependencyObject, e As DependencyPropertyChangedEventArgs)
    Dim botao As BotaoEmergencia = TryCast(source, BotaoEmergencia)

    botao.ActualizarDesenho()
End Sub

Private Sub UserControl_IsEnabledChanged(sender As Object, e As DependencyPropertyChangedEventArgs) Handles Me.IsEnabledChanged
    ActualizarDesenho()
End Sub

Protected Sub ActualizarDesenho()
    If IsEnabled Then
        If IsPressed Then
            Canvas.SetTop(elpCamadaVermelha1, 9.45)
            Canvas.SetLeft(elpCamadaVermelha1, -20)
            Canvas.SetTop(elpCamadaVermelha2, -122)
            Canvas.SetLeft(elpCamadaVermelha2, -61)
            Canvas.SetTop(elpContornoBotao, 16.8)
            Canvas.SetLeft(elpContornoBotao, 78)
            elpContornoBotao.Width = 52
            elpContornoBotao.Height = 52
            elpContornoBotao.Stroke = If(IsEnabled, pressedcontornolinhas, pressedcontornolinhas)
            elpCamadaVermelha1.Fill = If(IsEnabled, pressedcolorvermelho, pressedcolorvermelho)
            elpCamadaVermelha2.Stroke = If(IsEnabled, pressedcontornolinhas, pressedcontornolinhas)
            elpCamadaVermelha2.StrokeThickness = 0.8
            elpFundoAmarelo.Fill = If(IsEnabled, pressedfundoamarelo, pressedfundoamarelo)

大家好,我正在为正在运行的软件制作一些按钮,我需要提供一些3D视觉,这就是为什么我要使用渐变的原因。 这是我的solidcolorbrush代码,我想制作一些Gradientcolorbrush,但我不知道如何从这里制作出来...

你们能帮忙吗?

1 个答案:

答案 0 :(得分:0)

反正还是->->->

Private normalgradientbigcircle As LinearGradientBrush = New LinearGradientBrush(Color.FromRgb(219, 142, 141), Color.FromRgb(212, 7, 7), New Point(0.5, 0), New Point(0.5, 1))