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 property page for encouragements #27
Conversation
I spent some time looking at this. I'll start with saying that low level UI, especially older Win32 UI, is not my specialty so take what I say with a grain of skepticism. ;) The VS options dialog under the hood is a property sheet. All of the message processing for the dialog appears to obey these basic semantics. In this case the enter key appears to go through normal processing. It sees There appears to be no way at the Visual Studio level to opt out of this behavior. There may be a way to do this at a lower level (like overriding My guess is they will say that the best approach is to use a list box style control with Add / Remove buttons. Essentially taking the Enter key out of the equation. |
sigh That's what I figured. I guess I could try to override |
The VS team got back to me and it is possible to handle Enter in the options page but it does involve a bit of The WPF version of |
@jaredpar thanks man! |
return Settings.Default.Encouragements.Split( | ||
new [] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries) | ||
.ToList(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of application settings is not version safe in a VSIX. The location of the stored setting file path in part includes the version string and hashes of the executable. When Visual Studio installs an official update these values change and as a consequence change the setting file path. Visual Studio itself doesn't support the use of application settings hence it makes no attempt to migrate this file to the new location and all information is essentially lost.
The supported method of settings is the WritableSettingsStore
. It's very similar to application settings and easy enough to access via SVsServiceProvider
public static WritableSettingsStore GetWritableSettingsStore(this SVsServiceProvider vsServiceProvider)
{
var shellSettingsManager = new ShellSettingsManager(vsServiceProvider);
return shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
}
This may or may not be considered a blocker for you. IIRC the settings just reset on every upgrade so it wouldn't necessarily lose all information, just new information.
@jaredpar Thanks to your suggestions, I changed my approach to settings. Since The problem is I'm having trouble getting that value to the other services. I made this class also export I tried to do that in |
Mixing options pages and MEF components is problematic because they have different activation models: COM vs. MEF. Even though it's logically one service eventually two instances of Generally the best approach here is to keep the MEF service separate and then import it into the
I was writing up a much longer comment here about how to get the interplay between the two services correct and eventually realized it may be better to just demonstrate it with code. As for the persistence of the property on the dialog it seemed to only be persisting it for the current Visual Studio session on my box vs across restarts of Visual Studio. I think that's just an effect of how |
Weird, that doesn't build for me. :(
|
Ah, I changed the reference to <Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> and that seemed to fix it. |
Blarg! Insert general grumblings about Visual Studio SDK not embracing NuGet as a deployment solution. I just updated that branch to add the appropriate reference assembly. Need to take that vs. changing the reference tag because changing the reference tag will break the ability to deploy to VS 2012. The version "12.0.0.0" tag actually targets VS 2013 and not VS 2012. |
Ah, right. Shit. |
🍔 I think this PR is ready! Thanks @jaredpar |
👍 Looks good to me! |
✨ Thanks! BTW, I've got a rough draft of a blog post that explains this process. I quote you a bit. Mind taking a look when you have some time? haacked/haacked.com#140 |
Add property page for encouragements
This adds the simplest possible property page for customizing encouragements.
The only problem so far is that you can't hit
Enter
in the text box to add another encouragement. So if you need to add multiple, you have to cut and paste.The "OK" button seems to steal the Enter keypress. I tried to handle it in the KeyDown event, but I think the OK button receives it first.
@jaredpar any thoughts on what we can do here?