Property() 공개 메소드

public Property ( string prop ) : OSAE.OSAEObjectProperty
prop string
리턴 OSAE.OSAEObjectProperty
 // Code to Initialize your custom User Control
 public CustomUserControl(OSAEObject sObj, string ControlName)
 {
     InitializeComponent();
     _controlname = ControlName;
     screenObject = sObj;
     _mjpeg = new MjpegDecoder();
     _mjpeg.FrameReady += mjpeg_FrameReady;
     _mjpeg.Error += _mjpeg_Error;
     var imgsWidth = OSAEObjectPropertyManager.GetObjectPropertyValue(sObj.Property("Object Name").Value, "Width").Value;
     var imgsHeight = OSAEObjectPropertyManager.GetObjectPropertyValue(sObj.Property("Object Name").Value, "Height").Value;
     streamURI = OSAEObjectPropertyManager.GetObjectPropertyValue(sObj.Property("Object Name").Value, "Stream Address").Value;
     if (imgsWidth != "") { imgWidth = Convert.ToDouble(imgsWidth); }
     if (imgsHeight != "") { imgHeight = Convert.ToDouble(imgsHeight); }
     this.Width = imgWidth;
     this.Height = imgHeight;
     image.Width = imgWidth;
     image.Height = imgHeight;
     if (streamURI == null)
     {
         this.Log.Error("Stream Path Not Found: " + streamURI);
         message.Content = "Can Not Open: " + streamURI;
     }
     else
     {
         streamURI = renameingSys(streamURI);
         this.Log.Info("Streaming: " + streamURI);
         _mjpeg.ParseStream(new Uri(streamURI));
     }
 }
        private void updateObjectCoordsStateImg(OSAE.OSAEObject obj, string state, string X, string Y)
        {
            OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, state + " X", X, "GUI");
            OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, state + " Y", Y, "GUI");

            obj.Property(state + " X").Value = X;
            obj.Property(state + " Y").Value = Y;
        }
