⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultvb.aspx.vb

📁 Telerik是很大的第三方软件制造商
💻 VB
字号:

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Telerik.QuickStart
Imports Telerik.WebControls


Namespace Telerik.ChartExamplesVB.Configurator.Apperance.Gradients
    '/ <summary>
    '/ Summary description for _Default.
    '/ </summary>

    Public Class DefaultVB
        Inherits XhtmlPage
        Protected Label1 As System.Web.UI.WebControls.Label
        Protected WithEvents Button1 As System.Web.UI.WebControls.Button
        Protected Label2 As System.Web.UI.WebControls.Label
        Protected Label3 As System.Web.UI.WebControls.Label
        Protected ddlMainColor As System.Web.UI.WebControls.DropDownList
        Protected ddlSecondColor As System.Web.UI.WebControls.DropDownList
        Protected ddlGradientFillStyle As System.Web.UI.WebControls.DropDownList
        Protected Label6 As System.Web.UI.WebControls.Label
        Protected txtBoxGradientFocus As System.Web.UI.WebControls.TextBox
        Protected cbGammaCorrection As System.Web.UI.WebControls.CheckBox
        Protected Label4 As System.Web.UI.WebControls.Label
        Protected RangeValidator1 As System.Web.UI.WebControls.RangeValidator
        Protected Label5 As System.Web.UI.WebControls.Label
        Protected RadChart1 As Telerik.WebControls.RadChart
        Protected WithEvents ddlChartElement As System.Web.UI.WebControls.DropDownList

        Private chartElementsHash As System.Collections.Hashtable

        Private keyNames As String() = {"Background", "Plot area", "Title", "Legend", "Series 1", "Series 2", "Item 1", "Item 2"}


        Private Sub BuildHashTable()
            chartElementsHash = New System.Collections.Hashtable()
            chartElementsHash.Add(keyNames(0), RadChart1.Background)
            chartElementsHash.Add(keyNames(1), RadChart1.PlotArea)
            chartElementsHash.Add(keyNames(2), RadChart1.Title1.Background)
            chartElementsHash.Add(keyNames(3), RadChart1.Legend.Background)
            chartElementsHash.Add(keyNames(4), RadChart1.GetChartSeries(0).Appearance)
            chartElementsHash.Add(keyNames(5), RadChart1.GetChartSeries(1).Appearance)
            chartElementsHash.Add(keyNames(6), RadChart1.GetChartSeries(0).Items(0).Appearance)
            chartElementsHash.Add(keyNames(7), RadChart1.GetChartSeries(1).Items(0).Appearance)
        End Sub 'BuildHashTable


        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            BuildHashTable()

            If Not Page.IsPostBack Then
                InitControls()
                SetControlValues()
            End If
        End Sub 'Page_Load


        Private Sub InitControls()
            Dim valueNames() As String

            ' Init Colors
            valueNames = [Enum].GetNames(GetType(KnownColor))

            ddlMainColor.Items.Clear()
            ddlSecondColor.Items.Clear()

            Dim s As String
            For Each s In valueNames
                ddlMainColor.Items.Add(s)
                ddlSecondColor.Items.Add(s)
            Next s

            ' Init gradient fill styles:
            valueNames = [Enum].GetNames(GetType(GradientFillStyle))

            ddlGradientFillStyle.Items.Clear()

            For Each s In valueNames
                ddlGradientFillStyle.Items.Add(s)
            Next s

            ddlChartElement.Items.Clear()

            For Each s In keyNames
                ddlChartElement.Items.Add(s)
            Next s
        End Sub 'InitControls


        Private Sub SetControlValues()
            Dim appearance As ChartRectShape = GetCurrentAppearance()

            If Not (appearance Is Nothing) Then
                ddlMainColor.SelectedIndex = ddlMainColor.Items.IndexOf(ddlMainColor.Items.FindByText(appearance.MainColor.ToKnownColor().ToString()))
                ddlSecondColor.SelectedIndex = ddlSecondColor.Items.IndexOf(ddlSecondColor.Items.FindByText(appearance.SecondColor.ToKnownColor().ToString()))
                ddlGradientFillStyle.SelectedIndex = ddlGradientFillStyle.Items.IndexOf(ddlGradientFillStyle.Items.FindByText(appearance.GradientFillStyle.ToString()))
                cbGammaCorrection.Checked = appearance.GammaCorrection
                txtBoxGradientFocus.Text = appearance.GradientFocus.ToString()
            End If
        End Sub 'SetControlValues


        Private Function GetCurrentAppearance() As ChartRectShape
            Return CType(chartElementsHash(ddlChartElement.SelectedItem.Value), ChartRectShape)
        End Function 'GetCurrentAppearance


#Region "Web Form Designer generated code"

        Protected Overrides Sub OnInit(ByVal e As EventArgs)
            '
            ' CODEGEN: This call is required by the ASP.NET Web Form Designer.
            '
            InitializeComponent()
            MyBase.OnInit(e)
        End Sub 'OnInit


        '/		Required method for Designer support - do not modify
        '/		the contents of this method with the code editor.
        '/ </summary>
        Private Sub InitializeComponent()
        End Sub 'InitializeComponent

#End Region


        Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim elementAppearance As ChartRectShape = GetCurrentAppearance()

            If Not (elementAppearance Is Nothing) Then
                elementAppearance.MainColor = Color.FromName(ddlMainColor.SelectedItem.Value)
                elementAppearance.SecondColor = Color.FromName(ddlSecondColor.SelectedItem.Value)
                elementAppearance.GradientFillStyle = CType([Enum].Parse(GetType(GradientFillStyle), ddlGradientFillStyle.SelectedItem.Value, True), GradientFillStyle)
                Try
                    elementAppearance.GradientFocus = Single.Parse(txtBoxGradientFocus.Text)
                Catch
                    txtBoxGradientFocus.Text = "Value must be between 0 and 1"
                End Try
                elementAppearance.GammaCorrection = cbGammaCorrection.Checked
                elementAppearance.FillStyle = FillStyle.Gradient
            End If
        End Sub 'Button1_Click


        Private Sub ddlChartElement_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlChartElement.SelectedIndexChanged
            SetControlValues()
        End Sub 'ddlChartElement_SelectedIndexChanged
    End Class 'DefaultCS 
End Namespace 'Telerik.ChartExamplesCS.Gradients

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -