Skip to content
Permalink
Browse files

Merge pull request #4929 from Vogel612/fix/language-change-exception

Fix language change exception
  • Loading branch information...
retailcoder committed Apr 23, 2019
2 parents dd68164 + 702f18c commit 4d5420b6397f22cacf2cbcba9e48c1f75623ef1b
@@ -12,6 +12,7 @@
<DisabledWarnings>$(DisabledWarnings);1591</DisabledWarnings>
<ApplicationIcon>Ducky.ico</ApplicationIcon>
<!-- Give a fixed version to not blow XAML generated code to smithereens -->
<!-- This also fixes "Input string was not in the correct format" error message when referring to the current assembly in an XAML-Namespace -->
<AssemblyVersion>2.4.1</AssemblyVersion>
</PropertyGroup>
<Import Project="..\RubberduckBaseProject.csproj" />
@@ -9,7 +9,7 @@
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:controls="clr-namespace:Rubberduck.UI.Controls"
xmlns:system="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="380" d:DesignWidth="600"
d:DataContext="{d:DesignInstance local:AddRemoveReferencesViewModel}">
<UserControl.Resources>
@@ -26,7 +26,6 @@
<local:ReferenceStatusImageSourceConverter x:Key="StatusToIcon" />
<local:PriorityButtonVisibilityConverter x:Key="PriorityButtonVisibility" />
<local:PriorityButtonImageSourceConverter x:Key="PriorityButtonIcon" />
<converters:SearchImageSourceConverter x:Key="SearchToIcon" />
<converters:BooleanToNonDimmedBrushConverter x:Key="BooleanToNonDimmed" />
<converters:BoolToHiddenVisibilityConverter x:Key="ProjectVisibilityConverter" />

@@ -35,39 +34,6 @@
<Setter Property="Height" Value="24" />
<Setter Property="Padding" Value="10,0" />
</Style>
<Style x:Key="PlaceHolder" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<TextBox Text="{Binding Path=Text,
RelativeSource={RelativeSource TemplatedParent},
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
x:Name="textSource"
Background="Transparent"
Panel.ZIndex="2"
VerticalContentAlignment="Center" />
<TextBox Text="{TemplateBinding Tag}" Background="{TemplateBinding Background}" Panel.ZIndex="1">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="Transparent"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Text, Source={x:Reference textSource}}" Value="">
<Setter Property="Foreground" Value="LightGray"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
@@ -204,32 +170,11 @@
BorderThickness="1"
Margin="0,5"
Padding="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<TextBox Name="SearchBox" Grid.Column="0">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource PlaceHolder}">
<Setter Property="Height" Value="20" />
<Setter Property="Width" Value="Auto" />
<Setter Property="Tag" Value="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=References_SearchPlaceholder}" />
<Setter Property="Text" Value="{Binding Search, UpdateSourceTrigger=PropertyChanged}" />
</Style>
</TextBox.Style>
</TextBox>
<Button Name="SearchButton" Grid.Column="1" Command="{Binding ClearSearchCommand}"
BorderBrush="{x:Static SystemColors.ControlLightBrush}"
Background="Transparent"
Width="20" Height="20" Padding="0" Margin="0,1">
<Image VerticalAlignment="Center" HorizontalAlignment="Center"
Width="16" Height="16" Source="{Binding Search, Converter={StaticResource SearchToIcon}, UpdateSourceTrigger=PropertyChanged}" />
<i:Interaction.Behaviors>
<controls:FocusElementAfterClickBehavior FocusElement="{Binding ElementName=SearchBox, Mode=OneWay}"/>
</i:Interaction.Behaviors>
</Button>
</Grid>
<controls:SearchBox x:Name="SearchBox" Grid.Column="0"
Background="{x:Static SystemColors.WindowBrush}"
Width="Auto"
Text="{Binding Search, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Hint="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=References_SearchPlaceholder}" />
</Border>
<Border Grid.Row="1" Grid.Column="0">
<ListView Name="LibrarySelect" SelectedItem="{Binding SelectedLibrary, Mode=TwoWay}"
@@ -5,9 +5,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:codeExplorer="clr-namespace:Rubberduck.Navigation.CodeExplorer"
xmlns:controls="clr-namespace:Rubberduck.UI.Controls"
xmlns:converters="clr-namespace:Rubberduck.UI.Converters"
xmlns:local="clr-namespace:Rubberduck.UI.CodeExplorer"
xmlns:controls="clr-namespace:Rubberduck.UI.Controls;assembly="
xmlns:converters="clr-namespace:Rubberduck.UI.Converters;assembly="
xmlns:local="clr-namespace:Rubberduck.UI.CodeExplorer;assembly="
ResxExtension.DefaultResxName="Rubberduck.Resources.CodeExplorer.CodeExplorerUI"
Language="{UICulture}"
Name="CodeExplorer"
@@ -48,7 +48,6 @@
<converters:BoolToHiddenVisibilityConverter x:Key="BoolToHiddenVisibility" />
<converters:BooleanToDimmedBrushConverter x:Key="BooleanToDimmed" />
<converters:TemplateCommandParameterToTupleConverter x:Key="TemplateCommandParameterToTuple" />
<converters:SearchImageSourceConverter x:Key="SearchToIcon" />
<converters:InvertBoolValueConverter x:Key="NotBool" />
<converters:CodeExplorerNodeToIconConverter x:Key="NodeToIcon" />
<converters:AccessibilityToIconConverter x:Key="AccessibilityToIcon" />
@@ -64,37 +63,6 @@
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Black" />

<Style x:Key="PlaceHolder" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<TextBox Text="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
x:Name="textSource"
Background="Transparent"
Panel.ZIndex="2"
VerticalContentAlignment="Center"/>
<TextBox Text="{TemplateBinding Tag}" Background="{TemplateBinding Background}" Panel.ZIndex="1">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="Transparent"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Text, Source={x:Reference textSource}}" Value="">
<Setter Property="Foreground" Value="LightGray"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

<CompositeCollection x:Key="AddModuleCommands">
<MenuItem Header="{Resx ResxName=Rubberduck.Resources.CodeExplorer.CodeExplorerUI, Key=CodeExplorer_AddVBFormText}"
Command="{Binding AddVBFormCommand}"
@@ -419,32 +387,13 @@
BorderBrush="{x:Static SystemColors.ActiveBorderBrush}"
BorderThickness="1"
Padding="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<TextBox Name="SearchBox" Grid.Column="0">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource PlaceHolder}">
<Setter Property="Height" Value="20" />
<Setter Property="Width" Value="Auto" />
<Setter Property="Tag" Value="{Resx ResxName=Rubberduck.Resources.CodeExplorer.CodeExplorerUI, Key=CodeExplorer_SearchPlaceholder}" />
<Setter Property="Text" Value="{Binding Search, UpdateSourceTrigger=PropertyChanged}" />
</Style>
</TextBox.Style>
</TextBox>
<Button Name="SearchButton" Grid.Column="1" Command="{Binding ClearSearchCommand}"
BorderBrush="{x:Static SystemColors.ControlLightBrush}"
Background="Transparent"
Width="20" Height="20" Padding="0" Margin="0,1">
<Image VerticalAlignment="Center" HorizontalAlignment="Center"
Width="16" Height="16" Source="{Binding Search, Converter={StaticResource SearchToIcon}, UpdateSourceTrigger=PropertyChanged}" />
<i:Interaction.Behaviors>
<controls:FocusElementAfterClickBehavior FocusElement="{Binding ElementName=SearchBox, Mode=OneWay}"/>
</i:Interaction.Behaviors>
</Button>
</Grid>
<controls:SearchBox x:Name="SearchBox"
Background="{x:Static SystemColors.WindowBrush}"
Text="{Binding Search, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Hint="{Resx ResxName=Rubberduck.Resources.CodeExplorer.CodeExplorerUI,
Key=CodeExplorer_SearchPlaceholder}"
Grid.Column="0"
Width="Auto"/>
</Border>

<TreeView x:Name="ProjectTree"
@@ -0,0 +1,58 @@
using System.Windows;
using System.Windows.Controls.Primitives;

