private void TextureChangerForm_Load(object sender, EventArgs e) { _textureChangerOptions = new TextureChangerOptions(); #region SAIのフォルダが未指定のときはユーザに指定してもらう if (_textureChangerOptions.PathToSaiFolder == "") { string temp = this.RequestPathToSaiFolder(); if (temp != "") { _textureChangerOptions.PathToSaiFolder = temp; } else { CenteredMessageBox.Show( this , "SAIのインストール先を設定できませんでした。\n" + "操作先のSAIがわからないため、処理を継続できません。\n"+ "申し訳ありませんが、プログラムの起動を中断します。" , "TexureChanger起動確認" , MessageBoxButtons.OK, MessageBoxIcon.Error); ForceExitProgram = true; Application.Exit(); return; } } //このプログラムの特性上、PathToSaiFolderが空ということは無しの前提で動かす #endregion #region メニューのチェック状態の再構築 SetCheckingForMenuFirstExpandingFolder(); mniPromptToExitProgram.Checked = _textureChangerOptions.PromptToExitProgram; #endregion #region ウィンドウの状況を復元 Rectangle bounds; FormWindowState state; _textureChangerOptions.LoadWindowConditions(out bounds, out state); Bounds = bounds; WindowState = state; splNorthSouth.SplitterDistance = _textureChangerOptions.SplitterDistanceNorthSouth <= splNorthSouth.Panel1MinSize ? splNorthSouth.Panel1MinSize : _textureChangerOptions.SplitterDistanceNorthSouth; splTreeList.SplitterDistance = _textureChangerOptions.SplitterDistanceTreeList <= splTreeList.Panel1MinSize ? splTreeList.Panel1MinSize : _textureChangerOptions.SplitterDistanceTreeList; #endregion #region 起動確認 CenteredMessageBox.Show(this, "SAIに対するテクスチャの設定変更は、直接即座に上書きされます。 \n" + "また、TextureChanger起動中にSAIを起動した場合、\n" + "それまでの状況に関わらずSAIの設定が再読み込みされます。\n" + "\n" + "TextureChangerとSAIはお互いを知らないので、\n" + "SAI起動中にTextureChangerを実行することができません。\n" , "TexureChanger起動確認" , MessageBoxButtons.OK, MessageBoxIcon.Information); #endregion #region SAIの起動中確認とテクスチャ情報の読み込み _saiProcessCheckTimer = new Timer(); _saiProcessCheckTimer.Tick += new EventHandler(SaiProcessCheckTimerHandler); _saiProcessCheckTimer.Interval = 1000; _textureManager = null; SaiProcessCheckTimerHandler(sender, e); #endregion #region エクスプローラの初期表示 trvFolder.InitFolderTreeView(this); trvFolder.DrillToFolder(_textureChangerOptions.FirstExpandingFolder); #endregion #region ステータスバーに編集中のテクスチャのフォルダのフルパスを表示する lblStatus.Text = _textureChangerOptions.LastEditingTextureName + " - " + _textureChangerOptions.PathToSaiFolder + "\\" + _textureManager.GetDirectoryFromConfname(_textureChangerOptions.LastEditingTextureName); #endregion #region アプリケーションの準備ができた時点で更新を確認 if (_textureChangerOptions.CheckUpdateAtStartUp) { HttpUpdater httpUpdater = new HttpUpdater(this); httpUpdater.BeginAsyncCheckAppConfigUpdated(); } #endregion }
private void mniRestore_Click( object sender, EventArgs e ) { _saiProcessCheckTimer.Stop(); _textureManager.Restore(this); _textureManager = null; SaiProcessCheckTimerHandler( sender, e ); }
private void SaiProcessCheckTimerHandler(object sender, EventArgs e) { //リロード目的で呼ばれる場合:あらかじめ_textureManager=nullしてからこれを呼ぶ //プロセス監視目的で呼ばれる場合:既存の_textureManager!=nullで呼ばれる _saiProcessCheckTimer.Stop(); Process[] hProcesses = Process.GetProcessesByName(SAI); while (hProcesses.Length != 0) { _textureManager = null; DialogResult res = CenteredMessageBox.Show(this, "SAIの起動が検出されました。\n" + "このプログラムはSAIの起動中は処理を行えません。\n" + "\n" + "SAIを通常終了し、3つほど数えてから「OK」してみて下さい。 \n" + "最新のテクスチャ情報を再読み込みします。\n" + "\n" + "確認しますか? (「キャンセル」でこちらが強制終了です)" , "--- SAI起動中 ---" , MessageBoxButtons.OKCancel, MessageBoxIcon.Information ); if (res == DialogResult.Cancel) { ForceExitProgram = true; Application.Exit(); return; } else { hProcesses = Process.GetProcessesByName(SAI); } } // この先は、まったく引っかからなかったか、OKして抜けてきている if (_textureManager == null) { _textureManager = new TextureManager(_textureChangerOptions.PathToSaiFolder,this); lsvTextureImage_UpdateImages(sender, e); } _saiProcessCheckTimer.Start(); }
private void mniRequestSaiFolder_Click(object sender, EventArgs e) { string temp = RequestPathToSaiFolder(); if (temp != "") { _saiProcessCheckTimer.Stop(); _textureChangerOptions.PathToSaiFolder = temp; _textureManager = null; SaiProcessCheckTimerHandler(sender, e); } }