예제 #3
0
 public override void ProcessCommand(OSAEMethod method)
 {
     this.Log.Info("RECEIVED: " + method.ObjectName + " - " + method.MethodName);
     sMethod = method.MethodName;
     camName = method.ObjectName;
     camobj = OSAEObjectManager.GetObjectByName(camName);
     if (sMethod == "SNAPSHOT")
     {
         string i = DateTime.Now.ToLongTimeString();
         string j = DateTime.Now.ToShortDateString();
         i = i.Replace(":", "_");
         j = j.Replace("/", "_");
         i = j + "_" + i;
         i = i.Replace(" ", "");
         try
         {
             string camSnapShot = camobj.Property("camSnapShot").Value;
             string camSloc = camobj.Property("Save Location").Value;
             camSloc = camSloc + @"\";
             string filename = camSloc + camName + "_" + i + ".jpg";
             var URI = new Uri(renameingSys(camSnapShot, "",""));
             WebClient wc = new WebClient();
             wc.Headers["Content-Type"] = "application/x-www-form-urlencoded";
             wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCallback2);
             wc.DownloadFile(URI, filename);  
             this.Log.Info(filename + " was created");
         }
         catch (Exception ex)
         {
             this.Log.Error("An error occurred durning the snapshot!!!: " + ex.Message);
         }
     }
     else
     {
         try
         {
             WebClient wc = new WebClient();
             sProperty = camobj.Property(sMethod).Value.ToString();
             wc.Headers["Content-Type"] = "application/x-www-form-urlencoded";
             wc.UploadStringCompleted += new UploadStringCompletedEventHandler(UploadStringCallback2);
             sProperty = renameingSys(sProperty, method.Parameter1, method.Parameter2);
             wc.UploadStringAsync(new Uri(sProperty), "POST", "");
             this.Log.Info("SENT TO: " + method.ObjectName + ": " + sProperty);
         }
         catch (Exception ex)
         {
             this.Log.Error("An error occurred!!!: " + ex.Message);
         }
     }
     this.Log.Info("===================================================");
 }
        // Code to Initialize your custom User Control
        public CustomUserControl(OSAEObject sObj, string ControlName)
        {
            InitializeComponent();
            _controlname = ControlName;
            screenObject = sObj;
            objName = sObj.Property("Object Name").Value;
            CurState = OSAEObjectStateManager.GetObjectStateValue(objName).Value;
            LastStateChange = OSAEObjectStateManager.GetObjectStateValue(objName).LastStateChange;

            // Retreive any other information needed from the database here....

            // Execute the refreshControl function. See below!
            refreshControl();
        }
        private void Load_All_Weather()
        {
            weatherObj = OSAEObjectManager.GetObjectByName("Weather");
            lblCurTemp.Content = weatherObj.Property("Temp").Value + "°";
            lblConditions.Content = weatherObj.Property("Today Forecast").Value;
            lblLastUpd.Content = weatherObj.Property("Last Updated").Value;

            LoadLows();
            LoadHighs();
            LoadDayLabels();
            LoadDaySummaryLabels();
            LoadNightSummaryLabels();
            LoadDates();
            LoadImageControls();

            lblForcast.Text = "";
        }
        private void LoadControl(OSAE.OSAEObject obj)
        {
            this.Dispatcher.Invoke((Action)(() =>
            {
                String sStateMatch = "";

                #region CONTROL STATE IMAGE
                if (obj.Type == "CONTROL STATE IMAGE")
                {
                    StateImage stateImageControl = new StateImage(obj);

                    foreach (OSAE.OSAEObjectProperty p in obj.Properties)
                    {
                        if (p.Value.ToLower() == stateImageControl.CurState.ToLower())
                        {
                            sStateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' '));
                        }
                    }
                    int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                    stateImageControl.Location.X = Double.Parse(obj.Property(sStateMatch + " X").Value);
                    stateImageControl.Location.Y = Double.Parse(obj.Property(sStateMatch + " Y").Value);
                    canGUI.Children.Add(stateImageControl);
                    Canvas.SetLeft(stateImageControl, stateImageControl.Location.X);
                    Canvas.SetTop(stateImageControl, stateImageControl.Location.Y);
                    Canvas.SetZIndex(stateImageControl, dZ);
                    stateImages.Add(stateImageControl);
                    controlTypes.Add(typeof(StateImage));
                    stateImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                }
                #endregion

                #region CONTROL PROPERTY LABEL
                else if (obj.Type == "CONTROL PROPERTY LABEL")
                {
                    logging.AddToLog("Loading PropertyLabelControl: " + obj.Name, false);
                    PropertyLabel pl = new PropertyLabel(obj);
                    canGUI.Children.Add(pl);
                    int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                    pl.Location.X = Double.Parse(obj.Property("X").Value);
                    pl.Location.Y = Double.Parse(obj.Property("Y").Value);
                    Canvas.SetLeft(pl, pl.Location.X);
                    Canvas.SetTop(pl, pl.Location.Y);
                    Canvas.SetZIndex(pl, dZ);
                    propLabels.Add(pl);
                    controlTypes.Add(typeof(PropertyLabel));
                    pl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                }
                #endregion

                #region CONTROL STATIC LABEL
                else if (obj.Type == "CONTROL STATIC LABEL")
                {
                    logging.AddToLog("Loading PropertyLabelControl: " + obj.Name, false);
                    OSAE.UI.Controls.StaticLabel sl = new OSAE.UI.Controls.StaticLabel(obj);
                    canGUI.Children.Add(sl);
                    int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                    sl.Location.X = Double.Parse(obj.Property("X").Value);
                    sl.Location.Y = Double.Parse(obj.Property("Y").Value);
                    Canvas.SetLeft(sl, sl.Location.X);
                    Canvas.SetTop(sl, sl.Location.Y);
                    Canvas.SetZIndex(sl, dZ);
                    staticLabels.Add(sl);
                    controlTypes.Add(typeof(OSAE.UI.Controls.StaticLabel));
                    sl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                }
                #endregion

                #region CONTROL TIMER LABEL
                else if (obj.Type == "CONTROL TIMER LABEL")
                {
                    logging.AddToLog("Loading PropertyLabelControl: " + obj.Name, false);
                    OSAE.UI.Controls.TimerLabel tl = new OSAE.UI.Controls.TimerLabel(obj);
                    canGUI.Children.Add(tl);
                    int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                    tl.Location.X = Double.Parse(obj.Property("X").Value);
                    tl.Location.Y = Double.Parse(obj.Property("Y").Value);
                    Canvas.SetLeft(tl, tl.Location.X);
                    Canvas.SetTop(tl, tl.Location.Y);
                    Canvas.SetZIndex(tl, dZ);
                    timerLabels.Add(tl);
                    controlTypes.Add(typeof(OSAE.UI.Controls.TimerLabel));
                    tl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                }
                #endregion

                #region CONTROL METHOD IMAGE
                else if (obj.Type == "CONTROL METHOD IMAGE")
                {
                    try
                    {
                        MethodImage methodImageControl = new MethodImage(obj);
                        canGUI.Children.Add(methodImageControl);

                        OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.OSAEObjectProperty pX = obj.Property("X");
                        OSAE.OSAEObjectProperty pY = obj.Property("Y");
                        Double dX = Convert.ToDouble(pX.Value);
                        Canvas.SetLeft(methodImageControl, dX);
                        Double dY = Convert.ToDouble(pY.Value);
                        Canvas.SetTop(methodImageControl, dY);
                        int dZ = Convert.ToInt32(pZOrder.Value);
                        Canvas.SetZIndex(methodImageControl, dZ);
                        methodImageControl.Location.X = dX;
                        methodImageControl.Location.Y = dY;
                        methodImages.Add(methodImageControl);
                        controlTypes.Add(typeof(MethodImage));
                        methodImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (MySqlException myerror)
                    {
                        MessageBox.Show("GUI Error Load Navigation Image: " + myerror.Message);
                    }
                }
                #endregion

                #region CONTROL NAVIGATION IMAGE
                else if (obj.Type == "CONTROL NAVIGATION IMAGE")
                {
                    try
                    {
                        NavigationImage navImageControl = new NavigationImage(obj.Property("Screen").Value, obj);
                        navImageControl.MouseLeftButtonUp += new MouseButtonEventHandler(Navigaton_Image_MouseLeftButtonUp);
                        canGUI.Children.Add(navImageControl);

                        OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.OSAEObjectProperty pX = obj.Property("X");
                        OSAE.OSAEObjectProperty pY = obj.Property("Y");
                        Double dX = Convert.ToDouble(pX.Value);
                        Canvas.SetLeft(navImageControl, dX);
                        Double dY = Convert.ToDouble(pY.Value);
                        Canvas.SetTop(navImageControl, dY);
                        int dZ = Convert.ToInt32(pZOrder.Value);
                        Canvas.SetZIndex(navImageControl, dZ);
                        navImageControl.Location.X = dX;
                        navImageControl.Location.Y = dY;
                        navImages.Add(navImageControl);
                        controlTypes.Add(typeof(NavigationImage));
                        navImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (MySqlException myerror)
                    {
                        MessageBox.Show("GUI Error Load Navigation Image: " + myerror.Message);
                    }
                }
                #endregion

                #region CONTROL CAMERA VIEWER
                else if (obj.Type == "CONTROL CAMERA VIEWER")
                {
                    try
                    {
                        string stream = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
                        VideoStreamViewer vsv = new VideoStreamViewer(stream, obj);
                        canGUI.Children.Add(vsv);
                        OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.OSAEObjectProperty pX = obj.Property("X");
                        OSAE.OSAEObjectProperty pY = obj.Property("Y");
                        Double dX = Convert.ToDouble(pX.Value);
                        Canvas.SetLeft(vsv, dX);
                        Double dY = Convert.ToDouble(pY.Value);
                        Canvas.SetTop(vsv, dY);
                        int dZ = Convert.ToInt32(pZOrder.Value);
                        Canvas.SetZIndex(vsv, dZ);
                        vsv.Location.X = dX;
                        vsv.Location.Y = dY;
                        cameraViewers.Add(vsv);
                        controlTypes.Add(typeof(VideoStreamViewer));
                        vsv.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (MySqlException myerror)
                    {
                        MessageBox.Show("GUI Error Load Camera Viewer: " + myerror.Message);
                    }
                }
                #endregion

                #region USER CONTROL
                else if (obj.Type == "USER CONTROL")
                {
                    string sUCType = obj.Property("Control Type").Value;
                    if (sUCType == "USER CONTROL WEATHER")
                    {
                        Weather wc = new Weather(obj);
                        canGUI.Children.Add(wc);
                        OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.OSAEObjectProperty pX = obj.Property("X");
                        OSAE.OSAEObjectProperty pY = obj.Property("Y");
                        Double dX = Convert.ToDouble(pX.Value);
                        Canvas.SetLeft(wc, dX);
                        Double dY = Convert.ToDouble(pY.Value);
                        Canvas.SetTop(wc, dY);
                        int dZ = Convert.ToInt32(pZOrder.Value);
                        Canvas.SetZIndex(wc, dZ);

                        wc.Location.X = dX;
                        wc.Location.Y = dY;
                        userControls.Add(wc);
                        controlTypes.Add(typeof(Weather));
                        wc.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                }
                #endregion
            }));
        }
        public PropertyLabel(OSAEObject sObj)
        {
            InitializeComponent();
            screenObject = sObj;
            ObjectName = screenObject.Property("Object Name").Value;
            PropertyName = screenObject.Property("Property Name").Value;

            string sPropertyValue;
            if (string.Equals(PropertyName, "STATE", StringComparison.CurrentCultureIgnoreCase))
            {
                sPropertyValue = OSAEObjectStateManager.GetObjectStateValue(ObjectName).StateLabel;
                LastState = sPropertyValue;
                LastStateChange = OSAEObjectStateManager.GetObjectStateValue(ObjectName).LastStateChange;
                TimeSpan newSpan = (DateTime.Now - LastStateChange);
                sPropertyValue += " (" + newSpan.ToString(@"dd\ hh\:mm\:ss") + ")";
            }
            else
            {
                sPropertyValue = OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, PropertyName).Value;
            }
            string sBackColor = screenObject.Property("Back Color").Value;
            string sForeColor = screenObject.Property("Fore Color").Value;
            string sPrefix = screenObject.Property("Prefix").Value;
            string sSuffix = screenObject.Property("Suffix").Value;
            string iFontSize = screenObject.Property("Font Size").Value;
            string sFontName = screenObject.Property("Font Name").Value;

            if (sPropertyValue != "")
            {
                if (sBackColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
                        propLabel.Background = brush;
                    }
                    catch (Exception)
                    {}
                }
                if (sForeColor != "")
                {
                    try
                    {
                        BrushConverter conv = new BrushConverter();
                        SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
                        propLabel.Foreground = brush;
                    }
                    catch (Exception)
                    {}
                }
                if (iFontSize != "")
                {
                    try
                    {
                        propLabel.FontSize = Convert.ToDouble(iFontSize);
                    }
                    catch (Exception)
                    {}
                }
                if (sFontName != "")
                {
                    try
                    {
                        propLabel.FontFamily = new FontFamily(sFontName);
                    }
                    catch (Exception)
                    {}
                }
                propLabel.Content = sPrefix + sPropertyValue + sSuffix;
            }
            else
                propLabel.Content = "";
        }
