Пример #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Title += "     版本号: " + BuildInfo.Version + "  " + BuildInfo.HeadShaShort;

            string workdir = string.Empty;

            try
            {
                workdir = File.ReadAllText(LAST_WORK_DIR_FILE);
            }
            catch (Exception) { }
            var wdw = new WorkDirectoryWindow()
            {
                Owner    = this,
                WorkPath = workdir,
            };

            if (wdw.ShowDialog() == true)
            {
                workdir = wdw.WorkPath;
            }
            else
            {
                Environment.Exit(-1);
                return;
            }

            if (!Recorder.Initialize(workdir))
            {
                MessageBox.Show("初始化错误", "录播姬", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(-2);
                return;
            }
        }
Пример #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Title += " " + BuildInfo.Version + " " + BuildInfo.HeadShaShort;

            bool   skip_ui = false;
            string workdir = string.Empty;

            CommandLineOption commandLineOption = null;

            Parser.Default
            .ParseArguments <CommandLineOption>(Environment.GetCommandLineArgs())
            .WithParsed(x => commandLineOption = x);

            if (commandLineOption?.WorkDirectory != null)
            {
                skip_ui = true;
                workdir = commandLineOption.WorkDirectory;
            }

            if (!skip_ui)
            {
                try
                {
                    workdir = File.ReadAllText(LAST_WORK_DIR_FILE);
                }
                catch (Exception) { }
                var wdw = new WorkDirectoryWindow()
                {
                    Owner    = this,
                    WorkPath = workdir,
                };

                if (wdw.ShowDialog() == true)
                {
                    workdir = wdw.WorkPath;
                }
                else
                {
                    Environment.Exit(-1);
                    return;
                }
            }

            if (!Recorder.Initialize(workdir))
            {
                if (!skip_ui)
                {
                    MessageBox.Show("初始化错误", "录播姬", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                Environment.Exit(-2);
                return;
            }

            NotifyIcon.Visibility = Visibility.Visible;
        }