Skip to content

Commit

Permalink
fix fonts not changed when there are multiple note windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Chang committed May 9, 2019
1 parent c301239 commit f6fef47
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 20 deletions.
4 changes: 2 additions & 2 deletions DesktopNote.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -26,8 +27,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<ApplicationVersion>1.0.0.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down
30 changes: 15 additions & 15 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,21 +437,21 @@ private void Win_Main_Loaded(object sender, RoutedEventArgs e)
if (f.Source == CurrentSetting.Font) mi.IsSelected = true;
}
App.FormatWindow.CB_Font.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Content", System.ComponentModel.ListSortDirection.Ascending));
App.FormatWindow.CB_Font.SelectionChanged += (object s1, SelectionChangedEventArgs e1) =>
{
if (App.FormatWindow.Opacity == 1 && e1.AddedItems.Count == 1)
{
var mi = (ComboBoxItem)e1.AddedItems[0];

if (!RTB_Main.Selection.IsEmpty) //only change selected
RTB_Main.Selection.ApplyPropertyValue(TextElement.FontFamilyProperty, mi.FontFamily);
else //change default
{
RTB_Main.FontFamily = mi.FontFamily;
CurrentSetting.Font = mi.FontFamily.Source;
}
}
};
//App.FormatWindow.CB_Font.SelectionChanged += (object s1, SelectionChangedEventArgs e1) =>
//{
// if (App.FormatWindow.Opacity == 1 && e1.AddedItems.Count == 1)
// {
// var mi = (ComboBoxItem)e1.AddedItems[0];

// if (!RTB_Main.Selection.IsEmpty) //only change selected
// RTB_Main.Selection.ApplyPropertyValue(TextElement.FontFamilyProperty, mi.FontFamily);
// else //change default
// {
// RTB_Main.FontFamily = mi.FontFamily;
// CurrentSetting.Font = mi.FontFamily.Source;
// }
// }
//};
}

//loading contents
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.2.0")]
[assembly: AssemblyFileVersion("1.4.2.0")]
[assembly: AssemblyVersion("1.4.2.1")]
[assembly: AssemblyFileVersion("1.4.2.1")]
3 changes: 2 additions & 1 deletion Win_Format.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
</Button>
<ContentPresenter Grid.Column="5" Grid.Row="1" x:Name="CP_Font" Content="{StaticResource CP_Main}" ToolTip="{StaticResource tooltip_font_color}"/>
<ContentPresenter Grid.Column="6" Grid.Row="1" x:Name="CP_Back" Content="{StaticResource CP_Main}" ToolTip="{StaticResource tooltip_back_color}"/>
<ComboBox Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="4" x:Name="CB_Font" IsEditable="True" SelectedValuePath="Content" Height="21.6" Margin="2.5,0"/>
<ComboBox Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="4" x:Name="CB_Font" IsEditable="True" SelectedValuePath="Content" Height="21.6" Margin="2.5,0"
SelectionChanged="CB_Font_SelectionChanged"/>
<Button Grid.Column="6" Grid.Row="3" Click="DecreaseSize" ToolTip="{StaticResource tooltip_decrease_size}">
<Image Stretch="None" Source="Resources/SizeDecrease.ico"/>
</Button>
Expand Down
16 changes: 16 additions & 0 deletions Win_Format.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,21 @@ private void Button_Close_Click(object sender, RoutedEventArgs e)
}
catch { }
}

private void CB_Font_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (App.FormatWindow.Opacity == 1 && e.AddedItems.Count == 1)
{
var mi = (ComboBoxItem)e.AddedItems[0];

if (!RTB_Main.Selection.IsEmpty) //only change selected
RTB_Main.Selection.ApplyPropertyValue(TextElement.FontFamilyProperty, mi.FontFamily);
else //change default
{
RTB_Main.FontFamily = mi.FontFamily;
MainWin.CurrentSetting.Font = mi.FontFamily.Source;
}
}
}
}
}
Binary file modified bin/Release/DesktopNote.exe
Binary file not shown.

0 comments on commit f6fef47

Please sign in to comment.