Esempio n. 1
0
        public FrmEditEnvVar(ref EnvironmentSnapshot snapshot, EnvironmentVariable variable)
        {
            InitializeComponent();
            this.snapshot          = snapshot;
            this.variable          = variable;
            this.MinimumSize       = new Size(327, 439);
            dgvValuesList.TabIndex = 0;
            LoadSettings();
            txtVariableName.CausesValidation = false;
            dgvHandler = new DgvHandler(ref dgvValuesList);

            // set default icon
            dgvValuesList_UserAddedRow(null, null);

            this.txtVariableName.Text = variable.Name;
            this.validator            = new EnvironmentValueValidator();

            if (txtVariableName.Text.Length != 0)
            {
                // Check if we are editing variable
                LoadEnvironmentVariableValues();
            }

            // Set form title
            this.Text = (txtVariableName.Text.Length != 0
                ? "Edit" : "New") + " "
                        + (this.snapshot.Target == EnvironmentVariableTarget.Machine
                ? "System" : "User") + " Variable";

            #region Create DgvHandler Commands
            commandsList = new CommandStack();
            dgvHandler.SetCurrentCell(0);
            editVarNameCommand = new EditVarNameCommand(txtVariableName);
            #endregion DgvHandler Commands

            // disable buttons
            SetBtnState();
            txtVariableName.CausesValidation = true;
            isVarNameChanged = false;

            // Open/Save File dialogs
            openFileDialog.Filter     = FILE_FILTER;
            openFileDialog.DefaultExt = DEFAULT_FILTER_EXTENSION;
            saveFileDialog.Filter     = FILE_FILTER;
            saveFileDialog.DefaultExt = DEFAULT_FILTER_EXTENSION;

            if (EnvironmentVariableManager.IsElevated)
            {
                btnSave.Image = Resources.Save;
            }
            else
            {
                btnSave.Image = Resources.shield_uac;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrmEditEnvVar"/> class.
        /// </summary>
        /// <param name="variableName">Name of the variable.</param>
        /// <param name="variableType">Type of the variable.</param>
        public FrmEditEnvVar(
            string variableName, EnvironmentVariableTarget variableType)
        {
            this.InitializeComponent();
            this.MinimumSize       = new Size(327, 439);
            dgvValuesList.TabIndex = 0;
            this.LoadSettings();
            txtVariableName.CausesValidation = false;
            this.dgvHandler = new DgvHandler(ref dgvValuesList);

            // set default icon
            this.DgvValuesList_UserAddedRow(null, null);

            this.txtVariableName.Text = variableName;

            // remember current name
            this.variableName = variableName;
            this.variableType = variableType;
            this.validator    = new EnvVarValueValidator();

            if (txtVariableName.Text.Length != 0)
            {
                // Check if we are editing variable
                this.LoadEnvironmentVariableValues();
            }

            // Set form title
            this.Text = (txtVariableName.Text.Length != 0
                ? "Edit" : "New") + " "
                        + (this.variableType == EnvironmentVariableTarget.Machine
                ? "System" : "User") + " Variable";

            this.commandsList = new UndoRedoCommandList();
            this.dgvHandler.SetCurrentCell(0);
            this.editVarNameCommand = new EditVarNameCommand(txtVariableName);

            // disable buttons
            this.SetBtnState();
            txtVariableName.CausesValidation = true;
            this.isVarNameChanged            = false;

            // Open/Save File dialogs
            openFileDialog.Filter     = FileFilter;
            openFileDialog.DefaultExt = DefaultFilterExtension;
            saveFileDialog.Filter     = FileFilter;
            saveFileDialog.DefaultExt = DefaultFilterExtension;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrmEditEnvVar"/> class.
        /// </summary>
        /// <param name="variableName">Name of the variable.</param>
        /// <param name="variableType">Type of the variable.</param>
        public FrmEditEnvVar(
            string variableName, EnvironmentVariableTarget variableType)
        {
            this.InitializeComponent();
            this.MinimumSize = new Size(327, 439);
            dgvValuesList.TabIndex = 0;
            this.LoadSettings();
            txtVariableName.CausesValidation = false;
            this.dgvHandler = new DgvHandler(ref dgvValuesList);

            // set default icon
            this.DgvValuesList_UserAddedRow(null, null);

            this.txtVariableName.Text = variableName;

            // remember current name
            this.variableName = variableName;
            this.variableType = variableType;
            this.validator = new EnvVarValueValidator();

            if (txtVariableName.Text.Length != 0)
            {   
                // Check if we are editing variable
                this.LoadEnvironmentVariableValues();
            }

            // Set form title
            this.Text = (txtVariableName.Text.Length != 0
                ? "Edit" : "New") + " "
                + (this.variableType == EnvironmentVariableTarget.Machine
                ? "System" : "User") + " Variable";

            this.commandsList = new UndoRedoCommandList();
            this.dgvHandler.SetCurrentCell(0);
            this.editVarNameCommand = new EditVarNameCommand(txtVariableName);
            
            // disable buttons
            this.SetBtnState();
            txtVariableName.CausesValidation = true;
            this.isVarNameChanged = false;

            // Open/Save File dialogs
            openFileDialog.Filter = FileFilter;
            openFileDialog.DefaultExt = DefaultFilterExtension;
            saveFileDialog.Filter = FileFilter;
            saveFileDialog.DefaultExt = DefaultFilterExtension;
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 /// <param name="commandName">Name of the command.</param>
 public DgvCommand(DgvHandler dgvHandler, string commandName)
 {
     this.dgvHandler = dgvHandler;
     this.commandName = commandName;
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvMoveDownCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 public DgvMoveDownCommand(DgvHandler dgvHandler)
     : base(dgvHandler, "Move Value Down")
 {
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvMoveToTopCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 public DgvMoveToTopCommand(DgvHandler dgvHandler)
     : base(dgvHandler, "Move Value to Top")
 {
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvMoveUpCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 public DgvMoveUpCommand(DgvHandler dgvHandler)
     : base(dgvHandler, "Move Value Up")
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvMoveToTopCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 public DgvMoveToTopCommand(DgvHandler dgvHandler)
     : base(dgvHandler, "Move Value to Top")
 {
 }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvMoveDownCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 public DgvMoveDownCommand(DgvHandler dgvHandler)
     : base(dgvHandler, "Move Value Down")
 {
 }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvMoveUpCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 public DgvMoveUpCommand(DgvHandler dgvHandler)
     : base(dgvHandler, "Move Value Up")
 {
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 /// <param name="commandName">Name of the command.</param>
 public DgvCommand(DgvHandler dgvHandler, string commandName)
 {
     this.dgvHandler  = dgvHandler;
     this.commandName = commandName;
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvMoveToBottomCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 public DgvMoveToBottomCommand(DgvHandler dgvHandler)
     : base(dgvHandler, "Move Value to Bottom")
 {
 }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DgvMoveToBottomCommand"/> class.
 /// </summary>
 /// <param name="dgvHandler">The DGV handler.</param>
 public DgvMoveToBottomCommand(DgvHandler dgvHandler)
     : base(dgvHandler, "Move Value to Bottom")
 {
 }