コード例 #1
0
        /// <include file='doc\DesignerPackage.uex' path='docs/doc[@for="DesignerPackage.SetSite"]/*' />
        /// <devdoc>
        ///     Overrides SetSite to create our editor factory.
        /// </devdoc>
        public override void SetSite(object site)
        {
            base.SetSite(site);

            // Now initialize our editor factory
            //
            editorFactory = new DesignerEditorFactory(site);

            // Initialize this thread's culture info with that of the shell's LCID
            //
            IUIHostLocale loc = (IUIHostLocale)GetService(typeof(IUIHostLocale));

            Debug.Assert(loc != null, "Unable to get IUIHostLocale, defaulting CLR designer to current thread LCID");
            if (loc != null)
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(loc.GetUILocale());
            }

            SystemEvents.DisplaySettingsChanged += new EventHandler(this.OnSystemSettingChanged);
            SystemEvents.InstalledFontsChanged  += new EventHandler(this.OnSystemSettingChanged);
            SystemEvents.UserPreferenceChanged  += new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged);

            // Initialize the ShellLicenseManagerService so it can listen to solution events.
            //
            GetService(typeof(ILicenseManagerService));
            Debug.Assert(licenseManagerService != null, "No license manager service available");

            // Wake up the toolbox service so it registers as a data provider
            //
            GetService(typeof(IToolboxService));
        }
コード例 #2
0
        //==========================================================================================
        // Constructors
        //==========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="PackageContext"/> class.
        /// </summary>
        /// <param name="serviceProvider">
        /// The <see cref="ServiceProvider"/> instance to use for getting services from the environment.
        /// </param>
        public PackageContext(ServiceProvider serviceProvider)
        {
            Tracer.VerifyNonNullArgument(serviceProvider, "serviceProvider");
            this.serviceProvider = serviceProvider;

            // Get an IUIHostLocale instance and Visual Studio's locale
            IUIHostLocale hostLocale = this.GetService(typeof(SUIHostLocale)) as IUIHostLocale;

            Tracer.Assert(hostLocale != null, "Cannot get Visual Studio's locale. Defaulting to current thread's locale.");
            int lcid = Thread.CurrentThread.CurrentUICulture.LCID;

            if (hostLocale != null)
            {
                uint lcidUnsigned;
                int  hr = hostLocale.GetUILocale(out lcidUnsigned);
                if (NativeMethods.Succeeded(hr))
                {
                    lcid = (int)lcidUnsigned;
                }
                else
                {
                    Tracer.Fail("Cannot get Visual Studio's locale. Defaulting to current thread's locale.");
                }
            }

            // Initialize our helpers
            this.managedResources = this.CreateManagedResourceManager();
            this.nativeResources  = new NativeResourceManager(lcid);
            this.settings         = this.CreatePackageSettings(this.ServiceProvider);
        }
コード例 #3
0
        public static uint GetProviderLocale(ServiceProvider provider)
        {
            CultureInfo ci   = CultureInfo.CurrentCulture;
            uint        lcid = (uint)ci.LCID;

            if (provider != null)
            {
                try {
                    IUIHostLocale locale = (IUIHostLocale)provider.QueryService(VsConstants.SID_SUIHostLocale, typeof(IUIHostLocale));
                    locale.GetUILocale(out lcid);
                } catch (Exception) {
                }
            }
            return(lcid);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SnippetDirectories"/> class.
        /// </summary>
        private SnippetDirectories()
        {
            var           version    = SnippetDesignerPackage.Instance.VSVersion;
            IUIHostLocale localeHost = (IUIHostLocale)SnippetDesignerPackage.Instance.GetService(typeof(IUIHostLocale));
            uint          lcid       = (uint)CultureInfo.CurrentCulture.LCID;

            localeHost.GetUILocale(out lcid);

            registryPathReplacements.Add("%InstallRoot%", GetInstallRoot(version));
            registryPathReplacements.Add("%LCID%", lcid.ToString());
            registryPathReplacements.Add("%MyDocs%", RegistryLocations.GetVisualStudioUserDataPath(version));
            replaceRegex = new Regex("(%InstallRoot%)|(%LCID%)|(%MyDocs%)", RegexOptions.Compiled);

            GetUserSnippetDirectories();
            GetSnippetDirectoriesFromRegistry(Registry.LocalMachine, false, version);
            GetSnippetDirectoriesFromRegistry(Registry.CurrentUser, true, version);
        }
コード例 #5
0
ファイル: HelpUrlBuilder.cs プロジェクト: zyonet/VS-PPT
        public static string Build(Dictionary <string, string[]> attributes)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(HelpUrlPrefix);

            uint          lcid;
            IUIHostLocale loc = (IUIHostLocale)ServiceProvider.GlobalProvider.GetService(typeof(IUIHostLocale));

            if (loc != null && ErrorHandler.Succeeded(loc.GetUILocale(out lcid)))
            {
                var cultureInfo = new CultureInfo((int)lcid);
                sb.Append(cultureInfo.Name);
            }
            else
            {
                sb.Append("EN-US");
            }

            if (attributes.ContainsKey("keyword"))
            {
                foreach (var keyword in attributes["keyword"])
                {
                    AppendUrlParameter(sb, "&k=k({0})", keyword);
                }
            }

            if (attributes.ContainsKey("TargetFrameworkMoniker"))
            {
                AppendUrlParameter(sb, ";k(TargetFrameworkMoniker-{0})", attributes["TargetFrameworkMoniker"][0]);
            }

            if (attributes.ContainsKey("DevLang"))
            {
                AppendUrlParameter(sb, ";k(DevLang-{0})", attributes["DevLang"][0]);
            }

            sb.Append(HelpUrlSuffix);
            return(sb.ToString());
        }