Interaction logic for StateImage.xaml
상속: System.Windows.Controls.UserControl
        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
            }));
        }
        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)
                        {
                            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);
                        double dOpacity = Convert.ToDouble(stateImageControl.LightLevel) / 100.00;
                        //Opacity is new and unknow in 044
                        stateImageControl.Opacity = dOpacity;
                        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);
                        tl.MouseRightButtonDown += new MouseButtonEventHandler(Timer_Label_MouseRightButtonDown);
                        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.BaseType == "USER CONTROL")
                {
                    string sUCType = obj.Property("Control Type").Value;
                    sUCType = sUCType.Replace("USER CONTROL ", "");
                    OSAE.Types.AvailablePlugin selectedPlugin = GlobalUserControls.OSAEUserControls.AvailablePlugins.Find(sUCType);
                    selectedPlugin.Instance.InitializeMainCtrl(obj);
                    UserControl ucC = new UserControl();
                    dynamic uc = new UserControl();
                    uc = selectedPlugin.Instance.mainCtrl;
                    uc.MouseRightButtonDown += new MouseButtonEventHandler(UserControl_MouseRightButtonDown);
                    canGUI.Children.Add(uc);
                    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(uc, dX);
                    Double dY = Convert.ToDouble(pY.Value);
                    Canvas.SetTop(uc, dY);
                    int dZ = Convert.ToInt32(pZOrder.Value);
                    Canvas.SetZIndex(uc, dZ);
                    uc.Location.X = dX;
                    uc.Location.Y = dY;
                    userControls.Add(uc);
                    //controlTypes.Add(uc.GetType());
                    controlTypes.Add(typeof(UserControl));
                    uc.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 Load_Objects(String sScreen)
        {
            String sStateMatch = "";
            String sImage = "";

            List<OSAE.OSAEObject> screenObjects = OSAEApi.GetObjectsByContainer(sScreen);

            foreach (OSAE.OSAEObject obj in screenObjects)
            {
                #region CONTROL STATE IMAGE
                if (obj.Type == "CONTROL STATE IMAGE")
                {
                    StateImage stateImageControl = new StateImage(obj);

                    foreach (OSAE.ObjectProperty 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 (aScreenObject(iLoop).Control_Type = "CONTROL METHOD IMAGE")
                //        iMethodImageCount = iMethodImageCount + 1
                //        aScreenObject(iLoop).Object_Name = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Object Name")
                //        aScreenObject(iLoop).Control_Index = iMethodImageCount
                //        aControlMethodImage(aControlMethodImage.Count).Tag = iLoop
                //        g_toolTip.SetToolTip(aControlMethodImage(iMethodImageCount), aScreenObject(iLoop).Object_Name)
                //        CMD.Parameters.Clear()
                //        try
                //        {
                //            sImage = OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Image");
                //            sImage = sImage.Replace(".\", "\");
                //            If File.Exists(gAppPath & sImage) Then sImage = gAppPath & sImage
                //            iZOrder = Val(OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "ZOrder"));
                //            iX = Val("" & OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "X"));
                //            iY = Val("" & OSAEApi.GetObjectProperty(aScreenObject(iLoop).Control_Name, "Y"));
                //            if (File.Exists(sImage))
                //            {
                //                aControlMethodImage(aScreenObject(iLoop).Control_Index).Image = Image.FromFile(sImage);
                //                aScreenObject(iLoop).Object_State = ""
                //                aControlMethodImage(aScreenObject(iLoop).Control_Index).Left = iX;
                //                aControlMethodImage(aScreenObject(iLoop).Control_Index).Top = iY;
                //                aControlMethodImage(aScreenObject(iLoop).Control_Index).Visible = True;
                //            }
                //            else
                //            {
                //                aControlMethodImage(aScreenObject(iLoop).Control_Index).Image = Nothing;
                //                aControlMethodImage(aScreenObject(iLoop).Control_Index).Visible = False;
                //            }
                //        }
                //         catch (MySqlException myerror)
                //        {
                //            MessageBox.Show("GUI Error Load_Objects 4: " + myerror.Message);
                //            CN.Close();
                //         }
                #endregion

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

                        OSAE.ObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.ObjectProperty pX = obj.Property("X");
                        OSAE.ObjectProperty 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 = OSAEApi.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
                        VideoStreamViewer vsv = new VideoStreamViewer(stream);
                        canGUI.Children.Add(vsv);
                        OSAE.ObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.ObjectProperty pX = obj.Property("X");
                        OSAE.ObjectProperty 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.ObjectProperty pZOrder = obj.Property("ZOrder");
                        OSAE.ObjectProperty pX = obj.Property("X");
                        OSAE.ObjectProperty 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;
                        controlTypes.Add(typeof(Weather));
                        wc.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                }
                #endregion

                //If iStateImageList.EndsWith(",") Then iStateImageList = iStateImageList.Substring(0, iStateImageList.Length - 1)
                //Timer1.Enabled = True
            }
        }