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;
                }
            }
        }
Beispiel #2
0
        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
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        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);
        }