예제 #8
0
        private void LoadControl(OSAE.OSAEObject obj)
        {
            this.Dispatcher.Invoke((Action)(() =>
            {
                String sStateMatch = "";

                #region CONTROL STATE IMAGE
                if (obj.Type == "CONTROL STATE IMAGE")
                {
                    StateImage stateImageControl = new StateImage(obj);

                    foreach (OSAE.OSAEObjectProperty p in obj.Properties)
                    {
                        try
                        {
                            if (p.Value.ToLower() == stateImageControl.CurState.ToLower())
                            {
                                sStateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' '));
                            }
                        }
                        catch (Exception ex)
                        {
                            this.Log.Error("Error finding object ", ex);
                            return;
                        }
                    }
                    try
                    {
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        stateImageControl.MouseRightButtonDown += new MouseButtonEventHandler(State_Image_MouseRightButtonDown);
                        stateImageControl.Location.X = Double.Parse(obj.Property(sStateMatch + " X").Value);
                        stateImageControl.Location.Y = Double.Parse(obj.Property(sStateMatch + " Y").Value);
                        canGUI.Children.Add(stateImageControl);
                        Canvas.SetLeft(stateImageControl, stateImageControl.Location.X);
                        Canvas.SetTop(stateImageControl, stateImageControl.Location.Y);
                        Canvas.SetZIndex(stateImageControl, dZ);
                        stateImages.Add(stateImageControl);
                        controlTypes.Add(typeof(StateImage));
                        stateImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                        this.Log.Error("Error updating screenObject", ex);
                        return;
                    }
                }
                #endregion

                #region CONTROL PROPERTY LABEL
                else if (obj.Type == "CONTROL PROPERTY LABEL")
                {
                    this.Log.Debug("Loading PropertyLabelControl: " + obj.Name);
                    try
                    {
                        PropertyLabel pl = new PropertyLabel(obj);
                        pl.MouseRightButtonDown += new MouseButtonEventHandler(Property_Label_MouseRightButtonDown);
                        canGUI.Children.Add(pl);
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        pl.Location.X = Double.Parse(obj.Property("X").Value);
                        pl.Location.Y = Double.Parse(obj.Property("Y").Value);
                        Canvas.SetLeft(pl, pl.Location.X);
                        Canvas.SetTop(pl, pl.Location.Y);
                        Canvas.SetZIndex(pl, dZ);
                        propLabels.Add(pl);
                        controlTypes.Add(typeof(PropertyLabel));
                        pl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                        this.Log.Error("Error updating PropertyLabelControl", ex);
                        return;
                    }
                }
                #endregion

                #region CONTROL STATIC LABEL
                else if (obj.Type == "CONTROL STATIC LABEL")
                {
                    this.Log.Debug("Loading PropertyLabelControl: " + obj.Name);
                    try
                    {
                        OSAE.UI.Controls.StaticLabel sl = new OSAE.UI.Controls.StaticLabel(obj);
                        canGUI.Children.Add(sl);
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        sl.Location.X = Double.Parse(obj.Property("X").Value);
                        sl.Location.Y = Double.Parse(obj.Property("Y").Value);
                        Canvas.SetLeft(sl, sl.Location.X);
                        Canvas.SetTop(sl, sl.Location.Y);
                        Canvas.SetZIndex(sl, dZ);
                        staticLabels.Add(sl);
                        controlTypes.Add(typeof(OSAE.UI.Controls.StaticLabel));
                        sl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                        this.Log.Error("Error updating PropertyLabelControl", ex);
                        return;
                    }
                }
                #endregion

                #region CONTROL TIMER LABEL
                else if (obj.Type == "CONTROL TIMER LABEL")
                {
                    this.Log.Debug("Loading PropertyTimerControl: " + obj.Name);
                    try
                    {
                        OSAE.UI.Controls.TimerLabel tl = new OSAE.UI.Controls.TimerLabel(obj);
                        canGUI.Children.Add(tl);
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        tl.Location.X = Double.Parse(obj.Property("X").Value);
                        tl.Location.Y = Double.Parse(obj.Property("Y").Value);
                        Canvas.SetLeft(tl, tl.Location.X);
                        Canvas.SetTop(tl, tl.Location.Y);
                        Canvas.SetZIndex(tl, dZ);
                        timerLabels.Add(tl);
                        controlTypes.Add(typeof(OSAE.UI.Controls.TimerLabel));
                        tl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                        this.Log.Error("Error updating PropertyTimerControl", ex);
                        return;
                    }
                }
                #endregion

                #region CONTROL CLICK IMAGE
                else if (obj.Type == "CONTROL CLICK IMAGE")
                {
                    try
                    {
                        ClickImage ClickImageControl = new ClickImage(obj);
                        ClickImageControl.MouseRightButtonDown += new MouseButtonEventHandler(Click_Image_MouseRightButtonDown);
                        canGUI.Children.Add(ClickImageControl);

                        OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.OSAEObjectProperty pX = obj.Property("X");
                        OSAE.OSAEObjectProperty pY = obj.Property("Y");
                        Double dX = Convert.ToDouble(pX.Value);
                        Canvas.SetLeft(ClickImageControl, dX);
                        Double dY = Convert.ToDouble(pY.Value);
                        Canvas.SetTop(ClickImageControl, dY);
                        int dZ = Convert.ToInt32(pZOrder.Value);
                        Canvas.SetZIndex(ClickImageControl, dZ);
                        ClickImageControl.Location.X = dX;
                        ClickImageControl.Location.Y = dY;
                        clickImages.Add(ClickImageControl);
                        controlTypes.Add(typeof(ClickImage));
                        ClickImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (MySqlException myerror)
                    {
                        MessageBox.Show("GUI Error Load Click Image: " + myerror.Message);
                    }
                }
                #endregion

                #region CONTROL NAVIGATION IMAGE
                else if (obj.Type == "CONTROL NAVIGATION IMAGE")
                {
                    try
                    {
                        NavigationImage navImageControl = new NavigationImage(obj.Property("Screen").Value, obj);
                        navImageControl.MouseLeftButtonUp += new MouseButtonEventHandler(Navigaton_Image_MouseLeftButtonUp);
                        navImageControl.MouseRightButtonDown += new MouseButtonEventHandler(Navigaton_Image_MouseRightButtonDown);

                        canGUI.Children.Add(navImageControl);

                        OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.OSAEObjectProperty pX = obj.Property("X");
                        OSAE.OSAEObjectProperty pY = obj.Property("Y");
                        Double dX = Convert.ToDouble(pX.Value);
                        Canvas.SetLeft(navImageControl, dX);
                        Double dY = Convert.ToDouble(pY.Value);
                        Canvas.SetTop(navImageControl, dY);
                        int dZ = Convert.ToInt32(pZOrder.Value);
                        Canvas.SetZIndex(navImageControl, dZ);
                        navImageControl.Location.X = dX;
                        navImageControl.Location.Y = dY;
                        navImages.Add(navImageControl);
                        controlTypes.Add(typeof(NavigationImage));
                        navImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (MySqlException myerror)
                    {
                        MessageBox.Show("GUI Error Load Navigation Image: " + myerror.Message);
                    }
                }
                #endregion

                #region CONTROL CAMERA VIEWER
                else if (obj.Type == "CONTROL CAMERA VIEWER")
                {
                    try
                    {
                        string stream = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
                        VideoStreamViewer vsv = new VideoStreamViewer(stream, obj);
                        canGUI.Children.Add(vsv);
                        OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.OSAEObjectProperty pX = obj.Property("X");
                        OSAE.OSAEObjectProperty pY = obj.Property("Y");
                        Double dX = Convert.ToDouble(pX.Value);
                        Canvas.SetLeft(vsv, dX);
                        Double dY = Convert.ToDouble(pY.Value);
                        Canvas.SetTop(vsv, dY);
                        int dZ = Convert.ToInt32(pZOrder.Value);
                        Canvas.SetZIndex(vsv, dZ);
                        vsv.Location.X = dX;
                        vsv.Location.Y = dY;
                        cameraViewers.Add(vsv);
                        controlTypes.Add(typeof(VideoStreamViewer));
                        vsv.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (MySqlException myerror)
                    {
                        MessageBox.Show("GUI Error Load Camera Viewer: " + myerror.Message);
                    }
                }
                #endregion

                #region USER CONTROL
                else if (obj.Type == "USER CONTROL")
                {
                    string sUCType = obj.Property("Control Type").Value;
                    if (sUCType == "USER CONTROL WEATHER")
                    {
                        Weather wc = new Weather(obj);
                        canGUI.Children.Add(wc);
                        OSAE.OSAEObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.OSAEObjectProperty pX = obj.Property("X");
                        OSAE.OSAEObjectProperty pY = obj.Property("Y");
                        Double dX = Convert.ToDouble(pX.Value);
                        Canvas.SetLeft(wc, dX);
                        Double dY = Convert.ToDouble(pY.Value);
                        Canvas.SetTop(wc, dY);
                        int dZ = Convert.ToInt32(pZOrder.Value);
                        Canvas.SetZIndex(wc, dZ);

                        wc.Location.X = dX;
                        wc.Location.Y = dY;
                        userControls.Add(wc);
                        controlTypes.Add(typeof(Weather));
                        wc.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                }
                #endregion

                #region CONTROL BROWSER
                else if (obj.Type == "CONTROL BROWSER")
                {
                    this.Log.Debug("Loading BrowserControl: " + obj.Name);
                    try
                    {
                        OSAE.UI.Controls.BrowserFrame bf = new OSAE.UI.Controls.BrowserFrame(obj);
                        bf.MouseRightButtonDown += new MouseButtonEventHandler(Broswer_Control_MouseRightButtonDown);
                        //OSAE.UI.Controls.StaticLabel sl = new OSAE.UI.Controls.StaticLabel(obj);
                        canGUI.Children.Add(bf);
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        bf.Location.X = Double.Parse(obj.Property("X").Value);
                        bf.Location.Y = Double.Parse(obj.Property("Y").Value);
                        bf.Width = Double.Parse(obj.Property("Width").Value);
                        bf.Height = Double.Parse(obj.Property("Height").Value);
                        Canvas.SetLeft(bf, bf.Location.X);
                        Canvas.SetTop(bf, bf.Location.Y);
                        Canvas.SetZIndex(bf, dZ);
                        browserFrames.Add(bf);
                        controlTypes.Add(typeof(OSAE.UI.Controls.BrowserFrame));
                        //
                        bf.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                        this.Log.Error("Error updating BrowserControl", ex);
                        return;
                    }
                }
                #endregion
            }));
        }
    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
    }
        public static OSAEAdmin GetAdminSettings()
        {
            OSAEAdmin  adSets  = new OSAEAdmin();
            OSAEObject oObject = OSAEObjectManager.GetObjectByName("WEB SERVER");

            adSets.ScreenTrust              = Convert.ToInt32(oObject.Property("Screen Trust").Value);
            adSets.defaultScreen            = Convert.ToString(oObject.Property("Screen Trust").Value);
            adSets.ObjectsTrust             = Convert.ToInt32(oObject.Property("Objects Trust").Value);
            adSets.ObjectsAddTrust          = Convert.ToInt32(oObject.Property("Objects Add Trust").Value);
            adSets.ObjectsUpdateTrust       = Convert.ToInt32(oObject.Property("Objects Update Trust").Value);
            adSets.ObjectsDeleteTrust       = Convert.ToInt32(oObject.Property("Objects Delete Trust").Value);
            adSets.AnalyticsTrust           = Convert.ToInt32(oObject.Property("Analytics Trust").Value);
            adSets.LogsTrust                = Convert.ToInt32(oObject.Property("Logs Trust").Value);
            adSets.LogsClearTrust           = Convert.ToInt32(oObject.Property("Logs Clear Trust").Value);
            adSets.EventLogTrust            = Convert.ToInt32(oObject.Property("Event Log Trust").Value);
            adSets.MethodLogTrust           = Convert.ToInt32(oObject.Property("Method Log Trust").Value);
            adSets.ServerLogTrust           = Convert.ToInt32(oObject.Property("Server Log Trust").Value);
            adSets.DebugLogTrust            = Convert.ToInt32(oObject.Property("Debug Log Trust").Value);
            adSets.ValuesTrust              = Convert.ToInt32(oObject.Property("Values Trust").Value);
            adSets.ManagementTrust          = Convert.ToInt32(oObject.Property("Management Trust").Value);
            adSets.ObjectTypeTrust          = Convert.ToInt32(oObject.Property("ObjectType Trust").Value);
            adSets.ObjectTypeAddTrust       = Convert.ToInt32(oObject.Property("ObjectType Add Trust").Value);
            adSets.ObjectTypeUpdateTrust    = Convert.ToInt32(oObject.Property("ObjectType Update Trust").Value);
            adSets.ObjectTypeDeleteTrust    = Convert.ToInt32(oObject.Property("ObjectType Delete Trust").Value);
            adSets.ScriptTrust              = Convert.ToInt32(oObject.Property("Script Trust").Value);
            adSets.ScriptAddTrust           = Convert.ToInt32(oObject.Property("Script Add Trust").Value);
            adSets.ScriptUpdateTrust        = Convert.ToInt32(oObject.Property("Script Update Trust").Value);
            adSets.ScriptDeleteTrust        = Convert.ToInt32(oObject.Property("Script Delete Trust").Value);
            adSets.ScriptObjectAddTrust     = Convert.ToInt32(oObject.Property("Script Object Add Trust").Value);
            adSets.ScriptObjectTypeAddTrust = Convert.ToInt32(oObject.Property("Script ObjectType Add Trust").Value);
            adSets.PatternTrust             = Convert.ToInt32(oObject.Property("Pattern Trust").Value);
            adSets.PatternAddTrust          = Convert.ToInt32(oObject.Property("Pattern Add Trust").Value);
            adSets.PatternUpdateTrust       = Convert.ToInt32(oObject.Property("Pattern Update Trust").Value);
            adSets.PatternDeleteTrust       = Convert.ToInt32(oObject.Property("Pattern Delete Trust").Value);
            adSets.ReaderTrust              = Convert.ToInt32(oObject.Property("Reader Trust").Value);
            adSets.ReaderAddTrust           = Convert.ToInt32(oObject.Property("Reader Add Trust").Value);
            adSets.ReaderUpdateTrust        = Convert.ToInt32(oObject.Property("Reader Update Trust").Value);
            adSets.ReaderDeleteTrust        = Convert.ToInt32(oObject.Property("Reader Delete Trust").Value);
            adSets.ScheduleTrust            = Convert.ToInt32(oObject.Property("Schedule Trust").Value);
            adSets.ScheduleAddTrust         = Convert.ToInt32(oObject.Property("Schedule Add Trust").Value);
            adSets.ScheduleUpdateTrust      = Convert.ToInt32(oObject.Property("Schedule Update Trust").Value);
            adSets.ScheduleDeleteTrust      = Convert.ToInt32(oObject.Property("Schedule Delete Trust").Value);
            adSets.ImagesTrust              = Convert.ToInt32(oObject.Property("Images Trust").Value);
            adSets.ImagesAddTrust           = Convert.ToInt32(oObject.Property("Images Add Trust").Value);
            adSets.ImagesDeleteTrust        = Convert.ToInt32(oObject.Property("Images Delete Trust").Value);
            adSets.ConfigTrust              = Convert.ToInt32(oObject.Property("Config Trust").Value);
            return(adSets);
        }
        public CustomUserControl(OSAEObject sObj, string ControlName, string appName, string user)
        {
            InitializeComponent();
            sizes[0] = 90;
            sizes[1] = 157;
            sizes[2] = 220;
            sizes[3] = 295;
            sizes[4] = 365;
            sizes[5] = 435;
            sizes[6] = 504;
            sizes[7] = 574;

            gAppName = appName;
            currentUser = user;
            _controlname = ControlName;
            screenObject = sObj;
            objName = sObj.Property("Object Name").Value;

            try
            {
                //ControlWidth = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Width").Value);
                ControlHeight = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Height").Value);
                maxDays = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Max Days").Value);
            }
            catch (Exception ex)
            { }

            string sBackColor = screenObject.Property("Back Color").Value;
            string sForeColor = screenObject.Property("Fore Color").Value;
            string iFontSize = screenObject.Property("Font Size").Value;
            string sFontName = screenObject.Property("Font Name").Value;
            bool minimized = Convert.ToBoolean( screenObject.Property("Minimized").Value);

            if (minimized)
            {
                sMode = "Min";
                this.Width = sizes[0];
                ControlWidth = sizes[0];
                OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Width", sizes[0].ToString(), gAppName);
            }
            else
            {
                sMode = "Max";
                this.Width = sizes[maxDays];
                ControlWidth = sizes[maxDays];
                OSAEObjectPropertyManager.ObjectPropertySet(screenObject.Name, "Width", sizes[maxDays].ToString(), gAppName);
            }

            if (sBackColor != "")
            {
                try
                {
                    BrushConverter conv = new BrushConverter();
                    SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
                    this.Background = brush;
                }
                catch (Exception)
                { }
            }
            if (sForeColor != "")
            {
                try
                {
                    BrushConverter conv = new BrushConverter();
                    SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
                    lblCurTemp.Foreground = brush;
                    lblConditions.Foreground = brush;
                    lblDay1.Foreground = brush;
                    lblDay2.Foreground = brush;
                    lblDay3.Foreground = brush;
                    lblDay4.Foreground = brush;
                    lblDay5.Foreground = brush;
                    lblForcast.Foreground = brush;
                }
                catch (Exception)
                { }
            }
            if (iFontSize != "")
            {
                try
                {
                    lblConditions.FontSize = Convert.ToDouble(iFontSize);
                    lblDay1.FontSize = Convert.ToDouble(iFontSize) - 1;
                    lblDay2.FontSize = Convert.ToDouble(iFontSize) - 1;
                    lblDay3.FontSize = Convert.ToDouble(iFontSize) - 1;
                    lblDay4.FontSize = Convert.ToDouble(iFontSize) - 1;
                    lblDay5.FontSize = Convert.ToDouble(iFontSize) - 1;
                    lblDay6.FontSize = Convert.ToDouble(iFontSize) - 1;
                    lblDay7.FontSize = Convert.ToDouble(iFontSize) - 1;
                    lblForcast.FontSize = Convert.ToDouble(iFontSize);
                }
                catch (Exception)
                { }
            }
            if (sFontName != "")
            {
                try
                {
                    lblConditions.FontFamily = new FontFamily(sFontName);
                    lblDay1.FontFamily = new FontFamily(sFontName);
                    lblDay2.FontFamily = new FontFamily(sFontName);
                    lblDay3.FontFamily = new FontFamily(sFontName);
                    lblDay4.FontFamily = new FontFamily(sFontName);
                    lblDay5.FontFamily = new FontFamily(sFontName);
                    lblDay6.FontFamily = new FontFamily(sFontName);
                    lblDay7.FontFamily = new FontFamily(sFontName);
                    lblForcast.FontFamily = new FontFamily(sFontName);
                }
                catch (Exception)
                { }
            }

            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(timMain_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 30, 0);
            dispatcherTimer.Start();
            Load_All_Weather();
        }
        // Code to Initialize your custom User Control
        public CustomUserControl(OSAEObject sObj, string ControlName, string appName, string user)
        {
            InitializeComponent();
            gAppName = appName;
            currentUser = user;
            _controlname = ControlName;
            screenObject = sObj;
            objName = sObj.Property("Object Name").Value;
            DataSet ds = OSAEObjectStateManager.ObjectStateListGet(objName);
            if (ds.Tables[0].Rows.Count > 0)
            {
                State1Name = ds.Tables[0].Rows[0]["state_name"].ToString();
                State1Label = ds.Tables[0].Rows[0]["state_label"].ToString();
            }
            if (ds.Tables[0].Rows.Count > 1)
            {
                State2Name = ds.Tables[0].Rows[1]["state_name"].ToString();
                State2Label = ds.Tables[0].Rows[1]["state_label"].ToString();
            }
            CurState = OSAEObjectStateManager.GetObjectStateValue(objName).Value;
            LastStateChange = OSAEObjectStateManager.GetObjectStateValue(objName).LastStateChange;
            try
            {
                ControlWidth = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Width").Value);
                ControlHeight = Convert.ToInt32(OSAEObjectPropertyManager.GetObjectPropertyValue(screenObject.Name, "Height").Value);
            }
            catch (Exception ex)
            { }

            string sBackColor = screenObject.Property("Back Color").Value;
            string sForeColor = screenObject.Property("Fore Color").Value;
            string iFontSize = screenObject.Property("Font Size").Value;
            string sFontName = screenObject.Property("Font Name").Value;
            if (sBackColor != "")
            {
                try
                {
                    BrushConverter conv = new BrushConverter();
                    SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
                    btnState.Background = brush;
                }
                catch (Exception)
                { }
            }
            if (sForeColor != "")
            {
                try
                {
                    BrushConverter conv = new BrushConverter();
                    SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
                    btnState.Foreground = brush;
                }
                catch (Exception)
                { }
            }
            if (iFontSize != "")
            {
                try
                { btnState.FontSize = Convert.ToDouble(iFontSize); }
                catch (Exception)
                { }
            }
            if (sFontName != "")
            {
                try
                { btnState.FontFamily = new FontFamily(sFontName); }
                catch (Exception)
                { }
            }
            //propLabel.Content = sPrefix + sPropertyValue + sSuffix;

            Update_Button();
        }