Ejemplo n.º 1
0
 public int OnUserPreferencesChanged2(VIEWPREFERENCES2[] viewPrefs, FRAMEPREFERENCES2[] framePrefs, LANGPREFERENCES2[] langPrefs, FONTCOLORPREFERENCES2[] colorPrefs) {
     if (langPrefs != null && langPrefs.Length > 0 && langPrefs[0].guidLang == this._preferences.guidLang) {
         _preferences.IndentStyle = langPrefs[0].IndentStyle;
         _preferences.fAutoListMembers = langPrefs[0].fAutoListMembers;
         _preferences.fAutoListParams = langPrefs[0].fAutoListParams;
         _preferences.fHideAdvancedAutoListMembers = langPrefs[0].fHideAdvancedAutoListMembers;
     }
     return VSConstants.S_OK;
 }
Ejemplo n.º 2
0
        public LanguageInfo(SVsServiceProvider serviceProvider, Guid languageGuid)
        {
            Contract.Requires<ArgumentNullException>(serviceProvider != null, "serviceProvider");

            _serviceProvider = serviceProvider;
            _languageGuid = languageGuid;

            IVsTextManager2 textManager = serviceProvider.GetTextManager2();
            LANGPREFERENCES2[] preferences = new LANGPREFERENCES2[1];
            preferences[0].guidLang = languageGuid;
            ErrorHandler.ThrowOnFailure(textManager.GetUserPreferences2(null, null, preferences, null));
            _languagePreferences = CreateLanguagePreferences(preferences[0]);
            _languagePreferencesCookie = ((IConnectionPointContainer)textManager).Advise<LanguagePreferences, IVsTextManagerEvents2>(_languagePreferences);
        }
Ejemplo n.º 3
0
        public LanguageInfo(SVsServiceProvider serviceProvider, Guid languageGuid)
        {
            Contract.Requires <ArgumentNullException>(serviceProvider != null, "serviceProvider");

            _serviceProvider = serviceProvider;
            _languageGuid    = languageGuid;

            IVsTextManager2 textManager = serviceProvider.GetTextManager2();

            LANGPREFERENCES2[] preferences = new LANGPREFERENCES2[1];
            preferences[0].guidLang = languageGuid;
            ErrorHandler.ThrowOnFailure(textManager.GetUserPreferences2(null, null, preferences, null));
            _languagePreferences       = CreateLanguagePreferences(preferences[0]);
            _languagePreferencesCookie = ((IConnectionPointContainer)textManager).Advise <LanguagePreferences, IVsTextManagerEvents2>(_languagePreferences);
        }
Ejemplo n.º 4
0
 public LanguageInfo(SVsServiceProvider serviceProvider, Guid languageGuid)
 {
     if (serviceProvider == null)
     {
         throw new ArgumentNullException("serviceProvider");
     }
     this._serviceProvider = serviceProvider;
     this._languageGuid = languageGuid;
     IVsTextManager2 manager = serviceProvider.GetTextManager2();
     LANGPREFERENCES2[] pLangPrefs = new LANGPREFERENCES2[1];
     pLangPrefs[0].guidLang = languageGuid;
     ErrorHandler.ThrowOnFailure(manager.GetUserPreferences2(null, null, pLangPrefs, null));
     this._languagePreferences = this.CreateLanguagePreferences(pLangPrefs[0]);
     this._languagePreferencesCookie = ((IConnectionPointContainer) manager).Advise<Smi.VisualStudio.Language.LanguagePreferences, IVsTextManagerEvents2>(this._languagePreferences);
 }
Ejemplo n.º 5
0
        /// <include file='doc\PropertySheet.uex' path='docs/doc[@for="LanguagePreferences.Apply"]/*' />
        public virtual void Apply()
        {
            IVsTextManager2 textMgr2 = site.GetService(typeof(SVsTextManager)) as IVsTextManager2;

            if (textMgr2 != null)
            {
                this.prefs.guidLang = langSvc;
                LANGPREFERENCES2[] langPrefs2 = new LANGPREFERENCES2[1];
                langPrefs2[0] = this.prefs;
                if (!NativeMethods.Succeeded(textMgr2.SetUserPreferences2(null, null, langPrefs2, null)))
                {
                    Debug.Assert(false, "textMgr2.SetUserPreferences2");
                }
            }
        }
