Skip to content

Commit 20e60e6

Browse files
committed
Aphid VS shell.
1 parent 1e4cea0 commit 20e60e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3823
-0
lines changed

.gitattributes

+50
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,56 @@ AphidCodeGenerator/IAphidCodeObject.cs -text
2121
AphidCodeGenerator/ParserRules.alx -text
2222
AphidCodeGenerator/Program.cs -text
2323
AphidCodeGenerator/Properties/AssemblyInfo.cs -text
24+
AphidVSShell/AphidVSShell.AboutBoxPackage/AboutBox.xaml -text
25+
AphidVSShell/AphidVSShell.AboutBoxPackage/AboutBox.xaml.cs -text
26+
AphidVSShell/AphidVSShell.AboutBoxPackage/AphidVSShell.AboutBoxPackage.cs -text
27+
AphidVSShell/AphidVSShell.AboutBoxPackage/AphidVSShell.AboutBoxPackage.csproj -text
28+
AphidVSShell/AphidVSShell.AboutBoxPackage/AphidVSShell.AboutBoxPackage.csproj.vspscc -text
29+
AphidVSShell/AphidVSShell.AboutBoxPackage/AphidVSShell.AboutBoxPackage.vsct -text
30+
AphidVSShell/AphidVSShell.AboutBoxPackage/Guids.cs -text
31+
AphidVSShell/AphidVSShell.AboutBoxPackage/Key.snk -text svneol=unset#unset
32+
AphidVSShell/AphidVSShell.AboutBoxPackage/PkgCmdID.cs -text
33+
AphidVSShell/AphidVSShell.AboutBoxPackage/Properties/AssemblyInfo.cs -text
34+
AphidVSShell/AphidVSShell.AboutBoxPackage/VSPackage.resx -text
35+
AphidVSShell/AphidVSShell.AboutBoxPackage/source.extension.vsixmanifest -text
36+
AphidVSShell/AphidVSShell/AphidVSShell.Application.pkgdef -text svneol=unset#unset
37+
AphidVSShell/AphidVSShell/AphidVSShell.cpp -text svneol=unset#unset
38+
AphidVSShell/AphidVSShell/AphidVSShell.exe.config -text
39+
AphidVSShell/AphidVSShell/AphidVSShell.exe.manifest -text
40+
AphidVSShell/AphidVSShell/AphidVSShell.h -text svneol=unset#unset
41+
AphidVSShell/AphidVSShell/AphidVSShell.pkgdef -text
42+
AphidVSShell/AphidVSShell/AphidVSShell.pkgundef -text
43+
AphidVSShell/AphidVSShell/AphidVSShell.rc -text
44+
AphidVSShell/AphidVSShell/AphidVSShell.reg -text svneol=unset#unset
45+
AphidVSShell/AphidVSShell/AphidVSShell.vcxproj -text
46+
AphidVSShell/AphidVSShell/AphidVSShell.vcxproj.filters -text
47+
AphidVSShell/AphidVSShell/AphidVSShell.vcxproj.vspscc -text
48+
AphidVSShell/AphidVSShell/AphidVSShell.winprf -text
49+
AphidVSShell/AphidVSShell/ApplicationIcon.ico -text svneol=unset#unset
50+
AphidVSShell/AphidVSShell/DebuggerProxy.dll -text svneol=unset#unset
51+
AphidVSShell/AphidVSShell/DebuggerProxy.dll.manifest -text
52+
AphidVSShell/AphidVSShell/Documentation/Images/AppEnv.jpg -text svneol=unset#unset
53+
AphidVSShell/AphidVSShell/Documentation/ReadMe.htm -text
54+
AphidVSShell/AphidVSShell/General.vssettings -text
55+
AphidVSShell/AphidVSShell/Resource.h -text svneol=unset#unset
56+
AphidVSShell/AphidVSShell/ShellSection.cpp -text
57+
AphidVSShell/AphidVSShell/ShellSection.h -text
58+
AphidVSShell/AphidVSShell/Splash.bmp -text svneol=unset#unset
59+
AphidVSShell/AphidVSShell/VsSDK.props -text
60+
AphidVSShell/AphidVSShell/small.ico -text svneol=unset#unset
61+
AphidVSShell/AphidVSShell/stdafx.cpp -text svneol=unset#unset
62+
AphidVSShell/AphidVSShell/stdafx.h -text svneol=unset#unset
63+
AphidVSShell/AphidVSShellUI/AphidVSShellUI.cpp -text svneol=unset#unset
64+
AphidVSShell/AphidVSShellUI/AphidVSShellUI.rc -text
65+
AphidVSShell/AphidVSShellUI/AphidVSShellUI.vcxproj -text
66+
AphidVSShell/AphidVSShellUI/AphidVSShellUI.vcxproj.filters -text
67+
AphidVSShell/AphidVSShellUI/AphidVSShellUI.vcxproj.vspscc -text
68+
AphidVSShell/AphidVSShellUI/ApplicationCommands.vsct -text
69+
AphidVSShell/AphidVSShellUI/resource.h -text svneol=unset#unset
70+
AphidVSShell/ShellExtensionsVSIX/Properties/AssemblyInfo.cs -text
71+
AphidVSShell/ShellExtensionsVSIX/ShellExtensionsVSIX.csproj -text
72+
AphidVSShell/ShellExtensionsVSIX/ShellExtensionsVSIX.csproj.vspscc -text
73+
AphidVSShell/ShellExtensionsVSIX/source.extension.vsixmanifest -text
2474
Components.Aphid.Net/AphidRequest.cs -text
2575
Components.Aphid.Net/Components.Aphid.Net.csproj -text
2676
Components.Aphid.Net/Components.Aphid.Net.csproj.vspscc -text
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<vsui:DialogWindow x:Class="AphidVSShell.AboutBoxPackage.AboutBox"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:vsui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.11.0"
5+
Title="{Binding RelativeSource={RelativeSource Self}, Mode=OneTime, Path=ProductTitle}"
6+
Style="{DynamicResource AboutDialogStyle}" WindowStartupLocation="CenterOwner">
7+
<Window.Resources>
8+
<XmlDataProvider x:Key="aboutProvider" XPath="ApplicationInfo" IsAsynchronous="False" IsInitialLoadEnabled="True">
9+
<x:XData>
10+
<ApplicationInfo xmlns="">
11+
<Link x:Uid="moreinfo" Uri="http://www.My Company.com">More Info</Link>
12+
</ApplicationInfo>
13+
</x:XData>
14+
</XmlDataProvider>
15+
<Style x:Key="AboutDialogStyle" TargetType="Window">
16+
<Setter Property="Height" Value="Auto" />
17+
<Setter Property="Width" Value="500" />
18+
<Setter Property="ShowInTaskbar" Value="False" />
19+
<Setter Property="ResizeMode" Value="NoResize" />
20+
<Setter Property="WindowStyle" Value="SingleBorderWindow" />
21+
<Setter Property="SizeToContent" Value="Height" />
22+
</Style>
23+
<Style x:Key="DisplayAreaStyle" TargetType="{x:Type StackPanel}">
24+
<Setter Property="Margin" Value="10,10,10,5" />
25+
</Style>
26+
<Style TargetType="Label">
27+
<Setter Property="Padding" Value="0" />
28+
</Style>
29+
<Style x:Key="ParagraphSeparator" TargetType="{x:Type Label}">
30+
<Setter Property="Padding" Value="0,10,0,0" />
31+
</Style>
32+
<Style x:Key="LinkLabelStyle">
33+
<Setter Property="Control.Padding" Value="0" />
34+
<Setter Property="Control.VerticalAlignment" Value="Center" />
35+
</Style>
36+
<Style x:Key="ReadOnlyDescStyle" TargetType="{x:Type TextBox}">
37+
<Setter Property="MinLines" Value="6" />
38+
<Setter Property="MaxLines" Value="6" />
39+
<Setter Property="IsReadOnly" Value="True" />
40+
<Setter Property="TextWrapping" Value="WrapWithOverflow" />
41+
<Setter Property="VerticalScrollBarVisibility" Value="Visible" />
42+
</Style>
43+
<Style x:Key="OkButtonStyle" TargetType="{x:Type Button}">
44+
<Setter Property="MinWidth" Value="75" />
45+
<Setter Property="Margin" Value="0,5" />
46+
<Setter Property="DockPanel.Dock" Value="Right" />
47+
<Setter Property="IsDefault" Value="True" />
48+
<Setter Property="IsCancel" Value="True" />
49+
</Style>
50+
</Window.Resources>
51+
<StackPanel>
52+
<StackPanel Style="{StaticResource DisplayAreaStyle}"
53+
DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Mode=OneTime}">
54+
<Label x:Name="productName"
55+
Content="{Binding Mode=OneTime, Path=Product}" />
56+
<StackPanel Orientation="Horizontal">
57+
<Label x:Name="versionLabel" x:Uid="VersionLabel" Content="Version - " />
58+
<Label x:Name="version" Content="{Binding Mode=OneTime, Path=Version}" />
59+
</StackPanel>
60+
<Label x:Name="copyright" Content="{Binding Mode=OneTime, Path=Copyright}" />
61+
<Label x:Name="company" Content="{Binding Mode=OneTime, Path=Company}" />
62+
<Label x:Name="reserved" x:Uid="reserved" Content="All Rights Reserved." />
63+
<Label x:Name="info" x:Uid="info" Style="{StaticResource ParagraphSeparator}"
64+
Content="Product details:" />
65+
<TextBox x:Name="description" Text="{Binding Mode=OneTime, Path=Description}"
66+
Style="{StaticResource ReadOnlyDescStyle}" />
67+
<DockPanel>
68+
<Button x:Name="okButton" x:Uid="okButton" Style="{StaticResource OkButtonStyle}"
69+
Content="OK" />
70+
<Label x:Name="productLink" Style="{StaticResource LinkLabelStyle}" >
71+
<Hyperlink x:Name="hyperlink" NavigateUri="{Binding Mode=OneTime, Path=LinkUri}" Style="{StaticResource LinkLabelStyle}"
72+
Hyperlink.RequestNavigate="hyperlink_RequestNavigate">
73+
<TextBlock Text="{Binding Mode=OneTime, Path=LinkText}" />
74+
</Hyperlink>
75+
</Label>
76+
</DockPanel>
77+
</StackPanel>
78+
</StackPanel>
79+
</vsui:DialogWindow>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using System.Reflection;
5+
using System.Windows;
6+
using System.Windows.Data;
7+
using System.Xml;
8+
using Microsoft.VisualStudio.PlatformUI;
9+
10+
namespace AphidVSShell.AboutBoxPackage
11+
{
12+
/// <summary>
13+
/// Interaction logic for AboutBox.xaml
14+
/// </summary>
15+
public partial class AboutBox : DialogWindow
16+
{
17+
/// <summary>
18+
/// Default constructor.
19+
/// </summary>
20+
public AboutBox()
21+
{
22+
InitializeComponent();
23+
}
24+
25+
/// <summary>
26+
/// Handles click navigation on the hyperlink in the About dialog.
27+
/// </summary>
28+
/// <param name="sender">Object that sent the event.</param>
29+
/// <param name="e">Navigation events arguments.</param>
30+
private void hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
31+
{
32+
if (e.Uri != null && string.IsNullOrEmpty(e.Uri.OriginalString) == false)
33+
{
34+
string uri = e.Uri.AbsoluteUri;
35+
Process.Start(new ProcessStartInfo(uri));
36+
e.Handled = true;
37+
}
38+
}
39+
40+
#region AboutData Provider
41+
#region Member data
42+
private XmlDocument xmlDoc = null;
43+
44+
private const string propertyNameTitle = "Title";
45+
private const string propertyNameDescription = "Description";
46+
private const string propertyNameProduct = "Product";
47+
private const string propertyNameCopyright = "Copyright";
48+
private const string propertyNameCompany = "Company";
49+
private const string xPathRoot = "ApplicationInfo/";
50+
private const string xPathTitle = xPathRoot + propertyNameTitle;
51+
private const string xPathVersion = xPathRoot + "Version";
52+
private const string xPathDescription = xPathRoot + propertyNameDescription;
53+
private const string xPathProduct = xPathRoot + propertyNameProduct;
54+
private const string xPathCopyright = xPathRoot + propertyNameCopyright;
55+
private const string xPathCompany = xPathRoot + propertyNameCompany;
56+
private const string xPathLink = xPathRoot + "Link";
57+
private const string xPathLinkUri = xPathRoot + "Link/@Uri";
58+
#endregion
59+
60+
#region Properties
61+
/// <summary>
62+
/// Gets the title property, which is display in the About dialogs window title.
63+
/// </summary>
64+
public string ProductTitle
65+
{
66+
get
67+
{
68+
string result = CalculatePropertyValue<AssemblyTitleAttribute>(propertyNameTitle, xPathTitle);
69+
if (string.IsNullOrEmpty(result))
70+
{
71+
// otherwise, just get the name of the assembly itself.
72+
result = Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
73+
}
74+
return result;
75+
}
76+
}
77+
78+
/// <summary>
79+
/// Gets the application's version information to show.
80+
/// </summary>
81+
public string Version
82+
{
83+
get
84+
{
85+
string result = string.Empty;
86+
// first, try to get the version string from the assembly.
87+
Version version = Assembly.GetExecutingAssembly().GetName().Version;
88+
if (version != null)
89+
{
90+
result = version.ToString();
91+
}
92+
else
93+
{
94+
// if that fails, try to get the version from a resource in the Application.
95+
result = GetLogicalResourceString(xPathVersion);
96+
}
97+
return result;
98+
}
99+
}
100+
101+
/// <summary>
102+
/// Gets the description about the application.
103+
/// </summary>
104+
public string Description
105+
{
106+
get { return CalculatePropertyValue<AssemblyDescriptionAttribute>(propertyNameDescription, xPathDescription); }
107+
}
108+
109+
/// <summary>
110+
/// Gets the product's full name.
111+
/// </summary>
112+
public string Product
113+
{
114+
get { return CalculatePropertyValue<AssemblyProductAttribute>(propertyNameProduct, xPathProduct); }
115+
}
116+
117+
/// <summary>
118+
/// Gets the copyright information for the product.
119+
/// </summary>
120+
public string Copyright
121+
{
122+
get { return CalculatePropertyValue<AssemblyCopyrightAttribute>(propertyNameCopyright, xPathCopyright); }
123+
}
124+
125+
/// <summary>
126+
/// Gets the product's company name.
127+
/// </summary>
128+
public string Company
129+
{
130+
get { return CalculatePropertyValue<AssemblyCompanyAttribute>(propertyNameCompany, xPathCompany); }
131+
}
132+
133+
/// <summary>
134+
/// Gets the link text to display in the About dialog.
135+
/// </summary>
136+
public string LinkText
137+
{
138+
get { return GetLogicalResourceString(xPathLink); }
139+
}
140+
141+
/// <summary>
142+
/// Gets the link uri that is the navigation target of the link.
143+
/// </summary>
144+
public string LinkUri
145+
{
146+
get { return GetLogicalResourceString(xPathLinkUri); }
147+
}
148+
#endregion
149+
150+
#region Resource location methods
151+
/// <summary>
152+
/// Gets the specified property value either from a specific attribute, or from a resource dictionary.
153+
/// </summary>
154+
/// <typeparam name="T">Attribute type that we're trying to retrieve.</typeparam>
155+
/// <param name="propertyName">Property name to use on the attribute.</param>
156+
/// <param name="xpathQuery">XPath to the element in the XML data resource.</param>
157+
/// <returns>The resulting string to use for a property.
158+
/// Returns null if no data could be retrieved.</returns>
159+
private string CalculatePropertyValue<T>(string propertyName, string xpathQuery)
160+
{
161+
string result = string.Empty;
162+
// first, try to get the property value from an attribute.
163+
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(T), false);
164+
if (attributes.Length > 0)
165+
{
166+
T attrib = (T)attributes[0];
167+
PropertyInfo property = attrib.GetType().GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance);
168+
if (property != null)
169+
{
170+
result = property.GetValue(attributes[0], null) as string;
171+
}
172+
}
173+
174+
// if the attribute wasn't found or it did not have a value, then look in an xml resource.
175+
if (result == string.Empty)
176+
{
177+
// if that fails, try to get it from a resource.
178+
result = GetLogicalResourceString(xpathQuery);
179+
}
180+
return result;
181+
}
182+
183+
/// <summary>
184+
/// Gets the XmlDataProvider's document from the resource dictionary.
185+
/// </summary>
186+
protected virtual XmlDocument ResourceXmlDocument
187+
{
188+
get
189+
{
190+
if (xmlDoc == null)
191+
{
192+
// if we haven't already found the resource XmlDocument, then try to find it.
193+
XmlDataProvider provider = this.TryFindResource("aboutProvider") as XmlDataProvider;
194+
if (provider != null)
195+
{
196+
// save away the XmlDocument, so we don't have to get it multiple times.
197+
xmlDoc = provider.Document;
198+
}
199+
}
200+
return xmlDoc;
201+
}
202+
}
203+
204+
/// <summary>
205+
/// Gets the specified data element from the XmlDataProvider in the resource dictionary.
206+
/// </summary>
207+
/// <param name="xpathQuery">An XPath query to the XML element to retrieve.</param>
208+
/// <returns>The resulting string value for the specified XML element.
209+
/// Returns empty string if resource element couldn't be found.</returns>
210+
protected virtual string GetLogicalResourceString(string xpathQuery)
211+
{
212+
string result = string.Empty;
213+
// get the About xml information from the resources.
214+
XmlDocument doc = this.ResourceXmlDocument;
215+
if (doc != null)
216+
{
217+
// if we found the XmlDocument, then look for the specified data.
218+
XmlNode node = doc.SelectSingleNode(xpathQuery);
219+
if (node != null)
220+
{
221+
if (node is XmlAttribute)
222+
{
223+
// only an XmlAttribute has a Value set.
224+
result = node.Value;
225+
}
226+
else
227+
{
228+
// otherwise, need to just return the inner text.
229+
result = node.InnerText;
230+
}
231+
}
232+
}
233+
return result;
234+
}
235+
#endregion
236+
#endregion
237+
}
238+
}

0 commit comments

Comments
 (0)