Ejemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            if (e.Args.Length > 0)        // コマンドライン引数があれば
            {
                DocumentPath = e.Args[0]; // ドキュメント ファイルのパスとする
            }
            if (singleDocumentApplication.Initialize(new Ticker(), DocumentPath, sourcePath => DocumentPath = sourcePath))
            {
                MainWindow.Show();
            }
            else
            {
                Shutdown(); // 他のプロセスが既に起動していれば終了
            }
        }
Ejemplo n.º 2
0
        public bool Run(Form mainForm)
        {
            var commandLineArgs = Environment.GetCommandLineArgs();

            if (commandLineArgs.Length > 1)        // コマンドライン引数があれば
            {
                DocumentPath = commandLineArgs[1]; // ドキュメント ファイルのパスとする
            }
            using (var singleDocumentApplication = new SingleDocumentHelper.Application()) {
                if (singleDocumentApplication.Initialize(new Ticker(), DocumentPath, sourcePath => DocumentPath = sourcePath))
                {
                    Application.Run(mainForm);
                    return(true);
                }
                return(false); // 他のプロセスが既に起動していれば終了
            }
        }