示例#1
0
        public AutomationTextBox(Control parent, AnnAutomation automation, AnnEditTextEventArgs editTextEvent, RemoveAction removeAction)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            if (editTextEvent == null)
            {
                throw new ArgumentNullException("editTextEvent");
            }

            _textObject = editTextEvent.TextObject;
            if (_textObject == null)
            {
                throw new InvalidOperationException("No annotation text object was found in the event");
            }

            _removeAction = removeAction;
            _automation   = automation;

            var rect = editTextEvent.Bounds.ToLeadRect();

            rect.Inflate(12, 12);

            this.SuspendLayout();
            this.Location = new Point(rect.X, rect.Y);
            this.Size     = new Size(rect.Width, rect.Height);
            this.AutoSize = false;
            this.Tag      = _textObject;
            this.Text     = _textObject.Text;
            this.Name     = "AnnotationsText";
            this.Font     = AnnWinFormsRenderingEngine.ToFont(_textObject.Font);

            var brush = _textObject.TextForeground as AnnSolidColorBrush;

            if (brush != null)
            {
                this.ForeColor = Color.FromName(brush.Color);
            }

            this.WordWrap      = false;
            this.AcceptsReturn = true;
            this.Multiline     = true;
            this.ResumeLayout();

            //this.LostFocus += new EventHandler(AutomationTextBox_LostFocus);
            //this.KeyPress += new KeyPressEventHandler(AutomationTextBox_KeyPress);

            parent.Controls.Add(this);

            this.Focus();
            this.SelectAll();
        }
示例#2
0
        void automation_EditText(object sender, AnnEditTextEventArgs e)
        {
            TextBox   text = new TextBox();
            Rectangle rc   = new Rectangle((int)e.Bounds.Left, (int)e.Bounds.Top, (int)e.Bounds.Width, (int)e.Bounds.Height);

            rc.Inflate(12, 12);
            text.Location      = rc.Location;
            text.Size          = rc.Size;
            text.AutoSize      = false;
            text.Tag           = e.TextObject;
            text.Text          = e.TextObject.Text;
            text.ForeColor     = Color.FromName((e.TextObject.TextForeground as AnnSolidColorBrush).Color);
            text.Font          = AnnWinFormsRenderingEngine.ToFont(e.TextObject.Font);
            text.WordWrap      = false;
            text.AcceptsReturn = true;
            text.Multiline     = true;
            text.Tag           = e.TextObject;

            text.LostFocus += new EventHandler(text_LostFocus);
            _imageViewer.Controls.Add(text);
            text.Focus();
            text.SelectAll();
        }
示例#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);
        }