namespace Rubberduck.UI.Controls.Behavior
{
using ButtonBehavior = System.Windows.Interactivity.Behavior<ButtonBase>;

public class ResetValueBehavior : ButtonBehavior
{
private ButtonBase _associatedButton;

protected override void OnAttached()
{
_associatedButton = AssociatedObject;

_associatedButton.Click += AssociatedButtonClick;
}

protected override void OnDetaching()
{
_associatedButton.Click -= AssociatedButtonClick;
}

private void AssociatedButtonClick(object sender, RoutedEventArgs e)
{
Affects = Default;
}

public object Affects
{
get => GetValue(AffectsProperty);
set
{
var oldValue = Affects;
SetValue(AffectsProperty, value);
OnPropertyChanged(new DependencyPropertyChangedEventArgs(AffectsProperty, oldValue, value));
}
}

public object Default
{
get => GetValue(DefaultProperty);
set
{
var oldValue = Default;
SetValue(DefaultProperty, value);
OnPropertyChanged(new DependencyPropertyChangedEventArgs(DefaultProperty, oldValue, value));
}
}

// Using a DependencyProperty as the backing store for Affects.
// This enables animation, styling, binding, etc...
public static readonly DependencyProperty AffectsProperty =
DependencyProperty.Register("Affects", typeof(object), typeof(ResetValueBehavior), new UIPropertyMetadata());
public static readonly DependencyProperty DefaultProperty =
DependencyProperty.Register("Default", typeof(object), typeof(ResetValueBehavior), new UIPropertyMetadata(defaultValue: null));
}
}
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using Rubberduck.Settings;

// credit to http://stackoverflow.com/a/2752538
@@ -9,7 +10,7 @@ namespace Rubberduck.UI.Controls
/// <summary>
/// Interaction logic for NumberPicker.xaml
/// </summary>
public partial class NumberPicker : IDataErrorInfo
public partial class NumberPicker : UserControl, IDataErrorInfo
{
public static readonly DependencyProperty NumValueProperty =
DependencyProperty.Register(nameof(NumValue), typeof(int), typeof(NumberPicker), new UIPropertyMetadata(default(int), PropertyChangedCallback));
@@ -0,0 +1,68 @@
<UserControl x:Class="Rubberduck.UI.Controls.SearchBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:local="clr-namespace:Rubberduck.UI.Controls;assembly="
xmlns:ib="clr-namespace:Rubberduck.UI.Controls.Behavior;assembly="
xmlns:converters="clr-namespace:Rubberduck.UI.Converters;assembly="
mc:Ignorable="d"
MinWidth="50" MinHeight="20"
Height="20"
Name="Root"
d:DesignHeight="20" d:DesignWidth="400"
d:DataContext="{d:DesignInstance local:SearchBox, IsDesignTimeCreatable=True}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<TextBox Text="{Binding Path=Text, ElementName=Root, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
x:Name="ValueContainer"
Background="Transparent"
Panel.ZIndex="2"
VerticalContentAlignment="Center"
Width="Auto"
Grid.Row="0" Grid.Column="0"/>
<!-- this is the actual hint container, it's BELOW the displaying control -->
<TextBox Text="{Binding Path=Hint, ElementName=Root, Mode=OneWay}"
Background="{Binding Path=Background, ElementName=Root}"
Width="{Binding Path=ActualWidth, ElementName=ValueContainer}"
Height="{Binding Path=ActualHeight, ElementName=ValueContainer}"
Panel.ZIndex="1"
VerticalContentAlignment="Center"
Grid.Row="0" Grid.Column="0">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<!-- Setter needs to be within this type to be overwritable with a trigger -->
<Setter Property="Foreground" Value="Transparent" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Text, Source={x:Reference ValueContainer}}" Value="">
<Setter Property="Foreground" Value="{x:Static SystemColors.GrayTextBrush}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<Button Name="SearchButton" Grid.Column="1" Command="{Binding ClearSearchCommand}"
BorderBrush="{x:Static SystemColors.ControlLightBrush}"
Background="Transparent"
Width="20" Height="20" Padding="0" Margin="0,1"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Button.Resources>
<converters:SearchImageSourceConverter x:Key="SearchToIcon" />
</Button.Resources>
<Image VerticalAlignment="Center" HorizontalAlignment="Center"
Width="16" Height="16"
Source="{Binding Text, ElementName=ValueContainer,
Converter={StaticResource SearchToIcon},
UpdateSourceTrigger=PropertyChanged}" />
<i:Interaction.Behaviors>
<local:FocusElementAfterClickBehavior FocusElement="{x:Reference ValueContainer}"/>
<ib:ResetValueBehavior Affects="{Binding Path=Text, ElementName=ValueContainer, Mode=OneWayToSource}"
Default="{x:Static sys:String.Empty}"/>
</i:Interaction.Behaviors>
</Button>
</Grid>
</UserControl>

0 comments on commit 4d5420b

Please sign in to comment.
You can’t perform that action at this time.