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

📄 orgchart.cs

📁 r r
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.Design;
using System.ComponentModel;
using System.Drawing;
using System.Collections;
using System.IO;
using System.Text;

namespace wssmax
{
	/// <summary>
	/// OrgChart 的摘要说明。
	/// </summary>
	[Designer(typeof(OrgChartDesigner)), ParseChildren(true), ToolboxData("<{0}:OrgChart runat=server  ChartStyle=Horizontal></{0}:OrgChart>")]
	public class OrgChart : WebControl
	{
		private OrgNode OrgNodeDemo;
		private Color OrgNodeColor;
		private Unit OrgNodeUnit;
		private OrgNodeCollection OrgNodeCollectionDemo;
		private Orientation OrgNodeOrientation;
		private string OrgNodestring;
		private string HttpContent;
		private string ImgFolder;

		public OrgChart()
		{

		}

		public enum Orientation
		{
			Horizontal = 1,
			Vertical = 0
		}

		public enum ExpandableValue
		{
			Always = 0,
			Auto = 1,
			CheckOnce = 2
		}

		/// <summary>
		/// 创建图形
		/// </summary>
		private void CreatGraphic(OrgNode node1)
		{
			this.HttpContent = this.HttpContent + "<table cellspacing=0 cellpadding=0 border=0 Width=100%>";
			if (node1.Nodes.Count > 1)
			{
				this.HttpContent = this.HttpContent + "<tr>";
				this.HttpContent = this.HttpContent + "<td height=1 align=Right>" + this.CreatTableStyleRight("50%", 1) + "</td>";
				for (int num1 = 1; num1 < (node1.Nodes.Count - 1); num1++)
				{
					this.HttpContent = this.HttpContent + "<td height=1 align=Right>" + this.CreatTableStyleRight("100%", 1) + "</td>";
				}
				this.HttpContent = this.HttpContent + "<td height=1 align=Left>" + this.CreatTableStyleRight("50%", 1) + "</td>";
				this.HttpContent = this.HttpContent + "</tr>";
				this.HttpContent = this.HttpContent + "<tr>";
				for (int num2 = 0; num2 < node1.Nodes.Count; num2++)
				{
					this.HttpContent = this.HttpContent + "<td align=Center>" + this.CreatTableStyleCenter(1, 20) + "</td>";
				}
				this.HttpContent = this.HttpContent + "</tr>";
			}
			this.HttpContent = this.HttpContent + "<tr>";
			for (int num3 = 0; num3 < node1.Nodes.Count; num3++)
			{
				this.HttpContent = this.HttpContent + "<td valign=top >";
				this.HttpContent = this.HttpContent + this.OrgNodeHtmlImg(node1.Nodes[num3]);
				if (node1.Nodes[num3].Nodes.Count > 0)
				{
					this.HttpContent = this.HttpContent + "<table cellspacing=0 cellpadding=0 align=center>";
					this.HttpContent = this.HttpContent + "<tr>";
					this.HttpContent = this.HttpContent + "<td colspan=0 valign=top align=Center width=100% class=OrgChartCellPadding>";
					this.HttpContent = this.HttpContent + this.CreatTableStyleCenter(1, 20);
					this.OrgNodeHtmlImg(node1.Nodes[num3]);
					this.HttpContent = this.HttpContent + "</td>";
					this.HttpContent = this.HttpContent + "</tr>";
					this.HttpContent = this.HttpContent + "</table>";
				}
				this.HttpContent = this.HttpContent + "</td>";
			}
			this.HttpContent = this.HttpContent + "</tr>";
			this.HttpContent = this.HttpContent + "</table>";
		}
    	/// <summary>
		/// 创建有颜色的风格
		/// </summary>
		private string CreatTableStyleColor(string text3, string text4)
		{
			string text1 = this.LineColor.Name;
			StringBuilder builder1 = new StringBuilder();
			string text2 = "<table cellspacing=0 cellpadding=0 border=0 width={0} height={1} ><tr><td height=50%></td></tr><tr><td width=1 height=50% bgcolor={2}></td></tr></Table>";
			builder1.AppendFormat(text2, text3, text4, text1);
			return builder1.ToString();
		}
 
