Esempio n. 1
0
        /// <summary>
        /// Based on the number of tools in the list and the index of a selected tool,
        /// adjust all button enables. If multiple tools are selected, only Remove
        /// operation is enabled.
        /// Also, fill in the information from the selected tool into this form.
        /// </summary>
        private void AdjustEnables()
        {
            var tool = new ClassTool();
            int numSelected = listTools.SelectedIndices.Count;
            btEdit.Enabled = btUp.Enabled = btDown.Enabled = numSelected == 1;
            btRemove.Enabled = numSelected > 0;
            if (numSelected == 1)
            {
                int sel = listTools.SelectedIndex;
                tool = CustomTools.Tools[sel];

                if (sel == 0)
                    btUp.Enabled = false;
                if (sel == listTools.Items.Count - 1)
                    btDown.Enabled = false;
            }

            textCmd.Text = tool.Cmd;
            textArgs.Text = tool.Args;
            textDir.Text = tool.Dir;
            textDesc.Text = tool.Desc;
            checkAddToContextMenu.Checked = tool.IsAddToContextMenu;
            checkConsoleApp.Checked = tool.IsConsoleApp;
            checkWriteToStatus.Checked = tool.IsWriteOutput;
            checkCloseUponExit.Checked = tool.IsCloseWindowOnExit;
            checkRefresh.Checked = tool.IsRefresh;
            checkPrompt.Checked = tool.IsPromptForArgs;
            checkBrowse.Checked = tool.IsAddBrowse;
        }
Esempio n. 2
0
        /// <summary>
        /// Utility function to find few local tools: experimental
        /// </summary>
        public static List <ClassTool> FindLocalTools()
        {
            List <ClassTool> tools = new List <ClassTool>();

            try
            {
                // If we have msysgit, we should also have few other bundled tools
                string gitpath = Properties.Settings.Default.GitPath;
                if (File.Exists(gitpath))
                {
                    string gitRoot = Path.GetDirectoryName(gitpath);

                    //      ======= Find and add Git Bash =======
                    string GitBash = Path.Combine(gitRoot, "sh.exe");
                    if (File.Exists(GitBash))
                    {
                        ClassTool newTool = new ClassTool();
                        newTool.Name               = "Git Bash";
                        newTool.Cmd                = GitBash;
                        newTool.Dir                = "%r";
                        newTool.Args               = "--login -i";
                        newTool.IsConsoleApp       = true;
                        newTool.IsAddToContextMenu = true;
                        tools.Add(newTool);
                    }
                }
            }
            catch { }   // Never mind.

            return(tools);
        }
Esempio n. 3
0
        /// <summary>
        /// Based on the number of tools in the list and the index of a selected tool,
        /// adjust all button enables.
        /// Also, fill in the information from the selected tool into this form.
        /// </summary>
        private void AdjustEnables()
        {
            ClassTool tool = new ClassTool();
            btEdit.Enabled = btRemove.Enabled = btUp.Enabled = btDown.Enabled = listTools.Items.Count > 0;
            if (listTools.Items.Count > 0)
            {
                int sel = listTools.SelectedIndex;
                tool = CustomTools.Tools[sel];

                if (sel == 0)
                    btUp.Enabled = false;
                if (sel == listTools.Items.Count - 1)
                    btDown.Enabled = false;
            }

            textCmd.Text = tool.Cmd;
            textArgs.Text = tool.Args;
            textDir.Text = tool.Dir;
            textDesc.Text = tool.Desc;
            checkAddToContextMenu.Checked = tool.Checks[0];
            checkConsoleApp.Checked = tool.Checks[1];
            checkWriteToStatus.Checked = tool.Checks[2];
            checkCloseUponExit.Checked = tool.Checks[3];
            checkRefresh.Checked = tool.Checks[4];
            checkPrompt.Checked = tool.Checks[5];
            checkBrowse.Checked = tool.Checks[6];
        }
Esempio n. 4
0
        /// <summary>
        /// Based on the number of tools in the list and the index of a selected tool,
        /// adjust all button enables. If multiple tools are selected, only Remove
        /// operation is enabled.
        /// Also, fill in the information from the selected tool into this form.
        /// </summary>
        private void AdjustEnables()
        {
            var tool        = new ClassTool();
            int numSelected = listTools.SelectedIndices.Count;

            btEdit.Enabled   = btUp.Enabled = btDown.Enabled = numSelected == 1;
            btRemove.Enabled = numSelected > 0;
            if (numSelected == 1)
            {
                int sel = listTools.SelectedIndex;
                tool = CustomTools.Tools[sel];

                if (sel == 0)
                {
                    btUp.Enabled = false;
                }
                if (sel == listTools.Items.Count - 1)
                {
                    btDown.Enabled = false;
                }
            }

            textCmd.Text  = tool.Cmd;
            textArgs.Text = tool.Args;
            textDir.Text  = tool.Dir;
            textDesc.Text = tool.Desc;
            checkAddToContextMenu.Checked = tool.IsAddToContextMenu;
            checkConsoleApp.Checked       = tool.IsConsoleApp;
            checkWriteToStatus.Checked    = tool.IsWriteOutput;
            checkCloseUponExit.Checked    = tool.IsCloseWindowOnExit;
            checkRefresh.Checked          = tool.IsRefresh;
            checkPrompt.Checked           = tool.IsPromptForArgs;
            checkBrowse.Checked           = tool.IsAddBrowse;
        }
