Skip to content

Commit b6a7469

Browse files
authored
Merge branch 'next' into booleanAssignment
2 parents 0d46064 + 2752460 commit b6a7469

File tree

16 files changed

+397
-85
lines changed

16 files changed

+397
-85
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Branch | Description | Build Status |
1616
[nextBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/next?svg=true
1717
[masterBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/master?svg=true
1818

19-
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/rubberduck-vba/rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/rubberduck "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/rubberduck-vba/rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/rubberduck "Percentage of issues still open")
19+
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/rubberduck-vba/Rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/Rubberduck "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/rubberduck-vba/Rubberduck.svg)](http://isitmaintained.com/project/rubberduck-vba/Rubberduck "Percentage of issues still open")
2020

2121
> **[rubberduckvba.com](http://rubberduckvba.com)** [Wiki](https://github.com/retailcoder/Rubberduck/wiki) [Rubberduck News](https://rubberduckvba.wordpress.com/)
2222
> contact@rubberduckvba.com

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 28 additions & 21 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.CodeAnalysis;
45
using System.Globalization;
56
using System.Linq;
67
using NLog;
@@ -21,6 +22,7 @@
2122
using System.Windows;
2223

2324
// ReSharper disable CanBeReplacedWithTryCastAndCheckForNull
25+
// ReSharper disable ExplicitCallerInfoArgument
2426

2527
namespace Rubberduck.Navigation.CodeExplorer
2628
{
@@ -99,54 +101,45 @@ public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState st
99101

100102
SetNameSortCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
101103
{
102-
if ((bool)param == true)
104+
if ((bool)param)
103105
{
104106
SortByName = (bool)param;
105107
SortByCodeOrder = !(bool)param;
106108
}
107-
}, param =>
108-
{
109-
return SortByName ? false : true;
110-
});
109+
}, param => !SortByName);
111110

112111
SetCodeOrderSortCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
113112
{
114-
if ((bool)param == true)
113+
if ((bool)param)
115114
{
116115
SortByCodeOrder = (bool)param;
117116
SortByName = !(bool)param;
118-
};
119-
}, param =>
120-
{
121-
return SortByCodeOrder ? false : true;
122-
});
117+
}
118+
}, param => !SortByCodeOrder);
123119
}
124120

125121
private CodeExplorerItemViewModel _selectedItem;
126122
public CodeExplorerItemViewModel SelectedItem
127123
{
128-
get { return _selectedItem; }
124+
get => _selectedItem;
129125
set
130126
{
131127
_selectedItem = value;
132128
OnPropertyChanged();
133129

134-
// ReSharper disable ExplicitCallerInfoArgument
135130
OnPropertyChanged("CanExecuteIndenterCommand");
136131
OnPropertyChanged("CanExecuteRenameCommand");
137132
OnPropertyChanged("CanExecuteFindAllReferencesCommand");
138133
OnPropertyChanged("ExportVisibility");
139134
OnPropertyChanged("ExportAllVisibility");
140135
OnPropertyChanged("PanelTitle");
141136
OnPropertyChanged("Description");
142-
143-
// ReSharper restore ExplicitCallerInfoArgument
144137
}
145138
}
146139

