internal override void PerformAction() { TreeListColumn columnToCopy = _mainForm.GetMultiCellSelector().GetColumnIfExactlyOneSelected(); if (columnToCopy == null) { _actionIsCanceled = true; return; } foreach (TreeListNode selectedNode in _mainForm.GetMultiCellSelector().GetSelectedNodes(true, true)) { foreach (TreeListColumn column in _mainForm.treeList.Columns) { if (column.Tag != null && !_mainForm.GetTreeListManager().GetIDsOfHiddenSystems().Contains((column.Tag as SystemTreeListTag).GetSystemRow().ID)) { string value = selectedNode.GetValue((columnToCopy.Tag as SystemTreeListTag).GetSystemRow().Name).ToString(); (selectedNode.Tag as BaseTreeListTag).StoreChangedValue(value, (column.Tag as SystemTreeListTag).GetSystemRow()); selectedNode.SetValue(column, value); //enforce updating of the info provided by combo-boxes and Intelli-sense if Def-functions are changed TreeListManager.UpdateIntelliAndTUBoxInfo((selectedNode.Tag as BaseTreeListTag).GetFunctionName(), column); } } } }
internal static void SetSelectionPrivate(EM_UI_MainForm mainForm) { List <TreeListNode> selectedNodes = new List <TreeListNode>(); TreeListNode focusedNode = mainForm.treeList.FocusedNode; if (mainForm.GetMultiCellSelector().HasSelection() && (focusedNode == null || mainForm.GetMultiCellSelector().GetSelectedNodes().Contains(focusedNode))) { selectedNodes.AddRange(mainForm.GetMultiCellSelector().GetSelectedNodes()); } else { selectedNodes.Add(focusedNode); } mainForm.PerformAction(new SetSelectionPrivateStateAction(selectedNodes), false); }
void mniCopyValues_Click(object sender, EventArgs e) { if (_senderColumn == null || _senderNode == null) { return; } _mainForm.treeList.FocusedNode = _senderNode; _mainForm.treeList.FocusedColumn = _senderColumn; _mainForm.GetMultiCellSelector().CopyToClipBoard(); }
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; }
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); } } }