📄 defaultvb.aspx.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.Labels
'/ <summary>
'/ Summary description for _Default.
'/ </summary>
Public Class DefaultVB
Inherits XhtmlPage
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected Label1 As System.Web.UI.WebControls.Label
Protected Label2 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 Label6 As System.Web.UI.WebControls.Label
Protected Label7 As System.Web.UI.WebControls.Label
Protected Label8 As System.Web.UI.WebControls.Label
Protected Label9 As System.Web.UI.WebControls.Label
Protected WithEvents ddlLabel As System.Web.UI.WebControls.DropDownList
Protected tbText As System.Web.UI.WebControls.TextBox
Protected tbFont As System.Web.UI.WebControls.TextBox
Protected ddlTextColor As System.Web.UI.WebControls.DropDownList
Protected ddlBorderColor As System.Web.UI.WebControls.DropDownList
Protected tbBorderWidth As System.Web.UI.WebControls.TextBox
Protected cbRoundCorners As System.Web.UI.WebControls.CheckBox
Protected ddlFillStyle As System.Web.UI.WebControls.DropDownList
Protected tbRoundSize As System.Web.UI.WebControls.TextBox
Protected Label10 As System.Web.UI.WebControls.Label
Protected ddlBackColor As System.Web.UI.WebControls.DropDownList
Protected lblIncorrectSettings As System.Web.UI.WebControls.Label
Protected RadChart1 As Telerik.WebControls.RadChart
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
Private Sub InitControls()
InitControl(ddlBorderColor, GetType(KnownColor))
InitControl(ddlFillStyle, GetType(FillStyle))
InitControl(ddlTextColor, GetType(KnownColor))
InitControl(ddlBackColor, GetType(KnownColor))
End Sub 'InitControls
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 SetControlValues()
Dim fc As New FontConverter()
Dim cc As New ColorConverter()
Dim label As ChartBaseLabel = GetCurrentLabel()
tbText.Text = label.Text
tbFont.Text = fc.ConvertToString(label.TextFont)
SetControlValue(ddlTextColor, label.TextColor.ToKnownColor().ToString())
SetControlValue(ddlBackColor, label.Background.MainColor.ToKnownColor().ToString())
SetControlValue(ddlBorderColor, label.Background.BorderColor.ToKnownColor().ToString())
tbBorderWidth.Text = label.Background.BorderWidth.ToString()
If label.Background.Corners.TopLeft = CornerType.Round Then
cbRoundCorners.Checked = True
Else
cbRoundCorners.Checked = False
End If
tbRoundSize.Text = label.Background.Corners.RoundSize.ToString()
End Sub 'SetControlValues
Private Sub SetControlValue(ByVal ddList As DropDownList, ByVal val As String)
Dim listItem As listItem
listItem = ddList.SelectedItem
If Not (listItem Is Nothing) Then
listItem.Selected = False
End If
listItem = ddList.Items.FindByValue(val)
If Not (listItem Is Nothing) Then
listItem.Selected = True
End If
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 tbFont.Text Is Nothing OrElse tbFont.Text = String.Empty Then
tbFont.Text = "Arial; 12pt; style=bold"
End If
End Sub 'ValidateInput
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
ValidateInput()
ApplySettings(GetCurrentLabel())
lblIncorrectSettings.Visible = False
Catch
lblIncorrectSettings.Visible = True
End Try
End Sub 'Button1_Click
Private Sub ApplySettings(ByVal label As ChartBaseLabel)
Dim fc As New FontConverter()
Dim cc As New ColorConverter()
label.Text = tbText.Text
label.TextFont = CType(fc.ConvertFromString(tbFont.Text), Font)
label.TextColor = CType(cc.ConvertFromString(ddlTextColor.SelectedItem.Value), Color)
label.Background.MainColor = CType(cc.ConvertFromString(ddlBackColor.SelectedItem.Value), Color)
label.Background.BorderColor = CType(cc.ConvertFromString(ddlBorderColor.SelectedItem.Value), Color)
label.Background.BorderWidth = Integer.Parse(tbBorderWidth.Text)
label.Background.FillStyle = FillStyle.Solid
If cbRoundCorners.Checked Then
label.Background.Corners.SetCornersType(CornerType.Round)
Else
label.Background.Corners.SetCornersType(CornerType.Rectangle)
End If
label.Background.Corners.RoundSize = Integer.Parse(tbRoundSize.Text)
ApplyFillStyle(label)
End Sub 'ApplySettings
Private Sub ApplyFillStyle(ByVal label As ChartBaseLabel)
Select Case ddlFillStyle.SelectedIndex
Case 0
Exit Select
Case 1
label.Background.FillStyle = FillStyle.Gradient
label.Background.SecondColor = Color.White
Exit Select
Case 2
label.Background.FillStyle = FillStyle.Hatch
label.Background.SecondColor = Color.White
Exit Select
Case 3
label.Background.FillStyle = FillStyle.Image
label.Background.ImageMode = ImageMode.Tile
label.Background.ImageUrl = "texture.jpg"
Exit Select
End Select
End Sub 'ApplyFillStyle
Private Function GetCurrentLabel() As ChartBaseLabel
Select Case ddlLabel.SelectedIndex
Case 0
Return RadChart1.Title1
Case 1
Return RadChart1.XAxis.Label
Case 2
Return RadChart1.YAxis.Label
Case 3
Return RadChart1.ChartSeriesCollection(0).LabelAppearance
End Select
Return Nothing
End Function 'GetCurrentLabel
Private Sub ddlLabel_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlLabel.SelectedIndexChanged
SetControlValues()
End Sub 'ddlLabel_SelectedIndexChanged
End Class 'DefaultCS
End Namespace 'Telerik.ChartExamplesCS.Labels
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -