Changeset 13
- Timestamp:
- Nov 15, 2004, 2:12:03 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MacFaceFloat/MacFaceFloat.csproj
r9 r13 19 19 PreBuildEvent = "" 20 20 PostBuildEvent = "" 21 RootNamespace = "MacFace "21 RootNamespace = "MacFace.FloatApp" 22 22 RunPostBuildEvent = "OnBuildSuccess" 23 23 StartupObject = "" … … 114 114 /> 115 115 <File 116 RelPath = "AppSettings.cs" 117 SubType = "Code" 118 BuildAction = "Compile" 119 /> 120 <File 116 121 RelPath = "AssemblyInfo.cs" 117 122 SubType = "Code" 118 123 BuildAction = "Compile" 124 /> 125 <File 126 RelPath = "AutoConfigurator.cs" 127 SubType = "Code" 128 BuildAction = "Compile" 129 /> 130 <File 131 RelPath = "Configuration.cs" 132 SubType = "Code" 133 BuildAction = "Compile" 134 /> 135 <File 136 RelPath = "ConfigurationForm.cs" 137 SubType = "Form" 138 BuildAction = "Compile" 139 /> 140 <File 141 RelPath = "ConfigurationForm.resx" 142 DependentUpon = "ConfigurationForm.cs" 143 BuildAction = "EmbeddedResource" 119 144 /> 120 145 <File -
trunk/MacFaceFloat/MainForm.cs
r10 r13 17 17 using System.Threading; 18 18 19 namespace MacFace 19 namespace MacFace.FloatApp 20 20 { 21 21 public class MainForm : Misuzilla.Windows.Forms.AlphaForm … … 23 23 private System.Windows.Forms.ContextMenu contextMenu; 24 24 private System.Windows.Forms.MenuItem menuItemPatternSelect; 25 private System.Windows.Forms.MenuItem menuItemConfigure; 25 26 private System.Windows.Forms.MenuItem menuItemExit; 26 private Hashtable _property;27 private ArrayList _parts;28 27 private String _facePath; 29 28 private System.Windows.Forms.Timer _updateTimer; 29 30 private FaceDef _currentFaceDef; 31 private Configuration _config; 30 32 31 33 Int32 prevUsage; … … 62 64 } 63 65 64 // THIS METHOD IS MAINTAINED BY THE FORM DESIGNER65 // DO NOT EDIT IT MANUALLY! YOUR CHANGES ARE LIKELY TO BE LOST66 66 void InitializeComponent() { 67 67 this.menuItemPatternSelect = new System.Windows.Forms.MenuItem(); 68 this.menuItemConfigure = new System.Windows.Forms.MenuItem(); 68 69 this.menuItemExit = new System.Windows.Forms.MenuItem(); 69 70 this.contextMenu = new System.Windows.Forms.ContextMenu(); … … 71 72 // menuItemPatternSelect 72 73 // 73 this.menuItemPatternSelect.Index = 0;74 74 this.menuItemPatternSelect.Text = "çp^[ÌIð(&S)"; 75 this.menuItemPatternSelect.Click += new System.EventHandler(this.PatternSelect_Click); 76 75 this.menuItemPatternSelect.Click += new System.EventHandler(this.menuItemPatternSelect_Click); 76 77 // 78 // menuItemConfigure 79 // 80 this.menuItemConfigure.Text = "MacFace ÌÝè(&C)..."; 81 this.menuItemConfigure.Click +=new EventHandler(menuItemConfigure_Click); 77 82 // 78 83 // menuItemExit … … 81 86 this.menuItemExit.Shortcut = System.Windows.Forms.Shortcut.CtrlQ; 82 87 this.menuItemExit.Text = "I¹(&X)"; 83 this.menuItemExit.Click += new System.EventHandler(this. doQuit);88 this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click); 84 89 // 85 90 // contextMenu 86 91 // 87 92 this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { 88 this.menuItemPatternSelect, new MenuItem("-"), this.menuItemExit});93 this.menuItemPatternSelect, this.menuItemConfigure, new MenuItem("-"), this.menuItemExit}); 89 94 // 90 95 // MainForm … … 102 107 this.TopMost = true; 103 108 this.Load += new EventHandler(MainForm_Load); 109 this.Closing += new CancelEventHandler(MainForm_Closing); 110 this.Move += new EventHandler(MainForm_Move); 104 111 } 105 112 … … 143 150 144 151 145 bool LoadFaceDefine(string path) 146 { 152 public bool LoadFaceDefine(string path) 153 { 154 FaceDef newFaceDef = null; 147 155 string plistPath = Path.Combine(path, "faceDef.plist"); 148 156 … … 155 163 } 156 164 157 Hashtable property;158 165 try 159 166 { 160 property = PropertyList.Load(plistPath);167 newFaceDef = MacFace.FaceDef.CreateFaceDefFromFile(path); 161 168 } 162 169 catch (System.IO.IOException ie) … … 180 187 if (_updateTimer != null) _updateTimer.Stop(); 181 188 182 _property = property; 183 _facePath = path; 184 _parts = (ArrayList)_property["parts"]; 189 _currentFaceDef = newFaceDef; 190 _facePath = _currentFaceDef.Path; 185 191 prevUsage = -10; 186 192 … … 205 211 206 212 if (prevUsage/10 != usage/10) { 207 ArrayList patterns = (ArrayList)_property["pattern"];208 ArrayList patternCpu = (ArrayList)patterns[0];209 ArrayList facePattern = (ArrayList)patternCpu[usage/10];210 211 213 this.Graphics.Clear(Color.FromArgb(0, 0, 0, 0)); 212 foreach (Int32 i in facePattern) { 213 Hashtable part = _parts[i] as Hashtable; 214 string filename = (string)part["filename"]; 215 string imgPath = Path.Combine(_facePath, filename); 216 using (Bitmap bitmap = new Bitmap(imgPath)) { 217 int x = (int)part["pos x"]; 218 int y = 128 - (int)part["pos y"] - bitmap.Size.Height; 219 this.Graphics.DrawImage(bitmap,x,y,bitmap.Size.Width,bitmap.Size.Height); 220 } 214 foreach (Part part in _currentFaceDef.FacePattern.GetPartList(usage, PageOutFlag.Normal)) 215 { 216 this.Graphics.DrawImage(part.Image, 217 part.Point.X, part.Point.Y, 218 part.Image.Size.Width, part.Image.Size.Height); 221 219 } 222 220 this.Update(); … … 227 225 228 226 227 // 228 // N® 229 // 229 230 public void MainForm_Load(object sender, System.EventArgs e) 230 231 { 231 string faceDefPath = Path.Combine(Application.StartupPath, "default.mcface"); 232 // Ýè 233 _config = Configuration.GetInstance(); 234 _config.Load(); 235 236 ApplyConfiguration(); 237 238 // çp^[ÇÝÝ 232 239 bool result = false; 233 234 if (Directory.Exists(faceDefPath)) 235 { 236 result = LoadFaceDefine(faceDefPath); 240 if (Directory.Exists(_config.FaceDefPath)) 241 { 242 result = LoadFaceDefine(_config.FaceDefPath); 237 243 } 238 244 … … 241 247 if (!SelectFaceDefine(Application.StartupPath)) 242 248 { 243 Application.Exit();249 this.Close(); 244 250 return; 245 251 } … … 247 253 } 248 254 } 255 256 // 257 // I¹ 258 // 259 private void MainForm_Closing(object sender, CancelEventArgs e) 260 { 261 // Û¶ 262 _config.Opacity = (int) (this.Opacity * 100); 263 _config.FaceDefPath = (_currentFaceDef != null ? _currentFaceDef.Path : Path.Combine(Application.StartupPath, "default.mcface")); 264 _config.Location = this.Location; 265 _config.TransparentMouseMessage = this.TransparentMouseMessage; 266 267 _config.Save(); 268 } 269 249 270 250 271 /* … … 252 273 [NbNCxg 253 274 */ 254 public void PatternSelect_Click(object sender, System.EventArgs e)275 public void menuItemPatternSelect_Click(object sender, System.EventArgs e) 255 276 { 256 277 SelectFaceDefine(_facePath); 257 278 } 258 279 259 public void doQuit(object sender, System.EventArgs e)280 public void menuItemExit_Click(object sender, System.EventArgs e) 260 281 { 261 282 _updateTimer.Stop(); 262 Application.Exit(); 263 } 264 283 this.Close(); 284 } 285 286 private void menuItemConfigure_Click(object sender, EventArgs e) 287 { 288 ConfigurationForm configForm = new ConfigurationForm(this); 289 if (configForm.ShowDialog() == DialogResult.OK) 290 { 291 ApplyConfiguration(); 292 } 293 } 294 295 private void ApplyConfiguration() 296 { 297 this.Opacity = (float)_config.Opacity / 100; 298 this.Location = _config.Location; 299 this.TransparentMouseMessage = _config.TransparentMouseMessage; 300 } 301 302 private void MainForm_Move(object sender, EventArgs e) 303 { 304 _config.Location = this.Location; 305 } 265 306 } 266 307 } -
trunk/MacFaceLibrary/Face.cs
-
Property
svn:keywords
set to
Id
-
Property
svn:keywords
set to
-
trunk/MacFaceLibrary/FaceDef.cs
r12 r13 16 16 public class FaceDef 17 17 { 18 public conststring FaceDefName = "faceDef.plist";19 public constint PatternCols = 11;20 public constint PatternRows = 3;21 22 pr otected string path;23 pr otected string title;24 pr otected string auther;25 pr otected string version;26 pr otected string webSite;27 28 protected PartListparts = new PartList();18 public static readonly string FaceDefName = "faceDef.plist"; 19 public static readonly int PatternCols = 11; 20 public static readonly int PatternRows = 3; 21 22 private string _path = ""; 23 private string _title = ""; 24 private string _auther = ""; 25 private string _version = ""; /*Version*/ 26 private Uri _webSite = null; 27 28 internal PartList _parts = new PartList(); 29 29 //protected int[][,] patterns; 30 //protected PartList makers = new PartList(); 30 internal PartList _makers = new PartList(); 31 internal FacePattern _patterns; 31 32 32 33 33 34 // ctor 34 private FaceDef() {} 35 35 public FaceDef() {} 36 36 37 37 // properties 38 public FacePattern FacePattern 39 { 40 get { return _patterns; } 41 } 42 public PartList Markers 43 { 44 get { return _makers; } 45 } 38 46 public PartList Parts 39 47 { 40 get { return parts; } 41 } 42 48 get { return _parts; } 49 } 50 public Uri WebSite 51 { 52 get { return _webSite; } 53 set { _webSite = value; } 54 } 55 public string /*Version*/ Version 56 { 57 get { return _version; } 58 set { _version = value; } 59 } 60 public string Author 61 { 62 get { return _auther; } 63 set { _auther = value; } 64 } 65 public string Title 66 { 67 get { return _title; } 68 set { _title = value; } 69 } 70 public string Path 71 { 72 get { return _path; } 73 set { _path = value; } 74 } 43 75 44 76 // methods … … 47 79 FaceDef faceDef = new FaceDef(); 48 80 49 string defFile = Path.Combine(path, FaceDefName); 50 Hashtable def = PropertyList.Load(path); 81 string defFile = System.IO.Path.Combine(path, FaceDefName); 82 Hashtable def = PropertyList.Load(defFile); 83 84 // îñ 85 faceDef.Title = (def.ContainsKey("title") ? def["title"] as string : String.Empty); 86 faceDef.Author = (def.ContainsKey("author") ? def["author"] as string : String.Empty); 87 faceDef.Version = (def.ContainsKey("version") ? def["version"] as string : String.Empty); 88 faceDef.Path = path; 89 90 if (def.ContainsKey("web site")) 91 { 92 try 93 { 94 faceDef.WebSite = new Uri(def["web site"] as string); 95 } 96 catch (UriFormatException) {} 97 } 98 51 99 52 100 // Part ðÇÝÞB … … 64 112 int x = (int)partDef["pos x"]; 65 113 int y = (int)partDef["pos y"]; 66 faceDef.Parts.Add(new Part( filename, x, y));114 faceDef.Parts.Add(new Part(System.IO.Path.Combine(path, filename), x, y)); 67 115 } 68 116 69 117 // TODO: pattern ðÇÝÞB 118 faceDef._patterns = new FacePattern(faceDef.Parts, def["pattern"] as ArrayList); 70 119 71 120 return faceDef; 72 121 } 73 122 } 123 124 public enum MarkerBitMask 125 { 126 None = 0x0000, 127 PageIn = 0x0001, 128 PageOut = 0x0002 129 } 130 131 public class FaceDefFormatException : ApplicationException 132 { 133 // TODO: tH[}bgªs³¾Á½Æ«É°éExceptionð¢ÄAs³¾Á½Æ«É°éæ¤É·éB 74 134 } 75 135 } -
trunk/MacFaceLibrary/HostStatistics.cs
-
Property
svn:keywords
set to
Id
-
Property
svn:keywords
set to
-
trunk/MacFaceLibrary/MacFaceLibrary.csproj
r12 r13 105 105 /> 106 106 <File 107 RelPath = "FacePattern.cs" 108 SubType = "Code" 109 BuildAction = "Compile" 110 /> 111 <File 107 112 RelPath = "HostStatistics.cs" 108 113 SubType = "Code" -
trunk/MacFaceLibrary/Part.cs
r8 r13 12 12 /// Part ÌTvÌà¾Å·B 13 13 /// </summary> 14 public class Part 14 public class Part : IDisposable 15 15 { 16 protected Image image; 17 protected string filename; 18 protected int x; 19 protected int y; 16 private Image _image; 17 private string _filename; 18 private Point _point; 20 19 21 20 /*public Part(string basePath, Hashtable partDef) … … 28 27 public Part(String path, int x, int y) 29 28 { 30 this.filename = filename;31 this.image = Image.FromFile(path);32 this. x= x;33 this. y= y;29 _filename = System.IO.Path.GetFileName(path); 30 _image = Image.FromFile(path); 31 this.X = x; 32 this.Y = y; 34 33 } 35 34 36 35 public Part(String path, Image image, int x, int y) 37 36 { 38 this.filename = filename;39 this.image = image;40 this. x= x;41 this. y= y;37 _filename = System.IO.Path.GetFileName(path); 38 _image = image; 39 this.X = x; 40 this.Y = y; 42 41 } 43 42 44 43 public string FileName 45 44 { 46 get { return filename; }45 get { return _filename; } 47 46 } 48 47 49 48 public Image Image 50 49 { 51 get { return image; }50 get { return _image; } 52 51 } 53 52 53 public Point Point 54 { 55 get { return _point; } 56 set { _point = value; } 57 } 54 58 public int X 55 59 { 56 get { return x; } 60 get { return _point.X; } 61 set { _point.X = value; } 57 62 } 58 63 59 64 public int Y 60 65 { 61 get { return y; } 66 get { return 128 - _point.Y - _image.Height; } 67 set { _point.Y = 128 - value - _image.Height; } 62 68 } 63 69 … … 67 73 g.DrawImage(img, x, drawY, img.Size.Width, img.Size.Height); 68 74 }*/ 75 76 #region IDisposable o 77 78 public void Dispose() 79 { 80 Dispose(true); 81 GC.SuppressFinalize(this); 82 } 83 84 protected virtual void Dispose(bool disposing) 85 { 86 if (disposing) 87 { 88 } 89 // í 90 if (_image != null) { _image.Dispose(); } 91 } 92 93 ~Part() 94 { 95 Dispose(false); 96 } 97 98 #endregion 69 99 } 70 100 }
Note: See TracChangeset
for help on using the changeset viewer.