📄 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.Legend
'/ <summary>
'/ Summary description for _Default.
'/ </summary>
Public Class DefaultVB
Inherits XhtmlPage
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 Label10 As System.Web.UI.WebControls.Label
Protected Label9 As System.Web.UI.WebControls.Label
Protected ddlVerAlignment As System.Web.UI.WebControls.DropDownList
Protected txtBoxHorSpacing As System.Web.UI.WebControls.TextBox
Protected txtBoxVerSpacing As System.Web.UI.WebControls.TextBox
Protected WithEvents btnApply As System.Web.UI.WebControls.Button
Protected ddlPosition As System.Web.UI.WebControls.DropDownList
Protected ddlHorAlignment As System.Web.UI.WebControls.DropDownList
Protected ddlLocation As System.Web.UI.WebControls.DropDownList
Protected Label1 As System.Web.UI.WebControls.Label
Protected Label8 As System.Web.UI.WebControls.Label
Protected ddlItemMark As System.Web.UI.WebControls.DropDownList
Protected txtBoxItemFont As System.Web.UI.WebControls.TextBox
Protected ddlItemsColor As System.Web.UI.WebControls.DropDownList
Protected Label2 As System.Web.UI.WebControls.Label
Protected Label11 As System.Web.UI.WebControls.Label
Protected Label12 As System.Web.UI.WebControls.Label
Protected txtBoxWidthRatio As System.Web.UI.WebControls.TextBox
Protected txtBoxHeightRatio As System.Web.UI.WebControls.TextBox
Protected cbAutoScale As System.Web.UI.WebControls.CheckBox
Protected Label13 As System.Web.UI.WebControls.Label
Protected Label14 As System.Web.UI.WebControls.Label
Protected Label15 As System.Web.UI.WebControls.Label
Protected Label17 As System.Web.UI.WebControls.Label
Protected Label18 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button3 As System.Web.UI.WebControls.Button
Protected ddlItemColor As System.Web.UI.WebControls.DropDownList
Protected ddlItemMark1 As System.Web.UI.WebControls.DropDownList
Protected txtBoxHRef As System.Web.UI.WebControls.TextBox
Protected txtBoxToolTip As System.Web.UI.WebControls.TextBox
Protected txtBoxAttributes As System.Web.UI.WebControls.TextBox
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(ddlItemMark, GetType(ChartLegendItemMark))
InitControl(ddlItemsColor, GetType(KnownColor))
InitControl(ddlLocation, GetType(ChartLocation))
InitControl(ddlPosition, GetType(ChartPosition))
InitControl(ddlHorAlignment, GetType(ChartHAlignment))
InitControl(ddlVerAlignment, GetType(ChartVAlignment))
InitControl(ddlItemColor, GetType(KnownColor))
InitControl(ddlItemMark1, GetType(ChartLegendItemMark))
End Sub 'InitControls
Private Sub SetControlValues()
Dim fc As New FontConverter()
SetControlValue(ddlItemMark, RadChart1.Legend.ItemMark.ToString())
txtBoxItemFont.Text = fc.ConvertToString(RadChart1.Legend.ItemFont)
SetControlValue(ddlItemsColor, RadChart1.Legend.ItemColor.ToKnownColor().ToString())
SetControlValue(ddlLocation, RadChart1.Legend.Location.ToString())
SetControlValue(ddlPosition, RadChart1.Legend.Position.ToString())
SetControlValue(ddlHorAlignment, RadChart1.Legend.HAlignment.ToString())
SetControlValue(ddlVerAlignment, RadChart1.Legend.VAlignment.ToString())
txtBoxHorSpacing.Text = RadChart1.Legend.HSpacing.ToString()
txtBoxVerSpacing.Text = RadChart1.Legend.VSpacing.ToString()
cbAutoScale.Checked = RadChart1.Legend.Visible
txtBoxHeightRatio.Text = RadChart1.Legend.HeightRatio.ToString()
txtBoxWidthRatio.Text = RadChart1.Legend.WidthRatio.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 ApplySettings()
Dim fc As New FontConverter()
Dim cc As New ColorConverter()
RadChart1.Legend.ItemColor = CType(cc.ConvertFromString(ddlItemsColor.SelectedItem.Value), Color)
RadChart1.Legend.ItemFont = CType(fc.ConvertFromString(txtBoxItemFont.Text), Font)
RadChart1.Legend.ItemMark = CType([Enum].Parse(GetType(ChartLegendItemMark), ddlItemMark.SelectedItem.Value), ChartLegendItemMark)
RadChart1.Legend.Location = CType([Enum].Parse(GetType(ChartLocation), ddlLocation.SelectedItem.Value), ChartLocation)
RadChart1.Legend.Position = CType([Enum].Parse(GetType(ChartPosition), ddlPosition.SelectedItem.Value), ChartPosition)
RadChart1.Legend.HAlignment = CType([Enum].Parse(GetType(ChartHAlignment), ddlHorAlignment.SelectedItem.Value), ChartHAlignment)
RadChart1.Legend.VAlignment = CType([Enum].Parse(GetType(ChartVAlignment), ddlVerAlignment.SelectedItem.Value), ChartVAlignment)
RadChart1.Legend.HSpacing = Integer.Parse(txtBoxHorSpacing.Text)
RadChart1.Legend.VSpacing = Integer.Parse(txtBoxVerSpacing.Text)
RadChart1.Legend.AutoSize = cbAutoScale.Checked
RadChart1.Legend.WidthRatio = Double.Parse(txtBoxWidthRatio.Text)
RadChart1.Legend.HeightRatio = Double.Parse(txtBoxHeightRatio.Text)
End Sub 'ApplySettings
Private Sub ValidateInput()
If txtBoxItemFont.Text Is Nothing OrElse txtBoxItemFont.Text = String.Empty Then
txtBoxItemFont.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 txtBoxWidthRatio_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub 'txtBoxWidthRatio_TextChanged
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
If RadChart1.Legend.Location = ChartLocation.OutsidePlotArea AndAlso RadChart1.Legend.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.Legend.Location = ChartLocation.OutsidePlotArea AndAlso RadChart1.Legend.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.Legend.Location = ChartLocation.OutsidePlotArea AndAlso RadChart1.Legend.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.Legend.Location = ChartLocation.OutsidePlotArea AndAlso RadChart1.Legend.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 Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim legendItem As New ChartLegendItem()
Dim cc As New ColorConverter()
legendItem.Appearance.MainColor = CType(cc.ConvertFromString(ddlItemColor.SelectedItem.Value), Color)
legendItem.Appearance.FillStyle = FillStyle.Solid
legendItem.ItemMark = CType([Enum].Parse(GetType(ChartLegendItemMark), ddlItemMark1.SelectedItem.Value), ChartLegendItemMark)
legendItem.Name = "Item " + RadChart1.Legend.Items.Count.ToString()
legendItem.ImageMap.HRef = txtBoxHRef.Text
legendItem.ImageMap.ToolTip = txtBoxToolTip.Text
legendItem.ImageMap.Attributes = txtBoxAttributes.Text
RadChart1.Legend.Items.Add(legendItem)
End Sub 'Button1_Click
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim legend As ChartLegend = RadChart1.Legend
If legend.Items.Count > 0 Then
legend.Items.RemoveAt((legend.Items.Count - 1))
End If
End Sub 'Button3_Click
End Class 'DefaultCS
End Namespace 'Telerik.ChartExamplesCS.Legend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -