|
@@ -15,11 +15,6 @@ namespace Compdfkit_Tools.Common
|
|
internal bool lockStyleName = false;
|
|
internal bool lockStyleName = false;
|
|
internal bool isFirstLoad = true;
|
|
internal bool isFirstLoad = true;
|
|
|
|
|
|
- private string regular = LanguageHelper.PropertyPanelManager.GetString("Font_Regular");
|
|
|
|
- private string bold = LanguageHelper.PropertyPanelManager.GetString("Font_Bold");
|
|
|
|
- private string italic = LanguageHelper.PropertyPanelManager.GetString("Font_Oblique");
|
|
|
|
- private string boldItalic = LanguageHelper.PropertyPanelManager.GetString("Font_BoldOblique");
|
|
|
|
-
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
public event EventHandler FontFamilyChanged;
|
|
public event EventHandler FontFamilyChanged;
|
|
public event EventHandler FontStyleChanged;
|
|
public event EventHandler FontStyleChanged;
|
|
@@ -31,11 +26,13 @@ namespace Compdfkit_Tools.Common
|
|
{
|
|
{
|
|
get => _familyName;
|
|
get => _familyName;
|
|
set
|
|
set
|
|
- {
|
|
|
|
- _familyName = value;
|
|
|
|
- if (FontFamilyComboBox.Items.Contains(_familyName))
|
|
|
|
|
|
+ {
|
|
|
|
+ if (UpdateProper(ref _familyName, value))
|
|
{
|
|
{
|
|
- FontFamilyComboBox.SelectedItem = _familyName;
|
|
|
|
|
|
+ if (FontFamilyComboBox.Items.Contains(_familyName))
|
|
|
|
+ {
|
|
|
|
+ FontFamilyComboBox.SelectedItem = _familyName;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -45,11 +42,13 @@ namespace Compdfkit_Tools.Common
|
|
{
|
|
{
|
|
get => _styleName;
|
|
get => _styleName;
|
|
set
|
|
set
|
|
- {
|
|
|
|
- _styleName = value;
|
|
|
|
- if (lockStyleName && FontStyleComboBox.Items.Contains(_styleName))
|
|
|
|
|
|
+ {
|
|
|
|
+ if (UpdateProper(ref _styleName, value))
|
|
{
|
|
{
|
|
- FontStyleComboBox.SelectedItem = _styleName;
|
|
|
|
|
|
+ if (FontStyleComboBox.Items.Contains(_styleName))
|
|
|
|
+ {
|
|
|
|
+ FontStyleComboBox.SelectedItem = _styleName;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -97,7 +96,7 @@ namespace Compdfkit_Tools.Common
|
|
set
|
|
set
|
|
{
|
|
{
|
|
_fontSizeValue = value;
|
|
_fontSizeValue = value;
|
|
- OnPropertyChanged(nameof(FontSizeValue));
|
|
|
|
|
|
+ OnPropertyChanged();
|
|
FontSizeChanged?.Invoke(this, EventArgs.Empty);
|
|
FontSizeChanged?.Invoke(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -114,14 +113,6 @@ namespace Compdfkit_Tools.Common
|
|
FontFamilyComboBox.ItemsSource = CPDFFont.GetFontNameDictionary().Keys;
|
|
FontFamilyComboBox.ItemsSource = CPDFFont.GetFontNameDictionary().Keys;
|
|
FontFamilyComboBox.SelectedIndex = 0;
|
|
FontFamilyComboBox.SelectedIndex = 0;
|
|
|
|
|
|
- List<string> fontStyleList = new List<string>()
|
|
|
|
- {
|
|
|
|
- regular,
|
|
|
|
- bold,
|
|
|
|
- italic,
|
|
|
|
- boldItalic
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
FontStyleComboBox.ItemsSource = CPDFFont.GetFontNameDictionary()[FontFamilyComboBox.SelectedValue.ToString()];
|
|
FontStyleComboBox.ItemsSource = CPDFFont.GetFontNameDictionary()[FontFamilyComboBox.SelectedValue.ToString()];
|
|
FontStyleComboBox.SelectedIndex = 0;
|
|
FontStyleComboBox.SelectedIndex = 0;
|
|
|
|
|
|
@@ -147,11 +138,6 @@ namespace Compdfkit_Tools.Common
|
|
FontSizeComboBox.InitPresetNumberArray(fontSizeList);
|
|
FontSizeComboBox.InitPresetNumberArray(fontSizeList);
|
|
}
|
|
}
|
|
|
|
|
|
- protected void OnPropertyChanged(string propertyName)
|
|
|
|
- {
|
|
|
|
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void FontFamilyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
private void FontFamilyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
{
|
|
if (isFirstLoad)
|
|
if (isFirstLoad)
|
|
@@ -168,34 +154,45 @@ namespace Compdfkit_Tools.Common
|
|
isFirstLoad = false;
|
|
isFirstLoad = false;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
var styleNames = CPDFFont.GetFontNameDictionary()[FontFamilyComboBox.SelectedValue.ToString()];
|
|
var styleNames = CPDFFont.GetFontNameDictionary()[FontFamilyComboBox.SelectedValue.ToString()];
|
|
- FontStyleComboBox.ItemsSource = styleNames;
|
|
|
|
- if (FamilyName != FontFamilyComboBox.SelectedValue.ToString())
|
|
|
|
|
|
+ FontStyleComboBox.ItemsSource = styleNames;
|
|
|
|
+
|
|
|
|
+ FamilyName = FontFamilyComboBox.SelectedValue.ToString();
|
|
|
|
+ if (styleNames.Count != 0)
|
|
{
|
|
{
|
|
- FamilyName = FontFamilyComboBox.SelectedValue.ToString();
|
|
|
|
- if (styleNames.Count != 0)
|
|
|
|
- {
|
|
|
|
- FontStyleComboBox.SelectedIndex = 0;
|
|
|
|
- }
|
|
|
|
- FontFamilyChanged?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
|
+ FontStyleComboBox.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ FontFamilyChanged?.Invoke(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
|
|
|
|
private void FontStyleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
private void FontStyleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
{
|
|
|
|
+ StyleName = FontStyleComboBox.SelectedValue?.ToString();
|
|
|
|
+ FontStyleChanged?.Invoke(this, EventArgs.Empty);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void AlignRadioButton_Checked(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ FontAlignChanged?.Invoke(this, EventArgs.Empty);
|
|
|
|
+ }
|
|
|
|
|
|
- if (!lockStyleName)
|
|
|
|
|
|
+ protected bool UpdateProper<T>(ref T properValue, T newValue, [CallerMemberName] string properName = "")
|
|
|
|
+ {
|
|
|
|
+ if (object.Equals(properValue, newValue))
|
|
{
|
|
{
|
|
- StyleName = FontStyleComboBox.SelectedValue?.ToString();
|
|
|
|
- FontStyleChanged?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
- lockStyleName = false;
|
|
|
|
|
|
+
|
|
|
|
+ properValue = newValue;
|
|
|
|
+ OnPropertyChanged(properName);
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
- private void AlignRadioButton_Checked(object sender, RoutedEventArgs e)
|
|
|
|
|
|
+ protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
{
|
|
{
|
|
- FontAlignChanged?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
|
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|