Skip to content

Commit 761b209

Browse files
committed
Close #104
1 parent 9b59f23 commit 761b209

File tree

11 files changed

+201
-32
lines changed

11 files changed

+201
-32
lines changed
492 Bytes
Loading

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,7 @@
12291229
<Resource Include="Resources\flask_mask.png" />
12301230
<Resource Include="Resources\disk.png" />
12311231
<Resource Include="Resources\arrow-circle-left.png" />
1232+
<Resource Include="Resources\terminal.png" />
12321233
<Content Include="Resources\arrow_circle_double_mask.bmp" />
12331234
<Content Include="Resources\balloon_ellipsis.bmp" />
12341235
<Content Include="Resources\balloon_mask.bmp" />

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Lines changed: 45 additions & 0 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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,4 +1632,19 @@ All our stargazers, likers &amp; followers, for the warm fuzzies
16321632
<data name="SourceControl_ExternalModifications" xml:space="preserve">
16331633
<value>A source file was modified out of the editor; should Rubberduck reload it?</value>
16341634
</data>
1635+
<data name="SourceControl_OpenCommandPromptButtonToolTip" xml:space="preserve">
1636+
<value>Open Command Prompt</value>
1637+
</data>
1638+
<data name="SourceControl_CommandPromptExeLabel" xml:space="preserve">
1639+
<value>Command Prompt Exe location</value>
1640+
</data>
1641+
<data name="SourceControl_FilePickerCommandPromptHeader" xml:space="preserve">
1642+
<value>Command Prompt Executable</value>
1643+
</data>
1644+
<data name="SourceControl_FilePickerDefaultRepoHeader" xml:space="preserve">
1645+
<value>Default Repository Directory</value>
1646+
</data>
1647+
<data name="SourceControl_OpenCommandPromptFailureTitle" xml:space="preserve">
1648+
<value>Failure opening command prompt</value>
1649+
</data>
16351650
</root>

RetailCoder.VBE/UI/SourceControl/SettingsView.xaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<TabItem x:Class="Rubberduck.UI.SourceControl.SettingsView"
1+
<UserControl x:Class="Rubberduck.UI.SourceControl.SettingsView"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:sourceControl="clr-namespace:Rubberduck.UI.SourceControl"
77
mc:Ignorable="d"
8-
Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControl_Settings}"
98
d:DesignHeight="300" d:DesignWidth="300"
109
d:DataContext="{d:DesignInstance {x:Type sourceControl:SettingsViewViewModel}, IsDesignTimeCreatable=False}">
11-
<TabItem.Resources>
12-
</TabItem.Resources>
10+
<!--
11+
Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControl_Settings}"
12+
-->
1313
<Grid>
1414
<ScrollViewer VerticalScrollBarVisibility="Auto">
1515
<StackPanel Margin="5"
@@ -38,7 +38,22 @@
3838
Margin="5,0"
3939
Grid.Column="1"
4040
FontSize="15"
41-
Command="{Binding ShowFilePickerCommand}" />
41+
Command="{Binding ShowDefaultRepoFolderPickerCommand}" />
42+
</Grid>
43+
<Label Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControl_CommandPromptExeLabel}" />
44+
<Grid>
45+
<Grid.ColumnDefinitions>
46+
<ColumnDefinition />
47+
<ColumnDefinition Width="40" />
48+
</Grid.ColumnDefinitions>
49+
<TextBox Margin="5,0,0,0"
50+
Padding="2"
51+
Text="{Binding CommandPromptLocation, Mode=TwoWay}" />
52+
<Button Content="&#8230;"
53+
Margin="5,0"
54+
Grid.Column="1"
55+
FontSize="15"
56+
Command="{Binding ShowCommandPromptExePickerCommand}" />
4257
</Grid>
4358
<WrapPanel Orientation="Horizontal"
4459
Margin="0,5">
@@ -96,4 +111,4 @@
96111
</StackPanel>
97112
</ScrollViewer>
98113
</Grid>
99-
</TabItem>
114+
</UserControl>

RetailCoder.VBE/UI/SourceControl/SettingsViewViewModel.cs

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,35 @@
88

