Exemplo n.º 1
0
        private void lbImage_SelectedIndexChanged(object sender, EventArgs e)
        {
            // вывод выбранного изображения
            ImageListItem imageInfo = lbImages.SelectedItem as ImageListItem;

            ChooseImageViewer(imageInfo);

            if (imageInfo == null)
            {
                pictureBox.Image = null;
            }
            else
            {
                try
                {
                    if (ctrlSvgViewer != null && imageInfo.IsSvg)
                    {
                        // display SVG
                        ctrlSvgViewer.ShowImage(imageInfo.Image.Data);
                    }
                    else
                    {
                        // display other type of image in the picture box
                        pictureBox.Image    = imageInfo.Source;
                        pictureBox.SizeMode =
                            imageInfo.ImageSize.Width <= pictureBox.Width &&
                            imageInfo.ImageSize.Height <= pictureBox.Height ?
                            PictureBoxSizeMode.CenterImage : PictureBoxSizeMode.Zoom;
                    }
                }
                catch (Exception ex)
                {
                    ChooseImageViewer(null);
                    pictureBox.Image = null;
                    ScadaUiUtils.ShowError(SchemePhrases.DisplayImageError + ":\n" + ex.Message);
                }
            }

            propGrid.SelectedObject = imageInfo;
            SetBtnsEnabled();
        }
        private void lbImage_SelectedIndexChanged(object sender, EventArgs e)
        {
            // вывод выбранного изображения
            ImageListItem imageInfo = lbImages.SelectedItem as ImageListItem;

            ChooseImageViewer(imageInfo);

            if (imageInfo == null)
            {
                pictureBox.Image = null;
            }
            else
            {
                try
                {
                    // display image in the picture box anyway
                    pictureBox.Image    = imageInfo.Source;
                    pictureBox.SizeMode =
                        imageInfo.ImageSize.Width <= pictureBox.Width &&
                        imageInfo.ImageSize.Height <= pictureBox.Height ?
                        PictureBoxSizeMode.CenterImage : PictureBoxSizeMode.Zoom;

                    // display SVG
                    if (ctrlSvgViewer != null && ctrlSvgViewer.Visible)
                    {
                        ctrlSvgViewer.ShowImage(imageInfo.Image.Data);
                    }
                }
                catch (Exception ex)
                {
                    ChooseImageViewer(null);
                    pictureBox.Image = null;
                }
            }

            propGrid.SelectedObject = imageInfo;
            SetBtnsEnabled();
        }