📄 orgchart.cs
字号:
return this.CreatTable(num1.ToString(), text1);
}
private string CreatTableStyleRight(string text1, int num1)
{
return this.CreatTable(text1, num1.ToString());
}
/// <summary>
/// 创建表格
/// </summary>
private string CreatTable(string text3, string text4)
{
string text1 = this.LineColor.Name;
StringBuilder builder1 = new StringBuilder();
string text2 = "<table valign=bottom cellspacing=0 cellpadding=0 border=0 width={0} height={1} bgcolor={2} ><tr><td></td></tr></Table>";
builder1.AppendFormat(text2, text3, text4, text1);
return builder1.ToString();
}
/// <summary>
/// 风格选择
/// </summary>
private void StyleSelect(OrgNode node1, Orientation orientation1)
{
if (orientation1 == Orientation.Horizontal)
{
this.HttpContent = orientation1.ToString();
}
else
{
this.CreatNode(node1);
}
}
/// <summary>
/// 节点属性设置
/// </summary>
private string NodeAttribute(string text4, OrgNode node1, int num1)/////////////
{
string text1;
num1 = num1++;
if ((text4 == null) || (text4 == ""))
{
text1 = "<TABLE Width=100 align=center border=0><TR><TD align=center class=\"orgchartTable\" title='{1}'>{3}<a href='{4}'>{0}</a></TD></TR></TABLE>";
}
else
{
text1 = text4;
}
StringBuilder builder1 = new StringBuilder();
string[] textArray1 = new string[5] { (node1.Text == null) ? "" : node1.Text, (node1.Description == null) ? "" : node1.Description, (node1.Type == null) ? "" : node1.Type, (node1.ImageUrl == "") ? "" : ("<img border=0 src='" + node1.ImageUrl + "'>"), (node1.NavigateUrl == null) ? "" : node1.NavigateUrl } ;
string text3 = node1.ImageUrl;
if ((text3 == null) || (text3 == ""))
{
string text2;
if ((text2 = node1.Type.ToUpper()) == null)
{
goto Label_014A;
}
text2 = string.IsInterned(text2);
if (text2 != "ROOT")
{
if (text2 == "GROUP")
{
text3 = "../images/X1Group.gif";
}
else if (text2 == "ROLES")
{
text3 = "../images/X1Roles.gif";
}
else
{
if (text2 != "LOGIN")
{
goto Label_014A;
}
text3 = "../images/X1Login.gif";
}
}
else
{
text3 = "../images/x1root.gif";
}
}
goto Label_0151;
Label_014A:
text3 = "";
Label_0151:
textArray1[3] = (text3 == "") ? "" : ("<img border=0 src='" + text3 + "'>");
builder1.AppendFormat(text1, textArray1);
return builder1.ToString();
}
/// <summary>
/// 样式选择后的样式
/// </summary>
private void StyleSelectStyle(OrgNode node1, Orientation orientation1)
{
if (orientation1 == Orientation.Horizontal)
{
this.HttpContent = this.HttpContent + "<table cellspacing=0 cellpadding=0 border=0 height='100%'>";
for (int num1 = 0; num1 < node1.Nodes.Count; num1++)
{
this.HttpContent = this.HttpContent + "<tr>";
if (node1.Nodes.Count > 1)
{
if (num1 == 0)
{
this.HttpContent = this.HttpContent + "<td width=1 align=Right vAlign=bottom>" + this.CreatTableStyleColor("1", "100%") + "</td>";
}
else if (num1 == (node1.Nodes.Count - 1))
{
this.HttpContent = this.HttpContent + "<td width=1 align=Right vAlign=top>" + this.CreatTableStyleLeft(1, "50%") + "</td>";
}
else
{
this.HttpContent = this.HttpContent + "<td width=1 align=Right vAlign=bottom>" + this.CreatTableStyleLeft(1, "100%") + "</td>";
}
this.HttpContent = this.HttpContent + "<td align=Left vAlign=middle>" + this.CreatTableStyleCenter(20, 1) + "</td>";
this.HttpContent = this.HttpContent + "<td align=Left vAlign=middle>" + this.OrgNodeHtmlImg(node1.Nodes[num1]) + "</td>";
}
else
{
this.HttpContent = this.HttpContent + "<td align=Left vAlign=middle>" + this.OrgNodeHtmlImg(node1.Nodes[num1]) + "</td>";
}
if (node1.Nodes[num1].Nodes.Count > 0)
{
this.HttpContent = this.HttpContent + "<td align=Left vAlign=middle>";
this.HttpContent = this.HttpContent + " <table cellspacing=0 cellpadding=0 align=Left border=0>";
this.HttpContent = this.HttpContent + " <tr>";
this.HttpContent = this.HttpContent + " <td colspan=0 valign=middle align=Left width=20 class=OrgChartCellPadding>";
if (node1.Nodes[num1].Nodes.Count == 1)
{
this.HttpContent = this.HttpContent + this.CreatTableStyleCenter(0x29, 1);
}
else
{
this.HttpContent = this.HttpContent + this.CreatTableStyleCenter(20, 1);
}
this.HttpContent = this.HttpContent + "\t </td>";
this.HttpContent = this.HttpContent + " <td>";
this.StyleSelectStyle(node1.Nodes[num1], orientation1);
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>";
}
else
{
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 num2 = 1; num2 < (node1.Nodes.Count - 1); num2++)
{
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 num3 = 0; num3 < node1.Nodes.Count; num3++)
{
this.HttpContent = this.HttpContent + "<td align=Center>" + this.CreatTableStyleCenter(1, 20) + "</td>";
}
this.HttpContent = this.HttpContent + "</tr>";
}
this.HttpContent = this.HttpContent + "<tr>";
for (int num4 = 0; num4 < node1.Nodes.Count; num4++)
{
this.HttpContent = this.HttpContent + "<td valign=top >";
this.HttpContent = this.HttpContent + this.OrgNodeHtmlImg(node1.Nodes[num4]);
if (node1.Nodes[num4].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.StyleSelectStyle(node1.Nodes[num4], orientation1);
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>";
}
}
protected override void RenderContents(HtmlTextWriter output)
{
// this.DefaultStyle(out this.OrgNodeDemo);//添加默认组织图
this.CreatNodeStyle(this.OrgNodeDemo, this.OrgNodeOrientation);
if (this.HttpContent != null)
{
output.Write(this.HttpContent);
}
}
public override void RenderEndTag(HtmlTextWriter writer)
{
int num2 = writer.GetHashCode();
string text1 = num2.ToString();
if ((text1 == null) || (text1 == ""))
{
string text2;
if ((text2 = text1) == null)
{
goto Label_00C4;
}
text2 = string.IsInterned(text2);
if (text2 != "ROOT")
{
if (text2 == "GROUP")
{
text1 = this.ImageFolder + "X1Group.gif";
goto Label_00CA;
}
if (text2 == "ROLES")
{
text1 = this.ImageFolder + "X1Roles.gif";
goto Label_00CA;
}
if (text2 == "LOGIN")
{
text1 = this.ImageFolder + "X1Login.gif";
goto Label_00CA;
}
goto Label_00C4;
}
text1 = this.ImageFolder + "x1root.gif";
}
goto Label_00CA;
Label_00C4:
text1 = "";
Label_00CA:
this.OrgNodestring = (text1 == "") ? "" : ("<img border=0 src='" + text1 + "'>");
}
[Description("机构图的扩展方向是垂直的还是水平的"), Category("Appearance"), DefaultValue(""), Bindable(true)]
public Orientation ChartStyle
{
get
{
return this.OrgNodeOrientation;
}
set
{
this.OrgNodeOrientation = value;
}
}
[Description("存放图片的目录"), DefaultValue(""), Bindable(true), Category("Appearance")]
public string ImageFolder
{
get
{
if (this.ImgFolder == null)
{
this.ImgFolder = "images/";
}
this.ImgFolder = this.ImgFolder.Trim();
if (!this.ImgFolder.EndsWith(@"\") && !this.ImgFolder.EndsWith("/"))
{
this.ImgFolder = this.ImgFolder + "/";
}
return this.ImgFolder;
}
set
{
this.ImgFolder = value;
}
}
[Category("Appearance"), Description("机构图连线的颜色"), DefaultValue("")]
public Color LineColor
{
get
{
if (this.OrgNodeColor.IsEmpty)
{
this.OrgNodeColor = Color.Blue;
}
return this.OrgNodeColor;
}
set
{
this.OrgNodeColor = value;
}
}
[Description("机构图连线的宽度"), Category("Appearance"), DefaultValue("1px")]
public Unit LineWidth
{
get
{
return this.OrgNodeUnit;
}
set
{
this.OrgNodeUnit = value;
}
}
public OrgNode Node
{
get
{
return this.OrgNodeDemo;
}
set
{
this.OrgNodeDemo = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -