Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Convert the current user setting to a workset.
        /// </summary>
        /// <param name="worksetName">The name of the workset.</param>
        /// <returns>The user settings converted to a workset.</returns>
        private Workset_t ConvertToWorkset(string worksetName)
        {
            Workset_t workset = new Workset_t();

            workset.Replicate(m_Workset);

            // This attribute is used to define the plot screen layout and is defined by the user when displaying the saved data file.
            workset.PlotTabPages = new PlotTabPage_t[workset.Column.Length];
            for (int tabPageindex = 0; tabPageindex < workset.Column.Length; tabPageindex++)
            {
                workset.PlotTabPages[tabPageindex].HeaderText        = m_TextBoxHeaders[tabPageindex].Text;
                workset.PlotTabPages[tabPageindex].OldIdentifierList = new List <short>();
                workset.PlotTabPages[tabPageindex].DisplayMaskList   = new List <uint>();

                for (int index = 0; index < m_ListBoxes[tabPageindex].Items.Count; index++)
                {
                    workset.PlotTabPages[tabPageindex].OldIdentifierList.Add(((WatchItem_t)m_ListBoxes[tabPageindex].Items[index]).OldIdentifier);
                    workset.PlotTabPages[tabPageindex].DisplayMaskList.Add(((WatchItem_t)m_ListBoxes[tabPageindex].Items[index]).DisplayMask);
                }
            }

            return(workset);
        }