internal override void PerformAction() { foreach (TreeListNode node in _senderNodes) { PolicyTreeListTag polTag = node.Tag as PolicyTreeListTag; FunctionTreeListTag funTag = node.Tag as FunctionTreeListTag; ParameterTreeListTag parTag = node.Tag as ParameterTreeListTag; if (polTag != null) { foreach (CountryConfig.PolicyRow policyRow in polTag.GetPolicyRows()) { policyRow.Private = policyRow.Private == DefPar.Value.YES ? DefPar.Value.NO : DefPar.Value.YES; } node.StateImageIndex = polTag.GetDefaultPolicyRow().Private == DefPar.Value.YES ? DefGeneral.IMAGE_IND_PRIV_POL : DefGeneral.IMAGE_IND_POL; } else if (funTag != null) { foreach (CountryConfig.FunctionRow funRow in funTag.GetFunctionRows()) { funRow.Private = funRow.Private == DefPar.Value.YES ? DefPar.Value.NO : DefPar.Value.YES; } node.StateImageIndex = funTag.GetDefaultFunctionRow().Private == DefPar.Value.YES ? DefGeneral.IMAGE_IND_PRIV_FUN : DefGeneral.IMAGE_IND_FUN; } else if (parTag != null) { foreach (CountryConfig.ParameterRow parRow in parTag.GetParameterRows()) { parRow.Private = parRow.Private == DefPar.Value.YES ? DefPar.Value.NO : DefPar.Value.YES; } node.StateImageIndex = parTag.GetDefaultParameterRow().Private == DefPar.Value.YES ? DefGeneral.IMAGE_IND_PRIV_PAR : -1; } } }
internal void PolicyViewChanged(bool toSinglePolicyView) { if (toSinglePolicyView == _singlePolicyView) { return; //nothing to do, just a click on the already selected option } //"manual" implementation of check-boxes, as that da... ribbon does not offer applicable check-boxes _mainForm.chkFullSpine.Glyph = toSinglePolicyView ? Properties.Resources.checkbox : Properties.Resources.checkbox_checked; _mainForm.chkSinglePolicy.Glyph = toSinglePolicyView ? Properties.Resources.checkbox_checked : Properties.Resources.checkbox; _singlePolicyView = toSinglePolicyView; _idsDisplayedSinglePolicy.Clear(); if (toSinglePolicyView) //change to single policy view with the focused policy as the single one { TreeListNode node = _mainForm.treeList.FocusedNode; while (node != null && node.ParentNode != null) { node = node.ParentNode; //get the policy node of focused functions/parameters } if (node != null && node.Tag != null) { PolicyTreeListTag policyTreeListTag = node.Tag as PolicyTreeListTag; if (policyTreeListTag != null) //need to gather policy-ids of all systems as the FillTreeList function has just one of them { foreach (CountryConfig.PolicyRow policyRow in policyTreeListTag.GetPolicyRows()) { _idsDisplayedSinglePolicy.Add(policyRow.ID); } } } } RedrawTreeForPolicyView(); //update the tree to realise the selected view }
internal PastePolicyAction(TreeListNode copyNode, EM_UI_MainForm copyCountryForm) { PolicyTreeListTag tag = (copyNode.Tag != null) ? (copyNode.Tag as PolicyTreeListTag) : null; if (tag != null) { _copyPolicyRows = new Dictionary <string, CountryConfig.PolicyRow>(); foreach (CountryConfig.PolicyRow policyRow in tag.GetPolicyRows()) { _copyPolicyRows.Add(policyRow.SystemRow.ID, policyRow); } } _copyCountryForm = copyCountryForm; }
internal void PolicySelectMenu_ItemSelected(CountryConfig.PolicyRow policyRow) { try { if (policyRow == null) //user selected menu item "Full Spine" { PolicyViewChanged(false); return; } CountryConfigFacade countryConfigFacade = CountryAdministration.CountryAdministrator.GetCountryConfigFacade(_mainForm.GetCountryShortName()); if (_singlePolicyView) //in single-poliy-view: display the selected policy as "the" policy { _idsDisplayedSinglePolicy.Clear(); //need to gather policy-ids of all systems as the FillTreeList function has just one of them foreach (string systemID in GetSystemIDs()) { System.Data.DataRow twinRow = CountryConfigFacade.GetTwinRow(policyRow, systemID); if (twinRow != null && (twinRow as CountryConfig.PolicyRow) != null) { _idsDisplayedSinglePolicy.Add((twinRow as CountryConfig.PolicyRow).ID); } } RedrawTreeForPolicyView(); //update the tree to realise the selected view } else //in full-spine-view: jump to the selected policy { foreach (TreeListNode policyNode in _mainForm.treeList.Nodes) { PolicyTreeListTag policyTag = policyNode.Tag as PolicyTreeListTag; //need to check policy-ids of all systems as the FillTreeList function (where the policies for the menu were gathered) provided just one of them foreach (CountryConfig.PolicyRow nodePolicyRow in policyTag.GetPolicyRows()) { if (nodePolicyRow.ID == policyRow.ID) { _mainForm.treeList.FocusedNode = policyNode; return; //done } } } } } catch (Exception exception) { UserInfoHandler.RecordIgnoredException("TreeListBuilder.selectPolicyMenu_ItemClicked", exception); } }
internal override void PerformAction() { PolicyTreeListTag policyTreeListTag = _senderNode.Tag as PolicyTreeListTag; if (CountryConfigFacade.IsReferencePolicy(policyTreeListTag.GetDefaultPolicyRow())) { Tools.UserInfoHandler.ShowInfo("The policy cannot be deleted as it is used by a(t least one) reference policy." + Environment.NewLine + "Please delete the reference policies before deleting the policy itself."); _actionIsCanceled = true; return; } _senderNode.TreeList.DeleteNode(_senderNode); foreach (CountryConfig.PolicyRow policyRow in policyTreeListTag.GetPolicyRows()) { policyRow.Delete(); EM_AppContext.Instance.GetActiveCountryMainForm().GetTreeListBuilder().RemoveFromAvailablePolicies(policyRow); } }
internal override void PerformAction() { PolicyTreeListTag policyTreeListTag = _senderNode.Tag as PolicyTreeListTag; string countryShortName = CountryConfigFacade.GetCountryShortName((_senderNode.Tag as PolicyTreeListTag).GetDefaultPolicyRow()).ToLower(); string policyName = policyTreeListTag.GetPolicyName(); string currentName = policyTreeListTag.GetDefaultPolicyRow().Name; if (!UserInfoHandler.GetPolicyName(ref policyName, countryShortName, _senderNode.TreeList, currentName)) { _actionIsCanceled = true; return; } foreach (CountryConfig.PolicyRow policyRow in policyTreeListTag.GetPolicyRows()) //loop over systems (actually over neighbour policies within systems) { policyRow.Name = policyName; _senderNode.SetValue(_mainForm.GetTreeListBuilder().GetSystemColumnByID(policyRow.SystemID), policyRow.Switch); } _senderNode.SetValue(_mainForm.GetTreeListBuilder().GetPolicyColumn(), policyName); }
internal void InsertPolicyNode(CountryConfig.PolicyRow distinctPolicyRow, int nodeIndex = -1) { TreeListNode policyNode = _mainForm.treeList.AppendNode(null, null); if (nodeIndex != -1) { _mainForm.treeList.SetNodeIndex(policyNode, nodeIndex); } //a reference policy is a policy that does not really exist, but marks (in the spine) //the re-calculation of a policy that was already calculated further up in the spine CountryConfig.PolicyRow referencePolicy = null; if (distinctPolicyRow.ReferencePolID != null && distinctPolicyRow.ReferencePolID != string.Empty) { referencePolicy = _countryConfigFacade.GetPolicyRowByID(distinctPolicyRow.ReferencePolID); //get the "real" policy to assess the necessary information (in essence the name) } //equip the node with the non system specific information about the policy policyNode.SetValue(_policyColumnName, referencePolicy == null ? distinctPolicyRow.Name : referencePolicy.Name); policyNode.SetValue(_commentColumnName, distinctPolicyRow.Comment); policyNode.Tag = new PolicyTreeListTag(_mainForm); //here create the tag - (system specific) information will be filled in below policyNode.StateImageIndex = policyNode.SelectImageIndex = PolicyTreeListTag.GetStateImageIndex(distinctPolicyRow); policyNode.ImageIndex = -1; //not used bool isFirstSystem = true; foreach (CountryConfig.SystemRow systemRow in _countryConfigFacade.GetSystemRowsOrdered()) { //equip the policy node with the system specific information about the policy CountryConfig.PolicyRow policyRow = _countryConfigFacade.GetPolicyRowByNameOrderAndSystemID(distinctPolicyRow.Name, distinctPolicyRow.Order, systemRow.ID); (policyNode.Tag as PolicyTreeListTag).AddPolicyRowOfSystem(systemRow.ID, policyRow); policyNode.SetValue(systemRow.Name, ExtensionAndGroupManager.GetExtensionAdaptedSwitch(policyRow)); FillPolicyNodeWithFunctions(systemRow, policyRow, policyNode, isFirstSystem); isFirstSystem = false; } }
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; }