Пример #1
0
 private void dgrExtensions_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == deleteColumn.Index)
     {
         dgrExtensions.Rows.RemoveAt(e.RowIndex);
         // update row index(Display) values
         for (int i = 0; i < dgrExtensions.Rows.Count; i++)
         {
             dgrExtensions[indexColumn.Name, i].Value = i + 1;
         }
     }
     else if (e.ColumnIndex == BrowseColumn.Index)
     {
         // show dialog to select files and folders in Components tree
         ComponentsForm componentsForm = new ComponentsForm(true);
         Point          pointToScreen  = PointToScreen(dgrExtensions.Location);
         int            x = pointToScreen.X + dgrExtensions.Columns[0].Width + dgrExtensions.Columns[1].Width + dgrExtensions.Columns[2].Width + dgrExtensions.Columns[3].Width - componentsForm.Width;
         int            y = pointToScreen.Y + dgrExtensions.ColumnHeadersHeight + dgrExtensions.Rows[e.RowIndex].Height * e.RowIndex;
         componentsForm.Location = new Point(x, y);
         if (componentsForm.ShowDialog() == DialogResult.OK)
         {
             if (componentsForm.SelectedComponentNode != null)
             {
                 ComponentNode componentNode = (ComponentNode)componentsForm.SelectedComponentNode.Tag;
                 dgrExtensions[applicationColumn.Name, e.RowIndex].Value = (new FileInfo(componentNode.Property.SourcePath)).Name;
                 dgrExtensions.Rows[e.RowIndex].Tag = componentsForm.SelectedComponentNode;
             }
         }
     }
     else
     {
         dgrExtensions.BeginEdit(true);
     }
 }
Пример #2
0
        public TreeNode SelectTreeNode()
        {
            // serialize tvComponents
            SerializeComponentsTree();
            ComponentsForm componentsForm = new ComponentsForm();// tvCompnents is loaded here

            if (componentsForm.ShowDialog() == DialogResult.OK)
            {
                return(componentsForm.SelectedComponentNode);
            }
            return(null);
        }
Пример #3
0
 private void addFile_Shortcuts_Click(object sender, EventArgs e)
 {
     if (tvShortcuts.SelectedNode != null)
     {
         ComponentsForm componentsForm = new ComponentsForm(true);
         if (componentsForm.ShowDialog() == DialogResult.OK)
         {
             TreeNode      selectedComponentNode = componentsForm.SelectedComponentNode;
             ComponentNode tag = (ComponentNode)tvShortcuts.SelectedNode.Tag;
             if ((tag != null && tag.Type == ComponentType.Folder) || tvShortcuts.SelectedNode.Level == 0)
             {
                 TreeNode newNode = new TreeNode(selectedComponentNode.Text, selectedComponentNode.ImageIndex, selectedComponentNode.SelectedImageIndex);
                 newNode.Tag = selectedComponentNode.Tag;                                // assign complete ComponentNode object of component node
                 ((ComponentNode)newNode.Tag).SecondaryTreeNode = selectedComponentNode; // assign Component Tree node itself
                 tvShortcuts.SelectedNode.Nodes.Add(newNode);
                 tvShortcuts.Invalidate();
             }
         }
         // Show component tree again
         pnlComponents.Controls.Clear();
         pnlComponents.Controls.Add(ControlsManager.TreeViews["Components"]);
     }
 }
Пример #4
0
        private void dgProperties_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (selectedCustomAction != null)
            {
                // show relevent form to select a file
                if (e.ColumnIndex == 2 && e.RowIndex == 2 && selectedCustomAction.Browsable)
                {
                    // ask user whether to overrite text in script editor
                    if (selectedCustomAction.Scriptable && selectedCustomAction.Script != string.Empty && MessageBox.Show("Script editor is not empty. This action will overrite content in the script editor. Do you want to continue ?", "Editor not empty", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                    {
                        return;
                    }

                    string filePath = string.Empty;
                    if (selectedCustomAction.IsInstalledFile == "True")
                    {
                        // show dialog to select files and folders in Components tree
                        ComponentsForm componentsForm = new ComponentsForm(true);
                        Point          pointToScreen  = PointToScreen(dgProperties.Location);
                        int            x = pointToScreen.X + dgProperties.Columns[0].Width + dgProperties.Columns[1].Width - componentsForm.Width;
                        int            y = pointToScreen.Y + dgProperties.ColumnHeadersHeight + dgProperties.Rows[e.RowIndex].Height * e.RowIndex;
                        componentsForm.Location = new Point(x, y);
                        if (componentsForm.ShowDialog() == DialogResult.OK)
                        {
                            if (componentsForm.SelectedComponentNode != null)
                            {
                                TreeNode componentNode = componentsForm.SelectedComponentNode;
                                filePath = ((ComponentNode)componentNode.Tag).Property.SourcePath;
                                selectedCustomAction.Tag = componentNode.Tag;
                            }
                        }
                    }
                    else
                    {
                        // show OpenFileDialog
                        OpenFileDialog dlg = new OpenFileDialog();
                        dlg.Multiselect      = false;
                        dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            filePath = dlg.FileName;
                        }
                    }
                    if (filePath != string.Empty)
                    {
                        // update Custom Action item
                        foreach (DataGridViewRow row in dgProperties.Rows)
                        {
                            if ((string)row.Cells[0].Value == selectedCustomAction.SourcePathLabel)
                            {
                                row.Cells[1].Value = selectedCustomAction.SourcePath = filePath;
                                if (selectedCustomAction.Scriptable)
                                {
                                    ReadScriptFile(filePath);
                                    btnSave.Visible = true;
                                }
                                break;
                            }
                        }
                    }
                }// show drop down if selected cell is of type ComboBox
                else if (e.ColumnIndex == 1 && e.RowIndex >= 0)
                {
                    dgProperties.BeginEdit(true);
                    Type type = dgProperties[e.ColumnIndex, e.RowIndex].GetType();
                    if (type == typeof(DataGridViewComboBoxCell))
                    {
                        DataGridViewComboBoxEditingControl comboboxEdit = (DataGridViewComboBoxEditingControl)dgProperties.EditingControl;
                        comboboxEdit.DroppedDown = true;
                    }
                }
            }
        }