Skip to content

Commit

Permalink
Addressed crash in XP for Issue benrhughes#117
Browse files Browse the repository at this point in the history
Added limited logging to ColorFontDialog.  Checked to ensure that named
font was found before setting the index value.  Changed default font to
Arial to allow it to function in XP.
  • Loading branch information
ImminentOrbit committed Sep 8, 2012
1 parent ad53d5d commit 9532fb1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Client/User.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Client/User.settings
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<Value Profile="(Default)" />
</Setting>
<Setting Name="TaskListFontFamily" Type="System.String" Scope="User">
<Value Profile="(Default)">Segoe UI</Value>
<Value Profile="(Default)">Arial</Value>
</Setting>
<Setting Name="TaskListFontSize" Type="System.Double" Scope="User">
<Value Profile="(Default)">12</Value>
Expand Down
2 changes: 1 addition & 1 deletion Client/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<value />
</setting>
<setting name="TaskListFontFamily" serializeAs="String">
<value>Segoe UI</value>
<value>Arial</value>
</setting>
<setting name="TaskListFontSize" serializeAs="String">
<value>12</value>
Expand Down
7 changes: 6 additions & 1 deletion ColorFont/ColorFont.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\ToDoLib\ToDoLib.csproj">
<Project>{07AA9CEA-4EF0-4B47-AFBD-6F74AD9C4653}</Project>
<Name>ToDoLib</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\colorfont_icon.png" />
</ItemGroup>
Expand Down
18 changes: 18 additions & 0 deletions ColorFont/ColorFontDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text;
using System.Windows;
using System.Windows.Media;
using ToDoLib;

namespace ColorFont
{
Expand All @@ -13,6 +14,7 @@ public partial class ColorFontDialog : Window

public ColorFontDialog()
{
Log.Debug("Loading ColorFontDialog");
this.selectedFont = null; // Default
InitializeComponent();
}
Expand All @@ -33,29 +35,42 @@ public FontInfo Font

private void SyncFontName()
{
Log.Debug("In SyncFontName");

string fontFamilyName = this.selectedFont.Family.Source;
bool isFontFound = false;

int idx = 0;
foreach (var item in this.colorFontChooser.lstFamily.Items)
{
string itemName = item.ToString();
if (fontFamilyName == itemName)
{
isFontFound = true;
break;
}
idx++;
}

if (!isFontFound)
{
idx = 0;
}

this.colorFontChooser.lstFamily.SelectedIndex = idx;
this.colorFontChooser.lstFamily.ScrollIntoView(this.colorFontChooser.lstFamily.Items[idx]);
}

private void SyncFontSize()
{
Log.Debug("In SyncFontSize");
double fontSize = this.selectedFont.Size;
this.colorFontChooser.fontSizeSlider.Value = fontSize;
}

private void SyncFontColor()
{
Log.Debug("In SyncFontColor");
int colorIdx = AvailableColors.GetFontColorIndex(this.Font.Color);
this.colorFontChooser.colorPicker.superCombo.SelectedIndex = colorIdx;
// The following does not work. Why???
Expand All @@ -65,6 +80,7 @@ private void SyncFontColor()

private void SyncFontTypeface()
{
Log.Debug("In SyncFontTypeface");
string fontTypeFaceSb = FontInfo.TypefaceToString(this.selectedFont.Typeface);
int idx = 0;
foreach (var item in this.colorFontChooser.lstTypefaces.Items)
Expand All @@ -87,10 +103,12 @@ private void btnOk_Click(object sender, RoutedEventArgs e)

private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
Log.Debug("In Window_Loaded_1" );
this.SyncFontColor();
this.SyncFontName();
this.SyncFontSize();
this.SyncFontTypeface();
Log.Debug("Leaving Window_Loaded_1");
}
}
}

0 comments on commit 9532fb1

Please sign in to comment.