コード例 #1
0
ファイル: BatesStampDialog.cs プロジェクト: sakpung/webstudy
        private void UpdateControls()
        {
            if (_listBoxContainerStamps.SelectedIndex != -1)
            {
                _btnRemoveStamp.Enabled         = true;
                _groupBoxStampText.Enabled      = true;
                _groupBoxStampAlignment.Enabled = true;
                _groupBoxStampLogo.Enabled      = true;
                _groupBoxStampElements.Enabled  = true;
            }
            else
            {
                _btnRemoveStamp.Enabled         = false;
                _groupBoxStampText.Enabled      = false;
                _groupBoxStampAlignment.Enabled = false;
                _groupBoxStampLogo.Enabled      = false;
                _groupBoxStampElements.Enabled  = false;
                _txtElements.Text            = string.Empty;
                _checkBoxStretchLogo.Checked = false;
            }

            if (_checkBoxStretchLogo.Checked)
            {
                _groupBoxLogoPosition.Enabled = false;
            }
            else
            {
                _groupBoxLogoPosition.Enabled = true;
            }

            _currentBatesStamp = _listBoxContainerStamps.SelectedItem as AnnBatesStamp;

            if (_currentBatesStamp != null)
            {
                AnnBatesStampLogo logo = _currentBatesStamp.Logo;

                _lblBatesText.Font = AnnWinFormsRenderingEngine.ToFont(_currentBatesStamp.Font);
                AnnSolidColorBrush solidBrush = _currentBatesStamp.Foreground as AnnSolidColorBrush;
                _lblBatesText.ForeColor = ColorTranslator.FromHtml(solidBrush.Color);
                _lblBatesText.Text      = _currentBatesStamp.AsString(_automation.Container);
                _comboHorizontalAlignment.SelectedIndex = (int)_currentBatesStamp.HorizontalAlignment;
                _comboVerticalAlignment.SelectedIndex   = (int)_currentBatesStamp.VerticalAlignment;

                AnnPicture logoPicture = logo.Picture;
                if (_logoPictureBox.Image != null)
                {
                    _logoPictureBox.Image.Dispose();
                }

                if (logoPicture != null && logoPicture.PictureData != null)
                {
                    using (MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(logoPicture.PictureData)))
                    {
                        _logoPictureBox.Image = Image.FromStream(memoryStream);
                    }
                }
                else
                {
                    _logoPictureBox.Image = null;
                }

                LeadRectD logoPosition = _automation.Container.Mapper.RectFromContainerCoordinates(logo.LogoRect, AnnFixedStateOperations.None);
                _txtLogoPositionX.Text      = Math.Max(0, logoPosition.X).ToString();
                _txtLogoPositionY.Text      = Math.Max(0, logoPosition.Y).ToString();
                _txtLogoPositionWidth.Text  = Math.Round(logoPosition.Width, 1).ToString();
                _txtLogoPositionHeight.Text = Math.Round(logoPosition.Height, 1).ToString();

                _txtLogoOpacity.Text       = logo.Opacity.ToString();
                _txtLogoText.Text          = logo.Text;
                _txtLogoRotationAngle.Text = logo.Angle.ToString();

                _checkBoxStretchLogo.Checked = logo.StretchLogo;

                _txtElements.Text = _translator.WriteElementsToString(_currentBatesStamp.Elements.ToArray());
            }
            else //set default values
            {
                _lblBatesText.Font      = new Font(new FontFamily("Microsoft Sans Serif"), 8);
                _lblBatesText.ForeColor = Color.Black;
                _lblBatesText.Text      = string.Empty;
                _comboHorizontalAlignment.SelectedIndex = -1;
                _comboVerticalAlignment.SelectedIndex   = -1;
                _logoPictureBox.Image       = null;
                _txtLogoPositionX.Text      = "0";
                _txtLogoPositionY.Text      = "0";
                _txtLogoPositionWidth.Text  = "0";
                _txtLogoPositionHeight.Text = "0";
                _txtLogoOpacity.Text        = "1";
                _txtLogoText.Text           = string.Empty;
                _txtLogoRotationAngle.Text  = "0";
            }

            _btnDeleteLogoPicture.Enabled = (_logoPictureBox.Image != null);
            _automation.Invalidate(LeadRectD.Empty);
        }