Skip to content

Commit

Permalink
Merge pull request #3541 from IvenBach/next
Browse files Browse the repository at this point in the history
Version info copyable from about window
  • Loading branch information
Vogel612 committed Nov 21, 2017
2 parents bed752c + 6cba3a3 commit 5bb807c
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 16 deletions.
10 changes: 5 additions & 5 deletions RetailCoder.VBE/App.cs
Expand Up @@ -192,11 +192,11 @@ public void LogRubberduckStart()
GlobalDiagnosticsContext.Set("RubberduckVersion", version.ToString());
var headers = new List<string>
{
string.Format("\r\n\tRubberduck version {0} loading:", version),
string.Format("\tOperating System: {0} {1}", Environment.OSVersion.VersionString, Environment.Is64BitOperatingSystem ? "x64" : "x86"),
string.Format("\tHost Product: {0} {1}", Application.ProductName, Environment.Is64BitProcess ? "x64" : "x86"),
string.Format("\tHost Version: {0}", Application.ProductVersion),
string.Format("\tHost Executable: {0}", Path.GetFileName(Application.ExecutablePath)),
$"\r\n\tRubberduck version {version} loading:",
$"\tOperating System: {Environment.OSVersion.VersionString} {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}",
$"\tHost Product: {Application.ProductName} {(Environment.Is64BitProcess ? "x64" : "x86")}",
$"\tHost Version: {Application.ProductVersion}",
$"\tHost Executable: {Path.GetFileName(Application.ExecutablePath).ToUpper()}", // .ToUpper() used to convert ExceL.EXE -> EXCEL.EXE
};
LogLevelHelper.SetDebugInfo(string.Join(Environment.NewLine, headers));
}
Expand Down
20 changes: 15 additions & 5 deletions RetailCoder.VBE/UI/About/AboutControl.xaml
Expand Up @@ -6,7 +6,8 @@
xmlns:about="clr-namespace:Rubberduck.UI.About"
mc:Ignorable="d"
d:DesignWidth="499"
d:DataContext="{d:DesignInstance {x:Type about:AboutControlViewModel}, IsDesignTimeCreatable=False}">
d:DataContext="{d:DesignInstance {x:Type about:AboutControlViewModel}, IsDesignTimeCreatable=False}"
KeyDown="OnKeyDownHandler">
<UserControl.Resources>
<BitmapImage x:Key="Ducky" UriSource="../../Resources/AboutBanner.png" />
<BitmapImage x:Key="RD" UriSource="../../Resources/Rubberduck.png" />
Expand All @@ -22,10 +23,19 @@
<RowDefinition Height="64" />
</Grid.RowDefinitions>

<Border Grid.Column="0" Grid.Row="0" Background="White" Margin="5,5,0,0">
<TextBlock Margin="5,10,5,10" Text="{Binding Version}" Foreground="Black"
FontWeight="Bold" FontSize="14"
VerticalAlignment="Top" HorizontalAlignment="Left" />
<Border Grid.Column="0" Grid.Row="0" Background="White" Margin="5,5,0,0"
MouseLeftButtonDown="CopyVersionInfo_MouseLeftButtonDown">
<StackPanel>
<TextBlock x:Name="Version"
Margin="5,10,5,0" Text="{Binding Version}" Foreground="Black"
FontWeight="Bold" FontSize="14"
VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Label Name="CopyVersionInfo"
Foreground="Gray"
FontSize="8"
HorizontalAlignment="Center"
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=AboutWindow_CopyVersionLabel}"/>
</StackPanel>
</Border>

<Border Grid.Column="1" Grid.Row="0" Background="White" Margin="0,5,5,0">
Expand Down
35 changes: 34 additions & 1 deletion RetailCoder.VBE/UI/About/AboutControl.xaml.cs
@@ -1,4 +1,10 @@
namespace Rubberduck.UI.About
using System.Windows;
using System.Windows.Input;
using System;
using System.IO;
using Application = System.Windows.Forms.Application;

namespace Rubberduck.UI.About
{
/// <summary>
/// Interaction logic for AboutControl.xaml
Expand All @@ -9,5 +15,32 @@ public AboutControl()
{
InitializeComponent();
}

private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
bool isControlCPressed = (Keyboard.IsKeyDown(Key.C) && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)));
if (isControlCPressed)
{
CopyVersionInfoToClipboard();
}
}

private void CopyVersionInfo_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
CopyVersionInfoToClipboard();
}

private void CopyVersionInfoToClipboard()
{
var sb = new System.Text.StringBuilder();
sb.AppendLine($"Rubberduck version: {this.Version.Text}");
sb.AppendLine($"Operating System: {Environment.OSVersion.VersionString}, {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}");
sb.AppendLine($"Host Product: {Application.ProductName} {(Environment.Is64BitProcess ? "x64" : "x86")}");
sb.AppendLine($"Host Version: {Application.ProductVersion}");
sb.AppendFormat($"Host Executable: {Path.GetFileName(Application.ExecutablePath).ToUpper()}"); // .ToUpper() used to convert ExceL.EXE -> EXCEL.EXE

Clipboard.SetText(sb.ToString());
System.Windows.MessageBox.Show(RubberduckUI.AboutWindow_CopyVersionMessage, RubberduckUI.AboutWindow_CopyVersionCaption);
}
}
}
31 changes: 29 additions & 2 deletions RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions RetailCoder.VBE/UI/RubberduckUI.resx
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -59,7 +59,7 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
Expand Down Expand Up @@ -2122,4 +2122,13 @@ Would you like to import them to Rubberduck?</value>
<data name="ToDoExplorer_CopyToolTip" xml:space="preserve">
<value>Copy to clipboard</value>
</data>
</root>
<data name="AboutWindow_CopyVersionCaption" xml:space="preserve">
<value>Copy successful</value>
</data>
<data name="AboutWindow_CopyVersionLabel" xml:space="preserve">
<value>Click here to copy version info to clipboard.</value>
</data>
<data name="AboutWindow_CopyVersionMessage" xml:space="preserve">
<value>Version information copied to clipboard.</value>
</data>
</root>

0 comments on commit 5bb807c

Please sign in to comment.