コード例 #1
0
        /// <summary>
        /// Updates the camera list from the thread manager.
        /// </summary>
        private void UpdateCameraList()
        {
            string selectedValue           = "";
            NameValueCollection cameraList = HikAlarmThreadManager.CameraNameList();

            if (cameraList.Count > 0)
            {
                selectedValue = cameraList.Get(0);
            }

            UpdateDropList("ListBoxCameras", ref cameraList, SelectedValue: selectedValue);
            ChangeCameraSelection(selectedValue);
        }
コード例 #2
0
        /// <summary>
        /// Add a new camera device to the HomeSeer configuration.
        /// </summary>
        /// <param name="name">The name for the HomeSeer device.</param>
        /// <param name="ipAddress">The IP address for the camera.</param>
        /// <param name="username">The username to use for the camera.</param>
        /// <param name="password">The password to use for the camera.</param>
        private void AddCameraButton(string name, string ipAddress, string username, string password)
        {
            if ((name == "") || (ipAddress == "") || (username == "") || (password == ""))
            {
                return;
            }

            int refId = plugin.CreateDeviceFromConfig(name, ipAddress, username, password);

            NameValueCollection cameraList = HikAlarmThreadManager.CameraNameList();

            UpdateDropList("ListBoxCameras", ref cameraList, SelectedValue: refId.ToString());
            ChangeCameraSelection(refId.ToString());
        }
コード例 #3
0
        /// <summary>
        /// Builds the web page body for the configuration page.
        /// The page has separate forms so that only the data in the appropriate form is returned when a button is pressed.
        /// </summary>
        private string BuildWebPageBody()
        {
            StringBuilder       stb        = new StringBuilder();
            NameValueCollection cameraList = HikAlarmThreadManager.CameraNameList();
            bool   allowEdit     = (cameraList.Count > 0);
            string editIpAddress = "";
            string editUsername  = "";
            string editPassword  = "";

            if (allowEdit)
            {
                plugin.GetDeviceParameters(cameraList.Get(0), ref editIpAddress, ref editUsername, ref editPassword);
                editPassword = "******";
            }

            try
            {
                stb.Append("<table width='1000' cellpadding='0' cellspacing='0' border='0'>");

                // Help button
                stb.Append(" <tr>");
                stb.Append("  <td></td>");
                stb.Append("  <td align='right'>");
                //stb.Append("   <a href='HikAlaramCheck%20Help%20File\\HikAlarmCheck-Help.htm'>Help Page</a>");
                stb.Append("  </td>");
                stb.Append(" </tr>");

                // Add new item section
                stb.Append(" <tr>");
                stb.Append("  <td colspan='2'>");
                stb.Append(PageBuilderAndMenu.clsPageBuilder.FormStart("frmAddCamera", "AddCamera", "Post"));
                stb.Append("   <table width='1000' cellpadding='0' cellspacing='0' style='border-right: black thin solid; border-top: black thin solid; border-left: black thin solid; border-bottom: black thin solid;'>");
                stb.Append("    <tr><td style='background-color: #Cdcdcd; text-align: center;'><br /></td></tr>");
                stb.Append("    <tr>");
                stb.Append("     <td align='center' style='background-color: #f5f5f5;'>");
                stb.Append("      <table width='100%'>");
                stb.Append("       <col width='100'><col width='100'>");
                stb.Append("       <tr><td><strong>Add New Camera:</strong></td></tr>");
                stb.Append("       <tr><td>Name:</td><td>" + BuildTextBox("TextBoxName") + "</td></tr>");
                stb.Append("       <tr><td>Ip Address:</td><td>" + BuildTextBox("TextBoxIpAddress") + "</td></tr>");
                stb.Append("       <tr><td>Username:</td><td>" + BuildTextBox("TextBoxUsername") + "</td></tr>");
                stb.Append("       <tr><td>Password:</td><td>" + BuildTextBox("TextBoxPassword") + "</td></tr>");
                stb.Append("       <tr><td></td><td>" + BuildButton("Add Camera", "ButAddCamera") + "</td></tr>");
                stb.Append("      </table>");
                stb.Append("     </td>");
                stb.Append("    </tr>");
                stb.Append("   </table>");
                stb.Append(PageBuilderAndMenu.clsPageBuilder.FormEnd());
                stb.Append("  </td>");
                stb.Append(" </tr>");

                // Select item to edit
                stb.Append(" <tr>");
                stb.Append("  <td colspan='2'>");
                stb.Append(PageBuilderAndMenu.clsPageBuilder.FormStart("frmEditCamera", "EditCamera", "Post"));
                stb.Append("   <table width='1000' cellpadding='0' cellspacing='0' style='border-right: black thin solid; border-top: none; border-left: black thin solid; border-bottom: black thin solid;'>");
                stb.Append("    <tr><td style='background-color: #Cdcdcd; text-align: center;'><br /></td></tr>");
                stb.Append("    <tr>");
                stb.Append("     <td align='center' style='background-color: #f5f5f5;'>");
                stb.Append("      <table width='100%'>");
                stb.Append("       <col width='100'><col width='100'>");
                stb.Append("       <tr><td><strong>Edit Camera:</strong></td><td>" + BuildDropList("ListBoxCameras", ref cameraList) + "</td></tr>");
                stb.Append("       <tr><td>Ip Address:</td><td>" + BuildTextBox("TextBoxIpAddressEdit", editIpAddress, allowEdit) + "</td></tr>");
                stb.Append("       <tr><td>Username:</td><td>" + BuildTextBox("TextBoxUsernameEdit", editUsername, allowEdit) + "</td></tr>");
                stb.Append("       <tr><td>Password:</td><td>" + BuildTextBox("TextBoxPasswordEdit", editPassword, allowEdit) + "</td></tr>");
                stb.Append("       <tr><td></td>");
                stb.Append("        <td align='left'>");
                stb.Append("         <table width='20%'>");
                stb.Append("          <col width='30'><col width='30'>");
                stb.Append("          <tr><td>" + BuildButton("Save", "ButSaveCamera", allowEdit) + "</td><td>" + BuildButton("Delete", "ButDeleteCamera", allowEdit) + "</td></tr>");
                stb.Append("         </table>");
                stb.Append("        </td>");
                stb.Append("      </table>");
                stb.Append("     </td>");
                stb.Append("    </tr>");
                stb.Append("   </table>");
                stb.Append(PageBuilderAndMenu.clsPageBuilder.FormEnd());
                stb.Append("  </td>");
                stb.Append(" </tr>");

                // End of table
                stb.Append("</table>");

                return(stb.ToString());
            }
            catch (Exception)
            {
            }
            return(null);
        }