示例#1
0
        //------------------------------------------------------
        // Refresh the FileType listbox for this control
        private void RefreshDirList(ControlDefinition def)
        {
            def.mComboBox.Items.Clear();

            // Obtain the file system entries in the directory path.
            if (System.IO.Directory.Exists(def.mDirectory) == false)
            {
                return;
            }

            string pattern = "*." + def.mExtension;

            string[] directoryEntries = System.IO.Directory.GetFileSystemEntries(def.mDirectory, pattern);

            foreach (string str in directoryEntries)
            {
                System.Console.WriteLine(str);
                def.mComboBox.Items.Add(str);
            }

            if (def.mComboBox.Items.Count > 0)
            {
                def.mComboBox.SelectedIndex = 0;
            }
        }
示例#2
0
        //------------------------------------------------------
        // we are removing a single button
        private void UnloadCustomButton(ControlDefinition def, int RemoveFromList)
        {
            switch ((ETYPE)def.mEType)
            {
            case ETYPE.STD_BUTTON:
                def.mButton.Dispose();
                break;

            case ETYPE.STD_BUTTON_EDIT:
                def.mButton.Dispose();
                def.mTextBox.Dispose();
                break;

            case ETYPE.STD_FILETYPE_LIST:
            case ETYPE.STD_FOLDERBROWSER:
                def.mButton.Dispose();
                def.mComboBox.Dispose();
                break;
            }

            if (RemoveFromList != 0)
            {
                mControlsList.RemoveAt(mControlsList.IndexOf(def));
            }
        }
示例#3
0
        //------------------------------------------------------
        private void CreateFileBrowser(string ButtonName, string ComboName, string path, string extension)
        {
            ControlDefinition def = new ControlDefinition();

            def.mEType     = (int)ETYPE.STD_FOLDERBROWSER;
            def.mDirectory = path;
            def.mExtension = extension;

            def.mButton             = new Button();
            def.mButton.Location    = new System.Drawing.Point(0, 0);
            def.mButton.Text        = ButtonName;
            def.mButton.FlatStyle   = FlatStyle.System;
            def.mButton.Name        = "" + mControlsList.Count;
            def.mButton.Click      += new System.EventHandler(this.Event_FolderBrowserHandler);
            def.mButton.ContextMenu = this.ButtonContext;

            def.mComboBox          = new ComboBox();
            def.mComboBox.Location = new System.Drawing.Point(0, 0);
            def.mComboBox.Size     = new System.Drawing.Size(def.mButton.Size.Width * 2, 20);
            def.mComboBox.Name     = ComboName;
            def.mComboBox.TabIndex = 1;
            def.mComboBox.Text     = "";

            this.Controls.Add(def.mButton);
            this.Controls.Add(def.mComboBox);
            mControlsList.Add(def);
            RefreshDirList(def);
        }
示例#4
0
        //------------------------------------------------------
        private void CreateFileTypeButton(string ButtonName, string ComboName, string path, string extension, string command, int HiddenOutput)
        {
            ControlDefinition def = new ControlDefinition();

            def.mEType        = (int)ETYPE.STD_FILETYPE_LIST;
            def.mHiddenOutput = HiddenOutput;
            def.mDirectory    = path;
            def.mExtension    = extension;
            def.mCommand      = command;

            def.mButton             = new Button();
            def.mButton.Location    = new System.Drawing.Point(0, 0);
            def.mButton.Text        = ButtonName;
            def.mButton.FlatStyle   = FlatStyle.System;
            def.mButton.Name        = "" + mControlsList.Count;
            def.mButton.Click      += new System.EventHandler(this.Event_FileTypeClickHandler);
            def.mButton.ContextMenu = this.ButtonContext;

            def.mComboBox          = new ComboBox();
            def.mComboBox.Location = new System.Drawing.Point(0, 0);
            def.mComboBox.Size     = new System.Drawing.Size(def.mButton.Size.Width * 2, 20);
            def.mComboBox.Name     = ComboName;
            def.mComboBox.TabIndex = 1;
            def.mComboBox.Text     = "";

            this.Controls.Add(def.mButton);
            this.Controls.Add(def.mComboBox);
            mControlsList.Add(def);
            RefreshDirList(def);
        }
