Skip to content

Commit e67b182

Browse files
authored
Merge pull request #3544 from IvenBach/2946_Toolstrip_Backing
UI Tweaks
2 parents 5bb807c + 24a2bb6 commit e67b182

27 files changed

+168
-211
lines changed

RetailCoder.VBE/UI/About/AboutControlViewModel.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ public AboutControlViewModel(IVersionCheck version)
1616
_version = version;
1717
}
1818

19-
public string Version
20-
{
21-
get
22-
{
23-
return string.Format(RubberduckUI.Rubberduck_AboutBuild, _version.CurrentVersion);
24-
}
25-
}
19+
public string Version => string.Format(RubberduckUI.Rubberduck_AboutBuild, _version.CurrentVersion);
2620

2721
private CommandBase _uriCommand;
2822
public CommandBase UriCommand

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public CodeExplorerControl()
1515
InitializeComponent();
1616
}
1717

18-
private CodeExplorerViewModel ViewModel { get { return DataContext as CodeExplorerViewModel; } }
18+
private CodeExplorerViewModel ViewModel => DataContext as CodeExplorerViewModel;
1919

2020
private void TreeView_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
2121
{

RetailCoder.VBE/UI/CodeExplorer/Commands/AddComponentCommand.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,17 @@ private Declaration GetDeclaration(CodeExplorerItemViewModel node)
5252

5353
private string GetFolder(CodeExplorerItemViewModel node)
5454
{
55-
if (node == null)
55+
switch (node)
5656
{
57-
return DefaultFolder;
57+
case null:
58+
return DefaultFolder;
59+
case ICodeExplorerDeclarationViewModel declarationNode:
60+
return string.IsNullOrEmpty(declarationNode.Declaration.CustomFolder)
61+
? DefaultFolder
62+
: declarationNode.Declaration.CustomFolder.Replace("\"", string.Empty);
63+
default:
64+
return ((CodeExplorerCustomFolderViewModel)node).FullPath;
5865
}
59-
60-
var declarationNode = node as ICodeExplorerDeclarationViewModel;
61-
if (declarationNode != null)
62-
{
63-
return string.IsNullOrEmpty(declarationNode.Declaration.CustomFolder)
64-
? DefaultFolder
65-
: declarationNode.Declaration.CustomFolder.Replace("\"", string.Empty);
66-
}
67-
68-
return ((CodeExplorerCustomFolderViewModel)node).FullPath;
6966
}
7067
}
7168
}

