<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeBehind="LabelLevelAnalay.aspx.cs" Inherits="PowerEasy.Module.General.WebSite.Admin.Template.LabelLevelAnalay" Title="标签层次分析" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CphNavigation" runat="server">
    <pe:ExtendedSiteMapPath ID="SmpNavigator" SiteMapProvider="AdminMapProvider" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CphContent" runat="server">
<style type="text/css">
canvas { border: 2px solid #000; float:left; margin-right: 20px; margin-bottom: 20px; }
#linkcontent{
        padding:0px;
        cursor:hand;
        position:absolute;
        z-index:900;
        border-right:1px solid #aaa;
        border-bottom:1px solid #aaa;
        border-top:1px solid #fff;
        border-left:1px solid #fff;
        font-size:13px;
        word-break:keep-all;
}
</style>
<script type="text/xaml" id="xaml">
<?xml version="1.0"?>
<Canvas xmlns="http://schemas.microsoft.com/client/2007"></Canvas>
</script>
<script type="text/javascript" id="uuCanvas.mini" src="<%=BasePath%>Admin/JS/excanvas/uuCanvas.mini.js"></script>
<script type="text/javascript">
<!--
function boot() {
  draw(document.getElementById('vmlcanvas').getContext('2d'));
}

function draw(ctx) {
  var w = <% =m_TemplateWidth.ToString() %>, h = <% =m_TemplateHight.ToString() %>;
  var strokeleft = 10,stroketop = 100,stroketoplevel = 25;
  var strokewidth = 175,strokeheight = 20;
  var fillText = [<% =outxmltext %>];
  var lablevel = new Array();
  
  fillty(ctx);

  for (i = 0, iz = fillText.length; i < iz; ++i) 
  {
      if(fillText[i] != null)
      {
	  var tt = fillText[i];
	  labellevel = tt.substring(0,tt.indexOf('|||'));
	  t1 = tt.indexOf('|||') + 3;
	  labelname = tt.substring(t1, tt.length);
          lasplit = labellevel.split('.');
          left = strokeleft + lasplit[0] * (strokewidth + 20);
          
          //画框
          if(lasplit[4] == "sql_sysquery" || lasplit[4] == "sql_sysstoredquery")
          {
              ctx.fillStyle = 'rgb(255,221,0)';
          }
          else if(lasplit[4] == "sql_outquery")
          {
              ctx.fillStyle = 'rgb(0,221,255)';
          }
          else if(lasplit[4] == "mdb_read" || lasplit[4] == "xsl_read")
          {
              ctx.fillStyle = 'rgb(0,0,221)';
          }
          else if(lasplit[4] == "orc_read")
          {
              ctx.fillStyle = 'rgb(221,0,255)';
          }
          else if(lasplit[4] == "odbc_read" || lasplit[4] == "ole_read")
          {
              ctx.fillStyle = 'rgb(255,0,221)';
          }
          else if(lasplit[4] == "static")
          {
              ctx.fillStyle = 'rgb(0,221,0)';
          }
          else if(lasplit[4] == "DataSource")
          {
              ctx.fillStyle = 'rgb(0,255,221)';
          }
          else if(lasplit[4] == "Field")
          {
              ctx.fillStyle = 'rgb(230,221,230)';
          }
          else
          {
              ctx.fillStyle = 'rgb(221,0,0)';
          }

          ctx.strokeRect(left, stroketop + i * stroketoplevel, strokewidth, strokeheight);
          ctx.fillRect(left, stroketop + i * stroketoplevel, strokewidth, strokeheight);

	  //增加连接层
          if(lasplit[4] != "Field")
          {
        	var linkleft = parseInt(left) + 12;
        	var linktop = stroketop + i * stroketoplevel + 51;
        	var ldiv=document.createElement("div");
        	ldiv.id="linkcontent";
                ldiv.value=labelname;
		ldiv.style.left = linkleft + "px";
		ldiv.style.top = linktop + "px";
        	ldiv.style.width = strokewidth + "px";
        	ldiv.style.height = strokeheight + "px";
        	ldiv.onmouseover=function(e){
                        e = window.event || e;
                        target = e.srcElement || e.target;
        	        target.style.backgroundColor = "red";
                        target.innerHTML = target.value;
        	}
        	ldiv.onmouseout=function(e){
                        e = window.event || e;
                        target = e.srcElement || e.target;
        	        target.style.backgroundColor = "";
			target.innerHTML = "";
        	}
        	ldiv.onclick=function(e){
                        e = window.event || e;
                        target = e.srcElement || e.target;
              		parent.jQuery("#newFrameTab").click();
                	var d = jQuery(parent.document);
                	d.find("#main_right").attr("src", "<%=BasePath%><%= PowerEasy.Foundation.SiteConfig.SiteOption.ManageDir %>/Template/Label.aspx?name=" + escape(target.value));
                	d.find("#left").attr("src", "<%=BasePath%><%= PowerEasy.Foundation.SiteConfig.SiteOption.ManageDir %>/Template/LabelGuide.aspx");
        	}
        	document.body.appendChild(ldiv);
          }

          //写文字
          ctx.fillStyle = "black";
          ctx.fillText(labelname, left + 5, (stroketop + 2) + i * stroketoplevel);

          //判断标签类型并增加显示
          if(lasplit[3] == "True")
          {
            ctx.fillStyle = 'rgb(255,0,0)';
            ctx.fillRect(left + 147, stroketop + i * stroketoplevel, strokewidth - 147, strokeheight);
            ctx.fillStyle = 'rgb(0,0,0)';
            ctx.fillText("ajax", left + 148, (stroketop + 2) + i * stroketoplevel);
          }

          if(lasplit[4] == "DataSource")
          {
            ctx.fillStyle = 'rgb(0,221,0)';
            ctx.fillRect(left + 149, stroketop + i * stroketoplevel, strokewidth - 149, strokeheight);
            ctx.fillStyle = 'rgb(0,0,0)';
            ctx.fillText("DS", left + 152, (stroketop + 2) + i * stroketoplevel);
          }

          if(lasplit[4] == "Field")
          {
            ctx.fillStyle = 'rgb(0,221,0)';
            ctx.fillRect(left + 140, stroketop + i * stroketoplevel, strokewidth - 140, strokeheight);
            ctx.fillStyle = 'rgb(0,0,0)';
            ctx.fillText("field", left + 141, (stroketop + 2) + i * stroketoplevel);
          }

          if(parseInt(lasplit[2]) > 0)
          {
            ctx.beginPath();
            ctx.moveTo(strokewidth + left,(stroketop + strokeheight / 2) + i * stroketoplevel);
            ctx.lineTo(strokewidth + left + 10,(stroketop + strokeheight / 2) + i * stroketoplevel);
            ctx.stroke();

	    //保存上级连线终止地址
            lablevel[parseInt(lasplit[0])] = (stroketop + strokeheight / 2) + i * stroketoplevel;
          }

          if(lasplit[0] > 0)
          {
            ctx.beginPath();
            ctx.moveTo(left,(stroketop + strokeheight / 2) + i * stroketoplevel);
            ctx.lineTo(left - 10,(stroketop + strokeheight / 2) + i * stroketoplevel);
            ctx.lineTo(left - 10,lablevel[parseInt(lasplit[0]) - 1]);
            ctx.stroke();
          }
      }
  }
}

