// Convert AnnPicture to System.Drawing.Bitmap. public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { AnnPicture picture = null; AnnPicture annPicture = value as AnnPicture; if (annPicture != null) { picture = annPicture; } else if (_defaultValue != null) { picture = _defaultValue; } if (picture != null) { using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(picture.PictureData))) { return(Bitmap.FromStream(ms)); } } else { return(null); } }
private void imageViewer_Clicked(object sender, EventArgs e) { // return; MouseEventArgs eventArgs = (MouseEventArgs)e; Point p = new Point(eventArgs.X, eventArgs.Y); //Point clientP = imageViewer.Con Image image = null; if (toolBar != null && this.edit) { // this.imageViewer. if (Form.ModifierKeys == Keys.Control) { image = (Image.FromHbitmap(ImageEdit.RedCheckmarkOnly.GetHbitmap())); } else { image = (Image.FromHbitmap(ImageEdit.CheckmarkOnly.GetHbitmap())); } AnnPicture pic = new AnnPicture(image); AnnStampObject obj = new AnnStampObject(); obj.Picture = pic; obj.Visible = true; // obj. Transformer transform = new Transformer(); transform.Transform = this.imageViewer.Transform; PointF pf = transform.PointToLogical(new PointF(eventArgs.X - 10, eventArgs.Y - 10)); obj.Bounds = new AnnRectangle(pf.X, pf.Y, 20, 20, AnnUnit.Pixel); // obj.Bounds = new AnnRectangle(new Rectangle(, new SizeF(30, 30))); _annAutomation.Container.Objects.Add(obj); _annAutomation.ImageDirty = true; this.imageViewer.Invalidate(); } }
private void imageViewer_Clicked(object sender, EventArgs e) { // return; MouseEventArgs eventArgs = (MouseEventArgs)e; Point p = new Point(eventArgs.X,eventArgs.Y); //Point clientP = imageViewer.Con Image image = null; if (toolBar != null && this.edit) { // this.imageViewer. if (Form.ModifierKeys == Keys.Control) { image = (Image.FromHbitmap(ImageEdit.RedCheckmarkOnly.GetHbitmap())); } else { image = (Image.FromHbitmap(ImageEdit.CheckmarkOnly.GetHbitmap())); } AnnPicture pic = new AnnPicture(image); AnnStampObject obj = new AnnStampObject(); obj.Picture = pic; obj.Visible = true; // obj. Transformer transform = new Transformer(); transform.Transform = this.imageViewer.Transform; PointF pf = transform.PointToLogical(new PointF(eventArgs.X - 10, eventArgs.Y - 10)); obj.Bounds = new AnnRectangle(pf.X, pf.Y, 20, 20, AnnUnit.Pixel); // obj.Bounds = new AnnRectangle(new Rectangle(, new SizeF(30, 30))); _annAutomation.Container.Objects.Add(obj); _annAutomation.ImageDirty = true; this.imageViewer.Invalidate(); } }
public PictureConverter(AnnPicture defaultValue) { _defaultValue = defaultValue; }
public AnnPictureEditor(AnnPicture value, string category) { _category = category; Value = value; }
void AddPictureProperties(List <PropertyDescriptor> properties, string category, AnnPicture defaultValue) { Attribute[] attribs = new Attribute[1] { new EditorAttribute(typeof(BitmapEditor), typeof(UITypeEditor)) }; properties.Add(new CustomPropertyDescriptor(_type.GetProperty("Picture"), _object, "Picture", category, attribs, typeof(PictureConverter), defaultValue)); }
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); }