Skip to content

Commit 5b09c23

Browse files
committed
Add converter and use it
1 parent 00922e1 commit 5b09c23

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Data;
8+
using Rubberduck.UI.Refactorings;
9+
10+
namespace Rubberduck.UI.Converters
11+
{
12+
class ClassInstancingToBooleanConverter : IValueConverter
13+
{
14+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15+
{
16+
return (ClassInstancing)value == ClassInstancing.Private;
17+
}
18+
19+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20+
{
21+
return (bool)value
22+
? ClassInstancing.Private
23+
: ClassInstancing.PublicNotCreatable;
24+
}
25+
}
26+
}

Rubberduck.Core/UI/Refactorings/ExtractInterface/ExtractInterfaceView.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
mc:Ignorable="d" Height="378" Width="372">
88
<UserControl.Resources>
99
<converters:BoolToHiddenVisibilityConverter x:Key="BoolToHiddenVisibility" />
10+
<converters:ClassInstancingToBooleanConverter x:Key="ClassInstancingToBool" />
1011

1112
<LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0,1" StartPoint="0,0">
1213
<GradientStop Color="#FFD9F4FF" Offset="0"/>
@@ -93,10 +94,11 @@
9394
<GroupBox Header="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=ExtractInterface_InstancingGroupBox}"
9495
Grid.Row="1" Margin="5" Padding="5">
9596
<StackPanel Orientation="Horizontal">
96-
<RadioButton Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=ExtractInterface_PrivateRadioButton}"
97-
IsChecked="True" />
97+
<RadioButton x:Name="IsPrivateInstancing"
98+
Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=ExtractInterface_PrivateRadioButton}"
99+
IsChecked="{Binding Converter={StaticResource ClassInstancingToBool}, Mode=TwoWay, Path=ClassInstancing}" />
98100
<RadioButton Content="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=ExtractInterface_PublicNotCreatableRadioButton}"
99-
IsEnabled="{Binding IsInterfacePublicNotCreateable}"/>
101+
IsEnabled="{Binding IsInterfacePublicNotCreateableEnabled}" />
100102
</StackPanel>
101103
</GroupBox>
102104

Rubberduck.Core/UI/Refactorings/ExtractInterface/ExtractInterfaceViewModel.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
namespace Rubberduck.UI.Refactorings
1212
{
13+
public enum ClassInstancing
14+
{
15+
Private = 0,
16+
PublicNotCreatable,
17+
}
18+
1319
public class ExtractInterfaceViewModel : RefactoringViewModelBase<ExtractInterfaceModel>
1420
{
1521
public ExtractInterfaceViewModel(ExtractInterfaceModel model) : base(model)
@@ -61,7 +67,7 @@ public bool IsValidInterfaceName
6167
}
6268
}
6369

64-
public bool IsInterfacePublicNotCreateable
70+
public bool IsInterfacePublicNotCreateableEnabled
6571
{
6672
get
6773
{
@@ -76,6 +82,23 @@ public bool IsInterfacePublicNotCreateable
7682
}
7783
}
7884

85+
private ClassInstancing classInstancing = ClassInstancing.Private;
86+
public ClassInstancing ClassInstancing
87+
{
88+
get => classInstancing;
89+
set
90+
{
91+
if (value == classInstancing)
92+
{
93+
return;
94+
}
95+
96+
classInstancing = value;
97+
OnPropertyChanged();
98+
}
99+
}
100+
101+
79102
private void ToggleSelection(bool value)
80103
{
81104
foreach (var item in Members)

0 commit comments

Comments
 (0)