OSAE.UI.Controls.AddControlStateImage.LoadCurrentScreenObject C# (CSharp) Method

LoadCurrentScreenObject() private method

Load the objects from the DB into the combo box
private LoadCurrentScreenObject ( string controlName ) : void
controlName string
return void
        private void LoadCurrentScreenObject(string controlName)
        {
            string sCheckName = "";
            OSAEImageManager imgMgr = new OSAEImageManager();
            cboObject.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Object Name").Value;
            cboState1.SelectedValue = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Name").Value;
            try
            {
                sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image").Value;
                if (sCheckName != "")
                {
                    State1Img1 = imgMgr.GetImage(sCheckName);
                    MemoryStream ms1 = new MemoryStream(State1Img1.Data);
                    BitmapImage bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = ms1;
                    bitmapImage.EndInit();
                    ImageBehavior.SetAnimatedSource(imgState1Img1, bitmapImage);
                    //imgState1Img1.Source = LoadImage(State1Img1.Data);
                    Validate_Initial_Coordinates();
                    lblState1X.IsEnabled = false;
                    lblState1Y.IsEnabled = false;
                    txtState1X.IsEnabled = true;
                    txtState1Y.IsEnabled = true;
                    lblZOrder.IsEnabled = true;
                    txtZOrder.IsEnabled = true;
                    if (State1Img1.Type != "gif")
                    {
                        btnLoadS1I2.IsEnabled = true;
                        imgState1Img2.IsEnabled = true;
                    }
                }
            }
            catch { }

            try
            {
                sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 2").Value;
                if (sCheckName != "")
                {
                    State1Img2 = imgMgr.GetImage(sCheckName);
                    imgState1Img2.Source = LoadImage(State1Img2.Data);
                    txtDelay.IsEnabled = true;
                    chkRepeat.IsEnabled = true;
                    btnLoadS1I3.IsEnabled = true;
                    Validate_Initial_Coordinates();
                }
            }
            catch { }

            try
            {
                sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 3").Value;
                if (sCheckName != "")
                {
                    State1Img3 = imgMgr.GetImage(sCheckName);
                    imgState1Img3.Source = LoadImage(State1Img3.Data);
                    txtDelay.IsEnabled = true;
                    chkRepeat.IsEnabled = true;
                    btnLoadS1I4.IsEnabled = true;
                    Validate_Initial_Coordinates();
                }
            }
            catch { }

            try
            {
                sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Image 4").Value;
                if (sCheckName != "")
                {
                    State1Img4 = imgMgr.GetImage(sCheckName);
                    imgState1Img4.Source = LoadImage(State1Img4.Data);
                    txtDelay.IsEnabled = true;
                    chkRepeat.IsEnabled = true;
                    Validate_Initial_Coordinates();
                }
            }
            catch { }

            txtState1X.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 X").Value;
            txtState1Y.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 1 Y").Value;
            txtZOrder.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "ZOrder").Value;

            cboState2.SelectedValue = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Name").Value;
            try
            {
                sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image").Value;
                if (sCheckName != "")
                {
                    State2Img1 = imgMgr.GetImage(sCheckName);
                    MemoryStream ms1 = new MemoryStream(State2Img1.Data);
                    BitmapImage bitmapImage = new BitmapImage();

                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = ms1;
                    bitmapImage.EndInit();
                    ImageBehavior.SetAnimatedSource(imgState2Img1, bitmapImage);
                    //imgState2Img1.Source = LoadImage(State2Img1.Data);
                    Validate_Initial_Coordinates();
                    lblState2X.IsEnabled = true;
                    lblState2Y.IsEnabled = true;
                    txtState2X.IsEnabled = true;
                    txtState2Y.IsEnabled = true;
                    lblZOrder.IsEnabled = true;
                    txtZOrder.IsEnabled = true;
                    if (State1Img1.Type != "gif")
                    {
                        btnLoadS2I2.IsEnabled = true;
                        imgState1Img2.IsEnabled = true;
                    }
                }
            }
            catch { }

            try
            {
                sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 2").Value;
                if (sCheckName != "")
                {
                    State2Img2 = imgMgr.GetImage(sCheckName);
                    imgState2Img2.Source = LoadImage(State2Img2.Data);
                    txtDelay.IsEnabled = true;
                    chkRepeat.IsEnabled = true;
                    btnLoadS2I3.IsEnabled = true;
                    Validate_Initial_Coordinates();
                }
            }
            catch { }

            try
            {
                sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 3").Value;
                if (sCheckName != "")
                {
                    State2Img3 = imgMgr.GetImage(sCheckName);
                    imgState2Img3.Source = LoadImage(State2Img3.Data);
                    txtDelay.IsEnabled = true;
                    chkRepeat.IsEnabled = true;
                    btnLoadS2I4.IsEnabled = true;
                    Validate_Initial_Coordinates();
                }
            }
            catch { }

            try
            {
                sCheckName = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Image 4").Value;
                if (sCheckName != "")
                {
                    State2Img4 = imgMgr.GetImage(sCheckName);
                    imgState2Img4.Source = LoadImage(State2Img4.Data);
                    txtDelay.IsEnabled = true;
                    chkRepeat.IsEnabled = true;
                    Validate_Initial_Coordinates();
                }
            }
            catch { }

            txtState2X.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 X").Value;
            txtState2Y.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "State 2 Y").Value;

            chkSlider.IsEnabled = OSAEObjectPropertyManager.ObjectPropertyExists(cboObject.SelectedValue.ToString(), "Level");
            if (chkSlider.IsEnabled)
            {
                try
                { chkSlider.IsChecked = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Show Slider").Value); }
                catch
                { chkSlider.IsChecked = false; }

                if (chkSlider.IsChecked.Value) cboSliderMethod.SelectedValue = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Slider Method").Value;
            }

            try
            { chkRepeat.IsChecked = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Repeat Animation").Value); }
            catch
            { chkRepeat.IsChecked = true; }

            try
            { txtDelay.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Frame Delay").Value; }
            catch
            { txtDelay.Text = "500"; }
        }