Ejemplo n.º 6
0
        internal void Initialize()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsTextManager2 textManager = (IVsTextManager2)this.serviceProvider.GetService(typeof(SVsTextManager));
            VIEWPREFERENCES2[] viewPreferences = new VIEWPREFERENCES2[] { new VIEWPREFERENCES2() };
            LANGPREFERENCES2[] languagePreferences = new LANGPREFERENCES2[] { new LANGPREFERENCES2() { guidLang = Guids.Service } };

            int hresult = textManager.GetUserPreferences2(viewPreferences, pFramePrefs: null, pLangPrefs: languagePreferences, pColorPrefs: null);
            ErrorHandler.ThrowOnFailure(hresult);

            this.UpdatePreferences(viewPreferences, languagePreferences);

            this.connectionPoint = new AxHost.ConnectionPointCookie(textManager, this, typeof(IVsTextManagerEvents2));
        }
Ejemplo n.º 7
0
 int IVsTextManagerEvents2.OnUserPreferencesChanged2(VIEWPREFERENCES2[] pViewPrefs, FRAMEPREFERENCES2[] pFramePrefs, LANGPREFERENCES2[] pLangPrefs, FONTCOLORPREFERENCES2[] pColorPrefs)
 {
     Func<LANGPREFERENCES2, bool> predicate = null;
     if (pLangPrefs != null)
     {
         if (predicate == null)
         {
             predicate = i => i.guidLang == this._preferences.guidLang;
         }
         LANGPREFERENCES2[] langpreferencesArray = pLangPrefs.Where<LANGPREFERENCES2>(predicate).ToArray<LANGPREFERENCES2>();
         if (langpreferencesArray.Length > 0)
         {
             this._preferences = langpreferencesArray[0];
         }
     }
     return 0;
 }
Ejemplo n.º 8
0
        private void UpdatePreferences(VIEWPREFERENCES2[] viewPreferences, LANGPREFERENCES2[] languagePreferences)
        {
            if (viewPreferences != null && viewPreferences.Length > 0)
            {
                // this.AutoDelimiterHighlight = Convert.ToBoolean(viewPreferences[0].fAutoDelimiterHighlight);
            }

            if (languagePreferences != null && languagePreferences.Length > 0 &&
                Guid.Equals(languagePreferences[0].guidLang, Guids.Service))
            {
                this.singletons.FormattingUserSettings.IndentStyle = languagePreferences[0].IndentStyle;
                this.singletons.FormattingUserSettings.TabSize = languagePreferences[0].uTabSize;
                this.singletons.FormattingUserSettings.IndentSize = languagePreferences[0].uIndentSize;
                this.singletons.FormattingUserSettings.UsingTabs = Convert.ToBoolean(languagePreferences[0].fInsertTabs);
                this.FireOnUpdateLanguagePreferences();
            }
        }
