Exemple #1
0
        private void menuItemSetting_Click(object sender, EventArgs e)
        {
            Setting.Config temp    = config.clone();
            Setting        setting = new Setting(temp);
            DialogResult   result  = setting.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                setting.restore(ref config);
                xml.Xml.Write <Setting.Config>(config_path, config);

                // デフォルトカラーに戻すにはノード作ってつなぎ替えとかしないと駄目かもなので再起動推奨ですかね
                //setColor();
            }
        }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();

            this.Text += " " + version;


            setStatus("");

            //setStatus( "Loading..." );

            //System.Reflection.Assembly assem = System.Reflection.Assembly.GetExecutingAssembly();
            //string exe_path = assem.Location;

            exe_path    = Application.ExecutablePath;
            exe_dir     = System.IO.Path.GetDirectoryName(exe_path);
            config_path = exe_dir + @"\config.xml";
            lookup_path = exe_dir + @"\lookup.xml";

            if (System.IO.File.Exists(config_path))
            {
                Setting.Config temp = xml.Xml.Read <Setting.Config>(config_path);
                if (temp != null)     // おそもそも失敗したら例外でおちそう InvalidOperationException
                {
                    config = temp;
                }
            }
            else
            {
                xml.Xml.Write <Setting.Config>(config_path, config);
            }


            // カレントにするか実行ファイルにするか悩む デバッグ時はカレントが楽なんだけど
            //string exe_dir = System.IO.Directory.GetCurrentDirectory();
            System.IO.DirectoryInfo   info       = new System.IO.DirectoryInfo(exe_dir);
            System.IO.FileInfo[]      files      = info.GetFiles("*.txt");
            System.IO.DirectoryInfo[] dirs       = info.GetDirectories();
            List <string>             match_list = new List <string>();

            foreach (System.IO.FileInfo fi in files)
            {
                string name = System.IO.Path.GetFileNameWithoutExtension(fi.Name);   // どっちもinfoにする必要なさそう でもstring取得って中でinfo作ってそうなんだが
                foreach (System.IO.DirectoryInfo di in dirs)
                {
                    if (name == di.Name)
                    {
                        match_list.Add(fi.Name);
                        // listもなにもここでロードすりゃおk
                        setup(fi.FullName, di.FullName);
                    }
                }
            }

            if (System.IO.File.Exists(lookup_path))
            {
                lookup = xml.Xml.Read <Lookup>(lookup_path);
            }
            // 影響は無いが例外が出る
            //http://yk.tea-nifty.com/netdev/2009/03/xmlserializer-a.html

            // 色々な部分でSuspendLayout/ResumeLayoutでロード中の画面構築を止めて高速化できそうなんだが
            //System.IO.Directory.GetDirectories();
            // gffreadも同梱して、toolsetインストール者前提のお手軽中間ファイル構築コマンド作ってもいいかなあ

            //color
            setColor();


            // add handler
            toolStripMenuItemEdit.DropDownOpening += new EventHandler(toolStripMenuItemEdit_DropDownOpening);
        }