예제 #1
0
 // Methods
 public ArrowSelector()
 {
     this.endArrow = false;
     try
     {
         base.Items.Add("нч");
         SvgDocument fadde1   = new SvgDocument();
         string      filename = Path.GetDirectoryName(Assembly.GetAssembly(base.GetType()).Location) + "\\symbol\\arrow.xml";
         if (File.Exists(filename))
         {
             fadde1 = SvgDocumentFactory.CreateDocumentFromFile(filename);
         }
         else
         {
             ResourceManager manager1 = new ResourceManager(base.GetType());
             fadde1.LoadXml(manager1.GetString("arrow"));
         }
         XmlNodeList list1 = fadde1.GetElementsByTagName("marker");
         for (int num1 = 0; num1 < list1.Count; num1++)
         {
             XmlElement element1 = list1[num1] as XmlElement;
             if (element1 != null)
             {
                 base.Items.Add(new Arrow((SvgElement)element1));
             }
         }
     }
     catch (Exception exception1)
     {
         Console.Write(exception1.Message);
     }
     this.DrawMode    = System.Windows.Forms.DrawMode.OwnerDrawFixed;
     base.BorderStyle = BorderStyle.None;
     this.ItemHeight  = 16;
 }
예제 #2
0
        public static Bitmap GetImageForURL(string sURL, SvgElement element)
        {
            Bitmap bitmap1 = null;

            try
            {
                if ((sURL.StartsWith("http://") || sURL.StartsWith("https://")) || sURL.StartsWith("file://"))
                {
                    WebRequest   request1  = WebRequest.Create(sURL);
                    WebResponse  response1 = request1.GetResponse();
                    Stream       stream1   = response1.GetResponseStream();
                    MemoryStream stream2   = new MemoryStream();
                    for (int num1 = stream1.ReadByte(); num1 != -1; num1 = stream1.ReadByte())
                    {
                        stream2.WriteByte((byte)num1);
                    }
                    if (!response1.ContentType.StartsWith("image/svg+xml"))
                    {
                        bitmap1 = (Bitmap)System.Drawing.Image.FromStream(stream2);
                    }
                    stream1.Close();
                    return(bitmap1);
                }
                string text1 = Path.GetExtension(sURL);
                if (text1.Trim().ToLower() == ".svg")
                {
                    SvgDocument document1 = SvgDocumentFactory.CreateDocumentFromFile(sURL);
                    if ((document1 != null) && (document1.DocumentElement is SVG))
                    {
                        SVG svg1 = (SVG)document1.DocumentElement;
                        bitmap1 = new Bitmap((int)svg1.Width, (int)svg1.Height);
                        Graphics graphics1 = Graphics.FromImage(bitmap1);
                        svg1.Draw(graphics1, element.OwnerDocument.ControlTime);
                        graphics1.Dispose();
                    }
                    return(bitmap1);
                }
                if (regex.IsMatch(sURL))                //Base64±àÂë×ÊÔ´
                {
                    string text2   = sURL.Substring(regex.Match(sURL).Length);
                    Stream stream1 = FromBase64String(text2);
                    if (stream1 != null)
                    {
                        bitmap1 = (Bitmap)System.Drawing.Image.FromStream(stream1);
                    }
                    return(bitmap1);
                }
//				System.Drawing.Image a= System.Drawing.Image.FromFile(sURL,true);
//				if(a.GetType().FullName=="System.Drawing.Imaging.Metafile")
//				{
//
//					Metafile wmf=(Metafile)Metafile.FromFile(sURL);
//					int aa=wmf.Width;
//					int bb=wmf.Height;
//					Bitmap bm=new Bitmap(wmf.Width,wmf.Height);
//					Graphics gr=Graphics.FromImage(bm);
//					RectangleF dest_bounds=new RectangleF(0,0,wmf.Width,wmf.Height);
//					RectangleF source_bounds=new RectangleF(0,0,wmf.Width,wmf.Height);
//					gr.DrawImage(wmf, dest_bounds, source_bounds, GraphicsUnit.Pixel);
//
////					MemoryStream stream4=new MemoryStream() ;
////					bm.Save(stream4,bm.RawFormat);
//					bm.Save("C:\\1.bmp",ImageFormat.Bmp);
//
//					bitmap1 = (Bitmap) System.Drawing.Image.FromFile("C:\\1.bmp");
//					MemoryStream stream3=new MemoryStream() ;
//					bitmap1.Save(stream3,bitmap1.RawFormat);
//					if (stream3 != null)
//					{
//						string text3 = ToBase64String(stream3);
//
//						(element as XmlElement).SetAttribute("href", SvgDocument.XLinkNamespace, text3);
//					}
//					 gr.Dispose();
//				}
                else
                {
                    try {
                        bitmap1 = (Bitmap)System.Drawing.Image.FromFile(sURL);
                    } catch {
                        bitmap1 = (Bitmap)System.Drawing.Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\" + sURL);
                    }
                    if (bitmap1 != null && !SvgDocument.BkImageLoad)
                    {
                        MemoryStream stream3 = new MemoryStream();
                        bitmap1.Save(stream3, bitmap1.RawFormat);
                        if (stream3 != null)
                        {
                            string text3 = ToBase64String(stream3);

                            (element as XmlElement).SetAttribute("href", SvgDocument.XLinkNamespace, text3);
                        }
                    }
                }
            }
            catch (Exception exception1)
            {
                throw exception1;
            }
            return(bitmap1);
        }