private void init()
        {
            this.tree = new TreeManager(this.tvFolders);
            this.tree.OnProtectionStatusChanged += new EventHandler<ProtectionStatusChangedEventArgs>(tree_OnProtectionStatusChanged);
            this.tree.OnDeleteRequest += new EventHandler<DeleteRequestFromTreeEventArgs>(tree_OnDeleteRequest);

            this.lbAppTitle.Text += string.Format("{0}", Assembly.GetExecutingAssembly().GetName().Version.ToString());

            #region Bind config settings to controls

            // Read folder from the config file
            this.tbFolder.DataBindings.Add("Text", Properties.Settings.Default, "last_used_directory");

            this.cbIgnoreHiddenFolders.DataBindings.Add("Checked", Properties.Settings.Default, "dont_scan_hidden_folders");
            this.cbIgnore0kbFiles.DataBindings.Add("Checked", Properties.Settings.Default, "ignore_0kb_files");
            this.cbKeepSystemFolders.DataBindings.Add("Checked", Properties.Settings.Default, "keep_system_folders");
            this.cbClipboardDetection.DataBindings.Add("Checked", Properties.Settings.Default, "clipboard_detection");
            this.cbHideScanErrors.DataBindings.Add("Checked", Properties.Settings.Default, "hide_scan_errors");

            this.tbIgnoreFiles.DataBindings.Add("Text", Properties.Settings.Default, "ignore_files");
            this.tbIgnoreFolders.DataBindings.Add("Text", Properties.Settings.Default, "ignore_directories");

            this.nuMaxDepth.DataBindings.Add("Value", Properties.Settings.Default, "max_depth");
            this.nuInfiniteLoopDetectionCount.DataBindings.Add("Value", Properties.Settings.Default, "infinite_loop_detection_count");
            this.nuPause.DataBindings.Add("Value", Properties.Settings.Default, "pause_between");
            this.cbIgnoreErrors.DataBindings.Add("Checked", Properties.Settings.Default, "ignore_deletion_errors");

            // Special field
            this.lblRedStats.Text = String.Format(RED2.Properties.Resources.red_deleted, Properties.Settings.Default.delete_stats);

            // Delete mode
            foreach (var d in DeleteModeItem.GetList())
                this.cbDeleteMode.Items.Add(new DeleteModeItem(d));

            this.cbDeleteMode.DataBindings.Add("SelectedIndex", Properties.Settings.Default, "delete_mode");

            #region Check if the user started RED as admin

            var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

            if (principal.IsInRole(WindowsBuiltInRole.Administrator))
            {
                var isIntegrated = SystemFunctions.IsRegKeyIntegratedIntoWindowsExplorer();

                this.btnExplorerIntegrate.Enabled = !isIntegrated;
                this.btnExplorerRemove.Enabled = isIntegrated;

                this.Text += " (Admin mode)";
            }
            else
            {
                this.lblReqAdmin.ForeColor = Color.Red;
                this.btnExplorerIntegrate.Enabled = false;
                this.btnExplorerRemove.Enabled = false;
            }

            #endregion

            var credits = Path.Combine(Application.StartupPath, "credits.txt");

            if (File.Exists(credits))
                this.tbCredits.AppendText(File.ReadAllText(credits));
            else
                this.tbCredits.AppendText("Error: Could not find the credits text file:" + Environment.NewLine + credits);

            this.nuFolderAge.DataBindings.Add("Value", Properties.Settings.Default, "min_folder_age_hours");

            #endregion

            this.lbStatus.Text = "";
            this.cmStrip.Enabled = false;

            this.pbProgressStatus.Maximum = 100;
            this.pbProgressStatus.Minimum = 0;
            this.pbProgressStatus.Step = 5;

            this.btnShowLog.Enabled = false;

            drawDirectoryIcons();

            #region Read and apply command line arguments

            string[] args = Environment.GetCommandLineArgs();

            if (args.Length > 1)
            {
                args[0] = "";
                var path = String.Join("", args).Replace("\"", "").Trim();

                // add ending backslash
                if (!path.EndsWith("\\")) path += "\\";

                Properties.Settings.Default.last_used_directory = path;
            }

            #endregion
        }
