Esempio n. 1
0
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private void ShowToolWindow(object sender, EventArgs e)
        {
            DTE2 dte = (DTE2)this.ServiceProvider.GetService(typeof(DTE));

            EnvDTE.Project project = null;
            // имя текущего проета в решении
            try
            {
                var targetProjName = dte.Solution.Properties.Item("StartupProject").Value.ToString();
                // получить проект по имени
                project = GetCurrentProject(dte.Solution.Projects, targetProjName);
                // Get the instance number 0 of this tool window. This window is single instance so this instance
                // is actually the only one.
                // The last flag is set to true so that if the tool window does not exists it will be created.
                ToolWindowPane window = this.package.FindToolWindow(typeof(OptionsWindow), 0, true);
                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException("Cannot create tool window");
                }
                OptioinsWindowControl OptioinsWindow = window.Content as OptioinsWindowControl;
                // заполнить Configuration name
                FillConfs(OptioinsWindow, project);
                // отобразить окно
                //window.ToolBarLocation = (int)VSTWT_LOCATION.VSTWT_RIGHT;
                IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                //windowFrame.SetFramePos(VSSETFRAMEPOS.SFP_fDockRight, new Guid("4e6c34e8-a1dc-4116-9c56-c14adcb92015"), 10, 10, 60, 60);
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
            catch
            {
                MessageBox.Show("Не выбран проект");
            }
        }
Esempio n. 2
0
 private void FillConfs(OptioinsWindowControl OptioinsWindow, Project project)
 {
     OptioinsWindow.ComboBoxConf.Items.Clear();
     foreach (Configuration item in project.ConfigurationManager)
     {
         bool exist = false;
         foreach (string text in OptioinsWindow.ComboBoxConf.Items)
         {
             if (item.ConfigurationName == text)
             {
                 exist = true;
                 break;
             }
         }
         if (!exist)
         {
             OptioinsWindow.ComboBoxConf.Items.Add(item.ConfigurationName);
         }
     }
     OptioinsWindow.ComboBoxConf.SelectedValue = project.ConfigurationManager.ActiveConfiguration.ConfigurationName;
 }