Esempio n. 1
0
 // 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;
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
File: SVG.cs Progetto: stuart2w/SAW
        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));
        }
Esempio n. 4
0
        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;
            }
        }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
        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;
            }
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
 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)));
     }
 }
Esempio n. 10
0
        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;
            }
        }
Esempio n. 11
0
        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);
            }
        }
Esempio n. 12
0
        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);
                }
            }
        }
Esempio n. 13
0
 /// <summary>Scale parameter determines how large the image is drawn</summary>
 public abstract Fill CreateTextureBrush(SharedImage image, float scale);