<%@ Page Title="" Language="C#" MasterPageFile="~/Book/Book.master" AutoEventWireup="true" CodeBehind="RoomLayer.aspx.cs" Inherits="Book.Book.RoomLayer" %>
<%@ Register src="../UserControls/area.ascx" tagname="area" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cont_form" runat="server">
    <script src="../Javascript/jtopo-0.4.8-min.js"></script>





     <table class="table">
        <tr>
            <td>
                 
            </td>

            <td style="width:250px; padding-top:40px;">

                <ul class="nav nav-pills nav-stacked" role="tablist>
                    <li><a href="#">可以组建，单击添加</a></li>

                    <li>
  <a href="#" onclick='AddOffice();return false;'> 办公室 Office</a>
                    </li>

                    <asp:Repeater runat="server" ID="roomlist">
                        <ItemTemplate>

 <li>
  <a href="#" onclick="AddRoom(<%#Eval("id") %>,'<%#Eval("catname") %>');return false;"> <%#Eval("catname") %></a>
                    </li>
                            
                        </ItemTemplate>
                    </asp:Repeater>

                </ul>
              

            </td>
            <td>

                <div class="well">
                         <div class="pull-left">
                  
                             
    会议布局图  <uc1:area ID="area1" runat="server" OnAreaChanged="area1_changed" />

</div>
                    <div class="pull-right">
                        <asp:PlaceHolder runat="server" ID="pnl_hd">

                      
                           <input type="button"  value="保存"  onclick="save();" class="btn btn-primary"/>
          <input type="button"  value="清空"  onclick="clears();" class="btn btn-danger"/>
                              </asp:PlaceHolder>
                    </div>
                    <div class="clearfix"></div>
                </div>
               
               

                <canvas id="roomlayer" width="900px" height="450px"></canvas>

            </td>
        </tr>

    </table>





     
    <script src="../Javascript/roomlayer.js"></script>



    <script>
        function clears()
        {
            $.post("SaveRoomLayer.aspx",
             { json: "[]",aid:$("#ddl_area").val() },
             function (result) {
                 alert("操作成功");
                 window.location="RoomLayer.aspx";
             });
        }
        
        function save()
        {
            var _results = []; 
            var rooms= JTopo.stage.find("node");
            for (var i = 0; i < rooms.length; i++)
            {
                if (rooms[i].width > 20)
                {
                    var room = rooms[i]; 
                    _results.push({cx:room.cx,  cy:room.cy, fillColor:room.fillColor, text:room.text});

                }

            }
            var json = JSON.stringify(_results);

       
            $.post("SaveRoomLayer.aspx",
                { json: json,aid:$("#ddl_area").val() },
                function (result) {
                    alert("操作成功");
                });
              }



        var InitData = <%=initdata%>;

        
        function Init()
        { 
     
            for (var i = 0; i < InitData.length; i++)
            {
                InitRoom(InitData[i].text, InitData[i].cx, InitData[i].cy, InitData[i].fillColor);

            }

        }

        Init();

    </script>



</asp:Content>
