<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Domain.RoomTypeScene>" %>
<style type="text/css">
    #roomTypeSceneForm table th
    {
        font-weight: normal;
    }
</style>
<script type="text/javascript" src="/Scripts/room-type-index.js"></script>
<% switch ((int)Session["isCN"])
   {
       case 1: %>
<script type="text/javascript" src="/Scripts/en-US.js"></script>
<% break;
   case 2: %>
<script type="text/javascript" src="/Scripts/zh-TW.js"></script>
<% break;
   default: %>
<script type="text/javascript" src="/Scripts/zh-CN.js"></script>
<% break;
   } %>
<div class="easyui-layout" fit="true">
    <div data-options="region:'north',border:false" style="height: 130px;">
        <form id="roomTypeSceneForm" method="post" action="#">
        <input type="hidden" name="ID" value="<%: Model.ID %>" />
        <table style="margin: 1px auto;" cellpadding="1">
            <tr>
                <th>
                    <%: Html.Language("ChineseName")%>：
                </th>
                <td>
                    <input id="txtName" name="Name" class="easyui-validatebox textbox text" style="width: 140px;"
                        data-options="required:true" value='<%: Model.Name %>' />
                </td>
                <th>
                    <%: Html.Language("RoomType")%>：
                </th>
                <td>
                    <input id="cbxRoomType" name="RoomTypeID" class="easyui-combobox text" style="width: 150px;"
                        data-options="
								valueField: 'ID',
								textField: 'Name',
								required: true,
								panelHeight: 'auto',
								editable: false,
                                readonly: true,
								url: '/RoomType/LoadRoomType',
								value: <%: Model.RoomType == null ? "" : Model.RoomType.ID.ToString() %>
							" />
                </td>
            </tr>
            <tr>
                <th>
                    <%: Html.Language("AliasName")%>：
                </th>
                <td>
                    <input id="txtAliasName" name="AliasName" class="easyui-validatebox textbox text"
                        style="width: 140px;" data-options="required:false" value='<%: Model.AliasName %>' placeholder="<%: Html.Language("Flag1")%>" />
                </td>
                <th>
                    <%: Html.Language("Sort")%>
                </th>
                <td>
                    <input name="Sort" class="easyui-numberspinner text" value="1" style="width: 60px;"
                        data-options="required:true,min:1,value:<%: Model.Sort %>" />
                </td>
            </tr>
            <tr>
                <th>
                    <%: Html.Language("EnglishName")%>：
                </th>
                <td>
                    <input id="txtEnglishName" name="EnglishName" class="easyui-validatebox textbox text"
                        style="width: 140px;" data-options="required:false" value='<%: Model.EnglishName %>' />
                </td>
                <th>
                    <%: Html.Language("TWName")%>：
                </th>
                <td>
                    <input id="txtTWName" name="TWName" class="easyui-validatebox textbox text" style="width: 140px;"
                        data-options="required:false" value='<%: Model.TWName %>' />
                </td>
            </tr>
            <tr>
                <th>
                    <%: Html.Language("SceneType")%>：
                </th>
                <td>
                    <input type="radio" name="Type" value="0" onchange="sceneTypeOnchange(this)" <%: Model.Type == Domain.SceneType.Custom ? "checked='checked'" : "" %> /><%: Html.Language("CustomScene")%>
                    <input type="radio" name="Type" value="1" onchange="sceneTypeOnchange(this)" <%: Model.Type == Domain.SceneType.Command ? "checked='checked'" : "" %> /><%: Html.Language("CommandScene")%>
                </td>
                <th>
                    <%: Html.Language("SceneInstruction")%>：
                </th>
                <td>
                    <input id="txtGroupAddress" name="GroupAddress" class="easyui-validatebox textbox text"
                        style="width: 140px;" data-options="required:false" value='<%: Model.GroupAddress %>' />
                </td>
            </tr>
        </table>
        </form>
    </div>
    <div data-options="region:'center',border:false">
        <table id="dgDevice" class="easyui-datagrid" style="width: 100%;" data-options="
					toolbar: '#tb2',
					border: false,
					singleSelect: false,
					rownumbers: true,
					fit: false,
					fitColumns: false,
					striped: true,
					url: '/RoomTypeScene/LoadRoomTypeSceneModals/',
					queryParams: { roomTypeSceneID: <%: Model.ID %> },
					method: 'POST'
				">
            <thead>
                <tr>
                    <th data-options="field: 'ck', checkbox: true">
                    </th>
                    <th data-options="field: 'ModalAddress',align:'center'">
                        <%: Html.Language("ReturnAddress")%>
                    </th>
                    <th data-options="field: 'Name'">
                        <%: Html.Language("Name")%>
                    </th>
                    <th data-options="field: 'TypeName'">
                        <%: Html.Language("Type")%>
                    </th>
                    <th data-options="field: 'Status',align:'center',formatter: function(val) { return val == 1 ? lang.On : lang.Off; }">
                        <%: Html.Language("Status")%>
                    </th>
                    <th data-options="field: 'Brightness',align:'center',formatter: function(val) { return val + '%'; }">
                        <%: Html.Language("Brightness")%>/<%:Html.Language("Volume")%>
                    </th>
                    <th data-options="field: 'CurrentTemp',align:'center',formatter: function(val) { return val + '℃'; }">
                        <%: Html.Language("Temperature")%>
                    </th>
                    <th data-options="field: 'Mode',align:'center',formatter: formatterType">
                        <%: Html.Language("Mode")%>
                    </th>
                    <th data-options="field: 'FanSpeed',align:'center',formatter: 
                        function(val){
                            switch(val){
                                case 0:return lang.Automatic;
                                case 1:return lang.LowWindSpeed;
                                case 2:return lang.MediumWindSpeed;
                                case 3:return lang.HighWindSpeed;
                                default:return '';
                            }
                        }">
                        <%: Html.Language("AirPropertySpeed")%>
                    </th>
                    <th data-options="field: 'Valve',align:'center',formatter: 
                        function(val){
                            switch(val){
                                case 1:return lang.ValveOpen;
                                case 2:return lang.ValveClose;
                                default:return '';
                            }
                        }">
                        <%: Html.Language("Valve")%>
                    </th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="tb2">
        <div style="float: left;">
            <%: Html.Language("Device")%>
            <input id="cbxDevice" class="easyui-combogrid" style="width: 150px;" data-options="
				    editable:true,
				    idField: 'ID',
				    valueField: 'ID',
				    textField: 'Name',
				    panelWidth: 200,
				    fitColumns: true,
				    queryParams: { roomTypeId: <%: Model.RoomType != null ? Model.RoomType.ID : 0 %> },
                    url: '/RoomTypeScene/LoadDevices/',
				    onSelect: dgDeviceOnSelect,
				    columns:[[    
					    { field: 'Name', title: '<%: Html.Language("Name")%>' },
					    { field: 'ModalAddress', title: '<%: Html.Language("ReturnAddress")%>' },
					    { field: 'TypeName', title: lang.Type }
				    ]]  
			    " />
        </div>
        <div style="float: left; margin-left: 3px;">
            <%: Html.Language("Status")%>
            <input id="cbxStatus" class="easyui-combobox" style="width: 60px;" value="1" data-options="
				    editable:false,
				    panelHeight:'auto',
				    data:[
					    { value: 1, text: lang.Open, selected: true },
					    { value: 2, text: lang.Close }
				    ]" />
        </div>
        <div id="Brigh" style="display: none; float: left; margin-left: 3px;">
            <%: Html.Language("Brightness")%>
            <input id="txtBrightness" class="easyui-numberspinner" data-options="min:0,max:100,suffix:'%'"
                style="width: 60px;" value="100" />
        </div>
        <div id="volume" style="display: none; float: left; margin-left: 3px;">
            <%: Html.Language("Volume")%>
            <input id="txtVolume" class="easyui-numberspinner" data-options="min:0,max:10" style="width: 60px;"
                value="10" />
        </div>
        <div id="playmode" style="display: none; float: left; margin-left: 3px;">
            <%: Html.Language("Options")%>
            <input id="txtPlayMode" class="easyui-combobox" style="width: 65px; display: none;"
                value="1" data-options="
				    editable:false,
				    panelHeight:'auto',
                    panelWidth: 65,
				    data:[
					    { value: 1, text: lang.Music_Play, selected: true },
					    { value: 2, text: lang.Music_Pause },
					    { value: 3, text: lang.Music_PRE },
					    { value: 4, text: lang.Music_NEX },
					    { value: 5, text: lang.Volume_Up },
					    { value: 6, text: lang.Volume_Down }
				    ]" />
        </div>
        <div id="TVOptions" style="display: none; float: left; margin-left: 3px;">
            <%: Html.Language("Options")%>
            <input id="txtTV" class="easyui-combobox" style="width: 65px; display: none;" value="1"
                data-options="
				    editable:false,
				    panelHeight:'auto',
                    panelWidth: 65,
				    data:[
					    { value: 1, text: lang.Mute, selected: true },
					    { value: 2, text: lang.Suspend_Mode },
                        { value: 3, text: lang.Volume_Up },
                        { value: 4, text: lang.Volume_Down },
                        { value: 5, text: lang.Channel_Add },
                        { value: 6, text: lang.Channel_Reduce },
                        { value: 7, text: lang.Up },
                        { value: 8, text: lang.Down },
                        { value: 9, text: lang.Left },
                        { value: 10, text: lang.Right },
                        { value: 11, text: lang.OK },
                        { value: 12, text: lang.Homepage },
                        { value: 13, text: lang.Menu },
                        { value: 14, text: lang.Message_Source },
                        { value: 15, text: lang.LookBack }
				    ]" />
        </div>
        <div id="AicTemp" style="display: none; float: left; margin-left: 3px;">
            &nbsp;<input id="txtTemp" class="easyui-numberspinner" data-options="min:16,max:32,suffix:'℃'"
                style="width: 60px; display: none;" value="25" />
        </div>
        <div id="aicmode" style="display: none; float: left; margin-left: 3px;">
            <input id="txtAirmode" class="easyui-combobox" style="width: 55px; display: none;"
                value="1" data-options="
				    editable:false,
				    panelHeight:'auto',
                    panelWidth: 55,
				    data:[
					    { value: -1, text: lang.Mode, selected: true  },
                        { value: 1, text: lang.Refrigeration },
                        { value: 2, text: lang.Heating },
                        { value: 3, text: lang.BlowingIn }
				    ]" />
        </div>
        <div id="Airspeed" style="display: none; float: left; margin-left: 3px;">
            &nbsp;<input id="txtSpeed" class="easyui-combobox" style="width: 65px;" value="1"
                data-options="
				    editable:false,
				    panelHeight:'auto',
                    panelWidth: 55,
				    data:[
					    { value: -1, text: lang.FSpeed, selected: true },
                        { value: 0, text: lang.Automatic },
                        { value: 1, text: lang.LowWindSpeed },
                        { value: 2, text: lang.MediumWindSpeed },
                        { value: 3, text: lang.HighWindSpeed }
				    ]" />
        </div>
        <div id="Valve" style="display: none; float: left; margin-left: 3px; margin-top: 2px;">
            &nbsp;<input id="txtValve" class="easyui-combobox" style="width: 55px;" value="1"
                data-options="
				    editable:false,
				    panelHeight:'auto',
                    panelWidth: 55,
				    data:[
					    { value: -1, text: lang.ValveName, selected: true },
                        { value: 1, text: lang.ValveOpen },
                        { value: 2, text: lang.ValveClose }
				    ]" />
        </div>
        <div style="float: left; margin-left: 3px; margin-top: 2px;">
            <a href="javascript:void(0)" id="btnAddDevice" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true"
                onclick="addDevice()">
                <%: Html.Language("New")%></a> <a href="javascript:void(0)" id="btnRemoveDevice"
                    class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="delDevice()">
                    <%: Html.Language("Delete")%></a>
        </div>
    </div>
</div>
