Index: /trunk/AlphaForm.cs
===================================================================
--- /trunk/AlphaForm.cs (revision 1)
+++ /trunk/AlphaForm.cs (revision 1)
@@ -0,0 +1,495 @@
+/*
+ * AlphaForm.cs
+ * $Id: AlphaForm.cs,v 1.3 2003/07/10 20:07:16 Mayuki Sawatari Exp $
+ *
+ * Copyright (c) 2003 Mayuki Sawatari, All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE MISUZILLA.ORG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+using System;
+using System.Timers;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Drawing.Drawing2D;
+using System.Windows.Forms;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace Misuzilla.Windows.Forms
+{
+ /// sNZPÊAt@uhÌtH[
+ ///
+ ///
+ /// Windows2000/XPÌC[hEBhEðpµ
+ /// sNZPÊÅwãÌEBhEƼ§¾¬Å«étH[B
+ ///
+ ///
+ /// ±ÌtH[ÍÊíÌtH[Æá¢\bhÅ`æXVðw¦·éKvª èÜ·B
+ /// CxgÈÇÄ`æÌCxgඵܹñB
+ ///
+ ///
+ ///
+ public class AlphaForm : System.Windows.Forms.Form
+ {
+ private Byte m_opacity = 255;
+ private SByte m_fadeRatio = 25;
+ private Boolean m_movedrag = false;
+ private Boolean m_transMouseMsg = false;
+
+ private System.Drawing.Bitmap m_alphaMap = null;
+ private System.Drawing.Graphics m_graphics = null;
+
+ private IntPtr m_hDC = IntPtr.Zero;
+ private IntPtr m_hMemDC = IntPtr.Zero;
+
+ private Win32.Point m_pForm;
+ private Win32.Point m_pSurface;
+ private Win32.Size m_sBitmap;
+
+#if FADE_USE_TIMER
+ private System.Timers.Timer m_fadeTimer = null;
+#endif
+
+ public
+ AlphaForm()
+ {
+ if (OSFeature.Feature.GetVersionPresent(OSFeature.LayeredWindows) == null)
+ throw new ApplicationException("Layered Windows is not supported");
+
+ m_alphaMap = new Bitmap(100, 100);
+ m_graphics = Graphics.FromImage(m_alphaMap);
+ this.PrepareDC();
+ }
+
+ /// tH[ÉÖAt¯çê½IuWFNgð澵ܷB
+ ///
+ /// `æÉͱÌIuWFNgðp·éKvª èÜ·B
+ /// ܽA`æµ½ã\bhðÄÔ±ÆÅ\¦ªXV³êÜ·B
+ ///
+ ///
+ public System.Drawing.Graphics
+ Graphics
+ {
+ get
+ {
+ return m_graphics;
+ }
+ }
+
+ protected override void
+ Dispose(bool disposing)
+ {
+ this.CloseDC();
+ base.Dispose(disposing);
+ }
+
+ protected override CreateParams
+ CreateParams
+ {
+ get
+ {
+ CreateParams cp = base.CreateParams;
+ cp.ExStyle |= Win32.WS_EX_LAYERED; // WS_EX_LAYERED
+ return cp;
+ }
+ }
+
+ protected override void
+ OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ if (m_graphics != null) m_graphics.Dispose();
+ if (m_alphaMap != null) m_alphaMap.Dispose();
+ m_alphaMap = new Bitmap(this.Width, this.Height);
+ m_graphics = Graphics.FromImage(m_alphaMap);
+ this.PrepareDC();
+ this.SetSize();
+ this.SetPosition();
+ }
+ protected override void
+ OnMove(EventArgs e)
+ {
+ base.OnMove(e);
+ this.SetPosition();
+ }
+
+
+ private void
+ SetSize()
+ {
+ lock (this) {
+ m_sBitmap.cx = m_alphaMap.Width;
+ m_sBitmap.cy = m_alphaMap.Height;
+ }
+ }
+ private void
+ SetPosition()
+ {
+ m_pForm.x = this.Left;
+ m_pForm.y = this.Top;
+ m_pSurface.x = 0;
+ m_pSurface.y = 0;
+ }
+
+ private void
+ PrepareDC()
+ {
+ this.CloseDC();
+ m_hDC = Win32.GetDC(IntPtr.Zero);
+ m_hMemDC = Win32.CreateCompatibleDC(m_hDC);
+ if ((m_hDC == IntPtr.Zero) || (m_hMemDC == IntPtr.Zero)) {
+ this.CloseDC();
+ throw new ApplicationException("Couldn't allocate DeviceContext");
+ }
+ }
+ private void
+ CloseDC()
+ {
+ if (m_hMemDC != IntPtr.Zero) Win32.DeleteDC(m_hMemDC);
+ if (m_hDC != IntPtr.Zero) Win32.ReleaseDC(IntPtr.Zero, m_hDC);
+ }
+
+ /// tH[Ì\¦ðXVµÜ·B
+ ///
+ /// ±Ì\bhðÄÔ±ÆÅ\¦ªXV³êÜ·B
+ ///
+ public override void
+ Refresh()
+ {
+ Update(m_opacity);
+ }
+ /// tH[Ì\¦ðXVµÜ·B
+ ///
+ /// ±Ì\bhðÄÔ±ÆÅ\¦ªXV³êÜ·B
+ ///
+ public new void
+ Update()
+ {
+ Update(m_opacity);
+ }
+
+ /// tH[Ì\¦ðXVµÜ·B
+ ///
+ /// ±Ì\bhðÄÔ±ÆÅ\¦ªXV³êÜ·B
+ ///
+ /// XV·éÛÌtH[̧¾x
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ public void
+ Update(Byte bOpacity)
+ {
+ m_opacity = bOpacity;
+
+ if (m_alphaMap == null) return;
+ if (m_alphaMap.PixelFormat != PixelFormat.Format32bppArgb) return;
+
+ Win32.BlendFunction bf;
+ bf.BlendOp = 0; // AC_SRC_OVER
+ bf.BlendFlags = 0;
+ bf.AlphaFormat = 1; // AC_SRC_ALPHA
+ bf.SourceConstantAlpha = bOpacity;
+
+ m_opacity = bOpacity;
+
+ IntPtr hBitmapOld = IntPtr.Zero;
+ IntPtr hBitmap = IntPtr.Zero;
+
+ //lock (this) {
+ // lock (m_graphics) {
+ hBitmap = m_alphaMap.GetHbitmap(Color.FromArgb(0));
+ hBitmapOld = Win32.SelectObject(m_hMemDC, hBitmap);
+
+ if (Win32.UpdateLayeredWindow(
+ this.Handle,
+ m_hDC,
+ ref m_pForm,
+ ref m_sBitmap,
+ m_hMemDC,
+ ref m_pSurface,
+ 0,
+ ref bf,
+ 0x2) == 0
+ ){
+ //throw new ApplicationException("UpdateLayerdWindow was failed");
+ }
+ if (hBitmap != IntPtr.Zero) {
+ Win32.SelectObject(m_hMemDC, hBitmapOld);
+ Win32.DeleteObject(hBitmap);
+ }
+ // }
+ //}
+ }
+
+ public new Single
+ Opacity
+ {
+ get
+ {
+ return (m_opacity / 255.0F);
+ }
+ set
+ {
+ if (value > 1.0F)
+ value = 1.0F;
+ else if (value < 0.0F)
+ value = 0.0F;
+ m_opacity = (Byte)(value * 255.0F);
+ Update(m_opacity);
+ }
+ }
+
+ /// }EXhbOÉæÁÄtH[ÌÚ®ð·é©Ç¤©ðwèµÜ·B
+ ///
+ /// ±ÌvpeBªwè³êÄ¢éêtH[ãÅEhbOðs¤Æ
+ /// tH[ÌÚ®ªs¦Ü·B
+ ///
+ public Boolean
+ MoveAtFormDrag
+ {
+ get
+ {
+ return m_movedrag;
+ }
+ set
+ {
+ m_movedrag = value;
+ }
+ }
+
+ /// }EXbZ[WªtH[ð§ß·é©Ç¤©ðwèµÜ·B
+ ///
+ /// ±ÌvpeBªwè³êÄ¢éê}EXbZ[WÍ
+ /// tH[ð§ßµAwãÌtH[É`íèÜ·B
+ ///
+ public Boolean
+ TransparentMouseMessage
+ {
+ get
+ {
+ return m_transMouseMsg;
+ }
+ set
+ {
+ Int32 exStyle = Win32.GetWindowLong(this.Handle, Win32.GWL_EXSTYLE);
+
+ if (value)
+ exStyle |= Win32.WS_EX_TRANSPARENT;
+ else if ((exStyle & Win32.WS_EX_TRANSPARENT) == Win32.WS_EX_TRANSPARENT)
+ exStyle ^= Win32.WS_EX_TRANSPARENT;
+
+ Win32.SetWindowLong(this.Handle, Win32.GWL_EXSTYLE, exStyle);
+ m_transMouseMsg = value;
+ }
+ }
+
+ protected override void
+ OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+ if (m_movedrag) {
+ if (e.Button == MouseButtons.Left) {
+ Win32.ReleaseCapture();
+ // Int32 WM_NCLBUTTONDOWN = 0xa1;
+ // Int32 HTCAPTION = 0x02;
+ Win32.SendMessage(this.Handle, 0xa1, 0x02, IntPtr.Zero);
+ }
+ }
+ }
+
+ /// tH[ðtF[hCµÜ·B
+ ///
+ /// tH[̧¾xðwè³ê½Ô²ÆÉã°Ä¢«\¦µÜ·B
+ ///
+ /// §¾xÌXVÔu
+ public void
+ FadeinWindow(Double transMilliSec)
+ {
+ FadeWindow(transMilliSec, (SByte)(25), 255, 0);
+ }
+ /// §¾xÌXVÔu
+ /// §¾xÌÏ»¦
+ public void
+ FadeinWindow(Double transMilliSec, Byte fadeRatio)
+ {
+ FadeWindow(transMilliSec, (SByte)(fadeRatio), 255, 0);
+ }
+ /// §¾xÌXVÔu
+ /// §¾xÌÏ»¦
+ /// §¾xÌÅål
+ public void
+ FadeinWindow(Double transMilliSec, Byte fadeRatio, Byte opacityMax)
+ {
+ FadeWindow(transMilliSec, (SByte)(fadeRatio), opacityMax, 0);
+ }
+ /// tH[ðtF[hAEgµÜ·B
+ ///
+ /// tH[̧¾xðwè³ê½Ô²Æɺ°Ä¢«®Sɧ¾ÉµÜ·B
+ ///
+ /// §¾xÌXVÔu
+ public void
+ FadeoutWindow(Double transMilliSec)
+ {
+ FadeWindow(transMilliSec, (SByte)(-25), 255, 0);
+ }
+ /// §¾xÌXVÔu
+ /// §¾xÌÏ»¦
+ public void
+ FadeoutWindow(Double transMilliSec, Byte fadeRatio)
+ {
+ FadeWindow(transMilliSec, (SByte)(-fadeRatio), 255, 0);
+ }
+ /// §¾xÌXVÔu
+ /// §¾xÌÏ»¦
+ /// §¾xÌŬl
+ public void
+ FadeoutWindow(Double transMilliSec, Byte fadeRatio, Byte opacityMin)
+ {
+ FadeWindow(transMilliSec, (SByte)(-fadeRatio), 255, opacityMin);
+ }
+
+ [MethodImpl(MethodImplOptions.Synchronized)]
+ private void
+ FadeWindow(Double transMilliSec, SByte fadeRatio, Byte opacityMaxLimit, Byte opacityMinLimit)
+ {
+ m_fadeRatio = fadeRatio;
+
+#if FADE_USE_TIMER
+ if (m_fadeTimer == null)
+ m_fadeTimer = new System.Timers.Timer(transMilliSec);
+ else
+ m_fadeTimer.Interval = transMilliSec;
+
+ m_fadeTimer.Elapsed += new ElapsedEventHandler(this.OnTimedEvent);
+ m_fadeTimer.Enabled = true;
+#else
+ Byte i = m_opacity;//((m_fadeRatio > 0) ? (Byte)0 : m_opacity);
+ while (m_fadeRatio + i < opacityMaxLimit && m_fadeRatio + i > opacityMinLimit) {
+ i = (Byte)(i + m_fadeRatio);
+ System.Threading.Thread.Sleep((Int32)transMilliSec);
+ this.Update(i);
+ }
+
+ this.Update((Byte)((m_fadeRatio > 0) ? opacityMaxLimit : opacityMinLimit));
+#endif
+ }
+
+#if FADE_USE_TIMER
+ private void
+ OnTimedEvent(Object sender, ElapsedEventArgs e)
+ {
+ if (m_fadeRatio + m_opacity < 255 && m_fadeRatio + m_opacity > 0) {
+ i = (Byte)(i + m_fadeRatio);
+ System.Threading.Thread.Sleep((Int32)transMilliSec);
+ this.Update(i);
+ } else {
+ m_fadeTimer.Enabled = false;
+ this.Update((Byte)((m_fadeRatio > 0) ? 255 : 0));
+ }
+ }
+#endif
+
+ private class Win32
+ {
+ public const Int32 GWL_EXSTYLE = -20;
+ public const Int32 WS_EX_LAYERED = 0x00080000;
+ public const Int32 WS_EX_TRANSPARENT = 0x00000020;
+ public const Int32 AC_SRC_OVER = 0x00000001;
+ public const Int32 AC_SRC_ALPHA = 0x00000001;
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct
+ BlendFunction
+ {
+ public Byte BlendOp;
+ public Byte BlendFlags;
+ public Byte SourceConstantAlpha;
+ public Byte AlphaFormat;
+ }
+ [StructLayout(LayoutKind.Sequential)]
+ public struct
+ Point
+ {
+ public Int32 x;
+ public Int32 y;
+ }
+ [StructLayout(LayoutKind.Sequential)]
+ public struct
+ Size
+ {
+ public Int32 cx;
+ public Int32 cy;
+ }
+
+ [DllImport("user32.dll")]
+ public static extern Int32
+ UpdateLayeredWindow(
+ IntPtr hWnd,
+ IntPtr hdcDst,
+ ref Point pptDst,
+ ref Size psize,
+ IntPtr hdcSrc,
+ ref Point pptSrc,
+ UInt32 crKey,
+ ref BlendFunction pblend,
+ UInt32 dwFlags);
+
+ [DllImport("user32.dll")]
+ public static extern Int32
+ GetWindowLong(IntPtr hWnd, Int32 nIndex);
+ [DllImport("user32.dll")]
+ public static extern Int32
+ SetWindowLong(IntPtr hWnd, Int32 nIndex, Int32 dwNewLong);
+
+ [DllImport("gdi32.dll")]
+ public static extern IntPtr
+ CreateCompatibleDC(IntPtr hDC);
+
+ [DllImport("user32.dll")]
+ public static extern IntPtr
+ GetDC(IntPtr hWnd);
+
+ [DllImport("user32.dll")]
+ public static extern IntPtr
+ ReleaseDC(IntPtr hWnd, IntPtr hDC);
+
+ [DllImport("gdi32.dll")]
+ public static extern Boolean
+ DeleteDC(IntPtr hdc);
+
+ [DllImport("gdi32.dll")]
+ public static extern IntPtr
+ SelectObject(IntPtr hDC, IntPtr hObject);
+
+ [DllImport("gdi32.dll")]
+ public static extern Boolean
+ DeleteObject(IntPtr hObject);
+
+ [DllImport("user32.dll")]
+ public static extern Int32
+ ReleaseCapture();
+
+ [DllImport("user32.dll")]
+ public static extern Int32
+ SendMessage(IntPtr hWnd, Int32 wMsg, Int32 wParam, IntPtr lParam);
+ } // Win32
+ } // AlphaForm
+} // Misuzilla.Windows.Forms
Index: /trunk/AssemblyInfo.cs
===================================================================
--- /trunk/AssemblyInfo.cs (revision 1)
+++ /trunk/AssemblyInfo.cs (revision 1)
@@ -0,0 +1,32 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes specify the key for the sign of your assembly. See the
+// .NET Framework documentation for more information about signing.
+// This is not required, if you don't want signing let these attributes like they're.
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
Index: /trunk/FaceDef.cs
===================================================================
--- /trunk/FaceDef.cs (revision 1)
+++ /trunk/FaceDef.cs (revision 1)
@@ -0,0 +1,151 @@
+using System;
+using System.Drawing;
+using System.Xml;
+using System.Collections;
+
+namespace MacFace
+{
+ ///
+ /// FaceDef ÌTvÌà¾Å·B
+ ///
+ public class FaceDef
+ {
+ public static const string FACEDEF_NAME = "faceDef.plist";
+ public static const int PATTERN_COLS = 11;
+ public static const int PATTERN_ROWS = 3;
+
+ protected string path;
+ protected string title;
+ protected string auther;
+ protected string version;
+ protected string webSite;
+
+ protected Part[] parts;
+ protected int[][,] patterns;
+ protected Part[] makers;
+
+ public FaceDef(string path)
+ {
+ this.path = path;
+
+ //
+ string defFile = Path.Combine(path,FACEDEF_NAME);
+ XmlTextReader reader = new XmlTextReader(path);
+ reader.XmlResolver = null;
+ doc.Load(reader);
+
+ Hashtable def = ReadDictionary(doc.DocumentElement.FirstChild);
+
+ ArrayList partDefList = def["parts"];
+ parts = new Part[partDefList.Size];
+ for (int i = 0; i < partDefList.Size; i++)
+ {
+ Hashtable partDef = partDefList[i];
+ string filnemae = Path.Combine(path,partDef["filename"]);
+ int x = partDef["pos x"];
+ int y = partDef["pos y"];
+ parts[i] = new Part(filename,x,y);
+ }
+
+ ArrayList partDefList = def["pattern"];
+ parts = new Part[partDefList.Size];
+ for (int i = 0; i < partDefList.Size; i++)
+ {
+ Hashtable partDef = partDefList[i];
+ string filnemae = Path.Combine(path,partDef["filename"]);
+ int x = partDef["pos x"];
+ int y = partDef["pos y"];
+ parts[i] = new Part(filename,x,y);
+ }
+ }
+
+
+ protected static Part[] LoadPartList(string basePath,Hashtable def)
+ {
+ ArrayList partDefList = def["pattern"];
+ ArrayList list = new ArrayList();
+ foreach (Hashtable partDef in partDefList)
+ {
+ list.Add(new Part(partDef));
+ }
+
+ return list.ToArray();
+ }
+
+ protected static Hashtable LoadFaceDef(string path)
+ {
+ string defFile = Path.Combine(path,FACEDEF_NAME);
+ }
+ }
+
+ public class Pattern
+ {
+ Part[] parts;
+
+ public Pattern(Part[] parts)
+ {
+ this.parts = parts;
+ }
+
+ public Part this [int index]
+ {
+ get { return part[index]; }
+ }
+
+ public void Draw(Graphics g)
+ {
+ foreach (Part part in parts)
+ {
+ part.Draw(g);
+ }
+ }
+ }
+
+ public class Part
+ {
+ protected string path;
+ protected int x;
+ protected int y;
+
+ public Part(string basePath,Hashtable partDef)
+ {
+ this.path = (string)Path.Combine(partDef["filename"]);
+ this.x = (int)partDef["pos x"];
+ this.y = (int)partDef["pos y"];
+ }
+
+ public Part(String path,int x,int y)
+ {
+ this.path = path;
+ this.image = Image.FromFile(path);
+ this.x = x;
+ this.y = y;
+ }
+
+ public string Path
+ {
+ get { return path; }
+ }
+
+ public Image Image
+ {
+ get { return image; }
+ }
+
+ public int X
+ {
+ get { return x; }
+ }
+
+ public int Y
+ {
+ get { return y; }
+ }
+
+ public void Draw(Graphics g)
+ {
+ Image img = part.Image;
+ g.DrawImage(img, x, drawY, img.Size.Width, img.Size.Height);
+ }
+ }
+}
Index: /trunk/MacFace.cmbx
===================================================================
--- /trunk/MacFace.cmbx (revision 1)
+++ /trunk/MacFace.cmbx (revision 1)
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /trunk/MacFace.prjx
===================================================================
--- /trunk/MacFace.prjx (revision 1)
+++ /trunk/MacFace.prjx (revision 1)
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: unk/MacFaceForWin.sln
===================================================================
--- /trunk/MacFaceForWin.sln (revision 124)
+++ (revision )
@@ -1,34 +1,0 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MacFaceLibrary", "MacFaceLibrary\MacFaceLibrary.csproj", "{23267F41-38FE-41F6-BF08-2D8940A1E024}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MacFaceFloat", "MacFaceFloat\MacFaceFloat.csproj", "{60DE0E19-7B98-41E8-8001-A8C7A75AF08E}"
- ProjectSection(ProjectDependencies) = postProject
- {23267F41-38FE-41F6-BF08-2D8940A1E024} = {23267F41-38FE-41F6-BF08-2D8940A1E024}
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MacFaceTest", "MacFaceTest\MacFaceTest.csproj", "{40CD5CB5-835A-4DDD-928D-AEFE64EFAA8E}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {23267F41-38FE-41F6-BF08-2D8940A1E024}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {23267F41-38FE-41F6-BF08-2D8940A1E024}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {23267F41-38FE-41F6-BF08-2D8940A1E024}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {23267F41-38FE-41F6-BF08-2D8940A1E024}.Release|Any CPU.Build.0 = Release|Any CPU
- {60DE0E19-7B98-41E8-8001-A8C7A75AF08E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {60DE0E19-7B98-41E8-8001-A8C7A75AF08E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {60DE0E19-7B98-41E8-8001-A8C7A75AF08E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {60DE0E19-7B98-41E8-8001-A8C7A75AF08E}.Release|Any CPU.Build.0 = Release|Any CPU
- {40CD5CB5-835A-4DDD-928D-AEFE64EFAA8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {40CD5CB5-835A-4DDD-928D-AEFE64EFAA8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {40CD5CB5-835A-4DDD-928D-AEFE64EFAA8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {40CD5CB5-835A-4DDD-928D-AEFE64EFAA8E}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
Index: /trunk/MainForm.cs
===================================================================
--- /trunk/MainForm.cs (revision 1)
+++ /trunk/MainForm.cs (revision 1)
@@ -0,0 +1,114 @@
+// project created on 2004/06/02 at 2:43
+using System;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.IO;
+using System.Diagnostics;
+using System.Threading;
+
+namespace MacFace
+{
+ class MainForm : Misuzilla.Windows.Forms.AlphaForm
+ {
+ private Hashtable _property;
+ private ArrayList _parts;
+ private String _facePath;
+
+ public MainForm()
+ {
+ InitializeComponent();
+// this.Load += new EventHandler(this.Form1_Load);
+ _facePath = Path.Combine(Application.StartupPath,"default.mcface");
+ _property = PropertyList.load(Path.Combine(_facePath,"faceDef.plist"));
+ _parts = (ArrayList)_property["parts"];
+
+ (new Thread(new ThreadStart(CountProcessorUsage))).Start();
+ }
+
+ // THIS METHOD IS MAINTAINED BY THE FORM DESIGNER
+ // DO NOT EDIT IT MANUALLY! YOUR CHANGES ARE LIKELY TO BE LOST
+ void InitializeComponent()
+ {
+ //
+ // Set up generated class MainForm
+ //
+ this.SuspendLayout();
+ this.Name = "MainForm";
+ this.Text = "This is my form";
+ this.Size = new System.Drawing.Size(300, 300);
+ this.ResumeLayout(false);
+ this.ShowInTaskbar = false;
+ this.TopMost = true;
+ this.FormBorderStyle = FormBorderStyle.None;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.ControlBox = false;
+ this.TransparentMouseMessage = false;
+ this.MoveAtFormDrag = true;
+ this.Visible = true;
+ this.Opacity = 0.75F;
+ }
+
+ [STAThread]
+ public static void Main(string[] args)
+ {
+ Application.Run(new MainForm());
+ }
+
+ private void CountProcessorUsage()
+ {
+ PerformanceCounter perfCount = new PerformanceCounter();
+ perfCount.CategoryName = "Processor";
+ perfCount.CounterName = "% Processor Time";
+ perfCount.InstanceName = "_Total";
+
+ PerformanceCounter pageoutCount = new PerformanceCounter();
+ pageoutCount.CategoryName = "Memory";
+ pageoutCount.CounterName = "Pages Output/sec";
+
+ PerformanceCounter pageinCount = new PerformanceCounter();
+ pageinCount.CategoryName = "Memory";
+ pageinCount.CounterName = "Pages Input/sec";
+
+ Int32 prevUsage = -10;
+ while (true) {
+ Int32 usage = (Int32)perfCount.NextValue();
+ Int32 pagein = (Int32)pageinCount.NextValue();
+ Int32 pageout = (Int32)pageoutCount.NextValue();
+
+ Console.WriteLine("Processor: {0}% (pattern: {1}) {2} {3}", usage, usage/10, pagein, pageout);
+ if (usage >= 100) {
+ usage = 100;
+ } else if (usage < 0) {
+ usage = 0;
+ }
+
+ // OÌp^[Ư¶ÈçXVµÈ¢B
+ if (prevUsage/10 != usage/10) {
+ ArrayList patterns = (ArrayList)_property["pattern"];
+ ArrayList patternCpu = (ArrayList)patterns[0];
+ ArrayList facePattern = (ArrayList)patternCpu[usage/10];
+
+ foreach (Int32 i in facePattern) {
+ Hashtable part = _parts[i] as Hashtable;
+ string filename = (string)part["filename"];
+ string imgPath = Path.Combine(_facePath, filename);
+ using (Bitmap bitmap = new Bitmap(imgPath)) {
+ int x = (int)part["pos x"];
+ int y = 128 - (int)part["pos y"] - bitmap.Size.Height;
+ this.Graphics.DrawImage(bitmap,x,y,bitmap.Size.Width,bitmap.Size.Height);
+ }
+ }
+ this.Update();
+ }
+
+ prevUsage = usage;
+ Thread.Sleep(1000);
+ }
+
+ }
+ }
+}
Index: /trunk/PropertyList.cs
===================================================================
--- /trunk/PropertyList.cs (revision 1)
+++ /trunk/PropertyList.cs (revision 1)
@@ -0,0 +1,79 @@
+using System;
+using System.Xml;
+using System.Collections;
+using System.Diagnostics;
+
+namespace MacFace
+{
+ ///
+ /// PropertyList ÌTvÌà¾Å·B
+ ///
+ public class PropertyList : Hashtable
+ {
+ public static Hashtable load(string path)
+ {
+ XmlDocument doc = new XmlDocument();
+ XmlTextReader reader = new XmlTextReader(path);
+ reader.XmlResolver = null;
+ doc.Load(reader);
+
+ return readDictionary(doc.DocumentElement.FirstChild);
+ }
+
+ static Hashtable readDictionary(XmlNode node)
+ {
+ XmlNodeList children = node.ChildNodes;
+ int count = children.Count;
+ Hashtable table = new Hashtable();
+
+//Trace.WriteLine("#DICT#");
+ for (int i = 0; i < count; i+=2)
+ {
+ string key = children[i].InnerText;
+ object value = readValue(children[i+1]);
+
+ table.Add(key,value);
+ }
+//Trace.WriteLine("#/DICT#");
+ return table;
+ }
+
+ static ArrayList readArray(XmlNode node)
+ {
+ ArrayList array = new ArrayList();
+//Trace.WriteLine("#ARRAY#");
+ foreach (XmlNode child in node.ChildNodes)
+ {
+ array.Add(readValue(child));
+ }
+//Trace.WriteLine("#/ARRAY#");
+
+ return array;
+ }
+
+ static object readValue(XmlNode node)
+ {
+ object value;
+ switch (node.Name)
+ {
+ case "dict":
+ value = readDictionary(node);
+ break;
+ case "array":
+ value = readArray(node);
+ break;
+ case "string":
+ value = node.InnerText;
+ break;
+ case "integer":
+ value = int.Parse(node.InnerText);
+ break;
+ default:
+ value = node;
+ break;
+ }
+//Trace.WriteLine(value);
+ return value;
+ }
+ }
+}