Esempio n. 5
0
        /// <summary>
        /// Utility function to find few local tools: experimental
        /// </summary>
        public static List<ClassTool> FindLocalTools()
        {
            List<ClassTool> tools = new List<ClassTool>();

            try
            {
                // If we have msysgit, we should also have few other bundled tools
                string gitpath = Properties.Settings.Default.GitPath;
                if (File.Exists(gitpath))
                {
                    string gitRoot = Path.GetDirectoryName(gitpath);

                    //      ======= Find and add Git Bash =======
                    string GitBash = Path.Combine(gitRoot, "sh.exe");
                    if (File.Exists(GitBash))
                    {
                        ClassTool newTool = new ClassTool();
                        newTool.Name = "Git Bash";
                        newTool.Cmd = GitBash;
                        newTool.Dir = "%r";
                        newTool.Args = "--login -i";
                        newTool.IsConsoleApp = true;
                        newTool.IsAddToContextMenu = true;
                        tools.Add(newTool);
                    }
                }
            }
            catch { }   // Never mind.

            return tools;
        }
Esempio n. 6
0
        public FormEditTools(ClassTool tool)
        {
            InitializeComponent();
            ClassWinGeometry.Restore(this);
            Tool = (ClassTool)tool.Clone();

            textName.Text = tool.Name;
            textCmd.Text  = tool.Cmd;
            textArgs.Text = tool.Args;
            textDir.Text  = tool.Dir;
            textDesc.Text = tool.Desc;
            checkAddToContextMenu.Checked = tool.IsAddToContextMenu;
            checkConsoleApp.Checked       = tool.IsConsoleApp;
            checkWriteToStatus.Checked    = tool.IsWriteOutput;
            checkCloseUponExit.Checked    = tool.IsCloseWindowOnExit;
            checkRefresh.Checked          = tool.IsRefresh;
            checkPrompt.Checked           = tool.IsPromptForArgs;
            checkBrowse.Checked           = tool.IsAddBrowse;

            // TODO: Running a command line tool largely does not work on Linux at the moment
            if (ClassUtils.IsMono())
            {
                checkWriteToStatus.Enabled = checkCloseUponExit.Enabled = false;
                checkWriteToStatus.Checked = checkCloseUponExit.Checked = false;
                checkConsoleApp.Checked    = true; // FIXME: Some success when this is checked
            }

            // Adjust the enables (in this order)
            CheckCloseUponExitCheckedChanged(null, null);
            CheckConsoleAppCheckedChanged(null, null);

            // Set the width of drop-down portions of help combo box so when it expands (down)
            // it will show horizontally the complete text from all pre-defined lines.
            // Also set their tags to point to the buddy edit boxes into which to insert selected tokens.
            SetComboBoxWidth(comboHelpArg);
            comboHelpArg.Tag = textArgs;
            SetComboBoxWidth(comboHelpDir);
            comboHelpDir.Tag = textDir;
        }
Esempio n. 7
0
        public FormEditTools(ClassTool tool)
        {
            InitializeComponent();
            ClassWinGeometry.Restore(this);
            Tool = (ClassTool) tool.Clone();

            textName.Text = tool.Name;
            textCmd.Text = tool.Cmd;
            textArgs.Text = tool.Args;
            textDir.Text = tool.Dir;
            textDesc.Text = tool.Desc;
            checkAddToContextMenu.Checked = tool.IsAddToContextMenu;
            checkConsoleApp.Checked = tool.IsConsoleApp;
            checkWriteToStatus.Checked = tool.IsWriteOutput;
            checkCloseUponExit.Checked = tool.IsCloseWindowOnExit;
            checkRefresh.Checked = tool.IsRefresh;
            checkPrompt.Checked = tool.IsPromptForArgs;
            checkBrowse.Checked = tool.IsAddBrowse;

            // TODO: Running a command line tool does not work on Linux at the moment
            if(ClassUtils.IsMono())
            {
                checkConsoleApp.Enabled = checkWriteToStatus.Enabled = checkCloseUponExit.Enabled = false;
                checkConsoleApp.Checked = checkWriteToStatus.Checked = checkCloseUponExit.Checked = false;
            }

            // Adjust the enables (in this order)
            CheckCloseUponExitCheckedChanged(null, null);
            CheckConsoleAppCheckedChanged(null, null);

            // Set the width of drop-down portions of help combo box so when it expands (down)
            // it will show horizontally the complete text from all pre-defined lines.
            // Also set their tags to point to the buddy edit boxes into which to insert selected tokens.
            SetComboBoxWidth(comboHelpArg);
            comboHelpArg.Tag = textArgs;
            SetComboBoxWidth(comboHelpDir);
            comboHelpDir.Tag = textDir;
        }