Beispiel #2
0
        private void init()
        {
            this.tree = new TreeManager(this.tvFolders);
            this.tree.OnProtectionStatusChanged += new EventHandler <ProtectionStatusChangedEventArgs>(tree_OnProtectionStatusChanged);
            this.tree.OnDeleteRequest           += new EventHandler <DeleteRequestFromTreeEventArgs>(tree_OnDeleteRequest);

            this.lbAppTitle.Text += string.Format("{0}", Assembly.GetExecutingAssembly().GetName().Version.ToString());

            #region Bind config settings to controls

            // Read folder from the config file
            this.tbFolder.DataBindings.Add("Text", Properties.Settings.Default, "last_used_directory");

            this.cbIgnoreHiddenFolders.DataBindings.Add("Checked", Properties.Settings.Default, "dont_scan_hidden_folders");
            this.cbIgnore0kbFiles.DataBindings.Add("Checked", Properties.Settings.Default, "ignore_0kb_files");
            this.cbKeepSystemFolders.DataBindings.Add("Checked", Properties.Settings.Default, "keep_system_folders");
            this.cbClipboardDetection.DataBindings.Add("Checked", Properties.Settings.Default, "clipboard_detection");
            this.cbHideScanErrors.DataBindings.Add("Checked", Properties.Settings.Default, "hide_scan_errors");

            this.tbIgnoreFiles.DataBindings.Add("Text", Properties.Settings.Default, "ignore_files");
            this.tbIgnoreFolders.DataBindings.Add("Text", Properties.Settings.Default, "ignore_directories");

            this.nuMaxDepth.DataBindings.Add("Value", Properties.Settings.Default, "max_depth");
            this.nuInfiniteLoopDetectionCount.DataBindings.Add("Value", Properties.Settings.Default, "infinite_loop_detection_count");
            this.nuPause.DataBindings.Add("Value", Properties.Settings.Default, "pause_between");
            this.cbIgnoreErrors.DataBindings.Add("Checked", Properties.Settings.Default, "ignore_deletion_errors");

            // Special field
            this.lblRedStats.Text = String.Format(RED2.Properties.Resources.red_deleted, Properties.Settings.Default.delete_stats);

            // Delete mode
            foreach (var d in DeleteModeItem.GetList())
            {
                this.cbDeleteMode.Items.Add(new DeleteModeItem(d));
            }

            this.cbDeleteMode.DataBindings.Add("SelectedIndex", Properties.Settings.Default, "delete_mode");

            #region Check if the user started RED as admin

            var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());

            if (principal.IsInRole(WindowsBuiltInRole.Administrator))
            {
                var isIntegrated = SystemFunctions.IsRegKeyIntegratedIntoWindowsExplorer();

                this.btnExplorerIntegrate.Enabled = !isIntegrated;
                this.btnExplorerRemove.Enabled    = isIntegrated;

                this.Text += " (Admin mode)";
            }
            else
            {
                this.lblReqAdmin.ForeColor        = Color.Red;
                this.btnExplorerIntegrate.Enabled = false;
                this.btnExplorerRemove.Enabled    = false;
            }

            #endregion

            var credits = Path.Combine(Application.StartupPath, "credits.txt");

            if (File.Exists(credits))
            {
                this.tbCredits.AppendText(File.ReadAllText(credits));
            }
            else
            {
                this.tbCredits.AppendText("Error: Could not find the credits text file:" + Environment.NewLine + credits);
            }

            this.nuFolderAge.DataBindings.Add("Value", Properties.Settings.Default, "min_folder_age_hours");

            #endregion

            this.lbStatus.Text   = "";
            this.cmStrip.Enabled = false;

            this.pbProgressStatus.Maximum = 100;
            this.pbProgressStatus.Minimum = 0;
            this.pbProgressStatus.Step    = 5;

            this.btnShowLog.Enabled = false;

            drawDirectoryIcons();

            #region Read and apply command line arguments

            string[] args = Environment.GetCommandLineArgs();

            if (args.Length > 1)
            {
                args[0] = "";
                var path = String.Join("", args).Replace("\"", "").Trim();

                // add ending backslash
                if (!path.EndsWith("\\"))
                {
                    path += "\\";
                }

                Properties.Settings.Default.last_used_directory = path;
            }

            #endregion
        }