Ejemplo n.º 1
0
        protected override bool TryCreateCollectionSource(
            IVsHierarchyItem hierarchyItem,
            string flagsString,
            string?target,
            IRelationProvider relationProvider,
            [NotNullWhen(returnValue: true)] out AggregateRelationCollectionSource?containsCollectionSource)
        {
            if (ErrorHandler.Succeeded(hierarchyItem.HierarchyIdentity.Hierarchy.GetProperty(
                                           hierarchyItem.HierarchyIdentity.ItemID, (int)__VSHPROPID.VSHPROPID_ExtObject, out object projectItemObject)))
            {
                var projectItem         = projectItemObject as ProjectItem;
                EnvDTE.Properties?props = projectItem?.Properties;

                if (props?.Item("TargetingPackPath")?.Value is string path &&
                    props?.Item("OriginalItemSpec")?.Value is string name)
                {
                    string?profile = props?.Item("Profile").Value as string;

                    var framework = new FrameworkReferenceIdentity(path, profile, name);
                    var item      = new FrameworkReferenceItem(framework);
                    if (AggregateContainsRelationCollection.TryCreate(item, _relationProvider, out AggregateContainsRelationCollection? collection))
                    {
                        containsCollectionSource = new AggregateRelationCollectionSource(hierarchyItem, collection);
                        return(true);
                    }
                }
            }

            containsCollectionSource = null;
            return(false);
        }
        public ClangFormat(OutputWindowPane owp, EnvDTE.Properties props)
        {
            mProps = props;

            string[] dirToSearch = { @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LLVM\LLVM", @"HKEY_LOCAL_MACHINE\SOFTWARE\LLVM" };

            m_sSearchClangFormat = (bool)mProps.Item("SearchClangFormat").Value;

            if (m_sSearchClangFormat)
            {
                try
                {
                    foreach (string registryDir in dirToSearch)
                    {
                        string llvmInstallationDir = (string)Registry.GetValue(registryDir, "", null);
                        if (llvmInstallationDir != null)
                        {
                            m_sClangExecutable = llvmInstallationDir + "\\bin\\clang-format.exe";
                            mProps.Item("ClangExecutable").Value = m_sClangExecutable;
                            break;
                        }
                    }
                }
                catch
                {
                    LogToOutputWindow("Caught exception, while trying to read registry and search for clang-format.");
                    LogToOutputWindow(Environment.NewLine);
                }
            }

            m_dTopLine           = 0;
            m_dBottomLine        = 0;
            m_dCursorLine        = 0;
            m_dRestoreCaret      = 0;
            m_fullFileName       = "";
            cfOutput             = "";
            cfErrOutput          = "";
            m_dCurrentFileBuffer = "";
            m_sCfStyle           = "";
            m_sFallbackStyle     = "";
            m_sAssumeFilename    = "";
            m_sCursorPosition    = "Restore";
            m_sSortIncludes      = true;
            m_sSearchClangFormat = true;
            m_sSaveOnFormat      = true;
            m_sOutputEnabled     = true;
            m_formatLinesOnly    = false;
            m_CfSuccessful       = false;
            m_argument           = "";

            m_owp = owp;

            m_procStart.RedirectStandardInput  = true;
            m_procStart.RedirectStandardOutput = true;
            m_procStart.RedirectStandardError  = true;
            m_procStart.UseShellExecute        = false;
            m_procStart.CreateNoWindow         = true;
        }
 public void RefreshOptions()
 {
     this.IsPending = true;
     try
     {
         var serviceProvoder     = GitLabMainWindowCommand.Instance.ServiceProvider;
         var dte                 = (DTE)serviceProvoder.GetService(typeof(DTE));
         EnvDTE.Properties props = dte.Properties["GitLab Code Review", "General"];
         this.GitOptions.ApiUrl                    = (string)props.Item(nameof(GitLabOptions.ApiUrl)).Value;
         this.GitOptions.PrivateToken              = (string)props.Item(nameof(GitLabOptions.PrivateToken)).Value;
         this.GitOptions.SelectedProjectId         = (long?)props.Item(nameof(GitLabOptions.SelectedProjectId)).Value;
         this.GitOptions.FavoriteProjects          = (string)props.Item(nameof(GitLabOptions.FavoriteProjects)).Value;
         this.GitOptions.RepositoryLocalPath       = (string)props.Item(nameof(GitLabOptions.RepositoryLocalPath)).Value;
         this.GitOptions.WorkingDirectory          = (string)props.Item(nameof(GitLabOptions.WorkingDirectory)).Value;
         this.GitOptions.AutoCleanWorkingDirectory = (bool)props.Item(nameof(GitLabOptions.AutoCleanWorkingDirectory)).Value;
         this.GitOptions.MaxItemsPerPage           = (int?)props.Item(nameof(GitLabOptions.MaxItemsPerPage)).Value;
         this.GitOptions.MaxPages                  = (int?)props.Item(nameof(GitLabOptions.MaxPages)).Value;
     }
     catch (Exception ex)
     {
         this.errorService.AddError(ex);
     }
     finally
     {
         this.IsPending = false;
     }
 }
Ejemplo n.º 4
0
 private static bool HasProperty(EnvDTE.Properties properties, string name)
 {
     try
     {
         return(((properties.Item(name) != null) && (properties.Item(name).Value != null)) && !string.IsNullOrEmpty(properties.Item(name).Value.ToString()));
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 5
0
        public static bool TryGetProperty <T>(this EnvDTE.Properties properties,
                                              string propertyName,
                                              out T value)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            value = default(T);
            var foundProperty = false;

            for (var i = 1; i < properties.Count; i++)
            {
                try
                {
                    Property p = properties.Item(i);
                    if (0 == String.Compare(p.Name,
                                            propertyName,
                                            StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (p.Value is T casted)
                        {
                            foundProperty = true;
                            value         = casted;
                        }

                        break;
                    }
                }
                catch
                { }
            }

            return(foundProperty);
        }
        public void AddItemTemplateToProjectNew_ShouldReturnExpcted()
        {
            //Arange
            CodeInfo codeInfo = new CodeInfo()
            {
                Code = "code",
                Path = @"TestMethodName\TestFileName"
            };

            string expectedFilePath = @"ServerMethods\TestMethodName\TestFileName.cs";

            InitTestprojectStructure();
            EnvDTE.Property specialMethodFolderFullPathProperty = Substitute.For <EnvDTE.Property>();
            specialMethodFolderFullPathProperty.Value = @"ServerMethods\TestMethodName";

            EnvDTE.Properties specialMethodFolderProperties = Substitute.For <EnvDTE.Properties>();
            specialMethodFolderProperties.Item(Arg.Any <string>()).Returns(specialMethodFolderFullPathProperty);
            this.specialMethodFolder.Properties.Returns(specialMethodFolderProperties);

            this.specialMethodFolder.ProjectItems.AddFromFile(expectedFilePath).Returns(Substitute.For <ProjectItem>());

            //Act
            string resultFilePath = this.projectManager.AddItemTemplateToProjectNew(codeInfo, false);

            //Assert
            Assert.AreEqual(expectedFilePath, resultFilePath);
        }
        /// <summary>
        /// Creates a <see cref="RelativeLineNumbers"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        public RelativeLineNumbers(IWpfTextView textView, IEditorFormatMap formatMap, DTE dte)
        {
            _textView  = textView;
            _formatMap = formatMap;
            _dte       = dte;
            _lineMap   = new Dictionary <int, int>();

            _canvas = new Canvas();
            this.Children.Add(_canvas);

            this.ClipToBounds = true;

            _textView.Caret.PositionChanged += new EventHandler <CaretPositionChangedEventArgs>(OnCaretPositionChanged);
            _textView.ViewportHeightChanged += (sender, args) => DrawLineNumbers();
            _textView.LayoutChanged         += new EventHandler <TextViewLayoutChangedEventArgs>(OnLayoutChanged);
            _formatMap.FormatMappingChanged += (sender, args) => DrawLineNumbers();
            EnvDTE.Properties props = _dte.get_Properties("Relative Line Numbers", "Cursor Line Number");
            _mixedMode = (bool)props.Item("OptionBool").Value;


            this.ToolTip = "To customize Relative Line Numbers select:\n\n" +
                           "  Tools -> Options -> Fonts and Colors -> Relative Line Numbers\n" +
                           "  Tools -> Options -> Fonts and Colors -> Relative Line Numbers Cursor Line\n" +
                           "  Tools -> Options -> Relative Line Numbers -> Cursor Line Number\n";
        }
Ejemplo n.º 8
0
        public static Brush Get_Background_Color()
        {
            try
            {
                DTE dte = Package.GetGlobalService(typeof(SDTE)) as DTE;
                EnvDTE.Properties propertiesList = dte.get_Properties("FontsAndColors", "TextEditor");
                Property          prop           = propertiesList.Item("FontsAndColorsItems");

                FontsAndColorsItems fci = (FontsAndColorsItems)prop.Object;

                for (int i = 1; i < fci.Count; ++i)
                {
                    ColorableItems ci = fci.Item(i);
                    if (ci.Name.Equals("PLAIN TEXT", StringComparison.OrdinalIgnoreCase))
                    {
                        return(new SolidColorBrush(ConvertColor(System.Drawing.ColorTranslator.FromOle((int)ci.Background))));
                    }
                }
            }
            catch (Exception e)
            {
                AsmDudeToolsStatic.Output_ERROR("AsmDudeToolsStatic:Get_Background_Color " + e.Message);
            }
            AsmDudeToolsStatic.Output_WARNING("AsmDudeToolsStatic:Get_Background_Color: could not retrieve text color");
            return(new SolidColorBrush(Colors.Gray));
        }
Ejemplo n.º 9
0
        public void TestAutomationOnProjectProperties()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination      = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode projectNode = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                //get the automation model of the project
                EnvDTE.Project project = projectNode.GetAutomationObject() as EnvDTE.Project;

                //get properties collection
                EnvDTE.Properties projectProperties = project.Properties;
                Assert.IsNotNull(projectProperties, "Could not get an instance of the project properties object");

                //test the FullPath property returns the actual project path + project filename
                string fullPathFromProjectNode = projectNode.ProjectFolder + "\\";
                EnvDTE.Property fullPath       = projectProperties.Item(ProjectAutomationProperyNames.FullPath);
                Assert.IsFalse(String.IsNullOrEmpty(fullPath.Value.ToString()), "FullPath property is null or has not been assigned any value");
                Assert.IsTrue(0 == String.Compare(fullPath.Value.ToString(), fullPathFromProjectNode, true), "FullPath property does not return the correct Value");
            });
        }
        /// <summary>
        ///   Helper function to set a development environment property.
        /// </summary>
        /// <param name="category">
        ///   Category in the Tools - Options dialog.
        /// </param>
        /// <param name="page">
        ///   Page inside a category.
        /// </param>
        /// <param name="propertyName">
        ///   Name of the property to set.
        /// </param>
        /// <param name="newValue">
        ///   A new value of the property.
        /// </param>
        private void SetEnvProperty(string category, string page, string propertyName, object newValue)
        {
            int retryCount = 20;
            int count      = 0;

            while (count < retryCount)
            {
                try
                {
                    EnvDTE.Properties properties = m_devEnvApplicationObject.get_Properties(category, page);
                    Property          property   = properties.Item(propertyName);
                    Debug.Assert(property != null, "Property " + propertyName + " not found", "Category: " + category + " / Page: " + page);
                    property.Value = newValue;
                    Trace.WriteLine(string.Format("'SetEnvProperty({0}, {1}, {2}, {3})' executed in {4} attempts", category, page, propertyName, newValue, count + 1));
                    return;
                }
                catch (System.Runtime.InteropServices.COMException)
                {
                }
                catch (System.Runtime.InteropServices.InvalidComObjectException)
                {
                }
                System.Threading.Thread.Sleep(100);
                count++;
            }
            Trace.WriteLine(string.Format("Failed to execute 'SetEnvProperty({0}, {1}, {2}, {3})' in {4} attempts.", category, page, propertyName, newValue, retryCount));
        }
        /// <summary>
        ///   Helper function that fetches a development environment property.
        /// </summary>
        /// <param name="category">
        ///   Category in the Tools - Options dialog.
        /// </param>
        /// <param name="page">
        ///   Page inside a category.
        /// </param>
        /// <param name="propertyName">
        ///   Name of the property to fetch.
        /// </param>
        /// <returns>
        ///   Value of the property.
        /// </returns>
        private object GetEnvProperty(string category, string page, string propertyName)
        {
            EnvDTE.Properties properties = m_devEnvApplicationObject.get_Properties(category, page);
            Property          property   = properties.Item(propertyName);

            Debug.Assert(property != null, "Property " + propertyName + " not found", "Category: " + category + " / Page: " + page);
            return(property.Value);
        }
