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

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

    Public Class DefaultVB
        Inherits XhtmlPage

        Protected RadChart1 As Telerik.WebControls.RadChart
        Protected Label4 As System.Web.UI.WebControls.Label
        Protected Label1 As System.Web.UI.WebControls.Label
        Protected Label10 As System.Web.UI.WebControls.Label
        Protected Label9 As System.Web.UI.WebControls.Label
        Protected Label3 As System.Web.UI.WebControls.Label
        Protected Label5 As System.Web.UI.WebControls.Label
        Protected ddlVerAlignment As System.Web.UI.WebControls.DropDownList
        Protected Label6 As System.Web.UI.WebControls.Label
        Protected txtBoxHorSpacing As System.Web.UI.WebControls.TextBox
        Protected Label7 As System.Web.UI.WebControls.Label
        Protected txtBoxVerSpacing As System.Web.UI.WebControls.TextBox
        Protected Label8 As System.Web.UI.WebControls.Label
        Protected WithEvents btnApply As System.Web.UI.WebControls.Button
        Protected txtBoxText As System.Web.UI.WebControls.TextBox
        Protected txtBoxFont As System.Web.UI.WebControls.TextBox
        Protected ddlTextDirection As System.Web.UI.WebControls.DropDownList
        Protected WithEvents ddlPosition As System.Web.UI.WebControls.DropDownList
        Protected ddlHorAlignment As System.Web.UI.WebControls.DropDownList
        Protected Label2 As System.Web.UI.WebControls.Label
        Protected ddlLocation As System.Web.UI.WebControls.DropDownList
        Protected lblIncorrectSettings As System.Web.UI.WebControls.Label
        Protected ddlTextColor As System.Web.UI.WebControls.DropDownList


        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not Page.IsPostBack Then
                InitControls()
                SetControlValues()
            End If
        End Sub 'Page_Load


        Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
            If RadChart1.Title1.Location = ChartLocation.OutsidePlotArea AndAlso RadChart1.Title1.Position = ChartPosition.Left Then
                RadChart1.Margins.Left = Unit.Percentage(20)
                RadChart1.Margins.Top = Unit.Percentage(10)
                RadChart1.Margins.Right = Unit.Percentage(10)
                RadChart1.Margins.Bottom = Unit.Percentage(10)
            ElseIf RadChart1.Title1.Location = ChartLocation.OutsidePlotArea AndAlso RadChart1.Title1.Position = ChartPosition.Top Then
                RadChart1.Margins.Left = Unit.Percentage(10)
                RadChart1.Margins.Top = Unit.Percentage(20)
                RadChart1.Margins.Right = Unit.Percentage(10)
                RadChart1.Margins.Bottom = Unit.Percentage(10)
            ElseIf RadChart1.Title1.Location = ChartLocation.OutsidePlotArea AndAlso RadChart1.Title1.Position = ChartPosition.Bottom Then
                RadChart1.Margins.Left = Unit.Percentage(10)
                RadChart1.Margins.Top = Unit.Percentage(10)
                RadChart1.Margins.Right = Unit.Percentage(10)
                RadChart1.Margins.Bottom = Unit.Percentage(23)
            ElseIf RadChart1.Title1.Location = ChartLocation.OutsidePlotArea AndAlso RadChart1.Title1.Position = ChartPosition.Right Then
                RadChart1.Margins.Left = Unit.Percentage(10)
                RadChart1.Margins.Top = Unit.Percentage(10)
                RadChart1.Margins.Right = Unit.Percentage(20)
                RadChart1.Margins.Bottom = Unit.Percentage(10)
            End If
        End Sub 'OnPreRender


        Private Sub InitControls()
            InitControl(ddlTextColor, GetType(KnownColor))
            InitControl(ddlTextDirection, GetType(ChartTextDirection))
            InitControl(ddlLocation, GetType(ChartLocation))
            InitControl(ddlPosition, GetType(ChartPosition))
            InitControl(ddlHorAlignment, GetType(ChartHAlignment))
            InitControl(ddlVerAlignment, GetType(ChartVAlignment))
        End Sub 'InitControls


        Private Sub SetControlValues()
            Dim fc As New FontConverter()

            txtBoxText.Text = RadChart1.Title1.Text
            txtBoxFont.Text = fc.ConvertToString(RadChart1.Title1.TextFont)
            SetControlValue(ddlTextColor, RadChart1.Title1.TextColor.ToKnownColor().ToString())
            SetControlValue(ddlTextDirection, RadChart1.Title1.TextDirection.ToString())
            SetControlValue(ddlPosition, RadChart1.Title1.Position.ToString())
            SetControlValue(ddlLocation, RadChart1.Title1.Location.ToString())
            SetControlValue(ddlHorAlignment, RadChart1.Title1.HAlignment.ToString())
            SetControlValue(ddlVerAlignment, RadChart1.Title1.VAlignment.ToString())
            txtBoxHorSpacing.Text = RadChart1.Title1.HSpacing.ToString()
            txtBoxVerSpacing.Text = RadChart1.Title1.VSpacing.ToString()
        End Sub 'SetControlValues


        Private Sub InitControl(ByVal ddList As DropDownList, ByVal type As Type)
            Dim valueNames As String() = [Enum].GetNames(type)

            ddList.Items.Clear()

            Dim s As String
            For Each s In valueNames
                ddList.Items.Add(s)
            Next s
        End Sub 'InitControl


        Private Sub SetControlValue(ByVal ddList As DropDownList, ByVal val As String)
            ddList.SelectedIndex = ddList.Items.IndexOf(ddList.Items.FindByValue(val))
        End Sub 'SetControlValue

