Пример #1
0
        public LpsVoiceRoid(msgVoiceRoid option)
        {
            this.mvr = option;
            this.initThread();

            //空以外の場合にスレッド起動
            if (option.title == "")
            {
                flgNotFound = true;
            }
            else
            {

            }
        }
Пример #2
0
        private bool findVoiceroidWindow(msgVoiceRoid option, bool bStartup)
        {
            //起動チェック
            bool flag = LpsWindowsApi.IsWindow(this.hWindow);

            //プレイボタンチェック
            if (!flag && !LpsWindowsApi.IsWindow(this.hPlayButton))
            {
                flag = false;
            }

            //ストップボタンチェック
            if (!LpsWindowsApi.IsWindow(this.hStopButton))
            {
                flag = false;
            }

            //ストップボタンチェック
            if (!flag)
            {
                flag = this.getVoiceroidWindowHandle();
                if (!flag)
                {
                    this.hWindow = IntPtr.Zero;
                    this.hPlayButton = IntPtr.Zero;
                    this.hStopButton = IntPtr.Zero;
                }
            }

            //起動チェック
            if (!flag && bStartup)
            {
                bool flag2 = false;

                //ファイル存在チェック
                if (!File.Exists(option.path))
                {
                    this.clearMessage();
                    if (MessageBox.Show("VOICEROID.exeが見つかりません。\n設定を行なってください。", "Liplis", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        //起動をうながす。
                        flgNotFound = true;
                    }
                    return false;
                }

                //起動して待つ
                if (new Process { StartInfo = { FileName = option.path, WorkingDirectory = Path.GetDirectoryName(option.path) } }.Start())
                {
                    int num = 30;
                    do
                    {
                        Thread.Sleep(500);
                        num--;
                    }
                    while (num >= 0 && !this.findVoiceroidWindow(option, false));

                    //起動チェック(マイナス値になったら起動失敗と判断)
                    flag2 = (num >= 0);
                }

                //起動失敗チェック
                if (!flag2)
                {
                    this.clearMessage();
                    MessageBox.Show("VOICEROIDの起動が確認できませんでした", "Liplis", MessageBoxButtons.OK);
                    return false;
                }
                flag = flag2;
            }

            //見つかった!
            flgNotFound = false;

            //起動結果を返す
            return flag;
        }