// M_NewImage can never be forcibly disposed, because it has always created by Document.AddShared... which use a CRC to check for duplicates // therefore it could any time be an external image public void btnImageRemove_Click(object sender, EventArgs e) { m_NewImage = null; pnlImagePreview.Image = null; ImageChanged(); chkDisplayFromAction.Checked = false; }
public static SharedImage CreateForResource(string resourceID) { SharedImage image = new SharedImage(); image.m_ResourceName = resourceID; // Note that the CRC must NOT use string.GetHashCode because that can vary between machines. The value is stored in the data and must be reproducible image.CRC = CRCCalc.Calc(System.Text.Encoding.Unicode.GetBytes(resourceID)); return(image); }
public override Fill CreateTextureBrush(SharedImage image, float scale) { var netImage = image.GetNetImage(); string ID = PrepareImage((Bitmap)netImage, image.GetHashCode(), RectangleF.Empty); // This uses a different image key to the actual image insertion; but it is unlikely that the same image would be used both as a texture and an image // and it is not the end of the world if the image gets embedded twice return(new SVGTexture(ID, netImage.Size, this)); }
public void lstTextures_Click(object sender, EventArgs e) { ListView listView = (ListView)sender; if (listView.SelectedItems.Count == 1) { m_Chosen = (SharedImage)listView.SelectedItems[0].Tag; this.DialogResult = DialogResult.OK; } }
public void DrawImage(SharedImage image, int preferredSize, PointF[] destinationPoints, RectangleF sourceRect, ImageAttributes attributes = null) { if (!image.IsLightweight) { DrawImage(image.MemoryImage, destinationPoints, sourceRect, attributes); } else { DrawImage(image.ResourceName, preferredSize, destinationPoints, sourceRect, attributes); } }
public void btnResource_Click(object sender, EventArgs e) { string ID = frmResource.ChooseImage(this); if (!string.IsNullOrEmpty(ID)) { m_NewImage = Globals.Root.CurrentDocument.AddSharedBitmapForResource(ID, m_Transaction); ImageChanged(); chkDisplayFromAction.Checked = false; } }
public static SharedImage CreateFromStream(Stream stream, bool isSVG, int CRC = 0) { SharedImage create = new SharedImage(); create.m_Image = new MemoryImage(stream, isSVG); if (CRC == 0) { CRC = create.m_Image.CalcCRC(); } create.CRC = CRC; return(create); }
public override void CopyFrom(Datum other, CopyDepth depth, Mapping mapID) { base.CopyFrom(other, depth, mapID); SharedImage sharedImage = (SharedImage)other; if (depth >= CopyDepth.Duplicate) { m_Image = sharedImage.m_Image?.Clone(); CRC = sharedImage.CRC; } m_ResourceName = sharedImage.m_ResourceName; }
public override Fill CreateTextureBrush(SharedImage image, float scale) { try { TextureBrush create = new TextureBrush(image.GetNetImage()); Matrix matrix = create.Transform; // cannot do Brush.Transform.Scale because Transform returns a copy of the matrix matrix.Scale(scale, scale); create.Transform = matrix; return(new NetFill(create)); } catch (Exception ex) { // If this fails it returns a hatched brush Utilities.LogSubError(ex); return(new NetFill(new HatchBrush(HatchStyle.DiagonalCross, Color.Red, Color.White))); } }
public void btnLoad_Click(object sender, EventArgs e) { string filename = FileDialog.ShowOpen(FileDialog.Context.Image, "[Filter_Image1]"); if (string.IsNullOrEmpty(filename)) { return; } Transaction transaction = new Transaction(); SharedImage texture = (SharedImage)m_Document.AddSharedResourceFromFile(filename, transaction); Globals.Root.StoreNewTransaction(transaction); if (texture != null) { m_Chosen = texture; this.DialogResult = DialogResult.OK; } }
public void btnImageDisc_Click(object sender, EventArgs e) { string filename = FileDialog.ShowOpen(FileDialog.Context.Image); if (string.IsNullOrEmpty(filename)) { return; } try { m_NewImage = (SharedImage)Globals.Root.CurrentDocument.AddSharedResourceFromFile(filename, m_Transaction); ImageChanged(); chkDisplayFromAction.Checked = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void lstDocument_DrawItem(object sender, DrawListViewItemEventArgs e) { SharedImage texture = (SharedImage)e.Item.Tag; var rct = e.Bounds; rct.Inflate(-6, -6); // area to draw image in GUIUtilities.CalcDestRect(texture.GetSize(rct.Width), ref rct); texture.MemoryImage.Draw(e.Graphics, rct); Debug.WriteLine(e.State.ToString()); if ((e.State & ListViewItemStates.Focused) > 0) { rct = e.Bounds; rct.Inflate(-3, -3); using (Pen pn = new Pen(Color.Orange, 3)) { e.Graphics.DrawRectangle(pn, rct); } } }
/// <summary>Scale parameter determines how large the image is drawn</summary> public abstract Fill CreateTextureBrush(SharedImage image, float scale);