コード例 #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();
            }
        }
コード例 #2
0
        /// <summary>
        /// Event handler for the 'Set As Default' context menu option <c>Click</c> event. Sets the selected workset as the default workset.
        /// </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_ContextMenuItemSetAsDefault_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;
            }

            // Update the object reference with the new default setting.
            m_WorksetCollection.SetDefaultWorkset(selectedItem.Workset.Name);

            // Ensure that the security level of the default workset is set to the appropriate level.
            if (selectedItem.Workset.SecurityLevel < Security.SecurityLevelHighest)
            {
                // Copy the selected workset
                Workset_t workset = new Workset_t();
                workset = selectedItem.Workset;

                // Modify the security level of the workset to be the highest security level.
                workset.SecurityLevel = Security.SecurityLevelHighest;

                // 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();
        }
コード例 #3
0
        /// <summary>
        /// Event handler for the 'Copy' context menu option <c>Click</c> event. Copies an existing workset.
        /// </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_ContextMenuItemCopy_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.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            Cursor = Cursors.WaitCursor;

            // Create a temporary workset.
            Workset_t copyOfWorkset = new Workset_t();

            copyOfWorkset.Replicate(selectedItem.Workset);

            // Override the security level to be the security level of the current user.
            copyOfWorkset.SecurityLevel = Security.SecurityLevelCurrent;

            // Override the name of the workset.
            copyOfWorkset.Name = selectedItem.Workset.Name + CommonConstants.BindingMessage + Resources.TextCopy;
            m_WorksetCollection.Add(copyOfWorkset);
            Cursor = Cursors.Default;

            // Save the modified object to disk.
            Save();
            UpdateListView();
        }
