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

📄 defaultcs.aspx.cs

📁 Telerik是很大的第三方软件制造商
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Telerik.QuickStart;
using Telerik.WebControls;

namespace Telerik.ChartExamplesCS.ChartSettings
{
	/// <summary>
	/// Summary description for _Default.
	/// </summary>
	public class DefaultCS: XhtmlPage
	{
		protected Telerik.WebControls.RadChart RadChart1;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.TextBox txtBoxWidth;
		protected System.Web.UI.WebControls.TextBox txtBoxHeight;
		protected System.Web.UI.WebControls.TextBox txtBoxLeftMargin;
		protected System.Web.UI.WebControls.TextBox txtBoxRightMargin;
		protected System.Web.UI.WebControls.TextBox txtBoxTopMargin;
		protected System.Web.UI.WebControls.TextBox txtBoxBottomMargin;
		protected System.Web.UI.WebControls.Label Label7;
		protected System.Web.UI.WebControls.DropDownList ddlImageType;
		protected System.Web.UI.WebControls.Label Label8;
		protected System.Web.UI.WebControls.DropDownList ddlImageQuality;
		protected System.Web.UI.WebControls.Label Label9;
		protected System.Web.UI.WebControls.DropDownList ddlTextQuality;
		protected System.Web.UI.WebControls.Label lblIncorrectSetting;
		protected System.Web.UI.WebControls.Button Button1;

		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				InitControls();
				SetControlValues();
			}			
		}

		private void InitControls()
		{            
			InitControl(ddlImageQuality, typeof(ImageQuality));
			InitControl(ddlTextQuality, typeof(TextQuality));
		}

		private void InitControl(DropDownList ddList, Type type)
		{
			string[] valueNames = Enum.GetNames(type);

			ddList.Items.Clear();

			foreach (string s in valueNames)
			{
				ddList.Items.Add(s);
			}
		}

		private void SetControlValues()
		{
			txtBoxWidth.Text        = RadChart1.Width.ToString();
			txtBoxHeight.Text       = RadChart1.Height.ToString();
			txtBoxLeftMargin.Text   = RadChart1.Margins.Left.ToString();
			txtBoxRightMargin.Text  = RadChart1.Margins.Right.ToString();
			txtBoxTopMargin.Text    = RadChart1.Margins.Top.ToString();
			txtBoxBottomMargin.Text = RadChart1.Margins.Bottom.ToString();
			SetControlValue(ddlImageQuality, RadChart1.ImageQuality.ToString());
			SetControlValue(ddlTextQuality, RadChart1.TextQuality.ToString());
			SetControlValue(ddlImageType, RadChart1.ChartImageFormat.ToString());
		}

		private void SetControlValue(DropDownList ddList, string val)
		{
			ListItem listItem = ddList.SelectedItem;
			if (listItem != null)
			{
				listItem.Selected = false;
			}
			listItem = ddList.Items.FindByValue(val);
			if (listItem != null)
			{
				listItem.Selected = true;
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			try
			{
				ApplySettings();
				lblIncorrectSetting.Visible = false;
			}
			catch
			{
				lblIncorrectSetting.Visible = true;
			}
		}

		private void ApplySettings()
		{            
			RadChart1.Width          = Unit.Parse(txtBoxWidth.Text);                    
			RadChart1.Height         = Unit.Parse(txtBoxHeight.Text);

			RadChart1.Margins.Left   = Unit.Parse(txtBoxLeftMargin.Text);
			RadChart1.Margins.Right  = Unit.Parse(txtBoxRightMargin.Text);
			RadChart1.Margins.Top    = Unit.Parse(txtBoxTopMargin.Text);
			RadChart1.Margins.Bottom = Unit.Parse(txtBoxBottomMargin.Text);

			RadChart1.ImageQuality = (ImageQuality) Enum.Parse(typeof(ImageQuality), ddlImageQuality.SelectedItem.Value);
			RadChart1.TextQuality  = (TextQuality) Enum.Parse(typeof(TextQuality), ddlTextQuality.SelectedItem.Value);

			ImageFormatConverter ifc = new ImageFormatConverter();
			RadChart1.ChartImageFormat = (ImageFormat) ifc.ConvertFromString(ddlImageType.SelectedItem.Value);
		}			
	}
}

⌨️ 快捷键说明

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