Ejemplo n.º 12
0
		/// <summary>
		/// gets the option with the given name form the given page of the given category
		/// <para>note: this method only works if the default grid dialog page is used</para>
		/// </summary>
		/// <typeparam name="T">type of the option to retrieve</typeparam>
		/// <param name="category">name of the category where the page resides</param>
		/// <param name="page">name of the page containing the option</param>
		/// <param name="option">name of the option</param>
		/// <returns>the value of the option</returns>
		public static T GetOption<T>(string category, string page, string option)
		{
			DTE env = GetCurrentDTE();

			EnvDTE.Properties props = env.get_Properties(category, page);

			return (T)props.Item(option).Value;
		}
Ejemplo n.º 13
0
        public static string GetOutputPath(Project proj)
        {
            var prjPath = GetProjectPath(proj);

            if (string.IsNullOrWhiteSpace(prjPath))
            {
                return(string.Empty);
            }

            EnvDTE.Properties prop = null;

            string probKey = string.Empty;

            if (proj.ConfigurationManager.ActiveConfiguration.Properties == null)
            {
                if (TryGetPropertyByName(proj.Properties, "ActiveConfiguration", out _) == false)
                {
                    return(string.Empty);
                }

                prop = proj.Properties.Item("ActiveConfiguration").Value as EnvDTE.Properties;
                if (TryGetPropertyByName(prop, "PrimaryOutput", out _))
                {
                    probKey = "PrimaryOutput";
                }
            }
            else
            {
                prop = proj.ConfigurationManager.ActiveConfiguration.Properties;
                if (TryGetPropertyByName(prop, "OutputPath", out _))
                {
                    probKey = "OutputPath";
                }
            }

            if (TryGetPropertyByName(prop, probKey, out _) == false)
            {
                return(string.Empty);
            }

            var filePath = prop.Item(probKey).Value.ToString();

            if (Path.IsPathRooted(filePath) == false)
            {
                filePath = Path.Combine(prjPath, filePath);
            }

            var attr = File.GetAttributes(filePath);

            if (attr.HasFlag(FileAttributes.Directory))
            {
                return(filePath);
            }
            else
            {
                return(new FileInfo(filePath).Directory.FullName);
            }
        }
