Changeset 13


Ignore:
Timestamp:
Nov 15, 2004, 2:12:03 AM (19 years ago)
Author:
altba\tomoyo
Message:

MacFaceFloat?

  • %USERPROFILE%\Application Data\MacFace\ に設定を保存するようにした。
  • 設定ダイアログを作成した。

MacFaceLibrary?

  • パターンをクラスとして扱えるようにした(FacePattern?)。
Location:
trunk
Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MacFaceFloat/MacFaceFloat.csproj

    r9 r13  
    1919                PreBuildEvent = ""
    2020                PostBuildEvent = ""
    21                 RootNamespace = "MacFace"
     21                RootNamespace = "MacFace.FloatApp"
    2222                RunPostBuildEvent = "OnBuildSuccess"
    2323                StartupObject = ""
     
    114114                />
    115115                <File
     116                    RelPath = "AppSettings.cs"
     117                    SubType = "Code"
     118                    BuildAction = "Compile"
     119                />
     120                <File
    116121                    RelPath = "AssemblyInfo.cs"
    117122                    SubType = "Code"
    118123                    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"
    119144                />
    120145                <File
  • trunk/MacFaceFloat/MainForm.cs

    r10 r13  
    1717using System.Threading;
    1818
    19 namespace MacFace
     19namespace MacFace.FloatApp
    2020{
    2121        public class MainForm : Misuzilla.Windows.Forms.AlphaForm
     
    2323                private System.Windows.Forms.ContextMenu contextMenu;
    2424                private System.Windows.Forms.MenuItem menuItemPatternSelect;
     25                private System.Windows.Forms.MenuItem menuItemConfigure;
    2526                private System.Windows.Forms.MenuItem menuItemExit;
    26                 private Hashtable _property;
    27                 private ArrayList _parts;
    2827                private String _facePath;
    2928                private System.Windows.Forms.Timer _updateTimer;
     29
     30                private FaceDef _currentFaceDef;
     31                private Configuration _config;
    3032               
    3133                Int32 prevUsage;
     
    6264                }
    6365
    64                 // THIS METHOD IS MAINTAINED BY THE FORM DESIGNER
    65                 // DO NOT EDIT IT MANUALLY! YOUR CHANGES ARE LIKELY TO BE LOST
    6666                void InitializeComponent() {
    6767                        this.menuItemPatternSelect = new System.Windows.Forms.MenuItem();
     68                        this.menuItemConfigure = new System.Windows.Forms.MenuItem();
    6869                        this.menuItemExit = new System.Windows.Forms.MenuItem();
    6970                        this.contextMenu = new System.Windows.Forms.ContextMenu();
     
    7172                        // menuItemPatternSelect
    7273                        //
    73                         this.menuItemPatternSelect.Index = 0;
    7474                        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);
    7782                        //
    7883                        // menuItemExit
     
    8186                        this.menuItemExit.Shortcut = System.Windows.Forms.Shortcut.CtrlQ;
    8287                        this.menuItemExit.Text = "I—¹(&X)";
    83                         this.menuItemExit.Click += new System.EventHandler(this.doQuit);
     88                        this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
    8489                        //
    8590                        // contextMenu
    8691                        //
    8792                        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});
    8994                        //
    9095                        // MainForm
     
    102107                        this.TopMost = true;
    103108                        this.Load += new EventHandler(MainForm_Load);
     109                        this.Closing += new CancelEventHandler(MainForm_Closing);
     110                        this.Move += new EventHandler(MainForm_Move);
    104111                }
    105112                       
     
    143150
    144151
    145                 bool LoadFaceDefine(string path)
    146                 {
     152                public bool LoadFaceDefine(string path)
     153                {
     154                        FaceDef newFaceDef = null;
    147155                        string plistPath = Path.Combine(path, "faceDef.plist");
    148156
     
    155163                        }
    156164                       
    157                         Hashtable property;
    158165                        try
    159166                        {
    160                                 property = PropertyList.Load(plistPath);
     167                                newFaceDef = MacFace.FaceDef.CreateFaceDefFromFile(path);
    161168                        }
    162169                        catch (System.IO.IOException ie)
     
    180187                        if (_updateTimer != null) _updateTimer.Stop();
    181188
    182                         _property = property;
    183                         _facePath = path;
    184                         _parts = (ArrayList)_property["parts"];
     189                        _currentFaceDef = newFaceDef;
     190                        _facePath = _currentFaceDef.Path;
    185191                        prevUsage = -10;
    186192
     
    205211                               
    206212                        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                                
    211213                                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);
    221219                                }
    222220                                this.Update();
     
    227225               
    228226
     227                //
     228                // ‹N“®
     229                //
    229230                public void MainForm_Load(object sender, System.EventArgs e)
    230231                {
    231                         string faceDefPath = Path.Combine(Application.StartupPath, "default.mcface");
     232                        // Ý’è
     233                        _config = Configuration.GetInstance();
     234                        _config.Load();
     235
     236                        ApplyConfiguration();
     237
     238                        // Šçƒpƒ^[ƒ““ǂݍž‚Ý
    232239                        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);
    237243                        }
    238244
     
    241247                                if (!SelectFaceDefine(Application.StartupPath))
    242248                                {
    243                                         Application.Exit();
     249                                        this.Close();
    244250                                        return;
    245251                                }
     
    247253                        }
    248254                }
     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
    249270
    250271                /*
     
    252273[ƒNƒŠƒbƒNƒCƒxƒ“ƒg
    253274                 */
    254                 public void PatternSelect_Click(object sender, System.EventArgs e)
     275                public void menuItemPatternSelect_Click(object sender, System.EventArgs e)
    255276                {
    256277                        SelectFaceDefine(_facePath);   
    257278                }
    258279
    259                 public void doQuit(object sender, System.EventArgs e)
     280                public void menuItemExit_Click(object sender, System.EventArgs e)
    260281                {
    261282                        _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                }
    265306        }
    266307}
  • trunk/MacFaceLibrary/Face.cs

    • Property svn:keywords set to Id
  • trunk/MacFaceLibrary/FaceDef.cs

    r12 r13  
    1616        public class FaceDef
    1717        {
    18                 public const string FaceDefName = "faceDef.plist";
    19                 public const int PatternCols = 11;
    20                 public const int PatternRows = 3;
    21 
    22                 protected string path;
    23                 protected string title;
    24                 protected string auther;
    25                 protected string version;
    26                 protected string webSite;
    27 
    28                 protected PartList parts = 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();
    2929                //protected int[][,] patterns;
    30                 //protected PartList makers = new PartList();
     30                internal PartList _makers = new PartList();
     31                internal FacePattern _patterns;
    3132
    3233
    3334                // ctor
    34                 private FaceDef() {}
    35 
     35                public FaceDef() {}
    3636
    3737                // properties
     38                public FacePattern FacePattern
     39                {
     40                        get { return _patterns; }
     41                }
     42                public PartList Markers
     43                {
     44                        get { return _makers; }
     45                }
    3846                public PartList Parts
    3947                {
    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                }
    4375
    4476                // methods
     
    4779                        FaceDef faceDef = new FaceDef();
    4880
    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
    5199
    52100                        // Part ‚ð“ǂݍž‚ށB
     
    64112                                int x = (int)partDef["pos x"];
    65113                                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));
    67115                        }
    68116
    69117                        // TODO: pattern ‚ð“ǂݍž‚ށB
     118                        faceDef._patterns = new FacePattern(faceDef.Parts, def["pattern"] as ArrayList);
    70119
    71120                        return faceDef;
    72121                }
    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: ƒtƒH[ƒ}ƒbƒg‚ª•s³‚¾‚Á‚½‚Æ‚«‚É“Š‚°‚éException‚ð‘‚¢‚āA•s³‚¾‚Á‚½‚Æ‚«‚É“Š‚°‚é‚悤‚É‚·‚éB
    74134        }
    75135}
  • trunk/MacFaceLibrary/HostStatistics.cs

    • Property svn:keywords set to Id
  • trunk/MacFaceLibrary/MacFaceLibrary.csproj

    r12 r13  
    105105                />
    106106                <File
     107                    RelPath = "FacePattern.cs"
     108                    SubType = "Code"
     109                    BuildAction = "Compile"
     110                />
     111                <File
    107112                    RelPath = "HostStatistics.cs"
    108113                    SubType = "Code"
  • trunk/MacFaceLibrary/Part.cs

    r8 r13  
    1212        /// Part ‚ÌŠT—v‚Ìà–¾‚Å‚·B
    1313        /// </summary>
    14         public class Part
     14        public class Part : IDisposable
    1515        {
    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;
    2019
    2120                /*public Part(string basePath, Hashtable partDef)
     
    2827                public Part(String path, int x, int y)
    2928                {
    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;
    3433                }
    3534
    3635                public Part(String path, Image image, int x, int y)
    3736                {
    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;
    4241                }
    4342
    4443                public string FileName
    4544                {
    46                         get { return filename; }
     45                        get { return _filename; }
    4746                }
    4847
    4948                public Image Image
    5049                {
    51                         get { return image; }
     50                        get { return _image; }
    5251                }
    5352
     53                public Point Point
     54                {
     55                        get { return _point; }
     56                        set { _point = value; }
     57                }
    5458                public int X
    5559                {
    56                         get { return x; }
     60                        get { return _point.X; }
     61                        set { _point.X = value; }
    5762                }
    5863
    5964                public int Y
    6065                {
    61                         get { return y; }
     66                        get { return 128 - _point.Y - _image.Height; }
     67                        set { _point.Y = 128 - value - _image.Height; }
    6268                }
    6369
     
    6773                        g.DrawImage(img, x, drawY, img.Size.Width, img.Size.Height);
    6874                }*/
     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
    6999        }
    70100}
Note: See TracChangeset for help on using the changeset viewer.