GetImage() public method

Gets an image from the DB
public GetImage ( int imageId ) : OSAEImage
imageId int The id of the image to get
return OSAEImage
Example #1
0
        public void Load_Screen(string sScreen)
        {
            try
            {
                while (updatingScreen)
                {
                    System.Threading.Thread.Sleep(100);
                }
                loadingScreen = true;
                //this.Log.Debug("Loading screen: " + sScreen);

                stateImages.Clear();
                propLabels.Clear();
                navImages.Clear();
                clickImages.Clear();
                cameraViewers.Clear();
                canGUI.Children.Clear();
                browserFrames.Clear();

                gCurrentScreen = sScreen;
                OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Current Screen", sScreen, "GUI");
                OSAE.OSAEImageManager imgMgr = new OSAE.OSAEImageManager();
                string         imgID         = OSAEObjectPropertyManager.GetObjectPropertyValue(sScreen, "Background Image").Value;
                OSAE.OSAEImage img           = imgMgr.GetImage(imgID);

                //sPath = OSAEApi.APIpath + OSAEApi.GetObjectPropertyValue(sScreen, "Background Image").Value;
                //byte[] byteArray = File.ReadAllBytes(sPath);

                if (img.Data != null)
                {
                    var imageStream = new MemoryStream(img.Data);
                    var bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = imageStream;
                    bitmapImage.EndInit();
                    canGUI.Background = new ImageBrush(bitmapImage);
                    canGUI.Height     = bitmapImage.Height;
                    canGUI.Width      = bitmapImage.Width;
                }

                //Thread threadLoad = new Thread(() => Load_Objects(sScreen));
                //threadLoad.Start();

                Load_Objects(sScreen);
                loadingScreen = false;

                //this.Log.Debug("Loading screen complete: " + sScreen);
            }
            catch (Exception ex)
            {
                this.Log.Error("Failed to load screen: " + sScreen, ex);
            }
        }
        public void Load_Screen(string sScreen)
        {
            _timer.Stop();
            try
            {
                loadingScreen = true;
                while (updatingScreen)
                {
                    System.Threading.Thread.Sleep(100);
                }

                stateImages.Clear();
                propLabels.Clear();
                navImages.Clear();
                clickImages.Clear();
                cameraViewers.Clear();
                canGUI.Children.Clear();
                browserFrames.Clear();
                controlTypes.Clear();

                gCurrentScreen = sScreen;
                OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Current Screen", sScreen, "GUI");
                OSAE.OSAEImageManager imgMgr = new OSAE.OSAEImageManager();
                string imgID = OSAEObjectPropertyManager.GetObjectPropertyValue(sScreen, "Background Image").Value;
                OSAE.OSAEImage img = imgMgr.GetImage(imgID);

                if (img.Data != null)
                {
                    var imageStream = new MemoryStream(img.Data);
                    var bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = imageStream;
                    bitmapImage.EndInit();
                    canGUI.Background = new ImageBrush(bitmapImage);
                    canGUI.Height = bitmapImage.Height;
                    canGUI.Width = bitmapImage.Width;
                }

                Load_Objects(sScreen);
                loadingScreen = false;
            }
            catch (Exception ex)
            {
                this.Log.Error("Failed to load screen: " + sScreen, ex);
            }
            _timer.Start();
        }
        public void Load_Screen(string sScreen)
        {
            try
            {
                stateImages.Clear();
                propLabels.Clear();
                navImages.Clear();
                methodImages.Clear();
                cameraViewers.Clear();
                canGUI.Children.Clear();

                loadingScreen = true;
                logging.AddToLog("Loading screen: " + sScreen, false);
                gCurrentScreen = sScreen;
                OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Current Screen", sScreen, "GUI");
                OSAE.OSAEImageManager imgMgr = new OSAE.OSAEImageManager();
                string imgID = OSAEObjectPropertyManager.GetObjectPropertyValue(sScreen, "Background Image").Value;
                OSAE.OSAEImage img = imgMgr.GetImage(imgID);

                //sPath = OSAEApi.APIpath + OSAEApi.GetObjectPropertyValue(sScreen, "Background Image").Value;
                //byte[] byteArray = File.ReadAllBytes(sPath);

                if (img.Data != null)
                {
                    var imageStream = new MemoryStream(img.Data);
                    var bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = imageStream;
                    bitmapImage.EndInit();
                    canGUI.Background = new ImageBrush(bitmapImage);
                    canGUI.Height = bitmapImage.Height;
                    canGUI.Width = bitmapImage.Width;
                }
                Thread thread = new Thread(() => Load_Objects(sScreen));
                thread.Start();

                logging.AddToLog("Loading screen complete: " + sScreen, false);
            }
            catch (Exception ex)
            {
                logging.AddToLog("Failed to load screen: " + sScreen, true);
            }
        }
        public void Load_Screen(string sScreen)
        {
            _timer.Stop();
            try
            {
                loadingScreen = true;
                if (updatingScreen)
                {
                    System.Threading.Thread.Sleep(1000);
                    //The next line sucks an should not be done, but it was getting stuck in this loop sometimes
                    updatingScreen = false;
                }
                stateImages.Clear();
                propLabels.Clear();
                navImages.Clear();
                clickImages.Clear();
                cameraViewers.Clear();
                canGUI.Children.Clear();
                browserFrames.Clear();
                controlTypes.Clear();
                string titl = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Title").Value;
                Title = titl + " - " + sScreen;
                gCurrentScreen = sScreen;
                OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Current Screen", sScreen, gCurrentUser);
                OSAE.OSAEImageManager imgMgr = new OSAE.OSAEImageManager();
                string imgID = OSAEObjectPropertyManager.GetObjectPropertyValue(sScreen, "Background Image").Value;
                OSAE.OSAEImage img = imgMgr.GetImage(imgID);
                bool isMax = (this.WindowState == WindowState.Maximized);
                //this.WindowState = WindowState.Normal;
                if (img.Data != null)
                {
                    var imageStream = new MemoryStream(img.Data);
                    var bitmapImage = new BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = imageStream;
                    bitmapImage.EndInit();

                    gCurrentScreenHeight = bitmapImage.Height;
                    gCurrentScreenWidth = bitmapImage.Width;

                    canGUI.Background = new ImageBrush(bitmapImage);

                    bool gForcedScreenSettings = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Use Global Screen Settings").Value);
                    if (gForcedScreenSettings)
                    {
                        double gForcedScreenHeight = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Height").Value);
                        double gForcedScreenWidth = Convert.ToDouble(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Width").Value);
                        canGUI.Height = gForcedScreenHeight;
                        canGUI.Width = gForcedScreenWidth;
                        this.Height = gForcedScreenHeight;
                        this.Width = gForcedScreenWidth;
                        gHeightRatio = this.ActualHeight / gForcedScreenHeight;
                        gWidthRatio = this.ActualWidth / gForcedScreenWidth;

                        bool gForcedScreenShowFrame = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Show Frame").Value);
                        if (gForcedScreenShowFrame)
                        {
                            WindowStyle = System.Windows.WindowStyle.SingleBorderWindow;
                            this.ResizeMode = ResizeMode.CanResize;
                            menuFrameShow.IsChecked = true;
                        }
                        else
                        {
                            WindowStyle = System.Windows.WindowStyle.None;
                            this.ResizeMode = ResizeMode.NoResize;
                            menuFrameShow.IsChecked = false;
                        }
                    }
                    else
                    {
                        if (isMax)
                        {
                            gHeightRatio = this.ActualHeight / gCurrentScreenHeight;
                            gWidthRatio = this.ActualWidth / gCurrentScreenWidth;
                        }
                        else
                        {
                            canGUI.Height = bitmapImage.Height;
                            canGUI.Width = bitmapImage.Width;
                            this.Height = bitmapImage.Height;
                            this.Width = bitmapImage.Width;
                            gHeightRatio = 1;
                            gWidthRatio = 1;
                        }
                    }
                }

                Load_Objects(sScreen);
                if (isMax) this.WindowState = WindowState.Maximized;
                loadingScreen = false;
              //  tvControls
            }
            catch (Exception ex)
            { Log.Error("Failed to load screen: " + sScreen, ex); }

            Log.Debug("Loaded Screen:  " + sScreen);
            _timer.Start();
        }