Exemplo n.º 1
0
        private void _btnLoadImage_Click(object sender, EventArgs e)
        {
            if (_currentBatesStamp != null)
            {
                AnnBatesStampLogo logo = _currentBatesStamp.Logo;
                using (OpenFileDialog openFileDialog = new OpenFileDialog())
                {
                    openFileDialog.Title  = "Load Image";
                    openFileDialog.Filter = "Png files (*.png)|*.png";
                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        Image image = Image.FromFile(openFileDialog.FileName);
                        _logoPictureBox.Image = image;

                        using (MemoryStream memoryStream = new MemoryStream())
                        {
                            image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
                            logo.Picture = new AnnPicture(memoryStream.ToArray());
                        }
                    }
                }

                UpdateControls();
            }
        }
Exemplo n.º 2
0
 private void _txtLogoPosition_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (_currentBatesStamp != null)
         {
             AnnBatesStampLogo  logo         = _currentBatesStamp.Logo;
             AnnContainerMapper mapper       = _automation.Container.Mapper;
             LeadRectD          logoPosition = mapper.RectFromContainerCoordinates(logo.LogoRect, AnnFixedStateOperations.None);
             logoPosition.X      = double.Parse(_txtLogoPositionX.Text);
             logoPosition.Y      = double.Parse(_txtLogoPositionY.Text);
             logoPosition.Width  = double.Parse(_txtLogoPositionWidth.Text);
             logoPosition.Height = double.Parse(_txtLogoPositionHeight.Text);
             logo.LogoRect       = mapper.RectToContainerCoordinates(logoPosition);
             UpdateControls();
         }
     }
     catch
     {
     }
 }
Exemplo n.º 3
0
        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);
        }