コード例 #4
0
        /// <summary>
        /// Event handler for the 'Rename' context menu option <c>Click</c> event. Renames the selected workset.
        /// </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_ContextMenuItemRename_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();

            try
            {
                selectedItem    = (WorksetItem)m_ListView.SelectedItems[0];
                m_SelectedIndex = m_ListView.SelectedIndices[0];
            }
            catch (Exception)
            {
                selectedItem    = null;
                m_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;
            }

            // Check that the baseline configuration hasn't been selected.
            if (m_ListView.SelectedIndices[0] == 0)
            {
                MessageBox.Show(Resources.MBTUnauthorizedRenameBaselineWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // If the security level of the current user is less than that of the workset then don't allow the workset to be renamed.
            if (Security.SecurityLevelCurrent < selectedItem.Workset.SecurityLevel)
            {
                MessageBox.Show(Resources.MBTUnauthorizedRenameWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Allow the user to modify the name of the workset.
            m_ListView.Items[m_SelectedIndex].BeginEdit();
        }
コード例 #5
0
        /// <summary>
        /// Call the form which allows the user to edit the selected workset.
        /// </summary>
        /// <param name="selectedItem">The selected workset item.</param>
        protected override void EditSelectedWorkset(WorksetItem selectedItem)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            // Show the form which allows the user to edit the workset.
            FormWorksetDefineWatch formWorksetDefineWatch = new FormWorksetDefineWatch(m_WorksetCollection, selectedItem.Workset, false);

            // Allow the shown form to re-highlight the selected configuration before it closes.
            formWorksetDefineWatch.CalledFrom = this;
            formWorksetDefineWatch.ShowDialog();
            Cursor = Cursors.Default;
        }
コード例 #6
0
        /// <summary>
        /// Event handler for the context menu <c>Opened</c> event. Set the <c>Enabled</c> property of the Edit, Rename and Delete context menu options appropriate to
        /// the current security level and selected workset.
        /// </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_ContextMenu_Opened(object sender, EventArgs e)
        {
            // Local reference to the selected item.
            WorksetItem selectedItem = new WorksetItem();

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

            // Get the selected workset and index.
            try
            {
                selectedItem  = (WorksetItem)m_ListView.SelectedItems[0];
                selectedIndex = m_ListView.SelectedIndices[0];
            }
            catch (Exception)
            {
                selectedItem  = null;
                selectedIndex = 0;
            }

            // Check that a workset has been selected.
            if (selectedItem == null)
            {
                return;
            }

            // If the selected workset: (a) is the baseline workset, (b) has a security level higher than the current security level or (c) is the default
            // workset and the current security level is not the highest security level, disable the Edit, Rename and Delete context menu options; otherwise enable
            // the menu options.
            if ((selectedIndex == 0) ||
                (Security.SecurityLevelCurrent < selectedItem.Workset.SecurityLevel) ||
                ((selectedIndex == m_WorksetCollection.DefaultIndex) && (Security.SecurityLevelCurrent < Security.SecurityLevelHighest)))
            {
                m_ContextMenuItemEdit.Enabled   = false;
                m_ContextMenuItemDelete.Enabled = false;
                m_ContextMenuItemRename.Enabled = false;
            }
            else
            {
                m_ContextMenuItemEdit.Enabled   = true;
                m_ContextMenuItemDelete.Enabled = true;
                m_ContextMenuItemRename.Enabled = true;
            }
        }
コード例 #7
0
 /// <summary>
 /// Call the form which allows the user to edit the selected workset.
 /// </summary>
 /// <param name="selectedItem">The selected workset item.</param>
 protected virtual void EditSelectedWorkset(WorksetItem selectedItem)
 {
 }
コード例 #8
0
        /// <summary>
        /// Event handler for the 'Delete' context menu option <c>Click</c> event. Deletes the selected workset.
        /// </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_ContextMenuItemDelete_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;
            }

            // Check that the baseline workset hasn't been selected.
            if (m_ListView.SelectedIndices[0] == 0)
            {
                MessageBox.Show(Resources.MBTUnauthorizedDeleteBaselineWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // If the security level of the current user is less than that of the workset then don't allow the workset to be deleted.
            if (Security.SecurityLevelCurrent < selectedItem.Workset.SecurityLevel)
            {
                MessageBox.Show(Resources.MBTUnauthorizedDeleteWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Check if the selected setting is the default setting.
            if (m_ListView.SelectedIndices[0] == m_WorksetCollection.DefaultIndex)
            {
                if (Security.SecurityLevelCurrent < Security.SecurityLevelHighest)
                {
                    MessageBox.Show(Resources.MBTUnauthorizedDeleteDefaultWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    DialogResult dialogResult = MessageBox.Show(Resources.MBTQueryDeleteDefaultWorkset, Resources.MBCaptionInformation, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    Update();
                    if (dialogResult != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }
            else
            {
                // Get the user to confirm the selected deletion.
                DialogResult dialogResult = MessageBox.Show(string.Format(Resources.MBTQueryDeleteWorkset, ((WorksetItem)m_ListView.SelectedItems[0]).Workset.Name), Resources.MBCaptionInformation, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                Update();
                if (dialogResult != DialogResult.Yes)
                {
                    return;
                }
            }

            m_WorksetCollection.Remove(selectedItem.Workset.Name);

            // Save the modified object to disk.
            Save();
            UpdateListView();
        }
コード例 #9
0
        /// <summary>
        /// Event handler for the 'Edit' context menu option <c>Click</c> event. Edits the selected workset.
        /// </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_ContextMenuItemEdit_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;
            }
            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;
            }

            // Check that the baseline workset hasn't been selected.
            if (m_ListView.SelectedIndices[0] == 0)
            {
                MessageBox.Show(Resources.MBTUnauthorizedEditBaselineWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // If the security level of the current user is less than that of the workset then don't allow the workset to be deleted.
            if (Security.SecurityLevelCurrent < selectedItem.Workset.SecurityLevel)
            {
                MessageBox.Show(Resources.MBTUnauthorizedEditWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Check if the selected setting is the default setting.
            if (m_ListView.SelectedIndices[0] == m_WorksetCollection.DefaultIndex)
            {
                if (Security.SecurityLevelCurrent < Security.SecurityLevelHighest)
                {
                    MessageBox.Show(Resources.MBTUnauthorizedEditDefaultWorkset, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            EditSelectedWorkset(selectedItem);
        }