#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 ValidateInput()
            If txtBoxFont.Text Is Nothing OrElse txtBoxFont.Text = String.Empty Then
                txtBoxFont.Text = "Arial; 12pt; style=bold"
            End If
        End Sub 'ValidateInput


        Private Sub btnApply_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnApply.Click
            Try
                ValidateInput()
                ApplySettings()
                lblIncorrectSettings.Visible = False
            Catch
                lblIncorrectSettings.Visible = True
            End Try
        End Sub 'btnApply_Click


        Private Sub ApplySettings()
            Dim fc As New FontConverter()
            Dim cc As New ColorConverter()

            RadChart1.Title1.Text = txtBoxText.Text
            RadChart1.Title1.TextFont = CType(fc.ConvertFromString(txtBoxFont.Text), Font)
            RadChart1.Title1.TextColor = CType(cc.ConvertFromString(ddlTextColor.SelectedItem.Value), Color)
            RadChart1.Title1.TextDirection = CType([Enum].Parse(GetType(ChartTextDirection), ddlTextDirection.SelectedItem.Value), ChartTextDirection)
            RadChart1.Title1.Position = CType([Enum].Parse(GetType(ChartPosition), ddlPosition.SelectedItem.Value), ChartPosition)
            RadChart1.Title1.Location = CType([Enum].Parse(GetType(ChartLocation), ddlLocation.SelectedItem.Value), ChartLocation)
            RadChart1.Title1.HAlignment = CType([Enum].Parse(GetType(ChartHAlignment), ddlHorAlignment.SelectedItem.Value), ChartHAlignment)
            RadChart1.Title1.VAlignment = CType([Enum].Parse(GetType(ChartVAlignment), ddlVerAlignment.SelectedItem.Value), ChartVAlignment)
            RadChart1.Title1.HSpacing = Integer.Parse(txtBoxHorSpacing.Text)
            RadChart1.Title1.VSpacing = Integer.Parse(txtBoxVerSpacing.Text)
        End Sub 'ApplySettings


        Private Sub ddlPosition_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPosition.SelectedIndexChanged
            If RadChart1.Title1.Location = ChartLocation.OutsidePlotArea AndAlso ddlPosition.SelectedItem.Value.Equals("Left") Then
                SetControlValue(ddlTextDirection, "Left")
            ElseIf RadChart1.Title1.Location = ChartLocation.OutsidePlotArea AndAlso ddlPosition.SelectedItem.Value.Equals("Right") Then
                SetControlValue(ddlTextDirection, "Right")
            Else
                SetControlValue(ddlTextDirection, "Normal")
            End If
        End Sub 'ddlPosition_SelectedIndexChanged
    End Class 'DefaultCS 
End Namespace 'Telerik.ChartExamplesCS.Title

⌨️ 快捷键说明

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