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

📄 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.Elements.Borders
    '/ <summary>
    '/ Summary description for _Default.
    '/ </summary>

    Public Class DefaultVB
        Inherits XhtmlPage
        Protected Label2 As System.Web.UI.WebControls.Label
        Protected WithEvents ddlChartElement As System.Web.UI.WebControls.DropDownList
        Protected Label1 As System.Web.UI.WebControls.Label
        Protected Label3 As System.Web.UI.WebControls.Label
        Protected Label4 As System.Web.UI.WebControls.Label
        Protected Label5 As System.Web.UI.WebControls.Label
        Protected ddlBorderColor As System.Web.UI.WebControls.DropDownList
        Protected txtBoxBorderWidth As System.Web.UI.WebControls.TextBox
        Protected cbTopLeft As System.Web.UI.WebControls.CheckBox
        Protected cbTopRight As System.Web.UI.WebControls.CheckBox
        Protected cbBottomLeft As System.Web.UI.WebControls.CheckBox
        Protected cbBottomRight As System.Web.UI.WebControls.CheckBox
        Protected txtBoxRoundSize As System.Web.UI.WebControls.TextBox
        Protected RangeValidator1 As System.Web.UI.WebControls.RangeValidator
        Protected RangeValidator2 As System.Web.UI.WebControls.RangeValidator
        Protected RadChart1 As Telerik.WebControls.RadChart
        Protected WithEvents Button1 As System.Web.UI.WebControls.Button

        Private chartElementsHash As System.Collections.Hashtable
        Protected lblIncorrectSettings As System.Web.UI.WebControls.Label

        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()

                RadChart1.ChartSeriesCollection(0).Items(0).Appearance.CopyFrom(RadChart1.ChartSeriesCollection(0).Appearance)
                RadChart1.ChartSeriesCollection(1).Items(0).Appearance.CopyFrom(RadChart1.ChartSeriesCollection(1).Appearance)

                SetControlValues()
            End If
        End Sub 'Page_Load



        Private Sub InitControls()
            Dim valueNames() As String

            valueNames = [Enum].GetNames(GetType(KnownColor))

            ddlBorderColor.Items.Clear()

            Dim s As String
            For Each s In valueNames
                ddlBorderColor.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(False)

            If Not (appearance Is Nothing) Then
                ddlBorderColor.SelectedIndex = ddlBorderColor.Items.IndexOf(ddlBorderColor.Items.FindByText(appearance.BorderColor.ToKnownColor().ToString()))
                txtBoxBorderWidth.Text = appearance.BorderWidth.ToString()
                txtBoxRoundSize.Text = appearance.Corners.RoundSize.ToString()
                cbTopLeft.Checked = appearance.Corners.TopLeft = CornerType.Round
                cbTopRight.Checked = appearance.Corners.TopRight = CornerType.Round
                cbBottomLeft.Checked = appearance.Corners.BottomLeft = CornerType.Round
                cbBottomRight.Checked = appearance.Corners.BottomRight = CornerType.Round
            End If
        End Sub 'SetControlValues


        Private Function GetCornerType(ByVal isRound As Boolean) As CornerType
            If isRound Then
                Return CornerType.Round
            Else
                Return CornerType.Rectangle
            End If
        End Function 'GetCornerType


        Private Sub SetAppearance(ByVal appearance As ChartRectShape)
            appearance.BorderColor = Color.FromName(ddlBorderColor.SelectedItem.Value)

            Try
                appearance.BorderWidth = Integer.Parse(txtBoxBorderWidth.Text)
            Catch
                txtBoxBorderWidth.Text = "Invalid width."
            End Try

            Try
                appearance.Corners.RoundSize = Integer.Parse(txtBoxRoundSize.Text)
            Catch
                txtBoxRoundSize.Text = "Invalid size."
            End Try

            appearance.Corners.TopLeft = GetCornerType(cbTopLeft.Checked)
            appearance.Corners.TopRight = GetCornerType(cbTopRight.Checked)
            appearance.Corners.BottomLeft = GetCornerType(cbBottomLeft.Checked)
            appearance.Corners.BottomRight = GetCornerType(cbBottomRight.Checked)
        End Sub 'SetAppearance


        Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                SetAppearance(GetCurrentAppearance(True))
                lblIncorrectSettings.Visible = False
            Catch
                lblIncorrectSettings.Visible = True
            End Try
        End Sub 'Button1_Click


        Private Function GetCurrentAppearance(ByVal changeItemAppearance As Boolean) As ChartRectShape
            If changeItemAppearance Then
                If ddlChartElement.SelectedIndex = 4 Then
                    SetAppearance(CType(chartElementsHash(keyNames(6)), ChartRectShape))
                End If

                If ddlChartElement.SelectedIndex = 5 Then
                    SetAppearance(CType(chartElementsHash(keyNames(7)), ChartRectShape))
                End If
            End If

            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 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.Borders

⌨️ 快捷键说明

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