Ejemplo n.º 1
0
        /// <summary>
        /// Event handler for the 'Override Security' context menu option <c>Click</c> event. Sets the security level of the selected workset
        /// to the specified value.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Parameter passed from the object that raised the event.</param>
        private void m_ContextMenuItemOverrideSecurity_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            // Local reference to the selected item.
            WorksetItem selectedItem = new WorksetItem();

            // The index value of the selected workset.
            int selectedIndex;

            try
            {
                selectedItem  = (WorksetItem)m_ListView.SelectedItems[0];
                selectedIndex = m_ListView.SelectedIndices[0];
            }
            catch (Exception)
            {
                selectedItem  = null;
                selectedIndex = 0;
            }
            finally
            {
                Cursor = Cursors.Default;
            }

            // Check that an item has been selected.
            if (selectedItem == null)
            {
                MessageBox.Show(Resources.MBTInstructionSelectWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            FormSetSecurityLevel FormSetSecurityLevel = new FormSetSecurityLevel(selectedItem.Workset.Name, selectedItem.Workset.SecurityLevel);

            FormSetSecurityLevel.CalledFrom = this;
            DialogResult dialogResult = FormSetSecurityLevel.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                // Copy the selected workset
                Workset_t workset = new Workset_t();
                workset = selectedItem.Workset;

                // Modify the security level of the workset to the selected security level.
                workset.SecurityLevel = FormSetSecurityLevel.SecurityLevel;

                // Replace the existing workset with the workset with the modified security level.
                m_WorksetCollection.Edit(selectedItem.Workset.Name, workset);

                // Save the modified object to disk.
                Save();
                UpdateListView();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Event handler for the 'Override Security' context menu option <c>Click</c> event. Sets the security level of the selected workset 
        /// to the specified value.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Parameter passed from the object that raised the event.</param>
        private void m_ContextMenuItemOverrideSecurity_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            // Local reference to the selected item.
            WorksetItem selectedItem = new WorksetItem();

            // The index value of the selected workset.
            int selectedIndex;

            try
            {
                selectedItem = (WorksetItem)m_ListView.SelectedItems[0];
                selectedIndex = m_ListView.SelectedIndices[0];
            }
            catch (Exception)
            {
                selectedItem = null;
                selectedIndex = 0;
            }
            finally
            {
                Cursor = Cursors.Default;
            }

            // Check that an item has been selected.
            if (selectedItem == null)
            {
                MessageBox.Show(Resources.MBTInstructionSelectWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            FormSetSecurityLevel FormSetSecurityLevel = new FormSetSecurityLevel(selectedItem.Workset.Name, selectedItem.Workset.SecurityLevel);
            FormSetSecurityLevel.CalledFrom = this;
            DialogResult dialogResult = FormSetSecurityLevel.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                // Copy the selected workset
                Workset_t workset = new Workset_t();
                workset = selectedItem.Workset;

                // Modify the security level of the workset to the selected security level.
                workset.SecurityLevel = FormSetSecurityLevel.SecurityLevel;

                // Replace the existing workset with the workset with the modified security level.
                m_WorksetCollection.Edit(selectedItem.Workset.Name, workset);

                // Save the modified object to disk.
                Save();
                UpdateListView();
            }
        }