Ejemplo n.º 14
0
    public void ParsnipFiller()
    {
        //<Snippet5>
        DTE dte = (DTE)GetService(typeof(DTE));

        EnvDTE.Properties props = dte.get_Properties("My Category", "My Grid Page");
        int n = (int)props.Item("OptionInteger").Value;
        //</Snippet5>
    }
Ejemplo n.º 15
0
        /// <summary>
        /// Set font of code completion
        /// tools>options>Environment>Fonts and Colors>statement completion>courier new.
        /// https://msdn.microsoft.com/en-us/library/bb166382.aspx
        /// </summary>
        private void changeFontAutoComplete()
        {
            // experiments to change the font of the autocomplate
            try {
                DTE vsEnvironment = (DTE)GetService(typeof(SDTE));

                if (false)   // test to retrieve asm dude properties
                {
                    EnvDTE.Properties asmDudePropertiesList = vsEnvironment.get_Properties("AsmDude", "Asm Documentation");
                    if (asmDudePropertiesList != null)
                    {
                        string url = asmDudePropertiesList.Item("_asmDocUrl").Value as string;
                        AsmDudeToolsStatic.Output(string.Format(CultureInfo.CurrentCulture, "INFO: {0}:changeFontAutoComplete. url=", this.ToString(), url));
                    }
                }
                if (false)
                {
                    EnvDTE.Properties propertiesList = vsEnvironment.get_Properties("TextEditor", "Basic");
                    if (propertiesList != null)
                    {
                        Property tabSize = propertiesList.Item("TabSize");
                        short    oldSize = (short)tabSize.Value;

                        string message;
                        if (oldSize != 4)
                        {
                            tabSize.Value = 4;
                            message       = string.Format(CultureInfo.CurrentUICulture,
                                                          "For Basic, the Text Editor had a tab size of {0}" +
                                                          " and now has a tab size of {1}.", oldSize, tabSize.Value);
                        }
                        else
                        {
                            message = string.Format(CultureInfo.CurrentUICulture,
                                                    "For Basic, the Text Editor has a tab size of {0}.", tabSize.Value);
                        }
                        AsmDudeToolsStatic.Output(string.Format(CultureInfo.CurrentCulture, message));
                    }
                }
                if (false)
                {
                    //EnvDTE.Properties propertiesList = vsEnvironment.get_Properties("Environment", "Keyboard");
                    //EnvDTE.Property prop = propertiesList.Item("Scheme");
                    //AsmDudeToolsStatic.Output(string.Format(CultureInfo.CurrentCulture, "INFO: {0}:changeFontAutoComplete; prop={1}", this.ToString(), prop.Value));

                    EnvDTE.Properties propertiesList = vsEnvironment.get_Properties("Environment", "Fonts and Colors");
                    if (propertiesList != null)
                    {
                        AsmDudeToolsStatic.Output(string.Format(CultureInfo.CurrentCulture, "INFO: {0}:changeFontAutoComplete; prop={1}", this.ToString()));
                    }
                    //EnvDTE.Property prop = propertiesList.Item("Scheme");
                    //AsmDudeToolsStatic.Output(string.Format(CultureInfo.CurrentCulture, "INFO: {0}:changeFontAutoComplete; prop={1}", this.ToString(), prop.Value));
                }
            } catch (Exception e) {
                AsmDudeToolsStatic.Output(string.Format(CultureInfo.CurrentCulture, "ERROR: {0}:changeFontAutoComplete {1}", this.ToString(), e.Message));
            }
        }