		/// <summary>
		/// 创建节点的风格
		/// </summary>
		private void CreatNodeStyle(OrgNode node1, Orientation orientation1)
		{
			this.HttpContent = "";
			try
			{
				object obj1;
				object[] objArray1;
				if (orientation1 == Orientation.Horizontal)
				{
					this.HttpContent = this.HttpContent + "<table cellspacing=0 cellpadding=0 border=0 Width=100% height=>";
					this.HttpContent = this.HttpContent + "<tr>";
					if (node1.Nodes.Count > 0)
					{
						obj1 = this.HttpContent;
						objArray1 = new object[4] { obj1, "<td rowspan=", node1.Nodes.Count, " valign=middle align=Center width=1 class=OrgChartCellPadding>" } ;
						this.HttpContent = string.Concat(objArray1);
					}
					else
					{
						this.HttpContent = this.HttpContent + "<td valign=middle align=Center width=1 class=OrgChartCellPadding>";
					}
					this.HttpContent = this.HttpContent + this.OrgNodeHtmlImg(node1);
					this.HttpContent = this.HttpContent + "</td>\n";
					if (node1.Nodes.Count > 0)
					{
						if (node1.Nodes.Count == 1)
						{
							obj1 = this.HttpContent;
							objArray1 = new object[6] { obj1, "\t <td rowspan=", node1.Nodes.Count, " align=right width=2>", this.CreatTableStyleCenter(0x29, 1), "</td>" } ;
							this.HttpContent = string.Concat(objArray1);
							obj1 = this.HttpContent;
							objArray1 = new object[4] { obj1, "\t <td rowspan=", node1.Nodes.Count, " align=left width=>\n" } ;
							this.HttpContent = string.Concat(objArray1);
						}
						else
						{
							obj1 = this.HttpContent;
							objArray1 = new object[6] { obj1, "\t <td rowspan=", node1.Nodes.Count, " align=right width=2>", this.CreatTableStyleCenter(20, 1), "</td>" } ;
							this.HttpContent = string.Concat(objArray1);
							obj1 = this.HttpContent;
							objArray1 = new object[4] { obj1, "\t <td rowspan=", node1.Nodes.Count, " align=left width=>\n" } ;
							this.HttpContent = string.Concat(objArray1);
						}
						this.StyleSelectStyle(node1, orientation1);
						this.HttpContent = this.HttpContent + "\t </td>\n";
					}
					this.HttpContent = this.HttpContent + "</tr>";
					this.HttpContent = this.HttpContent + "</table>";
				}
				else
				{
					this.HttpContent = this.HttpContent + "<table cellspacing=0 cellpadding=0 border=0 Width=100%>";
					if (node1.Nodes.Count > 0)
					{
						obj1 = this.HttpContent;
						objArray1 = new object[4] { obj1, "<tr><td colspan=", node1.Nodes.Count, " valign=top align=Center width= class=orgChartCellPadding>" } ;
						this.HttpContent = string.Concat(objArray1);
					}
					else
					{
						this.HttpContent = this.HttpContent + "<tr><td valign=top align=Center width= class=orgChartCellPadding>";
					}
					this.HttpContent = this.HttpContent + this.OrgNodeHtmlImg(node1);
					this.HttpContent = this.HttpContent + "</td></tr>\n";
					if (node1.Nodes.Count > 0)
					{
						obj1 = this.HttpContent;
						objArray1 = new object[4] { obj1, "\t<tr><td colspan=", node1.Nodes.Count, " align=Center>" } ;
						this.HttpContent = string.Concat(objArray1);
						this.HttpContent = this.HttpContent + this.CreatTableStyleCenter(1, 20);
						this.HttpContent = this.HttpContent + "</td>";
						this.HttpContent = this.HttpContent + "</tr>";
						this.StyleSelectStyle(node1, orientation1);
					}
					this.HttpContent = this.HttpContent + "</table>";
				}
			}
			catch (Exception exception1)
			{
				string text1 = exception1.Message;
			}
		}
 
