internal ContextMenuStrip GetContextMenu(TreeListNode senderNode, TreeListColumn senderColumn)
        {
            //private comments are not available in public versions
            mniPrivateComment.Visible = !EM_AppContext.Instance.IsPublicVersion();
            separator.Visible         = !EM_AppContext.Instance.IsPublicVersion();

            //disable paste in (the rather unlikely) case that there is nothing on the clipboard
            mniPasteValues.Enabled = !MultiCellSelector.IsClipboardEmpty();

            _senderNode   = senderNode;
            _senderColumn = senderColumn;

            return(mnuCell);
        }
        void GreyState(TreeListNode senderNode)
        {
            if (senderNode == null)
            {
                return;
            }

            BaseTreeListTag treeListTag     = _mainForm.treeList.FocusedNode.Tag as BaseTreeListTag;
            bool            isParameterNode = treeListTag.GetDefaultParameterRow() != null;

            mniDeleteParameter.Enabled      = isParameterNode;
            mniDeleteFunction.ShortcutKeys  = isParameterNode ? System.Windows.Forms.Keys.None : System.Windows.Forms.Keys.Delete;
            mniDeleteParameter.ShortcutKeys = isParameterNode ? System.Windows.Forms.Keys.Delete : System.Windows.Forms.Keys.None;
            mniMoveFunctionDown.Enabled     = senderNode.NextNode != null;
            mniMoveFunctionUp.Enabled       = senderNode.PrevNode != null;
            mniPasteFunctionAfter.Enabled   = mniPasteFunctionBefore.Enabled = EM_AppContext.Instance.GetPasteFunctionAction() != null;
            mniPrivate.Enabled = !_mainForm._isAddOn;
            //the following is in fact not really correct (a reasonable copy of the selection is only possible if the function-name-cell lies within the selection and the selection contains editable cells)
            //it's aim is just to indicate that it is not possible to copy the values of the function with this menu (unless they are selected)
            mniCopyValues.Enabled        = _mainForm.GetMultiCellSelector().HasSelection();
            toolStripSeparator10.Enabled = !MultiCellSelector.IsClipboardEmpty();
            mniGroups.Enabled            = !_mainForm._isAddOn;
            mniExtensions.Enabled        = !_mainForm._isAddOn;
        }
        void GreyState(TreeListNode senderNode)
        {
            if (senderNode == null)
            {
                return;
            }
            bool singlePolicyView = (_mainForm != null && _mainForm.GetTreeListBuilder() != null && _mainForm.GetTreeListBuilder().SinglePolicyView);

            mniMovePolicyDown.Enabled       = senderNode.NextNode != null && !singlePolicyView;
            mniMovePolicyUp.Enabled         = senderNode.PrevNode != null && !singlePolicyView;
            mniPastePolicyAfter.Enabled     = mniPastePolicyBefore.Enabled = EM_AppContext.Instance.GetPastePolicyAction() != null && !singlePolicyView;
            mniPasteReferenceBefore.Enabled = mniPasteReferenceAfter.Enabled = !_mainForm._isAddOn &&
                                                                               EM_AppContext.Instance.GetPastePolicyAction() != null &&
                                                                               EM_AppContext.Instance.GetPastePolicyAction().GetCopyCountryShortName() == _mainForm.GetCountryShortName() &&
                                                                               !singlePolicyView;
            mniPasteFunction.Enabled      = EM_AppContext.Instance.GetPasteFunctionAction() != null && !PolicyTreeListTag.IsReferencePolicy(senderNode);
            mniCopyPolicy.Enabled         = !PolicyTreeListTag.IsReferencePolicy(senderNode);
            mniRenamePolicy.Enabled       = !PolicyTreeListTag.IsReferencePolicy(senderNode);
            mniChangePolicyType.Enabled   = !PolicyTreeListTag.IsReferencePolicy(senderNode);
            mniPrivate.Enabled            = !_mainForm._isAddOn;
            mniGoToReferredPolicy.Enabled = PolicyTreeListTag.IsReferencePolicy(senderNode);
            mniAddPolicyAfter.Enabled     = !singlePolicyView;
            mniAddPolicyBefore.Enabled    = !singlePolicyView;
            mniDeletePolicy.Enabled       = !singlePolicyView;
            //the following is in fact not really correct (a reasonable copy of the selection is only possible if the policy-name-cell lies within the selection and the selection contains editable cells)
            //it's aim is just to indicate that it is not possible to copy the values of the policy with this menu (unless they are selected)
            mniCopyValues.Enabled  = _mainForm.GetMultiCellSelector().HasSelection();
            mniPasteValues.Enabled = !MultiCellSelector.IsClipboardEmpty();
            if (_mniAddFunction == null)
            {
                return;
            }
            _mniAddFunction.Enabled = !PolicyTreeListTag.IsReferencePolicy(senderNode);
            mniGroups.Enabled       = !_mainForm._isAddOn;
            mniExtensions.Enabled   = !_mainForm._isAddOn;
        }
