Пример #1
0
        /// <summary>
        /// Return a new instance of a PropertiesObject, ignoring the
        /// current state of the UI.
        /// </summary>
        public void GetProperties(ref object PropertiesObject)
        {
            ExtensionComments comments = new ExtensionComments();

            comments.LoadFromRegistry();
            PropertiesObject = comments.CreatePropertiesDummy();
        }
Пример #2
0
        /// <summary>
        /// This is automatically called by VS when the Tools Options dialog has had
        /// its OK button hit. If OnAfterCreated() has been called (because the control
        /// was made visible and sited into its ActiveX container), it will have set
        /// the internal member variable, and we should serialize our contents.
        /// </summary>
        public void OnOK()
        {
            if (m_extComments != null)
            {
                try
                {
                    // If the user has just entered a value and then clicked the mouse on the OK button, then the
                    // DataGrid control will never have had a chance to update its internal data store (the
                    // DataTable) to reflect the user's changes.
                    try
                    {
                        if ((dgEntries.CurrentCell.ColumnNumber >= 1) &&
                            (dgEntries.CurrentCell.RowNumber >= 1))
                        {
                            dgEntries.EndEdit(dgEntries.TableStyles[0].GridColumnStyles[dgEntries.CurrentCell.ColumnNumber],
                                              dgEntries.CurrentCell.RowNumber, false);
                        }
                    }
                    catch (System.Exception)
                    {
                        // Ignore exceptions, since they only mean that the commit failed when the
                        // user had *not* made any changes yet.
                    }

                    // This will throw an exception (after having set the focus back to the correct
                    // row and telling the user about their error).
                    ValidateGrid();

                    m_extComments.Clear();

                    foreach (System.Data.DataRow row in dtValues.Rows)
                    {
                        m_extComments.Add(new ExtensionComment((string)row[m_strFileExtensionField],
                                                               (string)row[m_strBeginCommentField],
                                                               (string)row[m_strEndCommentField]));
                    }
                    m_extComments.Collapse      = cbCollapse.Checked;
                    m_extComments.PromptForTodo = cbPromptForTodo.Checked;

                    m_extComments.SaveToRegistry();

                    // We need to re-load the settings because OnOK does NOT mean that
                    // the toolsoptions page is going away; rather, the user has hit
                    // the OK button and may come back to it in its CURRENT state.
                    m_extComments = new ExtensionComments();
                    m_extComments.LoadFromRegistry();
                }
                catch (System.Exception)
                {
                    // Ignore exception.
                }
            }
        }
Пример #3
0
        /// <summary>
        /// This function is only called when the UI is about to be displayed. Therefore, the
        /// InitializeComponent() call has been moved into here to avoid making users of the
        /// automation model to drive this object pay the UI initialization penalty.
        /// </summary>
        public void OnAfterCreated(EnvDTE.DTE dte)
        {
            m_applicationObject = dte;
            m_extComments       = new ExtensionComments();
            m_extComments.LoadFromRegistry();

            try
            {
                m_strFileExtensionField = AMResources.GetLocalizedString("ToolsOptionsFileExtensionField");
                m_strBeginCommentField  = AMResources.GetLocalizedString("ToolsOptionsBeginCommentsField");
                m_strEndCommentField    = AMResources.GetLocalizedString("ToolsOptionsEndCommentsField");
            }
            catch (System.Exception)
            {
                m_strFileExtensionField = "";
                m_strBeginCommentField  = "";
                m_strEndCommentField    = "";
                return;
            }

            InitializeComponent();

            PopulateTable();
        }
Пример #4
0
 public void OnCancel()
 {
     // Reset the internal state.
     m_extComments = new ExtensionComments();
     m_extComments.LoadFromRegistry();
 }