Skip to content

Commit acb105d

Browse files
authored
Merge branch 'next' into Issue1788
2 parents 8d519b9 + 0bc0b21 commit acb105d

File tree

11 files changed

+250
-33
lines changed

11 files changed

+250
-33
lines changed
492 Bytes
Loading

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,7 @@
12311231
<Resource Include="Resources\flask_mask.png" />
12321232
<Resource Include="Resources\disk.png" />
12331233
<Resource Include="Resources\arrow-circle-left.png" />
1234+
<Resource Include="Resources\terminal.png" />
12341235
<Content Include="Resources\arrow_circle_double_mask.bmp" />
12351236
<Content Include="Resources\balloon_ellipsis.bmp" />
12361237
<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: 59 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,18 +115,28 @@ 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;
97129
EmailAddress = _config.EmailAddress;
98130
DefaultRepositoryLocation = _config.DefaultRepositoryLocation;
131+
CommandPromptLocation = _config.CommandPromptLocation;
99132
}
100133

101134
private void UpdateSettings()
102135
{
103136
_config.UserName = UserName;
104137
_config.EmailAddress = EmailAddress;
105138
_config.DefaultRepositoryLocation = DefaultRepositoryLocation;
139+
_config.CommandPromptLocation = CommandPromptLocation;
106140

107141
_configService.Save(_config);
108142

@@ -147,12 +181,21 @@ private void OpenFileInExternalEditor(GitSettingsFile fileType)
147181
Process.Start(filePath);
148182
}
149183

150-
private readonly ICommand _showFilePickerCommand;
151-
public ICommand ShowFilePickerCommand
184+
private readonly ICommand _showDefaultRepoFolderPickerCommand;
185+
public ICommand ShowDefaultRepoFolderPickerCommand
152186
{
153187
get
154188
{
155-
return _showFilePickerCommand;
189+
return _showDefaultRepoFolderPickerCommand;
190+
}
191+
}
192+
193+
private readonly ICommand _showCommandPromptExePickerCommand;
194+
public ICommand ShowCommandPromptExePickerCommand
195+
{
196+
get
197+
{
198+
return _showCommandPromptExePickerCommand;
156199
}
157200
}
158201

@@ -201,5 +244,13 @@ private void RaiseErrorEvent(string message, string innerMessage, NotificationTy
201244
handler(this, new ErrorEventArgs(message, innerMessage, notificationType));
202245
}
203246
}
247+
248+
public void Dispose()
249+
{
250+
if (_openFileDialog != null)
251+
{
252+
_openFileDialog.Dispose();
253+
}
254+
}
204255
}
205256
}

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}"

0 commit comments

Comments
 (0)