コード例 #1
0
ファイル: MacFaceApp.cs プロジェクト: OchseGit/MacFaceForWin
        public bool LoadFaceDefine(string path)
        {
            FaceDef newFaceDef = null;
            string  plistPath  = Path.Combine(path, "faceDef.plist");

            if (!File.Exists(plistPath))
            {
                System.Windows.Forms.MessageBox.Show(
                    String.Format("指定されたフォルダに顔パターン定義XMLファイル \"faceDef.plist\" が存在しません。\n\nフォルダ:\n{0}", path),
                    "MacFace for Windows", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            try
            {
                newFaceDef = new MacFace.FaceDef(path);
            }
            catch (System.IO.IOException ie)
            {
                System.Windows.Forms.MessageBox.Show(
                    String.Format("顔パターン定義XMLファイルを読み込む際にエラーが発生しました。\n\n原因:\n{0}",
                                  ie.ToString()), "MacFace for Windows", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(false);
            }
            catch (System.Xml.XmlException xe)
            {
                System.Windows.Forms.MessageBox.Show(
                    String.Format("顔パターン定義XMLファイルを読込み中にエラーが発生しました。\n\n原因:\n{0}",
                                  xe.ToString()), "MacFace for Windows", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(false);
            }

            curFaceDef = newFaceDef;

            if (patternWindow != null)
            {
                // 顔パターン差し替え中は更新を止めておく
                if (updateTimer != null)
                {
                    updateTimer.Stop();
                }

                patternWindow.FaceDef = newFaceDef;
                patternWindow.Refresh();

                notifyIcon.Text = "MacFace - " + patternWindow.FaceDef.Title;

                // 更新再開
                if (updateTimer != null)
                {
                    updateTimer.Start();
                }
            }

            return(true);
        }
コード例 #2
0
ファイル: MacFaceApp.cs プロジェクト: OchseGit/MacFaceForWin
        private void menuItemPatternList_Click(object sender, EventArgs e)
        {
            MacFace.FaceDef faceDef = new MacFace.FaceDef(config.FaceDefPath);
            Bitmap          image   = new Bitmap(128 * 11, 128 * 3);
            Graphics        g       = Graphics.FromImage(image);
            Image           patternImg;


            for (int suite = 0; suite <= 2; suite++)
            {
                for (int no = 0; no <= 10; no++)
                {
                    patternImg = faceDef.PatternImage((MacFace.FaceDef.PatternSuite)suite, no, 0);
                    g.DrawImage(patternImg, 128 * no, 128 * suite);
                }
            }

            g.Dispose();

            image.Save(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\facedump.png",
                       System.Drawing.Imaging.ImageFormat.Png);
        }