Permalink
Browse files

Used monospaced font for password field.

  • Loading branch information...
1 parent e96b986 commit 9c61f54115bf76de71bde182181ea77ad1a84d58 @7Pass committed Jan 29, 2012
Showing with 28 additions and 6 deletions.
  1. +23 −0 KeePass/Controls/ProtectedTextBox.xaml.cs
  2. +3 −5 KeePass/EntryDetails.xaml
  3. +2 −1 KeePass/PassGen.xaml
@@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
+using System.Windows.Media;
namespace KeePass.Controls
{
@@ -11,6 +12,10 @@ public partial class ProtectedTextBox
.Register("IsProtected", typeof(bool), typeof(ProtectedTextBox),
new PropertyMetadata(true, OnIsProtectedChanged));
+ public static DependencyProperty MonoSpacedProperty = DependencyProperty
+ .Register("MonoSpaced", typeof(bool), typeof(ProtectedTextBox),
+ new PropertyMetadata(false, OnMonoSpacedChanged));
+
public static DependencyProperty TextProperty = DependencyProperty
.Register("Text", typeof(string), typeof(ProtectedTextBox), null);
@@ -25,6 +30,12 @@ public bool IsProtected
set { SetValue(IsProtectedProperty, value); }
}
+ public bool MonoSpaced
+ {
+ get { return (bool)GetValue(MonoSpacedProperty); }
+ set { SetValue(MonoSpacedProperty, value); }
+ }
+
/// <summary>
/// Gets or sets the text.
/// </summary>
@@ -69,6 +80,18 @@ protected virtual void OnTextChanged(TextChangedEventArgs e)
protect.UpdateProtectState();
}
+ private static void OnMonoSpacedChanged(DependencyObject d,
+ DependencyPropertyChangedEventArgs e)
+ {
+ var protect = (ProtectedTextBox)d;
+
+ if (protect.MonoSpaced)
+ {
+ protect.txtPassword.FontFamily =
+ new FontFamily("Courier New");
+ }
+ }
+
private void UpdateProtectState()
{
if (!IsProtected)
@@ -32,22 +32,20 @@
<!-- Entry details -->
<TextBlock Text="{Binding Path=Strings.EntryDetails_Title, Source={StaticResource UiStrings}}"
Style="{StaticResource PhoneTextNormalStyle}" />
- <uc:ProtectedTextBox x:Name="txtTitle"
- GotFocus="txt_GotFocus"
+ <uc:ProtectedTextBox x:Name="txtTitle" GotFocus="txt_GotFocus"
Text="{Binding Title, Mode=TwoWay}"
c4f:TextBinding.UpdateSourceOnChange="True" />
<TextBlock Text="{Binding Path=Strings.EntryDetails_Username, Source={StaticResource UiStrings}}"
Style="{StaticResource PhoneTextNormalStyle}" />
- <uc:ProtectedTextBox x:Name="txtUsername"
- GotFocus="txt_GotFocus"
+ <uc:ProtectedTextBox x:Name="txtUsername" GotFocus="txt_GotFocus"
Text="{Binding UserName, Mode=TwoWay}"
c4f:TextBinding.UpdateSourceOnChange="True" />
<TextBlock Text="{Binding Path=Strings.EntryDetails_Password, Source={StaticResource UiStrings}}"
Style="{StaticResource PhoneTextNormalStyle}" />
<uc:ProtectedTextBox x:Name="txtPassword"
- GotFocus="txt_GotFocus"
+ GotFocus="txt_GotFocus" MonoSpaced="True"
Text="{Binding Password, Mode=TwoWay}"
c4f:TextBinding.UpdateSourceOnChange="True" />
@@ -44,7 +44,8 @@
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
- <TextBlock Text="{Binding}" Style="{StaticResource PhoneTextLargeStyle}" />
+ <TextBlock Text="{Binding}" FontFamily="Courier New"
+ Style="{StaticResource PhoneTextLargeStyle}" />
<uc:QualityProgressBar Password="{Binding}" />
</StackPanel>
</DataTemplate>

0 comments on commit 9c61f54

Please sign in to comment.