//填充图样
function fillty(ctx) {
  ctx.fillStyle = 'rgb(255,255,255)';
  ctx.strokeRect(5,5,750,70);
  ctx.fillRect(5,5,750,70);

  ctx.fillStyle = 'rgb(0,221,0)';
  ctx.strokeRect(70,30,20,20);
  ctx.fillRect(70,30,20,20);

  ctx.fillStyle = 'rgb(255,221,0)';
  ctx.strokeRect(160,30,20,20);
  ctx.fillRect(160,30,20,20);

  ctx.fillStyle = 'rgb(0,221,255)';
  ctx.strokeRect(250,30,20,20);
  ctx.fillRect(250,30,20,20);

  ctx.fillStyle = 'rgb(0,0,221)';
  ctx.strokeRect(330,30,20,20);
  ctx.fillRect(330,30,20,20);

  ctx.fillStyle = 'rgb(221,0,255)';
  ctx.strokeRect(420,30,20,20);
  ctx.fillRect(420,30,20,20);

  ctx.fillStyle = 'rgb(221,0,0)';
  ctx.strokeRect(510,30,20,20);
  ctx.fillRect(510,30,20,20);
  
  ctx.fillStyle = 'rgb(0,255,221)';
  ctx.strokeRect(600,30,20,20);
  ctx.fillRect(600,30,20,20);

  ctx.fillStyle = 'rgb(230,221,230)';
  ctx.strokeRect(690,30,20,20);
  ctx.fillRect(690,30,20,20);
  
  ctx.textBaseline = "top";
  ctx.font = "9pt 黑体";
  ctx.fillStyle = 'rgb(0,0,0)'
  ctx.fillText("图例", 10, 12);
  ctx.fillText("静态标签", 55, 52);
  ctx.fillText("站内SQL标签", 132, 52);
  ctx.fillText("站外SQL标签", 225, 52);
  ctx.fillText("电子表格标签", 303, 52);
  ctx.fillText("Oracle标签", 402, 52);
  ctx.fillText("XML数据标签", 488, 52);
  ctx.fillText("数据源标签", 578, 52);  
  ctx.fillText("数据源标签字段", 656, 52);   
}

window.onload = function() {
  uuCanvas.ready(boot);
};
-->
</script>

<table style="width: 100%; margin: 0 auto;" cellpadding="2" cellspacing="1" class="border">
<tr>
      <td class="spacingtitle" colspan="2" align="center">
          <b><% =out_TemplateName %></b></td>
</tr>
</table>
<table style="width: 100%; margin: 0 auto;"><tr><td align="center">
      <canvas id="vmlcanvas" class="vml" width="830" height="<% =m_TemplateHight.ToString() %>"></canvas>
</td></tr></table>   
</asp:Content>