99
namespace Rubberduck.UI.SourceControl
1010
{
11-
public class SettingsViewViewModel : ViewModelBase, IControlViewModel
11+
public class SettingsViewViewModel : ViewModelBase, IControlViewModel, IDisposable
1212
{
1313
private readonly ISourceControlConfigProvider _configService;
1414
private readonly IFolderBrowserFactory _folderBrowserFactory;
15+
private readonly IOpenFileDialog _openFileDialog;
1516
private readonly SourceControlSettings _config;
1617

1718
public SettingsViewViewModel(
1819
ISourceControlConfigProvider configService,
19-
IFolderBrowserFactory folderBrowserFactory)
20+
IFolderBrowserFactory folderBrowserFactory,
21+
IOpenFileDialog openFileDialog)
2022
{
2123
_configService = configService;
2224
_folderBrowserFactory = folderBrowserFactory;
2325
_config = _configService.Create();
2426

27+
_openFileDialog = openFileDialog;
28+
_openFileDialog.Filter = "Executables (*.exe)|*.exe|All files (*.*)|*.*";
29+
_openFileDialog.Multiselect = false;
30+
_openFileDialog.ReadOnlyChecked = true;
31+
_openFileDialog.CheckFileExists = true;
32+
2533
UserName = _config.UserName;
2634
EmailAddress = _config.EmailAddress;
2735
DefaultRepositoryLocation = _config.DefaultRepositoryLocation;
36+
CommandPromptLocation = _config.CommandPromptLocation;
2837

29-
_showFilePickerCommand = new DelegateCommand(_ => ShowFilePicker());
38+
_showDefaultRepoFolderPickerCommand = new DelegateCommand(_ => ShowDefaultRepoFolderPicker());
39+
_showCommandPromptExePickerCommand = new DelegateCommand(_ => ShowCommandPromptExePicker());
3040
_cancelSettingsChangesCommand = new DelegateCommand(_ => CancelSettingsChanges());
3141
_updateSettingsCommand = new DelegateCommand(_ => UpdateSettings());
3242
_showGitIgnoreCommand = new DelegateCommand(_ => ShowGitIgnore(), _ => Provider != null);
@@ -80,9 +90,23 @@ public string DefaultRepositoryLocation
8090
}
8191
}
8292

83-
private void ShowFilePicker()
93+
private string _commandPromptExeLocation;
94+
public string CommandPromptLocation
8495
{
85-
using (var folderPicker = _folderBrowserFactory.CreateFolderBrowser("Default Repository Directory"))
96+
get { return _commandPromptExeLocation; }
97+
set
98+
{
99+
if (_commandPromptExeLocation != value)
100+
{
101+
_commandPromptExeLocation = value;
102+
OnPropertyChanged();
103+
}
104+
}
105+
}
106+
107+
private void ShowDefaultRepoFolderPicker()
108+
{
109+
using (var folderPicker = _folderBrowserFactory.CreateFolderBrowser(RubberduckUI.SourceControl_FilePickerDefaultRepoHeader))
86110
{
87111
if (folderPicker.ShowDialog() == DialogResult.OK)
88112
{
@@ -91,6 +115,14 @@ private void ShowFilePicker()
91115
}
92116
}
93117

118+
private void ShowCommandPromptExePicker()
119+
{
120+
if (_openFileDialog.ShowDialog() == DialogResult.OK)
121+
{
122+
CommandPromptLocation = _openFileDialog.FileName;
123+
}
124+
}
125+
94126
private void CancelSettingsChanges()
95127
{
96128
UserName = _config.UserName;
@@ -103,6 +135,7 @@ private void UpdateSettings()
103135
_config.UserName = UserName;
104136
_config.EmailAddress = EmailAddress;
105137
_config.DefaultRepositoryLocation = DefaultRepositoryLocation;
138+
_config.CommandPromptLocation = CommandPromptLocation;
106139

107140
_configService.Save(_config);
108141

@@ -147,12 +180,21 @@ private void OpenFileInExternalEditor(GitSettingsFile fileType)
147180
Process.Start(filePath);
148181
}
149182

150-
private readonly ICommand _showFilePickerCommand;
151-
public ICommand ShowFilePickerCommand
183+
private readonly ICommand _showDefaultRepoFolderPickerCommand;
184+
public ICommand ShowDefaultRepoFolderPickerCommand
152185
{
153186
get
154187
{
155-
return _showFilePickerCommand;
188+
return _showDefaultRepoFolderPickerCommand;
189+
}
190+
}
191+
192+
private readonly ICommand _showCommandPromptExePickerCommand;
193+
public ICommand ShowCommandPromptExePickerCommand
194+
{
195+
get
196+
{
197+
return _showCommandPromptExePickerCommand;
156198
}
157199
}
158200

@@ -201,5 +243,13 @@ private void RaiseErrorEvent(string message, string innerMessage, NotificationTy
201243
handler(this, new ErrorEventArgs(message, innerMessage, notificationType));
202244
}
203245
}
246+
247+
public void Dispose()
248+
{
249+
if (_openFileDialog != null)
250+
{
251+
_openFileDialog.Dispose();
252+
}
253+
}
204254
}
205255
}

RetailCoder.VBE/UI/SourceControl/SourceControlView.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<BitmapImage x:Key="GitIcon" UriSource="../../Resources/icon-github.png" />
1919
<BitmapImage x:Key="ErrorImage" UriSource="../../Resources/cross-circle.png" />
2020
<BitmapImage x:Key="WarningIcon" UriSource="../../Resources/exclamation-white.png" />
21+
<BitmapImage x:Key="OpenCommandPromptImage" UriSource="../../Resources/Terminal.png" />
2122

2223
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
2324

