コード例 #1
0
ファイル: frmMain.cs プロジェクト: altoplano/HandBrake
        /// <summary>
        /// Initializes a new instance of the <see cref="frmMain"/> class.
        /// </summary>
        /// <param name="args">
        /// The arguments passed in on application startup.
        /// </param>
        public frmMain(string[] args)
        {
            InitializeComponent();
            this.presetsToolStrip.Renderer = new ToolStripRenderOverride();

            // We can use LibHB, if the library hb.dll exists.
            this.SourceScan = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();
            lbl_libhb_warning.Visible = File.Exists("hb.dll") ? true : false;

            // Update the users config file with the CLI version data.
            Main.SetCliVersionData();

            if (userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion).Contains("svn"))
            {
                this.Text += " " + userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion);
            }

            // Check for new versions, if update checking is enabled
            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.UpdateStatus))
            {
                if (DateTime.Now.Subtract(userSettingService.GetUserSetting<DateTime>(UserSettingConstants.LastUpdateCheckDate)).TotalDays
                    > userSettingService.GetUserSetting<int>(UserSettingConstants.DaysBetweenUpdateCheck))
                {
                    // Set when the last update was
                    this.userSettingService.SetUserSetting(UserSettingConstants.LastUpdateCheckDate, DateTime.Now);
                    string url = userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakePlatform).Contains("x86_64")
                                                  ? userSettingService.GetUserSetting<string>(UserSettingConstants.Appcast_x64)
                                                  : userSettingService.GetUserSetting<string>(UserSettingConstants.Appcast_i686);
                    UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false, url, userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild),
                        userSettingService.GetUserSetting<int>(UserSettingConstants.Skipversion));
                }
            }

            // Clear the log files in the background
            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.ClearOldLogs))
            {
                Thread clearLog = new Thread(() => GeneralUtilities.ClearLogFiles(30));
                clearLog.Start();
            }

            // Setup the GUI components
            LoadPresetPanel(); // Load the Preset Panel
            treeView_presets.ExpandAll();
            lbl_encode.Text = string.Empty;
            drop_mode.SelectedIndex = 0;
            queueWindow = new frmQueue(this.queueProcessor, this); // Prepare the Queue
            if (!userSettingService.GetUserSetting<bool>(UserSettingConstants.QueryEditorTab))
                tabs_panel.TabPages.RemoveAt(7); // Remove the query editor tab if the user does not want it enabled.
            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.TooltipEnable))
                ToolTip.Active = true;

            // Load the user's default settings or Normal Preset
            if (this.presetHandler.DefaultPreset != null)
            {
                this.loadPreset(this.presetHandler.DefaultPreset.Name);
            }
            else
                loadPreset("Normal");

            // Register with Growl (if not using Growl for the encoding completion action, this wont hurt anything)
            GrowlCommunicator.Register();

            // Event Handlers and Queue Recovery
            events();
            Main.RecoverQueue(this.queueProcessor);

            // If have a file passed in via command arguemtents, check it's a file and try scanning it.
            if (args.Length >= 1 && (File.Exists(args[0]) || Directory.Exists(args[0])))
            {
                this.StartScan(args[0], 0);
            }
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: saintdev/HandBrake
        /// <summary>
        /// Initializes a new instance of the <see cref="frmMain"/> class.
        /// </summary>
        /// <param name="args">
        /// The arguments passed in on application startup.
        /// </param>
        public frmMain(string[] args)
        {
            InitializeComponent();
            this.presetsToolStrip.Renderer = new ToolStripRenderOverride();

            // We can use LibHB, if the library hb.dll exists.
            this.SourceScan = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();

            // Update the users config file with the CLI version data.
            Main.SetCliVersionData();

            if (userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion).Contains("svn"))
            {
                this.Text += " " + userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion);
            }

            // Check for new versions, if update checking is enabled
            if (Settings.Default.updateStatus)
            {
                if (DateTime.Now.Subtract(Settings.Default.lastUpdateCheckDate).TotalDays > Properties.Settings.Default.daysBetweenUpdateCheck)
                {
                    // Set when the last update was
                    Settings.Default.lastUpdateCheckDate = DateTime.Now;
                    Settings.Default.Save();
                    string url = this.userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild).EndsWith("1")
                                                  ? Settings.Default.appcast_unstable
                                                  : Settings.Default.appcast;
                    UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false, url, userSettingService.GetUserSettingInt(UserSettingConstants.HandBrakeBuild), Settings.Default.skipversion, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion));
                }
            }

            // Clear the log files in the background
            if (Settings.Default.clearOldLogs)
            {
                Thread clearLog = new Thread(() => GeneralUtilities.ClearLogFiles(30));
                clearLog.Start();
            }

            // Setup the GUI components
            LoadPresetPanel(); // Load the Preset Panel
            treeView_presets.ExpandAll();
            lbl_encode.Text = string.Empty;
            drop_mode.SelectedIndex = 0;
            queueWindow = new frmQueue(this.queueProcessor, this); // Prepare the Queue
            if (!Settings.Default.QueryEditorTab)
                tabs_panel.TabPages.RemoveAt(7); // Remove the query editor tab if the user does not want it enabled.
            if (Settings.Default.tooltipEnable)
                ToolTip.Active = true;

            // Load the user's default settings or Normal Preset
            if (Settings.Default.defaultPreset != string.Empty && presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null)
            {
                string query = presetHandler.GetPreset(Settings.Default.defaultPreset).Query;
                if (query != null)
                {
                    x264Panel.Reset2Defaults();

                    EncodeTask presetQuery = QueryParserUtility.Parse(query);
                    PresetLoader.LoadPreset(this, presetQuery, Settings.Default.defaultPreset);

                    x264Panel.StandardizeOptString();
                    x264Panel.SetCurrentSettingsInPanel();
                }
            }
            else
                loadNormalPreset();

            // Register with Growl (if not using Growl for the encoding completion action, this wont hurt anything)
            GrowlCommunicator.Register();

            // Event Handlers and Queue Recovery
            events();
            Main.RecoverQueue(this.queueProcessor);

            // If have a file passed in via command arguemtents, check it's a file and try scanning it.
            if (args.Length >= 1 && (File.Exists(args[0]) || Directory.Exists(args[0])))
            {
                this.StartScan(args[0], 0);
            }
        }