Ejemplo n.º 9
0
 public int OnUserPreferencesChanged2(VIEWPREFERENCES2[] viewPrefs, FRAMEPREFERENCES2[] framePrefs, LANGPREFERENCES2[] langPrefs, FONTCOLORPREFERENCES2[] colorPrefs) {
     int hr = VSConstants.S_OK;
     if (langPrefs != null && langPrefs.Length > 0 && langPrefs[0].guidLang == this._preferences.guidLang) {
         _preferences.IndentStyle = langPrefs[0].IndentStyle;
         _preferences.fAutoListMembers = langPrefs[0].fAutoListMembers;
         _preferences.fAutoListParams = langPrefs[0].fAutoListParams;
         _preferences.fHideAdvancedAutoListMembers = langPrefs[0].fHideAdvancedAutoListMembers;
         if (_preferences.fDropdownBar != (_preferences.fDropdownBar = langPrefs[0].fDropdownBar)) {
             foreach(var window in _service.CodeWindowManagers) {
                 hr = window.ToggleNavigationBar(_preferences.fDropdownBar != 0);
                 if (ErrorHandler.Failed(hr)) {
                     break;
                 }
             }
         }
     }
     return VSConstants.S_OK;
 }
        public int OnUserPreferencesChanged2(VIEWPREFERENCES2[] pViewPrefs, FRAMEPREFERENCES2[] pFramePrefs, LANGPREFERENCES2[] pLangPrefs, FONTCOLORPREFERENCES2[] pColorPrefs)
        {
            if (pLangPrefs != null && pLangPrefs.Length > 0 && pLangPrefs[0].guidLang == _preferences.guidLang)
            {
                _preferences.IndentStyle = pLangPrefs[0].IndentStyle;

                if (_preferences.fDropdownBar != (_preferences.fDropdownBar = pLangPrefs[0].fDropdownBar))
                {
                    foreach (var window in _package.CodeWindowManagers)
                    {
                        var hr = window.ToggleNavigationBar(_preferences.fDropdownBar != 0);
                        if (ErrorHandler.Failed(hr))
                        {
                            break;
                        }
                    }
                }
            }
            return VSConstants.S_OK;
        }
        internal void Initialize()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsTextManager2 textManager = (IVsTextManager2)this.serviceProvider.GetService(typeof(SVsTextManager));

            VIEWPREFERENCES2[] viewPreferences     = new VIEWPREFERENCES2[] { new VIEWPREFERENCES2() };
            LANGPREFERENCES2[] languagePreferences = new LANGPREFERENCES2[] { new LANGPREFERENCES2()
                                                                              {
                                                                                  guidLang = Guids.Service
                                                                              } };

            int hresult = textManager.GetUserPreferences2(viewPreferences, pFramePrefs: null, pLangPrefs: languagePreferences, pColorPrefs: null);

            //ErrorHandler.ThrowOnFailure(hresult);

            this.UpdatePreferences(viewPreferences, languagePreferences);

            this.connectionPoint = new AxHost.ConnectionPointCookie(textManager, this, typeof(IVsTextManagerEvents2));
        }
 private static LANGPREFERENCES FromLangPrefs2(LANGPREFERENCES2 langPrefs)
 {
     return(new LANGPREFERENCES {
         fAutoListMembers = langPrefs.fAutoListMembers,
         fAutoListParams = langPrefs.fAutoListParams,
         fDropdownBar = langPrefs.fDropdownBar,
         fHideAdvancedAutoListMembers = langPrefs.fHideAdvancedAutoListMembers,
         fHotURLs = langPrefs.fHotURLs,
         fInsertTabs = langPrefs.fInsertTabs,
         fLineNumbers = langPrefs.fLineNumbers,
         fShowCompletion = langPrefs.fShowCompletion,
         fShowSmartIndent = langPrefs.fShowSmartIndent,
         fTwoWayTreeview = langPrefs.fTwoWayTreeview,
         fVirtualSpace = langPrefs.fVirtualSpace,
         fWordWrap = langPrefs.fWordWrap,
         IndentStyle = langPrefs.IndentStyle,
         guidLang = langPrefs.guidLang,
         szFileType = langPrefs.szFileType,
         uIndentSize = langPrefs.uIndentSize,
         uTabSize = langPrefs.uTabSize
     });
 }
Ejemplo n.º 13
0
        /// <include file='doc\Preferences.uex' path='docs/doc[@for="LanguagePreferences.GetLanguagePrefs"]/*' />
        public virtual void GetLanguagePreferences()
        {
            IVsTextManager textMgr = GetService <IVsTextManager>(typeof(SVsTextManager));

            if (textMgr != null)
            {
                this.prefs.guidLang = langSvc;
                IVsTextManager2 textMgr2 = textMgr as IVsTextManager2;
                if (textMgr != null)
                {
                    LANGPREFERENCES2[] langPrefs2 = new LANGPREFERENCES2[1];
                    langPrefs2[0] = this.prefs;
                    if (VSErr.Succeeded(textMgr2.GetUserPreferences2(null, null, langPrefs2, null)))
                    {
                        this.prefs = langPrefs2[0];
                    }
                    else
                    {
                        Debug.Assert(false, "textMgr2.GetUserPreferences2");
                    }
                }
            }
        }
