예제 #1
0
        internal abstract void CopySymbolicIdentfierToClipboard(); //copy the symbolic identifier of a policy (=policy name), function (e.g. yse_#3) or parameter (e.g. yse_#3.4) to the clipboard

        internal virtual void CopyIdentfierToClipboard()           //copy the real (system specific) identifier of a policy, function or parameter to the clipboard
        {
            SelectSystemsForm selectSystemsForm = new SelectSystemsForm(_mainForm.GetCountryShortName(), null, true);

            selectSystemsForm.SetSingleSelectionMode();
            if (selectSystemsForm.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            if (selectSystemsForm.IsAllSystemsSelected())
            {
                string clipboardText = string.Empty;
                foreach (TreeListColumn column in (from col in _mainForm.GetTreeListBuilder().GetSystemColums()
                                                   where col.VisibleIndex >= 0 select col).OrderBy(col => col.VisibleIndex))
                {
                    clipboardText += GetID((column.Tag as SystemTreeListTag).GetSystemRow().ID) + "\t";
                }
                ;
                clipboardText = clipboardText.TrimEnd('\t');
                System.Windows.Forms.Clipboard.SetText(clipboardText);
            }
            else if (selectSystemsForm.GetSelectedSystemRows().Count > 0)
            {
                System.Windows.Forms.Clipboard.SetText(GetID(selectSystemsForm.GetSelectedSystemRows().First().ID));
            }
        }
        void MoveToHiddenSystems_SelectSystems_MenuItemClick(object sender, EventArgs e)
        {
            _mainForm.treeList.BeginUpdate();
            //assess which systems are already hidden (and therefore listed in the column chooser)
            List <string> noShowSystemIDs = new List <string>();

            foreach (TreeListColumn column in _mainForm.treeList.Columns)
            {
                if (column.VisibleIndex == -1 && column.OptionsColumn.ShowInCustomizationForm == true && column.Tag != null)
                {
                    noShowSystemIDs.Add((column.Tag as SystemTreeListTag).GetSystemRow().ID);
                }
            }

            //allow user to select systems (which are not already hidden)
            SelectSystemsForm selectSystemsForm = new SelectSystemsForm(_mainForm.GetCountryShortName(), noShowSystemIDs);

            if (selectSystemsForm.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            //invoke column chooser if not already available
            //if no systems are selected for hiding, the column chooser gets visible, if it was closed with the close button (with its current content)
            if (_mainForm.treeList.CustomizationForm == null)
            {
                _mainForm.treeList.ColumnsCustomization();
            }

            _mainForm.ClearCellSelection(); //clear any existing selection of cells (to avoid that actions on selected cell change hidden systems)

            //hide the systems selected by the user
            List <string> selectedSystemIDs = (from sR in selectSystemsForm.GetSelectedSystemRows() select sR.ID).ToList();

            foreach (TreeListColumn column in _mainForm.treeList.Columns)
            {
                if (column.Tag != null && selectedSystemIDs.Contains((column.Tag as SystemTreeListTag).GetSystemRow().ID))
                {
                    column.VisibleIndex = -1;
                    column.OptionsColumn.ShowInCustomizationForm = true;
                }
            }
            _mainForm.treeList.EndUpdate();
        }