Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to read the configure #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion ArchivedSamples/Options_Page/C#/OptionsPagePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
using Microsoft.VisualStudio.Shell;
using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;

namespace Microsoft.Samples.VisualStudio.IDE.OptionsPage
{
Expand All @@ -19,7 +21,7 @@ namespace Microsoft.Samples.VisualStudio.IDE.OptionsPage
/// The package class uses a number of registration attributes to specify integration parameters.
/// </summary>
[PackageRegistration(UseManagedResourcesOnly = true)]
[ProvideOptionPageAttribute(typeof(OptionsPageGeneral),"My Options Page (C#)","General", 100, 101, true, new string[] { "Change sample general options (C#)" })]
[ProvideOptionPageAttribute(typeof(OptionsPageGeneral), "My Options Page (C#)", "General", 100, 101, true, new string[] { "Change sample general options (C#)" })]
[ProvideProfileAttribute(typeof(OptionsPageGeneral), "My Options Page (C#)", "General Options", 100, 101, true, DescriptionResourceID = 100)]
[ProvideOptionPageAttribute(typeof(OptionsPageCustom), "My Options Page (C#)", "Custom", 100, 102, true, new string[] { "Change sample custom options (C#)" })]
[InstalledProductRegistration("My Options Page (C#)", "My Options Page (C#) Sample", "1.0")]
Expand All @@ -35,5 +37,41 @@ protected override void Initialize()
base.Initialize();
// TODO: add initialization code here
}

public static OptionsPagePackageCS EnsurePackageIsLoaded()
{
IVsShell shell = Package.GetGlobalService(typeof(SVsShell)) as IVsShell;
if (shell != null)
{
IVsPackage package;
Guid guid = new Guid(GuidStrings.GuidPackage);

if (ErrorHandler.Succeeded(shell.LoadPackage(ref guid, out package)))
{
return package as OptionsPagePackageCS;
}
}
return null;
}

/// <summary>
/// Get the OptionsPageGeneral
/// </summary>
/// <returns></returns>
public static OptionsPageGeneral OptionsPageGeneral()
{
OptionsPagePackageCS package = EnsurePackageIsLoaded();
return package?.GetDialogPage(typeof(OptionsPageGeneral)) as OptionsPageGeneral;
}

/// <summary>
/// Get the OptionsPageCustom
/// </summary>
/// <returns></returns>
public static OptionsPageCustom OptionsPageCustom()
{
OptionsPagePackageCS package = EnsurePackageIsLoaded();
return package?.GetDialogPage(typeof(OptionsPageCustom)) as OptionsPageCustom;
}
}
}