Ejemplo n.º 14
0
        /// <include file='doc\Preferences.uex' path='docs/doc[@for="LanguagePreferences.GetLanguagePrefs"]/*' />
        public virtual void GetLanguagePreferences()
        {
            IVsTextManager textMgr = site.GetService(typeof(SVsTextManager)) as IVsTextManager;

            if (textMgr != null)
            {
                this.prefs.guidLang = langSvc;
                IVsTextManager2 textMgr2 = site.GetService(typeof(SVsTextManager)) as IVsTextManager2;
                if (textMgr != null)
                {
                    LANGPREFERENCES2[] langPrefs2 = new LANGPREFERENCES2[1];
                    langPrefs2[0] = this.prefs;
                    if (NativeMethods.Succeeded(textMgr2.GetUserPreferences2(null, null, langPrefs2, null)))
                    {
                        this.prefs = langPrefs2[0];
                    }
                    else
                    {
                        Debug.Assert(false, "textMgr2.GetUserPreferences2");
                    }
                }
                Marshal.ReleaseComObject(textMgr);
            }
        }
        private void InitializeOptions(ITextBuffer textBuffer)
        {
            // Ideally we would initialize options based on Razor specific options in the context menu.
            // But since we don't have support for that yet, we will temporarily use the settings from Html.

            var textManager = _serviceProvider.GetService(typeof(SVsTextManager)) as IVsTextManager2;

            Assumes.Present(textManager);

            var langPrefs2 = new LANGPREFERENCES2[] { new LANGPREFERENCES2()
                                                      {
                                                          guidLang = HtmlLanguageServiceGuid
                                                      } };

            if (VSConstants.S_OK == textManager.GetUserPreferences2(null, null, langPrefs2, null))
            {
                var insertSpaces = langPrefs2[0].fInsertTabs == 0;
                var tabSize      = langPrefs2[0].uTabSize;

                var razorOptions = _editorOptionsFactory.GetOptions(textBuffer);
                razorOptions.SetOptionValue(DefaultOptions.ConvertTabsToSpacesOptionId, insertSpaces);
                razorOptions.SetOptionValue(DefaultOptions.TabSizeOptionId, (int)tabSize);
            }
        }
Ejemplo n.º 16
0
 protected virtual LanguagePreferences CreateLanguagePreferences(LANGPREFERENCES2 preferences)
 {
     return(new LanguagePreferences(preferences));
 }
Ejemplo n.º 17
0
 public int OnUserPreferencesChanged2(VIEWPREFERENCES2[] pViewPrefs, FRAMEPREFERENCES2[] pFramePrefs, LANGPREFERENCES2[] pLangPrefs, FONTCOLORPREFERENCES2[] pColorPrefs)
 {
     if (pLangPrefs != null) {
         _preferences.IndentStyle = pLangPrefs[0].IndentStyle;
         _preferences.fAutoListMembers = pLangPrefs[0].fAutoListMembers;
         _preferences.fAutoListParams = pLangPrefs[0].fAutoListParams;
         _preferences.fHideAdvancedAutoListMembers = pLangPrefs[0].fHideAdvancedAutoListMembers;
         if (_preferences.fDropdownBar != (_preferences.fDropdownBar = pLangPrefs[0].fDropdownBar)) {
             CodeWindowManager.ToggleNavigationBar(_preferences.fDropdownBar != 0);
         }
     }
     return VSConstants.S_OK;
 }
Ejemplo n.º 18
0
        protected virtual LanguagePreferences CreateLanguagePreferences(LANGPREFERENCES2 preferences)
        {
            Contract.Ensures(Contract.Result<LanguagePreferences>() != null);

            return new LanguagePreferences(preferences);
        }
