Esempio n. 1
0
/*
 *      private void PurgeExpiredItems(TreeNodeCollection nodes)
 *      {
 *          PurgeExpiredItems(nodes, 0);
 *      }
 */

        //private void PurgeExpiredItems(TreeNodeCollection nodes, int level)
        //{
        //    // removes items that have expired
        //    // then removes nodes that have no item or child nodes
        //    // but does not remove root (level=0) nodes
        //    foreach (TreeNode node in nodes)
        //    {
        //        // check children first
        //        PurgeExpiredItems(node.Nodes, level + 1);
        //        // now check this node
        //        if (node.Tag != null)
        //        {
        //            if (node.Tag is ICoreItem)
        //            {
        //                var item = (ICoreItem)node.Tag;
        //                if (!item.IsCurrent())
        //                    node.Tag = null;
        //            }
        //        }
        //        if ((level != 0) && (node.Tag == null) && (node.Nodes.Count == 0))
        //            node.Remove();
        //    }
        //}

        /// <summary>
        /// Shows message box confirming deleting
        /// and
        /// deletes selected object in case of positive answer.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolStripMenuItem1Click(object sender, EventArgs e)
        {
            var itemToDelete = treeNavigation.SelectedNode?.Tag as ICoreItem;

            if (itemToDelete == null)
            {
                return;//nothing to delete...
            }
            if (null == _client)
            {
                return;//there's no way we cab delete anything without storage object
            }
            var message = "Do you want to delete the selected object?" + Environment.NewLine + Environment.NewLine +
                          "This object may contain important information and/or may have a sentimental value to its creator." +
                          Environment.NewLine + Environment.NewLine +
                          "Unathorised or inapropriate deletion of the objects is against Group policy and can lead to disciplinary action and or legal actions." +
                          Environment.NewLine + Environment.NewLine +
                          @"The use of the ""Delete object ..."" menu item is monitored and recorded." +
                          Environment.NewLine + Environment.NewLine +
                          "Where considered appropriate, such deletion of events may be reviewed for compliance with law and the Group's policies." +
                          Environment.NewLine + Environment.NewLine +
                          @"Clicking the ""Yes"" but confirm that you accept the conditions detailed in the Information Systems Security Policies and Codes of Conduct that apply to you in your work withing the group." +
                          Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine +
                          "Amen." +
                          Environment.NewLine + Environment.NewLine +
                          "*(hold CTRL button to suppress this warning the next time)";

            if (_suppressWarningMessageBox || DialogResult.Yes == MessageBox.Show(message, Resources.CoreViewerForm_ToolStripMenuItem1Click_Important_message, MessageBoxButtons.YesNo, MessageBoxIcon.Stop))
            {
                _suppressWarningMessageBox = ModifierKeys == Keys.Control;
                _client.DeleteItem(itemToDelete);
                treeNavigation.SelectedNode.Remove();
            }
        }