Ejemplo n.º 16
0
        protected Dictionary <string, object> GetAllProperties(EnvDTE.Properties props)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            for (int i = 1; i <= props.Count; i++)
            {
                try
                {
                    dic.Add(props.Item(i).Name, props.Item(i).Value);
                }
                catch (System.Runtime.InteropServices.COMException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }

            return(dic);
        }
Ejemplo n.º 17
0
        public override void Exec()
        {
            //System.Reflection.Assembly ass = System.Reflection.Assembly.Load(new System.Reflection.AssemblyName("System.Management.Automation"));
            System.Reflection.Assembly ass = System.Reflection.Assembly.Load("System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
            //System.Reflection.Assembly ass = System.Reflection.Assembly.LoadWithPartialName("System.Management.Automation");
            if (ass == null)
            {
                MessageBox.Show("PowerShell has not been detected. You need to download and install PowerShell from the Microsoft website in order to use this feature."
                                , "BIDS Helper PowerShell Window"
                                , MessageBoxButtons.OK
                                , MessageBoxIcon.Stop);
                return;
            }

            try
            {
                ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(true, "Launching Powershell...", 0, 1);

                this.changesvc = (IComponentChangeService)currentDB.Site.GetService(typeof(IComponentChangeService));

                //int iErrorCnt = 0;
                EnvDTE80.Windows2 toolWins;
                EnvDTE.Window     toolWin;
                object            objTemp = null;
                toolWins = (Windows2)ApplicationObject.Windows;
                toolWin  = toolWins.CreateToolWindow2(AddInInstance
                                                      , typeof(BIDSHelper.SSAS.PowerShellControl).Assembly.Location
                                                      , typeof(BIDSHelper.SSAS.PowerShellControl).FullName
                                                      , currentDB.Name + ": PowerShell Window", "{" + typeof(BIDSHelper.SSAS.PowerShellControl).GUID.ToString() + "}"
                                                      , ref objTemp);

                BIDSHelper.SSAS.PowerShellControl ctrl = (SSAS.PowerShellControl)objTemp;
                ctrl.CurrentDB   = currentDB;
                ctrl.ToolWindows = toolWins;
                EnvDTE.Properties prop = this.ApplicationObject.get_Properties("FontsAndColors", "TextEditor");
                ctrl.SetFont((string)prop.Item("FontFamily").Value, (float)Convert.ToDouble(prop.Item("FontSize").Value));

                //setting IsFloating and Linkable to false makes this window tabbed
                toolWin.IsFloating = false;
                toolWin.Linkable   = false;
                toolWin.Visible    = true;

                this.changesvc.OnComponentChanging(this.currentDB, null);
                this.changesvc.OnComponentChanged(this.currentDB, null, null, null);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

            finally
            {
                ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy);
                ApplicationObject.StatusBar.Progress(false, "Launching Powershell...", 2, 2);
            }
        }
Ejemplo n.º 18
0
        public static int getFontSize()
        {
            DTE dte = Package.GetGlobalService(typeof(SDTE)) as DTE;

            EnvDTE.Properties propertiesList = dte.get_Properties("FontsAndColors", "TextEditor");
            Property          prop           = propertiesList.Item("FontSize");
            int fontSize = (System.Int16)prop.Value;

            return(fontSize);
        }
Ejemplo n.º 19
0
        public static IProject GetProject(this _DTE dte, Document currentDoc, string code)
        {
            Project instantProject = new Project();

            instantProject.Sources.Add(Either <FileInfo, string> .B(code));

            EnvDTE.Project project = currentDoc.ProjectItem.ContainingProject;

            EnvDTE.Properties properties = project.ConfigurationManager.ActiveConfiguration.Properties;

            instantProject.DefinedConstants = (string)properties.Item("DefineConstants").Value;
            instantProject.AllowUnsafe      = (bool)properties.Item("AllowUnsafeBlocks").Value;
            instantProject.Optimize         = (bool)properties.Item("Optimize").Value;

            AddFiles(instantProject, project.ProjectItems, currentDoc);
            AddReferences(instantProject, ((VSProject)project.Object).References);

            return(instantProject);
        }
Ejemplo n.º 20
0
        public T GetOption <T>(string category, string page, string option, T defaultValue)
        {
            EnvDTE.Properties properties = _dte.Value.Properties[category, page];
            if (properties != null)
            {
                return((T)properties.Item(option).Value);
            }

            return(defaultValue);
        }
Ejemplo n.º 21
0
        public static Dictionary <string, object> CastToDictionary(this EnvDTE.Properties properties)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var dictionary = new Dictionary <string, object>();

            // Properties is not 0-based, it starts at 1.
            for (int i = 1; i < properties.Count; i++)
            {
                try
                {
                    var      propObj = properties.Item(i);
                    Property prop    = properties.Item(i);
                    string   name    = null;
                    object   value   = null;
                    try
                    {
                        name = prop.Name;
                    }
                    catch
                    {
                        // Skip if we can't get the name.
                        continue;
                    }

                    try
                    {
                        value = prop.Value;
                        var valType = prop?.Value?.GetType();
                    }
                    catch
                    { }

                    dictionary[name] = value;
                }
                catch
                {
                    continue;
                }
            }

            return(dictionary);
        }
