Enumerate Metafile : wmf file « 2D Graphics « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » 2D Graphics » wmf fileScreenshots 
Enumerate Metafile
 

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
   
class EnumMetafile: Form
{
     Metafile     mf;
     Panel        panel = new Panel();
   
     public static void Main()
     {
          Application.Run(new EnumMetafile());
     }
     public EnumMetafile()
     {
          Splitter splitter = new Splitter();
          splitter.Parent = this;
          splitter.Dock = DockStyle.Left; // Right;
   
          panel.Parent = this;
          panel.Dock = DockStyle.Left;
          panel.Paint += new PaintEventHandler(PanelOnPaint);
   
          Menu = new MainMenu();
          Menu.MenuItems.Add("&Open!"new EventHandler(MenuOpenOnClick));
     }
     void MenuOpenOnClick(object obj, EventArgs ea)
     {
          OpenFileDialog dlg = new OpenFileDialog();
          dlg.Filter = "All Metafiles|*.wmf;*.emf|" +
                       "Windows Metafile (*.wmf)|*.wmf|" +
                       "Enhanced Metafile (*.emf)|*.emf";
   
          if (dlg.ShowDialog() == DialogResult.OK)
          {
               mf = new Metafile(dlg.FileName);
               panel.Invalidate();
   
               Graphics grfx = CreateGraphics();
   
               grfx.EnumerateMetafile(mf, new Point(00)
                    new Graphics.EnumerateMetafileProc(EnumMetafileProc));
   
               grfx.Dispose();
          }
     }
     bool EnumMetafileProc(EmfPlusRecordType eprt, int iFlags,
                           int iDataSize, IntPtr ipData, 
                           PlayRecordCallback prc)
     {
          if (iDataSize > 0)
          {
               byte[] abyData = new Byte[iDataSize];
               Marshal.Copy(ipData, abyData, 0, iDataSize);
   
               foreach (byte by in abyData)
                    Console.WriteLine(" {0:X2}", by);
          }
          return true;
     }
     void PanelOnPaint(object obj, PaintEventArgs pea)
     {
          Panel    panel = (Panelobj;
          Graphics grfx  = pea.Graphics;
   
          if (mf != null)
               grfx.DrawImage(mf, 00);
     }
}

 
Related examples in the same category
1.Metafile Page Units
2.Create Metafile (Memory)
3.Create Metafile (Reload)
4.Create Metafile
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.