예제 #4
0
 internal ChangeNodeColorAction(int argbColor, MultiCellSelector multiCellSelector)
 {
     _argbColor         = argbColor;
     _multiCellSelector = multiCellSelector;
 }
예제 #5
0
        internal override void PerformAction()
        {
            List <List <string> > clipboardConent = MultiCellSelector.GetFromClipBoard();

            //one single cell copied: spread its content to the whole selected region
            if (clipboardConent.Count == 1 && clipboardConent.ElementAt(0).Count == 1)
            {
                foreach (TreeListNode node in _mainForm.GetMultiCellSelector().GetSelectedNodes(true))
                {
                    foreach (TreeListColumn column in _mainForm.GetMultiCellSelector().GetSelectedColumns(true))
                    {
                        PasteIntoCell(node, column, clipboardConent.ElementAt(0).ElementAt(0));
                    }
                }
                return;
            }

            //more than one single cell copied:
            //first get a possible selection; if there isn't any get the focused node; also get the focused node if it is outside the selection (this is accomplished by the parameters of GetSelected...)
            List <TreeListNode>   selectedNodes   = _mainForm.GetMultiCellSelector().GetSelectedNodes(true, true);
            List <TreeListColumn> selectedColumns = _mainForm.GetMultiCellSelector().GetSelectedColumns(true, true);

            int focusedNodeVisibleIndex = (selectedColumns.Count != 1 || selectedNodes.Count != 1) ? -1 :
                                          _mainForm.treeList.GetVisibleIndexByNode(selectedNodes.ElementAt(0));
            int focusedColumnVisibleIndex = (selectedColumns.Count != 1 || selectedNodes.Count != 1) ? -1 :
                                            selectedColumns.ElementAt(0).VisibleIndex;

            //then loop over the clipboard content
            int nodeIndex = 0;

            foreach (List <string> rowContent in clipboardConent) //loop over rows in clipboard
            {
                TreeListNode node = null;
                if (focusedNodeVisibleIndex == -1) //there is a selection: only paste those values, which fit into the selection
                {
                    if (nodeIndex >= selectedNodes.Count)
                    {
                        break;
                    }
                    node = selectedNodes.ElementAt(nodeIndex);
                }
                else //there is no selection: paste, starting from the focused node
                {
                    node = _mainForm.treeList.GetNodeByVisibleIndex(focusedNodeVisibleIndex + nodeIndex);
                    if (node == null)
                    {
                        break;
                    }
                }
                ++nodeIndex;

                int columnIndex = 0;
                foreach (string cellContent in rowContent) //loop over columns in clipboard
                {
                    TreeListColumn column = null;
                    if (focusedColumnVisibleIndex == -1) //there is a selection: only paste those values, which fit into the selection
                    {
                        if (columnIndex >= selectedColumns.Count)
                        {
                            break;
                        }
                        column = selectedColumns.ElementAt(columnIndex);
                    }
                    else //there is no selection: paste, starting from the focused column
                    {
                        column = _mainForm.treeList.GetColumnByVisibleIndex(focusedColumnVisibleIndex + columnIndex);
                        if (column == null)
                        {
                            break;
                        }
                    }
                    ++columnIndex;

                    PasteIntoCell(node, column, cellContent);
                }
            }
        }