Ejemplo n.º 22
0
        public static FontFamily Get_Font_Type()
        {
            DTE dte = Package.GetGlobalService(typeof(SDTE)) as DTE;

            EnvDTE.Properties propertiesList = dte.get_Properties("FontsAndColors", "TextEditor");
            Property          prop           = propertiesList.Item("FontFamily");
            string            font           = (string)prop.Value;

            //AsmDudeToolsStatic.Output_INFO(string.Format("AsmDudeToolsStatic:Get_Font_Type {0}", font));
            return(new FontFamily(font));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Set the DisableErrorReporting property value.
        /// </summary>
        /// <param name="disable"> The property value to set. </param>
        private void DisableIntelliSenseErrorReport(bool disable)
        {
            DTE dte = _applicationObject as DTE;

            EnvDTE.Properties txtEdCpp = dte.get_Properties("TextEditor", "C/C++ Specific");
            EnvDTE.Property   prop     = txtEdCpp.Item("DisableErrorReporting");
            if (prop != null)
            {
                prop.Value = disable;
            }
        }
Ejemplo n.º 24
0
 public static Property GetPropertyOrDefault(this EnvDTE.Properties properties, string propertyName)
 {
     try
     {
         return(properties.Item(propertyName));
     }
     catch (ArgumentException)
     {
         return(null);
     }
 }
Ejemplo n.º 25
0
 public static object TryGetPropertyValueOrDefault(this EnvDTE.Properties properties, string propertyName)
 {
     try
     {
         return(properties.Item(propertyName).Value);
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public void SaveOptions()
 {
     this.IsPending = true;
     try
     {
         var serviceProvoder     = GitLabMainWindowCommand.Instance.ServiceProvider;
         var dte                 = (DTE)serviceProvoder.GetService(typeof(DTE));
         EnvDTE.Properties props = dte.Properties["GitLab Code Review", "General"];
         props.Item(nameof(GitLabOptions.SelectedProjectId)).Value = this.GitOptions.SelectedProjectId;
         props.Item(nameof(GitLabOptions.FavoriteProjects)).Value  = this.GitOptions.FavoriteProjects;
     }
     catch (Exception ex)
     {
         this.errorService.AddError(ex);
     }
     finally
     {
         this.IsPending = false;
     }
 }
Ejemplo n.º 27
0
        public static FontFamily getFontType()
        {
            DTE dte = Package.GetGlobalService(typeof(SDTE)) as DTE;

            EnvDTE.Properties propertiesList = dte.get_Properties("FontsAndColors", "TextEditor");
            Property          prop           = propertiesList.Item("FontFamily");
            string            font           = (string)prop.Value;

            //AsmDudeToolsStatic.Output(string.Format(CultureInfo.CurrentCulture, "ERROR: AsmDudeToolsStatic:getFontType {0}", font));
            return(new FontFamily(font));
        }
Ejemplo n.º 28
0
        protected override void Initialize()
        {
            base.Initialize();

            DTE dte = (DTE)GetService(typeof(DTE));

            IsVS10 = (dte.Version == "10.0");

            EnvDTE.Properties props = dte.get_Properties(OptionNames.PageCategoryName, OptionNames.PageName);

            ScrollBarWidth      = (int)props.Item(OptionNames.ScrollBarWidth).Value;
            RenderTextEnabled   = (bool)props.Item(OptionNames.RenderTextEnabled).Value;
            CursorOpacity       = (double)props.Item(OptionNames.CursorOpacity).Value;
            CursorBorderEnabled = (bool)props.Item(OptionNames.CursorBorderEnabled).Value;
            SplitterEnabled     = (bool)props.Item(OptionNames.SplitterEnabled).Value;
            ErrorsEnabled       = (bool)props.Item(OptionNames.ErrorsEnabled).Value;
            AltHighlight        = (bool)props.Item(OptionNames.AltHighlight).Value;

            FindMarkSize   = (int)props.Item(OptionNames.FindMarkSize).Value;
            MatchCase      = (bool)props.Item(OptionNames.MatchCase).Value;
            MatchWholeWord = (bool)props.Item(OptionNames.MatchWholeWord).Value;
        }
Ejemplo n.º 29
0
 public static T GetProperty <T>(this EnvDTE.Properties properties, string name)
 {
     try
     {
         return((T)properties?
                .Item(name)
                .Value);
     }
     catch
     {
         return(default(T));
     }
 }
Ejemplo n.º 30
0
        private void CompareProperties(EnvDTE.Properties properties, Type propertyNamesType)
        {
            // test number of properties in the collection
            FieldInfo[] propertyNamesFieldInfo;
            propertyNamesFieldInfo = propertyNamesType.GetFields();
            Assert.AreEqual(properties.Count, propertyNamesFieldInfo.Length, "Number of properties does not match expected number of properties");

            //test that we have the expected set of property names
            foreach (FieldInfo info in propertyNamesFieldInfo)
            {
                string   propertyName = info.Name as string;
                Property prop         = properties.Item(propertyName);
                Assert.IsNotNull(prop, String.Format("Property %0 not for found in collection", propertyName));
            }
        }