RetailCoder.VBE/UI/Controls/BindableSelectedItemBehavior.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class BindableSelectedItemBehavior : Behavior<TreeView>
1111
{
1212
public object SelectedItem
1313
{
14-
get { return (object) GetValue(SelectedItemProperty); }
15-
set { SetValue(SelectedItemProperty, value); }
14+
get => (object) GetValue(SelectedItemProperty);
15+
set => SetValue(SelectedItemProperty, value);
1616
}
1717

1818
public static readonly DependencyProperty SelectedItemProperty =
@@ -21,8 +21,7 @@ public object SelectedItem
2121

2222
private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
2323
{
24-
var item = e.NewValue as TreeViewItem;
25-
if (item != null)
24+
if (e.NewValue is TreeViewItem item)
2625
{
2726
item.SetValue(TreeViewItem.IsSelectedProperty, true);
2827
}

RetailCoder.VBE/UI/Controls/BindableTextEditor.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public BindableTextEditor()
3131

3232
public new string Text
3333
{
34-
get { return base.Text; }
35-
set { base.Text = value; }
34+
get => base.Text;
35+
set => base.Text = value;
3636
}
3737

3838
public static readonly DependencyProperty TextProperty =
@@ -50,10 +50,7 @@ protected override void OnTextChanged(EventArgs e)
5050

5151
public void RaisePropertyChanged(string property)
5252
{
53-
if (PropertyChanged != null)
54-
{
55-
PropertyChanged(this, new PropertyChangedEventArgs(property));
56-
}
53+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
5754
}
5855

5956
public event PropertyChangedEventHandler PropertyChanged;

RetailCoder.VBE/UI/Controls/DeclarationTypeToStringConverter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ public class DeclarationTypeToStringConverter : IValueConverter
99
{
1010
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1111
{
12-
if (value is DeclarationType)
12+
if (value is DeclarationType type)
1313
{
14-
var type = (DeclarationType)value;
1514
var text = RubberduckUI.ResourceManager.GetString("DeclarationType_" + type, CultureInfo.CurrentUICulture) ?? string.Empty;
1615
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text);
1716
}

RetailCoder.VBE/UI/Controls/EmptyUIRefresh.xaml.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.Windows;
7-
using System.Windows.Controls;
8-
using System.Windows.Data;
9-
using System.Windows.Documents;
10-
using System.Windows.Input;
11-
using System.Windows.Media;
12-
using System.Windows.Media.Imaging;
13-
using System.Windows.Navigation;
14-
using System.Windows.Shapes;
1+
using System.Windows.Controls;
152

163
namespace Rubberduck.UI.Controls
174
{

RetailCoder.VBE/UI/Controls/GroupingGrid.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public partial class GroupingGrid
1010

1111
public bool ShowGroupingItemCount
1212
{
13-
get { return (bool) GetValue(ShowGroupingItemCountProperty); }
14-
set { SetValue(ShowGroupingItemCountProperty, value); }
13+
get => (bool) GetValue(ShowGroupingItemCountProperty);
14+
set => SetValue(ShowGroupingItemCountProperty, value);
1515
}
1616

1717
public GroupingGrid()
@@ -21,11 +21,11 @@ public GroupingGrid()
2121

2222
private void GroupingGridItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2323
{
24-
var context = DataContext as INavigateSelection;
25-
if (context == null)
24+
if (!(DataContext is INavigateSelection context))
2625
{
2726
return;
2827
}
28+
2929
var selection = context.SelectedItem;
3030
if (selection != null)
3131
{

RetailCoder.VBE/UI/Controls/MenuItemGroup.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ public static string GetGroupName(MenuItem element)
3030
private static void OnGroupNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
3131
{
3232
//Add an entry to the group name collection
33-
var menuItem = d as MenuItem;
3433

35-
if (menuItem != null)
34+
if (d is MenuItem menuItem)
3635
{
3736
var newGroupName = e.NewValue.ToString();
3837
var oldGroupName = e.OldValue.ToString();
@@ -44,16 +43,18 @@ private static void OnGroupNameChanged(DependencyObject d, DependencyPropertyCha
4443
else
4544
{
4645
//Switching to a new group
47-
if (newGroupName != oldGroupName)
46+
if (newGroupName == oldGroupName)
4847
{
49-
if (!string.IsNullOrEmpty(oldGroupName))
50-
{
51-
//Remove the old group mapping
52-
RemoveCheckboxFromGrouping(menuItem);
53-
}
54-
ElementToGroupNames.Add(menuItem, e.NewValue.ToString());
55-
menuItem.Checked += MenuItemChecked;
48+
return;
5649
}
50+
51+
if (!string.IsNullOrEmpty(oldGroupName))
52+
{
53+
//Remove the old group mapping
54+
RemoveCheckboxFromGrouping(menuItem);
55+
}
56+
ElementToGroupNames.Add(menuItem, e.NewValue.ToString());
57+
menuItem.Checked += MenuItemChecked;
5758
}
5859
}
5960
}
@@ -65,7 +66,7 @@ private static void RemoveCheckboxFromGrouping(MenuItem checkBox)
6566
}
6667

6768

68-
static void MenuItemChecked(object sender, RoutedEventArgs e)
69+
private static void MenuItemChecked(object sender, RoutedEventArgs e)
6970
{
7071
var menuItem = e.OriginalSource as MenuItem;
7172
foreach (var item in ElementToGroupNames)

RetailCoder.VBE/UI/Controls/NumberPicker.xaml.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,17 @@ public partial class NumberPicker : IDataErrorInfo
1414

1515
public int NumValue
1616
{
17-
get
18-
{
19-
return (int)GetValue(NumValueProperty);
20-
}
17+
get => (int)GetValue(NumValueProperty);
2118
set
2219
{
2320
SetValue(NumValueProperty, value);
2421
OnPropertyChanged(new DependencyPropertyChangedEventArgs(NumValueProperty, NumValue - 1, NumValue));
2522
}
2623
}
2724

28-
private int _minNumber = int.MinValue;
29-
public int MinNumber
30-
{
31-
get { return _minNumber; }
32-
set { _minNumber = value; }
33-
}
25+
public int MinNumber { get; set; } = int.MinValue;
3426

35-
private int _maxNumber = int.MaxValue;
36-
public int MaxNumber
37-
{
38-
get { return _maxNumber; }
39-
set { _maxNumber = value; }
40-
}
27+
public int MaxNumber { get; set; } = int.MaxValue;
4128

4229
public NumberPicker()
4330
{

0 commit comments

Comments
 (0)