		/// <summary>
		/// 默认样式
		/// </summary>
		private void DefaultStyle(out OrgNode nodeRef1)
		{
			nodeRef1 = new OrgNode();
			nodeRef1.Text = "公司总部";
			nodeRef1.Type = "Root";
			OrgNode node1 = new OrgNode();
			node1.Text = "西城营业厅";
			node1.Type = "LOGIN";
			nodeRef1.Nodes.Add(node1);
			OrgNode node2 = new OrgNode();
			node2.Text = "东城营业厅";
			node2.Type = "ROLES";
			nodeRef1.Nodes.Add(node2);
		}

		/// <summary>
		/// 显示风格需要javascript支持
		/// </summary>
		private string JSupport(string text2)
		{
			string text1;
			this.HttpContent = "<table cellspacing=0 cellpadding=0 border=0 Width=100%>";
			this.HttpContent = this.HttpContent + "<tr>";
			this.HttpContent = this.HttpContent + "<td height=1 align=Right><img src=../images/OrgChartLine.gif border=0 style=\"height:1px;width:50%;\" /></td>";
			if ((text1 = text2) != null)
			{
				text1 = string.IsInterned(text1);
				if (text1 != "A")
				{
					if (text1 == "B")
					{
						return this.JSupport(text2);
					}
					if (text1 == "D")
					{
						return null;
					}
					if (text1 == "F")
					{
						return (this.HttpContent + "F");
					}
				}
				else
				{
					foreach (OrgNode node1 in this.OrgNodeCollectionDemo)
					{
						this.HttpContent = this.HttpContent + node1.Text;
						if ((node1.Type != null) && (node1.Type != ""))
						{
							continue;
						}
						if (node1.Type == "none")
						{
							continue;
						}
						if ((text1 = node1.Type) == null)
						{
							goto Label_012B;
						}
						text1 = string.IsInterned(text1);
						if (text1 != "NODE")
						{
							if (text1 == "LOGN")
							{
								goto Label_0122;
							}
							goto Label_012B;
						}
						text2 = "客户支持JAVA、C#,";
						continue;
					Label_0122:
						text2 = "支持JS、VBS客览器,";
						continue;
					Label_012B:
						text2 = "A";
					}
					return this.JSupport(this.HttpContent.Trim());
				}
			}
			return this.HttpContent;
		}
		
 		/// <summary>
		/// 节点图片样式库
		/// </summary>
		private string OrgNodeHtmlImg(OrgNode node1)
		{
			node1.ImageFolder = this.ImageFolder;
			return node1.OrgNodeHtml();
		}
 
		/// <summary>
		/// 节点创建
		/// </summary>
		private void CreatNode(OrgNode node1)
		{
			object obj1;
			object[] objArray1;
			this.HttpContent = this.HttpContent + "<table cellspacing=0 cellpadding=0 border=0 Width=100%>";
			if (node1.Nodes.Count > 0)
			{
				obj1 = this.HttpContent;
				objArray1 = new object[4] { obj1, "<tr><td colspan=", node1.Nodes.Count, " valign=top align=Center width= class=orgChartCellPadding>" } ;
				this.HttpContent = string.Concat(objArray1);
			}
			else
			{
				this.HttpContent = this.HttpContent + "<tr><td valign=top align=Center width= class=orgChartCellPadding>";
			}
			this.HttpContent = this.HttpContent + this.OrgNodeHtmlImg(node1);
			this.HttpContent = this.HttpContent + "</td></tr>\n";
			if (node1.Nodes.Count > 0)
			{
				obj1 = this.HttpContent;
				objArray1 = new object[4] { obj1, "\t<tr><td colspan=", node1.Nodes.Count, " align=Center>" } ;
				this.HttpContent = string.Concat(objArray1);
				this.HttpContent = this.HttpContent + this.CreatTableStyleCenter(1, 20);
				this.HttpContent = this.HttpContent + "</td>";
				this.HttpContent = this.HttpContent + "</tr>";
				this.CreatGraphic(node1);
			}
			this.HttpContent = this.HttpContent + "</table>";
		}
 
		/// <summary>
		/// 创建不同风格的表格
		/// </summary>
		private string CreatTableStyleCenter(int num1, int num2)
		{
			return this.CreatTable(num1.ToString(), num2.ToString());
		}
 
		private string CreatTableStyleLeft(int num1, string text1)
		{

⌨️ 快捷键说明

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