示例#1
0
        List <Summary> INvnControl.GetSummary()
        {
            List <Summary> summaries = new List <Summary>();

            foreach (DataGridViewRow row in dgActions.Rows)
            {
                CustomActionBase customAction = (CustomActionBase)row.Tag;
                Summary          summary      = new Summary();
                summary.Title = customAction.Name;
                DataTable summaryData = new DataTable();
                summaryData.Columns.Add("PropertyName");
                summaryData.Columns.Add("Value");
                // get al property values into data table
                summaryData.Rows.Add("Type", customAction.Type.ToString());
                summaryData.Rows.Add(customAction.InstalledFileQueryLabel, customAction.IsInstalledFile);
                summaryData.Rows.Add(customAction.SourcePathLabel, customAction.SourcePath);
                summaryData.Rows.Add(customAction.FunctionLabel, customAction.Function);
                summaryData.Rows.Add(customAction.ExecuteTypeLabel, customAction.ExecuteType.ToString());

                summary.Data = summaryData;
                summaries.Add(summary);
            }

            return(summaries);
        }
示例#2
0
 void INvnControl.Validate()
 {
     foreach (DataGridViewRow row in dgActions.Rows)
     {
         CustomActionBase customAction = (CustomActionBase)row.Tag;
         customAction.Validate();
     }
 }
示例#3
0
 void INvnControl.Build()
 {
     foreach (DataGridViewRow row in dgActions.Rows)
     {
         CustomActionBase customAction = (CustomActionBase)row.Tag;
         object[]         items        = customAction.Build();
         MsiBuilder.CustomActionItems = Common.AddItemToArray(MsiBuilder.CustomActionItems, items);
     }
 }
示例#4
0
        void INvnControl.LoadSaveObjects(Dictionary <string, object> objects)
        {
            Dictionary <string, CustomActionBase> customActions = new Dictionary <string, CustomActionBase>();

            foreach (DataGridViewRow actionRow in dgActions.Rows)
            {
                CustomActionBase customAction = (CustomActionBase)actionRow.Tag;
                customActions.Add(customAction.Id, customAction);
            }
            objects.Add("CustomActions", customActions);
        }
        private void ShowProperties(CustomActionBase customAction)
        {
            dgProperties.Rows.Clear();
            // name
            dgProperties.Rows.Add("Name", customAction.Name);
            // install file type
            if (customAction.Browsable)
            {
                DataGridViewComboBoxCell installedFileCell = new DataGridViewComboBoxCell();
                installedFileCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                installedFileCell.DataSource      = new List <string> {
                    "True", "False"
                };
                installedFileCell.Value = customAction.IsInstalledFile;
                int i = dgProperties.Rows.Add(customAction.InstalledFileQueryLabel);
                dgProperties[1, i] = installedFileCell;
            }
            // source path
            int index = dgProperties.Rows.Add(customAction.SourcePathLabel, customAction.SourcePath);

            if (customAction.Browsable)
            {
                DataGridViewButtonCell browseBtn = new DataGridViewButtonCell();
                browseBtn.Value        = "...";
                dgProperties[2, index] = browseBtn;
            }
            // Function to call Or Arguments
            dgProperties.Rows.Add(customAction.FunctionLabel, customAction.Function);
            // Custom action install schedule
            DataGridViewComboBoxCell installSequenceCell = new DataGridViewComboBoxCell();

            installSequenceCell.DataSource      = Enum.GetNames(typeof(CustomActionExecuteType));
            installSequenceCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            installSequenceCell.Value           = customAction.ExecuteType.ToString();
            index = dgProperties.Rows.Add(customAction.ExecuteTypeLabel);
            dgProperties[1, index] = installSequenceCell;

            // change Code editor syntax
            if (customAction.Scriptable)
            {
                switch (customAction.Type)
                {
                case CustomActionType.JScript:
                    CodeEditorSyntaxLoader.SetSyntax(codeEditorControl, SyntaxLanguage.JavaScript); break;

                case CustomActionType.VBScript:
                    CodeEditorSyntaxLoader.SetSyntax(codeEditorControl, SyntaxLanguage.VBScript); break;
                }
                codeEditorControl.Refresh();
            }

            // Enable or Disable Save script button
            btnSave.Visible = customAction.Scriptable && String.IsNullOrEmpty(customAction.SourcePath) == false;
        }
 private void UpdateCustiomActionNames()
 {
     foreach (DataGridViewRow row in dgActions.Rows)
     {
         CustomActionBase customAction = (CustomActionBase)row.Tag;
         if (customAction.Scriptable && customAction.OriginalScript != string.Empty && customAction.OriginalScript.Equals(customAction.Script) == false)
         {
             row.Cells[0].Value = customAction.Name + "*";
         }
         else
         {
             row.Cells[0].Value = customAction.Name;
         }
     }
 }
示例#7
0
        void INvnControl.Open(Dictionary <string, object> objects)
        {
            Dictionary <string, CustomActionBase> customActions = (Dictionary <string, CustomActionBase>)objects["CustomActions"];

            // create items in datagrid
            foreach (string id in customActions.Keys)
            {
                CustomActionBase customAction = customActions[id];
                int index = dgActions.Rows.Add();
                dgActions[0, index].Value = customAction.Name;
                dgActions.Rows[index].Tag = customAction;
            }
            if (dgActions.Rows.Count > 0)
            {
                dgActions.Rows[0].Selected = true;
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            CustomActionBase customAction = null;

            switch ((CustomActionType)Enum.Parse(typeof(CustomActionType), cmbCustomActionType.Text))
            {
            case CustomActionType.Dll:
                customAction = new CustomAction_Dll();
                break;

            case CustomActionType.Exe:
                customAction = new CustomAction_Exe();
                break;

            case CustomActionType.ExeCommand:
                customAction = new CustomAction_ExeCommand();
                break;

            case CustomActionType.JScript:
                customAction = new CustomAction_JScript();
                break;

            case CustomActionType.VBScript:
                customAction = new CustomAction_VBScript();
                break;
            }
            customAction.Id = Common.GetId();
            int index = dgActions.Rows.Add();

            dgActions[0, index].Value = cmbCustomActionType.Text + " Custom Action";
            dgActions.Rows[index].Tag = customAction;
            // select the new row
            foreach (DataGridViewRow selectedRow in dgActions.SelectedRows)
            {
                selectedRow.Selected = false;
            }
            dgActions.Rows[index].Selected = true;
        }
 private void dgActions_SelectionChanged(object sender, EventArgs e)
 {
     foreach (DataGridViewRow selectedRow in dgActions.SelectedRows)
     {
         selectedCustomAction = null;
         CustomActionBase customAction = (CustomActionBase)selectedRow.Tag;
         if (customAction != null)
         {
             ShowProperties(customAction);
             if (customAction.Scriptable)
             {
                 codeEditorControl.Document.Text = customAction.Script;
                 codeEditorControl.Enabled       = true;
             }
             else
             {
                 codeEditorControl.Document.Text = string.Empty;
                 codeEditorControl.Enabled       = false;
             }
         }
         selectedCustomAction = customAction;
     }
 }