示例#5
0
        /// <summary>
        /// Create an edit Mog button
        /// </summary>
        /// <param name="ButtonName"></param>
        /// <param name="EditName">Name of edit text box</param>
        /// <param name="Text">Text in edit text box, by default</param>
        /// <param name="Command">Command for shellspawn</param>
        /// <param name="HiddenOutput">Greater than 0 to hide output</param>
        /// <param name="Section">Ini section name for button</param>
        private void CreateEditButton(string ButtonName, string EditName, string Text, string Command, int HiddenOutput, string Section)
        {
            ControlDefinition def = new ControlDefinition();

            def.mEType          = (int)ETYPE.STD_BUTTON_EDIT;
            def.mCommand        = Command;
            def.mHiddenOutput   = HiddenOutput;
            def.mIniSectionName = Section;
            def.mEditText       = Text;

            def.mButton             = new Button();
            def.mButton.Location    = new System.Drawing.Point(0, 0);
            def.mButton.Text        = ButtonName;
            def.mButton.FlatStyle   = FlatStyle.System;
            def.mButton.Name        = "" + mControlsList.Count;
            def.mButton.Click      += new System.EventHandler(this.Event_ParamButtonClickHandler);
            def.mButton.ContextMenu = this.ButtonContext;

            def.mTextBox              = new System.Windows.Forms.TextBox();
            def.mTextBox.Location     = new System.Drawing.Point(0, 0);
            def.mTextBox.Size         = new System.Drawing.Size(def.mButton.Size.Width * 2, 20);
            def.mTextBox.Name         = EditName;
            def.mTextBox.TextChanged += new System.EventHandler(this.ParameterTextChanged);
            def.mTextBox.TabIndex     = 1;
            def.mTextBox.Text         = Text;

            this.Controls.Add(def.mButton);
            this.Controls.Add(def.mTextBox);

            mControlsList.Add(def);
        }
示例#6
0
        //------------------------------------------------------
        // handle a click event on a button with associated edit / param box
        private void Event_ParamButtonClickHandler(object sender, System.EventArgs e)
        {
            string            output = "";
            Button            b      = (Button)sender;
            int               index  = LocateIndex(b);
            ControlDefinition def    = (ControlDefinition)mControlsList[index];

            string args = def.mTextBox.Text;

            args = ReplaceKeyWords(args);
            guiCommandLine.ShellSpawn(def.mCommand, args, def.mHiddenOutput != 0 ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Normal, ref output);
        }
示例#7
0
        //-------------------------------------------------------
        // handle FileType Click event
        private void Event_FileTypeClickHandler(object sender, System.EventArgs e)
        {
            string            output       = "";
            Button            b            = (Button)sender;
            int               idx          = LocateIndex(b);
            ControlDefinition def          = (ControlDefinition)mControlsList[idx];
            Object            selectedItem = def.mComboBox.SelectedItem;

            string args = selectedItem.ToString();

            args = ReplaceKeyWords(args);

            guiCommandLine.ShellSpawn(def.mCommand, args, def.mHiddenOutput != 0 ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Normal, ref output);
            System.Console.WriteLine("TEST");
        }
示例#8
0
        //------------------------------------------------------
        private void Event_FolderBrowserHandler(object sender, System.EventArgs e)
        {
            Button            b   = (Button)sender;
            int               idx = LocateIndex(b);
            ControlDefinition def = (ControlDefinition)mControlsList[idx];

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.SelectedPath = def.mDirectory;

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                def.mDirectory = fbd.SelectedPath;
                WriteSettingsToIni();
            }
        }
示例#9
0
        /// <summary>
        /// Create a standard MOG toolbox button
        /// </summary>
        /// <param name="ButtonName"></param>
        /// <param name="Command">Command for shellspawn</param>
        /// <param name="arguments">Command spawn arguments</param>
        /// <param name="HiddenOutput">Greater than 0 to hide output</param>
        /// <param name="Section">Ini section name for button</param>
        private void CreateStdButton(string ButtonName, string Command, string arguments, int HiddenOutput, string Section)
        {
            ControlDefinition def = new ControlDefinition();

            def.mEType          = (int)ETYPE.STD_BUTTON;
            def.mCommand        = Command;
            def.mHiddenOutput   = HiddenOutput;
            def.mIniSectionName = Section;
            def.mArguments      = arguments;

            def.mButton             = new Button();
            def.mButton.Location    = new System.Drawing.Point(0, 0);
            def.mButton.Text        = ButtonName;
            def.mButton.FlatStyle   = FlatStyle.System;
            def.mButton.Name        = "" + mControlsList.Count;
            def.mButton.Click      += new System.EventHandler(this.Event_ButtonClickHandler);
            def.mButton.ContextMenu = this.ButtonContext;

            // Add the button to the form.
            this.Controls.Add(def.mButton);
            mControlsList.Add(def);
        }
