private void LoadControl(OSAEObject obj) { #region State Image if (obj.Type == "CONTROL STATE IMAGE") { // Create instance of the UserControl SimpleControl ASP.ctrlStateImage ctrl = (ASP.ctrlStateImage)LoadControl("~/controls/ctrlStateImage.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); UpdatePlaceholder.Controls.Add(ctrl); //stateImages.Add(ctrl); } #endregion #region Click Image else if (obj.Type == "CONTROL CLICK IMAGE") { // Create instance of the UserControl SimpleControl ASP.ctrlClickImage ctrl = (ASP.ctrlClickImage)LoadControl("~/controls/ctrlClickImage.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); StaticPlaceholder.Controls.Add(ctrl); } #endregion #region Navigation Image else if (obj.Type == "CONTROL NAVIGATION IMAGE") { // Create instance of the UserControl SimpleControl ASP.ctrlNavigationImage ctrl = (ASP.ctrlNavigationImage)LoadControl("~/controls/ctrlNavigationImage.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); StaticPlaceholder.Controls.Add(ctrl); } #endregion #region Property Label else if (obj.Type == "CONTROL PROPERTY LABEL") { // Create instance of the UserControl SimpleControl ASP.ctrlPropertyLabel ctrl = (ASP.ctrlPropertyLabel)LoadControl("~/controls/ctrlPropertyLabel.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); UpdatePlaceholder.Controls.Add(ctrl); } #endregion #region Timer Label else if (obj.Type == "CONTROL TIMER LABEL") { // Create instance of the UserControl SimpleControl ASP.ctrlTimerLabel ctrl = (ASP.ctrlTimerLabel)LoadControl("~/controls/ctrlTimerLabel.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); UpdatePlaceholder.Controls.Add(ctrl); } #endregion #region Camera Viewer else if (obj.Type == "CONTROL CAMERA VIEWER") { // Create instance of the UserControl SimpleControl ASP.ctrlEmbedded ctrl = (ASP.ctrlEmbedded)LoadControl("~/controls/ctrlEmbedded.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); //ctrl.initialize(); ctrl.Source = OSAEObjectManager.GetObjectByName(ctrl.screenObject.Property("Object Name").Value).Property("Stream Address").Value; ctrl.width = "400"; ctrl.height = "300"; StaticPlaceholder.Controls.Add(ctrl); } #endregion #region User Control else if (obj.BaseType == "USER CONTROL") { string sUCType = obj.Property("Control Type").Value; string ucName = sUCType.Replace("USER CONTROL ", ""); // Create instance of the UserControl SimpleControl dynamic ctrl = LoadControl("~/controls/usercontrols/" + ucName + "/ctrlUserControl.ascx") as System.Web.UI.UserControl; // Set the Public Properties ctrl.screenObject = obj; ctrl.initialize(); UpdatePlaceholder.Controls.Add(ctrl); } #endregion #region Browser Control else if (obj.Type == "CONTROL BROWSER") { // Create instance of the UserControl SimpleControl ASP.ctrlBrowser ctrl = (ASP.ctrlBrowser)LoadControl("~/controls/ctrlBrowser.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(obj.Name); StaticPlaceholder.Controls.Add(ctrl); } #endregion }
protected void Page_Load(object sender, EventArgs e) { List <ASP.ctrlStateImage> stateImages = new List <ASP.ctrlStateImage>(); DataSet ds = OSAESql.RunSQL("SELECT object_name, property_value, image_id FROM osae_v_object_property p INNER JOIN osae_images i ON i.image_name = p.property_value WHERE object_name = '" + Request.QueryString["id"] + "' AND property_name = 'Background Image'"); string screenName = ds.Tables[0].Rows[0]["object_name"].ToString(); OSAEObject screen = OSAEObjectManager.GetObjectByName(screenName); List <OSAEScreenControl> controls = OSAEScreenControlManager.GetScreenControls(screenName); imgBackground.ImageUrl = "imgHandler.aspx?ImageID=" + ds.Tables[0].Rows[0]["image_id"].ToString(); foreach (OSAEScreenControl sc in controls) { if (sc.ControlType == "CONTROL STATE IMAGE") { // Create instance of the UserControl SimpleControl ASP.ctrlStateImage ctrl = (ASP.ctrlStateImage)LoadControl("~/controls/ctrlStateImage.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(sc.ControlName); UpdatePlaceholder.Controls.Add(ctrl); //stateImages.Add(ctrl); } else if (sc.ControlType == "CONTROL METHOD IMAGE") { // Create instance of the UserControl SimpleControl ASP.ctrlMethodImage ctrl = (ASP.ctrlMethodImage)LoadControl("~/controls/ctrlMethodImage.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(sc.ControlName); StaticPlaceholder.Controls.Add(ctrl); } else if (sc.ControlType == "CONTROL NAVIGATION IMAGE") { // Create instance of the UserControl SimpleControl ASP.ctrlNavigationImage ctrl = (ASP.ctrlNavigationImage)LoadControl("~/controls/ctrlNavigationImage.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(sc.ControlName); StaticPlaceholder.Controls.Add(ctrl); } else if (sc.ControlType == "CONTROL PROPERTY LABEL") { // Create instance of the UserControl SimpleControl ASP.ctrlPropertyLabel ctrl = (ASP.ctrlPropertyLabel)LoadControl("~/controls/ctrlPropertyLabel.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(sc.ControlName); UpdatePlaceholder.Controls.Add(ctrl); } else if (sc.ControlType == "CONTROL TIMER LABEL") { // Create instance of the UserControl SimpleControl ASP.ctrlTimerLabel ctrl = (ASP.ctrlTimerLabel)LoadControl("~/controls/ctrlTimerLabel.ascx"); // Set the Public Properties ctrl.screenObject = OSAEObjectManager.GetObjectByName(sc.ControlName); UpdatePlaceholder.Controls.Add(ctrl); } //else if (sc.ControlType == "CONTROL CAMERA VIEWER") //{ // // Create instance of the UserControl SimpleControl // ASP.ctrlEmbedded ctrl = (ASP.ctrlEmbedded)LoadControl("~/controls/ctrlEmbedded.ascx"); // // Set the Public Properties // ctrl.screenObject = OSAEObjectManager.GetObjectByName(sc.ControlName); // ctrl.Source = OSAEObjectManager.GetObjectByName(ctrl.screenObject.Property("Object Name").Value).Property("Stream Address").Value; // ctrl.width = "400"; // ctrl.height = "300"; // StaticPlaceholder.Controls.Add(ctrl); //} } }