Ejemplo n.º 19
0
 public int OnUserPreferencesChanged2(VIEWPREFERENCES2[] viewPreferences, FRAMEPREFERENCES2[] pFramePrefs, LANGPREFERENCES2[] languagePreferences, FONTCOLORPREFERENCES2[] pColorPrefs)
 {
     this.UpdatePreferences(viewPreferences, languagePreferences);
     return VSConstants.S_OK;
 }
Ejemplo n.º 20
0
 protected virtual LanguagePreferences CreateLanguagePreferences(LANGPREFERENCES2 preferences)
 {
     return new Smi.VisualStudio.Language.LanguagePreferences(preferences);
 }
Ejemplo n.º 21
0
 public LanguagePreferences(LANGPREFERENCES2 preferences)
 {
     this._preferences = preferences;
 }
Ejemplo n.º 22
0
 public int OnUserPreferencesChanged2(VIEWPREFERENCES2[] pViewPrefs, FRAMEPREFERENCES2[] pFramePrefs, LANGPREFERENCES2[] pLangPrefs, FONTCOLORPREFERENCES2[] pColorPrefs)
 {
     return VSConstants.S_OK;
 }
Ejemplo n.º 23
0
 public virtual int OnUserPreferencesChanged2(VIEWPREFERENCES2[] viewPrefs, FRAMEPREFERENCES2[] framePrefs, LANGPREFERENCES2[] langPrefs, FONTCOLORPREFERENCES2[] fontColorPrefs) {
     if (langPrefs != null && langPrefs.Length > 0 && langPrefs[0].guidLang == this.langSvc) {
         this.prefs = langPrefs[0];
     }
     return NativeMethods.S_OK;
 }
Ejemplo n.º 24
0
 /// <include file='doc\Preferences.uex' path='docs/doc[@for="LanguagePreferences.GetLanguagePrefs"]/*' />
 public virtual void GetLanguagePreferences() {
     IVsTextManager textMgr = site.GetService(typeof(SVsTextManager)) as IVsTextManager;
     if (textMgr != null) {
         this.prefs.guidLang = langSvc;
         IVsTextManager2 textMgr2 = site.GetService(typeof(SVsTextManager)) as IVsTextManager2;
         if (textMgr != null) {
             LANGPREFERENCES2[] langPrefs2 = new LANGPREFERENCES2[1];
             langPrefs2[0] = this.prefs;
             if (NativeMethods.Succeeded(textMgr2.GetUserPreferences2(null, null, langPrefs2, null))) {
                 this.prefs = langPrefs2[0];
             } else {
                 Debug.Assert(false, "textMgr2.GetUserPreferences2");
             }
         }
         Marshal.ReleaseComObject(textMgr);
     }
 }
Ejemplo n.º 25
0
        protected virtual LanguagePreferences CreateLanguagePreferences(LANGPREFERENCES2 preferences)
        {
            Contract.Ensures(Contract.Result <LanguagePreferences>() != null);

            return(new LanguagePreferences(preferences));
        }
Ejemplo n.º 26
0
        internal void SetLanguagePreferences(LANGPREFERENCES2 langPrefs)
        {
            var txtMgr = (IVsTextManager2)_container.GetService(typeof(SVsTextManager));

            ErrorHandler.ThrowOnFailure(txtMgr.SetUserPreferences2(null, null, new[] { langPrefs }, null));
        }
Ejemplo n.º 27
0
 public virtual void Apply() {
     IVsTextManager2 textMgr2 = site.GetService(typeof(SVsTextManager)) as IVsTextManager2;
     if (textMgr2 != null) {
         this.prefs.guidLang = langSvc;
         LANGPREFERENCES2[] langPrefs2 = new LANGPREFERENCES2[1];
         langPrefs2[0] = this.prefs;
         if (!NativeMethods.Succeeded(textMgr2.SetUserPreferences2(null, null, langPrefs2, null))) {
             Debug.Assert(false, "textMgr2.SetUserPreferences2");
         }
     }
 }