@@ -255,6 +256,13 @@
255256
<Image Source="{StaticResource PublishRepoImage}" />
256257
</Button>
257258
<Separator />
259+
<Button ToolTip="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SourceControl_OpenCommandPromptButtonToolTip}"
260+
Command="{Binding OpenCommandPromptCommand, Mode=OneWay}"
261+
BorderThickness="0"
262+
Background="Transparent">
263+
<Image Source="{StaticResource OpenCommandPromptImage}" />
264+
</Button>
265+
<Separator />
258266
<StackPanel Orientation="Horizontal">
259267
<Image Source="{StaticResource GitIcon}" Height="25" />
260268
<TextBlock Text="{Binding Status}"

RetailCoder.VBE/UI/SourceControl/SourceControlViewViewModel.cs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Collections.ObjectModel;
4+
using System.Diagnostics;
45
using System.Drawing;
56
using System.Globalization;
67
using System.IO;
@@ -16,7 +17,6 @@
1617
using Rubberduck.UI.Command;
1718
using Rubberduck.UI.Command.MenuItems;
1819
using Rubberduck.VBEditor.VBEInterfaces.RubberduckCodePane;
19-
using resx = Rubberduck.UI.RubberduckUI;
2020

2121
namespace Rubberduck.UI.SourceControl
2222
{
@@ -35,13 +35,14 @@ public sealed class SourceControlViewViewModel : ViewModelBase, IDisposable
3535
private readonly ISourceControlProviderFactory _providerFactory;
3636
private readonly IFolderBrowserFactory _folderBrowserFactory;
3737
private readonly ISourceControlConfigProvider _configService;
38-
private readonly SourceControlSettings _config;
3938
private readonly ICodePaneWrapperFactory _wrapperFactory;
4039
private readonly IMessageBox _messageBox;
4140
private readonly FileSystemWatcher _fileSystemWatcher;
4241
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
4342
private static readonly IEnumerable<string> VbFileExtensions = new[] { "cls", "bas", "frm" };
4443

44+
private SourceControlSettings _config;
45+
4546
public SourceControlViewViewModel(
4647
VBE vbe,
4748
RubberduckParserState state,
@@ -83,6 +84,8 @@ public SourceControlViewViewModel(
8384
_publishRepoOkButtonCommand = new DelegateCommand(_ => PublishRepo(), _ => !IsNotValidPublishRemotePath);
8485
_publishRepoCancelButtonCommand = new DelegateCommand(_ => ClosePublishRepoGrid());
8586

87+
_openCommandPromptCommand = new DelegateCommand(_ => OpenCommandPrompt());
88+
8689
TabItems = new ObservableCollection<IControlView>
8790
{
8891
changesView,
@@ -165,8 +168,8 @@ public void HandleRenamedComponent(VBComponent component, string oldName)
165168
private static readonly IDictionary<NotificationType, BitmapImage> IconMappings =
166169
new Dictionary<NotificationType, BitmapImage>
167170
{
168-
{ NotificationType.Info, GetImageSource((Bitmap) resx.ResourceManager.GetObject("information", CultureInfo.InvariantCulture))},
169-
{ NotificationType.Error, GetImageSource((Bitmap) resx.ResourceManager.GetObject("cross_circle", CultureInfo.InvariantCulture))}
171+
{ NotificationType.Info, GetImageSource((Bitmap) RubberduckUI.ResourceManager.GetObject("information", CultureInfo.InvariantCulture))},
172+
{ NotificationType.Error, GetImageSource((Bitmap) RubberduckUI.ResourceManager.GetObject("cross_circle", CultureInfo.InvariantCulture))}
170173
};
171174

172175
private void _state_StateChanged(object sender, ParserStateEventArgs e)
@@ -543,6 +546,11 @@ private void ViewModel_ErrorThrown(object sender, ErrorEventArgs e)
543546

544547
DisplayErrorMessageGrid = true;
545548
}
549+
550+
if (e.InnerMessage == RubberduckUI.SourceControl_UpdateSettingsMessage)
551+
{
552+
_config = _configService.Create();
553+
}
546554
}
547555

548556
private void DismissErrorMessage()
@@ -725,6 +733,20 @@ private void ClosePublishRepoGrid()
725733
DisplayPublishRepoGrid = false;
726734
}
727735

736+
private void OpenCommandPrompt()
737+
{
738+
try
739+
{
740+
Process.Start(_config.CommandPromptLocation);
741+
}
742+
catch (Exception e)
743+
{
744+
ViewModel_ErrorThrown(this,
745+
new ErrorEventArgs(RubberduckUI.SourceControl_OpenCommandPromptFailureTitle, e.Message,
746+
NotificationType.Error));
747+
}
748+
}
749+
728750
private void OpenRepoAssignedToProject()
729751
{
730752
if (!ValidRepoExists())
@@ -877,6 +899,15 @@ public ICommand PublishRepoCancelButtonCommand
877899
}
878900
}
879901

902+
private readonly ICommand _openCommandPromptCommand;
903+
public ICommand OpenCommandPromptCommand
904+
{
905+
get
906+
{
907+
return _openCommandPromptCommand;
908+
}
909+
}
910+
880911
private readonly ICommand _dismissErrorMessageCommand;
881912
public ICommand DismissErrorMessageCommand
882913
{

0 commit comments

Comments
 (0)