Skip to content

Commit 5bb807c

Browse files
authored
Merge pull request #3541 from IvenBach/next
Version info copyable from about window
2 parents bed752c + 6cba3a3 commit 5bb807c

File tree

5 files changed

+95
-16
lines changed

5 files changed

+95
-16
lines changed

RetailCoder.VBE/App.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ public void LogRubberduckStart()
192192
GlobalDiagnosticsContext.Set("RubberduckVersion", version.ToString());
193193
var headers = new List<string>
194194
{
195-
string.Format("\r\n\tRubberduck version {0} loading:", version),
196-
string.Format("\tOperating System: {0} {1}", Environment.OSVersion.VersionString, Environment.Is64BitOperatingSystem ? "x64" : "x86"),
197-
string.Format("\tHost Product: {0} {1}", Application.ProductName, Environment.Is64BitProcess ? "x64" : "x86"),
198-
string.Format("\tHost Version: {0}", Application.ProductVersion),
199-
string.Format("\tHost Executable: {0}", Path.GetFileName(Application.ExecutablePath)),
195+
$"\r\n\tRubberduck version {version} loading:",
196+
$"\tOperating System: {Environment.OSVersion.VersionString} {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}",
197+
$"\tHost Product: {Application.ProductName} {(Environment.Is64BitProcess ? "x64" : "x86")}",
198+
$"\tHost Version: {Application.ProductVersion}",
199+
$"\tHost Executable: {Path.GetFileName(Application.ExecutablePath).ToUpper()}", // .ToUpper() used to convert ExceL.EXE -> EXCEL.EXE
200200
};
201201
LogLevelHelper.SetDebugInfo(string.Join(Environment.NewLine, headers));
202202
}

RetailCoder.VBE/UI/About/AboutControl.xaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
xmlns:about="clr-namespace:Rubberduck.UI.About"
77
mc:Ignorable="d"
88
d:DesignWidth="499"
9-
d:DataContext="{d:DesignInstance {x:Type about:AboutControlViewModel}, IsDesignTimeCreatable=False}">
9+
d:DataContext="{d:DesignInstance {x:Type about:AboutControlViewModel}, IsDesignTimeCreatable=False}"
10+
KeyDown="OnKeyDownHandler">
1011
<UserControl.Resources>
1112
<BitmapImage x:Key="Ducky" UriSource="../../Resources/AboutBanner.png" />
1213
<BitmapImage x:Key="RD" UriSource="../../Resources/Rubberduck.png" />
@@ -22,10 +23,19 @@
2223
<RowDefinition Height="64" />
2324
</Grid.RowDefinitions>
2425

25-
<Border Grid.Column="0" Grid.Row="0" Background="White" Margin="5,5,0,0">
26-
<TextBlock Margin="5,10,5,10" Text="{Binding Version}" Foreground="Black"
27-
FontWeight="Bold" FontSize="14"
28-
VerticalAlignment="Top" HorizontalAlignment="Left" />
26+
<Border Grid.Column="0" Grid.Row="0" Background="White" Margin="5,5,0,0"
27+
MouseLeftButtonDown="CopyVersionInfo_MouseLeftButtonDown">
28+
<StackPanel>
29+
<TextBlock x:Name="Version"
30+
Margin="5,10,5,0" Text="{Binding Version}" Foreground="Black"
31+
FontWeight="Bold" FontSize="14"
32+
VerticalAlignment="Center" HorizontalAlignment="Center"/>
33+
<Label Name="CopyVersionInfo"
34+
Foreground="Gray"
35+
FontSize="8"
36+
HorizontalAlignment="Center"
37+
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=AboutWindow_CopyVersionLabel}"/>
38+
</StackPanel>
2939
</Border>
3040

3141
<Border Grid.Column="1" Grid.Row="0" Background="White" Margin="0,5,5,0">

RetailCoder.VBE/UI/About/AboutControl.xaml.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
namespace Rubberduck.UI.About
1+
using System.Windows;
2+
using System.Windows.Input;
3+
using System;
4+
using System.IO;
5+
using Application = System.Windows.Forms.Application;
6+
7+
namespace Rubberduck.UI.About
28
{
39
/// <summary>
410
/// Interaction logic for AboutControl.xaml
@@ -9,5 +15,32 @@ public AboutControl()
915
{
1016
InitializeComponent();
1117
}
18+
19+
private void OnKeyDownHandler(object sender, KeyEventArgs e)
20+
{
21+
bool isControlCPressed = (Keyboard.IsKeyDown(Key.C) && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)));
22+
if (isControlCPressed)
23+
{
24+
CopyVersionInfoToClipboard();
25+
}
26+
}
27+
28+
private void CopyVersionInfo_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
29+
{
30+
CopyVersionInfoToClipboard();
31+
}
32+
33+
private void CopyVersionInfoToClipboard()
34+
{
35+
var sb = new System.Text.StringBuilder();
36+
sb.AppendLine($"Rubberduck version: {this.Version.Text}");
37+
sb.AppendLine($"Operating System: {Environment.OSVersion.VersionString}, {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}");
38+
sb.AppendLine($"Host Product: {Application.ProductName} {(Environment.Is64BitProcess ? "x64" : "x86")}");
39+
sb.AppendLine($"Host Version: {Application.ProductVersion}");
40+
sb.AppendFormat($"Host Executable: {Path.GetFileName(Application.ExecutablePath).ToUpper()}"); // .ToUpper() used to convert ExceL.EXE -> EXCEL.EXE
41+
42+
Clipboard.SetText(sb.ToString());
43+
System.Windows.MessageBox.Show(RubberduckUI.AboutWindow_CopyVersionMessage, RubberduckUI.AboutWindow_CopyVersionCaption);
44+
}
1245
}
1346
}

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -59,7 +59,7 @@
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
62-
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
6363
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6464
<xsd:element name="root" msdata:IsDataSet="true">
6565
<xsd:complexType>
@@ -2122,4 +2122,13 @@ Would you like to import them to Rubberduck?</value>
21222122
<data name="ToDoExplorer_CopyToolTip" xml:space="preserve">
21232123
<value>Copy to clipboard</value>
21242124
</data>
2125-
</root>
2125+
<data name="AboutWindow_CopyVersionCaption" xml:space="preserve">
2126+
<value>Copy successful</value>
2127+
</data>
2128+
<data name="AboutWindow_CopyVersionLabel" xml:space="preserve">
2129+
<value>Click here to copy version info to clipboard.</value>
2130+
</data>
2131+
<data name="AboutWindow_CopyVersionMessage" xml:space="preserve">
2132+
<value>Version information copied to clipboard.</value>
2133+
</data>
2134+
</root>

0 commit comments

Comments
 (0)