示例#10
0
        //------------------------------------------------------------------
        // Edit the Control
        private void EditControl(object sender, System.EventArgs e)
        {
            MenuItem    item = (MenuItem)sender;
            ContextMenu menu = item.GetContextMenu();
            Button      b    = (Button)menu.SourceControl;

            int index             = LocateIndex(b);
            ControlDefinition def = (ControlDefinition)mControlsList[index];

            switch ((ETYPE)def.mEType)
            {
            case ETYPE.STD_BUTTON:
            case ETYPE.STD_BUTTON_EDIT:
                CustomButtonEdit bEdit = new CustomButtonEdit();

                bEdit.NameBox.Text    = b.Text;
                bEdit.CommandBox.Text = def.mCommand;
                bEdit.StartPosition   = FormStartPosition.CenterScreen;
                if ((ETYPE)def.mEType == ETYPE.STD_BUTTON)
                {
                    bEdit.FieldName.ReadOnly = true;
                    bEdit.Arguments.Text     = def.mArguments;
                }
                else
                {
                    bEdit.FieldName.Text = def.mTextBox.Name;
                    bEdit.Arguments.Text = def.mTextBox.Text;
                }

                DialogResult r = bEdit.ShowDialog();
                if (r == DialogResult.OK)
                {
                    def.mButton.Text  = bEdit.NameBox.Text;
                    def.mButton.Text  = bEdit.NameBox.Text;
                    def.mCommand      = bEdit.CommandBox.Text;
                    def.mHiddenOutput = bEdit.hideoutput.Checked? 1:0;

                    if ((ETYPE)def.mEType == ETYPE.STD_BUTTON)
                    {
                        def.mArguments = bEdit.Arguments.Text;
                    }

                    if ((ETYPE)def.mEType == ETYPE.STD_BUTTON_EDIT)
                    {
                        def.mTextBox.Name = bEdit.FieldName.Text;
                        def.mTextBox.Text = bEdit.Arguments.Text;
                    }

                    // write out update to ini
                    WriteSettingsToIni();
                    return;
                }
                break;

            case ETYPE.STD_FILETYPE_LIST:
                EditFileTypeButton form = new EditFileTypeButton();
                form.TBox_ButName.Text    = def.mButton.Text;
                form.TBox_Path.Text       = def.mDirectory;
                form.TBox_Ext.Text        = def.mExtension;
                form.TBox_Command.Text    = def.mCommand;
                form.Check_Hidden.Checked = def.mHiddenOutput == 0 ? false:true;
                form.StartPosition        = FormStartPosition.CenterScreen;
                form.FieldName.Text       = def.mComboBox.Name;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    def.mButton.Text   = form.TBox_ButName.Text;
                    def.mDirectory     = form.TBox_Path.Text;
                    def.mExtension     = form.TBox_Ext.Text;
                    def.mCommand       = form.TBox_Command.Text;
                    def.mHiddenOutput  = form.Check_Hidden.Checked == true ? 1:0;
                    def.mComboBox.Name = form.FieldName.Text;

                    WriteSettingsToIni();
                    RefreshDirList(def);
                    ScrollButtons(0);
                }
                break;

            case ETYPE.STD_FOLDERBROWSER:

                EditFileBrowserButton form2 = new EditFileBrowserButton();
                form2.StartPosition   = FormStartPosition.CenterScreen;
                form2.FieldName.Text  = def.mComboBox.Name;
                form2.ButtonName.Text = def.mButton.Text;
                if (form2.ShowDialog() == DialogResult.OK)
                {
                    def.mComboBox.Name = form2.FieldName.Text;
                    def.mButton.Text   = form2.ButtonName.Text;
                    WriteSettingsToIni();
                    RefreshDirList(def);
                    ScrollButtons(0);
                }
                break;
            }

            System.Console.WriteLine("TEST");
        }