147140
public bool SortByName
148141
{
149-
get { return _windowSettings.CodeExplorer_SortByName; }
142+
get => _windowSettings.CodeExplorer_SortByName;
150143
set
151144
{
152145
if (_windowSettings.CodeExplorer_SortByName == value)
@@ -166,7 +159,7 @@ public bool SortByName
166159

167160
public bool SortByCodeOrder
168161
{
169-
get { return _windowSettings.CodeExplorer_SortByCodeOrder; }
162+
get => _windowSettings.CodeExplorer_SortByCodeOrder;
170163
set
171164
{
172165
if (_windowSettings.CodeExplorer_SortByCodeOrder == value)
@@ -192,7 +185,7 @@ public bool SortByCodeOrder
192185

193186
public bool GroupByType
194187
{
195-
get { return _windowSettings.CodeExplorer_GroupByType; }
188+
get => _windowSettings.CodeExplorer_GroupByType;
196189
set
197190
{
198191
if (_windowSettings.CodeExplorer_GroupByType != value)
@@ -207,10 +200,22 @@ public bool GroupByType
207200
}
208201
}
209202

203+
private bool _canSearch;
204+
205+
public bool CanSearch
206+
{
207+
get => _canSearch;
208+
set
209+
{
210+
_canSearch = value;
211+
OnPropertyChanged();
212+
}
213+
}
214+
210215
private bool _isBusy;
211216
public bool IsBusy
212217
{
213-
get { return _isBusy; }
218+
get => _isBusy;
214219
set
215220
{
216221
_isBusy = value;
@@ -277,15 +282,17 @@ public string Description
277282
private ObservableCollection<CodeExplorerItemViewModel> _projects;
278283
public ObservableCollection<CodeExplorerItemViewModel> Projects
279284
{
280-
get { return _projects; }
285+
get => _projects;
281286
set
282287
{
283288
ReorderChildNodes(value);
284289
_projects = new ObservableCollection<CodeExplorerItemViewModel>(value.OrderBy(o => o.NameWithSignature));
285-
290+
CanSearch = _projects.Any();
291+
286292
OnPropertyChanged();
287293
// Once a Project has been set, show the TreeView
288294
OnPropertyChanged("TreeViewVisibility");
295+
OnPropertyChanged("CanSearch");
289296
}
290297
}
291298

RetailCoder.VBE/ToDoItems/ToDoItem.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Rubberduck.Parsing.Symbols;
1+
using Rubberduck.Common;
2+
using Rubberduck.Parsing.Symbols;
23
using Rubberduck.UI;
34
using Rubberduck.UI.Controls;
45
using Rubberduck.VBEditor;
@@ -9,7 +10,7 @@ namespace Rubberduck.ToDoItems
910
/// Represents a Todo comment and the necessary information to display and navigate to that comment.
1011
/// This is a binding item. Changing it's properties changes how it is displayed.
1112
/// </summary>
12-
public class ToDoItem : INavigateSource
13+
public class ToDoItem : INavigateSource, IExportable
1314
{
1415
private readonly string _description;
1516
public string Description { get { return _description; } }
@@ -31,5 +32,23 @@ public NavigateCodeEventArgs GetNavigationArgs()
3132
{
3233
return new NavigateCodeEventArgs(_selection);
3334
}
35+
36+
public object[] ToArray()
37+
{
38+
var module = _selection.QualifiedName;
39+
return new object[] { _type, Description, module.ProjectName, module.ComponentName, _selection.Selection.StartLine, _selection.Selection.StartColumn };
40+
}
41+
42+
public string ToClipboardString()
43+
{
44+
var module = _selection.QualifiedName;
45+
return string.Format(
46+
RubberduckUI.ToDoExplorerToDoItemFormat,
47+
_type,
48+
_description,
49+
module.ProjectName,
50+
module.ComponentName,
51+
_selection.Selection.StartLine);
52+
}
3453
}
3554
}

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@
291291

292292
<Style x:Key="XButtonStyle" TargetType="Button">
293293
<Setter Property="Background" Value="Transparent"/>
294+
<Setter Property="Content" Value=""/>
294295
<Setter Property="BorderThickness" Value="0"/>
295296
<Setter Property="HorizontalContentAlignment" Value="Center"/>
296297
<Setter Property="VerticalContentAlignment" Value="Center"/>
@@ -490,10 +491,32 @@
490491
</ToolBar>
491492
</ToolBarTray>
492493

493-
<TextBox Grid.Row="1" TextChanged="SearchBox_OnTextChanged" VerticalContentAlignment="Center" Name="SearchBox"></TextBox>
494-
<Image Grid.Row="1" Source="{StaticResource SearchImage}" HorizontalAlignment="Right" VerticalAlignment="Center" MaxHeight="16" Margin="0,0,1,0" MouseDown="SearchIcon_OnMouseDown" Visibility="{Binding ElementName=SearchBox, Path=Text.Length, Converter={StaticResource StringHasValueToVisibility}}" />
495-
<Button Grid.Row="1" Style="{StaticResource XButtonStyle}" HorizontalAlignment="Right" VerticalAlignment="Center" Height="18" Width="18" Margin="0,1,1,0" Visibility="{Binding ElementName=SearchBox, Path=Text.Length, Converter={StaticResource StringHasNoValueToVisibility}}" Click="ButtonBase_OnClick">✕</Button>
494+
<Border Grid.Row="1"
495+
BorderBrush="{StaticResource {x:Static SystemColors.ControlBrushKey}}"
496+
BorderThickness="1">
497+
<Grid>
498+
<TextBox x:Name="SearchBox"
499+
VerticalContentAlignment="Center"
500+
IsEnabled="{Binding CanSearch}"
501+
MinHeight="20"
502+
PreviewKeyDown="SearchBox_OnPreviewKeyDown"
503+
TextChanged="SearchBox_OnTextChanged" />
496504

505+
<Image Source="{StaticResource SearchImage}"
506+
HorizontalAlignment="Right" VerticalAlignment="Center"
507+
MaxHeight="16" Margin="0,0,1,0"
508+
IsEnabled="{Binding CanSearch}"
509+
Visibility="{Binding ElementName=SearchBox, Path=Text.Length, Converter={StaticResource StringHasValueToVisibility}}"
510+
MouseDown="SearchIcon_OnMouseDown" />
511+
512+
<Button Style="{StaticResource XButtonStyle}"
513+
HorizontalAlignment="Right" VerticalAlignment="Center"
514+
Height="18" Width="18" Margin="0,1,1,0"
515+
IsEnabled="{Binding CanSearch}"
516+
Visibility="{Binding ElementName=SearchBox, Path=Text.Length, Converter={StaticResource StringHasNoValueToVisibility}}"
517+
Click="ButtonBase_OnClick" />
518+
</Grid>
519+
</Border>
497520
<controls:EmptyUIRefresh Grid.Row="2" />
498521

499522
<TreeView x:Name="ProjectTree"

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,22 @@ private void SearchIcon_OnMouseDown(object sender, MouseButtonEventArgs e)
4343
}
4444

4545
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
46+
{
47+
ClearSearchBox();
48+
}
49+
50+
private void ClearSearchBox()
4651
{
4752
SearchBox.Text = string.Empty;
4853
SearchBox.Focus();
4954
}
55+
56+
private void SearchBox_OnPreviewKeyDown(object sender, KeyEventArgs e)
57+
{
58+
if (e.Key == Key.Escape)
59+
{
60+
ClearSearchBox();
61+
}
62+
}
5063
}
5164
}

RetailCoder.VBE/UI/Command/MenuItems/CodeExplorerCommandMenuItem.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Rubberduck.Parsing.VBA;
12
using Rubberduck.UI.Command.MenuItems.ParentMenus;
23

34
namespace Rubberduck.UI.Command.MenuItems
@@ -9,6 +10,8 @@ public CodeExplorerCommandMenuItem(CommandBase command)
910
{
1011
}
1112

13+
public override bool EvaluateCanExecute(RubberduckParserState state) => true;
14+
1215
public override string Key => "RubberduckMenu_CodeExplorer";
1316
public override int DisplayOrder => (int)NavigationMenuItemDisplayOrder.CodeExplorer;
1417
}

RetailCoder.VBE/UI/Command/MenuItems/CommandMenuItemBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public virtual Func<string> ToolTipText
4747
/// <remarks>Returns <c>true</c> if not overridden.</remarks>
4848
public virtual bool EvaluateCanExecute(RubberduckParserState state)
4949
{
50-
return state != null && _command.CanExecute(state);
50+
return state != null && (_command?.CanExecute(state) ?? false);
5151
}
5252

5353
public virtual ButtonStyle ButtonStyle => ButtonStyle.IconAndCaption;

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

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

RetailCoder.VBE/UI/RubberduckUI.de.resx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,4 +2050,18 @@ Möchten sie die Einstellungen in Rubberduck importieren?</value>
20502050
<data name="RubberduckMenu_Refresh">
20512051
<value>Aktualisieren</value>
20522052
</data>
2053+
<data name="ToDoExplorer_CopyToolTip">
2054+
<value>In die Zwischenablage kopieren</value>
2055+
</data>
2056+
<data name="ToDoExplorer_NumberOfIssuesFound_Plural">
2057+
<value>Rubberduck TODO Markierungen - {0}
2058+
{1} Markierungen gefunden.</value>
2059+
</data>
2060+
<data name="ToDoExplorerToDoItemFormat">
2061+
<value>{0}: {1} - {2}.{3} Zeile {4}.</value>
2062+
</data>
2063+
<data name="ToDoExplorer_NumberOfIssuesFound_Singular">
2064+
<value>Rubberduck TODO Markierungen - {0}
2065+
{1} Markierungen gefunden.</value>
2066+
</data>
20532067
</root>

RetailCoder.VBE/UI/RubberduckUI.fr.resx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,4 +2053,18 @@ les projets dans le VBE.</value>
20532053
<data name="Preview">
20542054
<value>Aperçu</value>
20552055
</data>
2056+
<data name="ToDoExplorer_CopyToolTip">
2057+
<value>Copier dans le presse-papier</value>
2058+
</data>
2059+
<data name="ToDoExplorer_NumberOfIssuesFound_Plural">
2060+
<value>Rubberduck - {0}
2061+
{1} marqueurs TODO trouvés.</value>
2062+
</data>
2063+
<data name="ToDoExplorerToDoItemFormat">
2064+
<value>{0}: {1} - {2}.{3} ligne {4}.</value>
2065+
</data>
2066+
<data name="ToDoExplorer_NumberOfIssuesFound_Singular">
2067+
<value>Rubberduck marqueurs TODO - {0}
2068+
{1} marqueurs trouvés.</value>
2069+
</data>
20562070
</root>

0 commit comments

Comments
 (0)