Skip to content

Commit

Permalink
Change name of EditorSettingsService to AppSettingsService
Browse files Browse the repository at this point in the history
Change name of EditorSettingsService to AppSettingsService
  • Loading branch information
0x7c13 committed May 11, 2020
1 parent 8b65692 commit 63abda3
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 134 deletions.
32 changes: 16 additions & 16 deletions src/Notepads/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private async Task ActivateAsync(IActivatedEventArgs e)
rootFrameCreated = true;

ThemeSettingsService.Initialize();
EditorSettingsService.Initialize();
AppSettingsService.Initialize();
}

var appLaunchSettings = new Dictionary<string, string>()
Expand All @@ -97,23 +97,23 @@ private async Task ActivateAsync(IActivatedEventArgs e)
{ "ThemeMode", ThemeSettingsService.ThemeMode.ToString() },
{ "UseWindowsAccentColor", ThemeSettingsService.UseWindowsAccentColor.ToString() },
{ "AppBackgroundTintOpacity", $"{(int) (ThemeSettingsService.AppBackgroundPanelTintOpacity * 10.0) * 10}" },
{ "ShowStatusBar", EditorSettingsService.ShowStatusBar.ToString() },
{ "EditorDefaultLineEnding", EditorSettingsService.EditorDefaultLineEnding.ToString() },
{ "EditorDefaultEncoding", EncodingUtility.GetEncodingName(EditorSettingsService.EditorDefaultEncoding) },
{ "EditorDefaultTabIndents", EditorSettingsService.EditorDefaultTabIndents.ToString() },
{ "EditorDefaultDecoding", EditorSettingsService.EditorDefaultDecoding == null ? "Auto" : EncodingUtility.GetEncodingName(EditorSettingsService.EditorDefaultDecoding) },
{ "EditorFontFamily", EditorSettingsService.EditorFontFamily },
{ "EditorFontSize", EditorSettingsService.EditorFontSize.ToString() },
{ "EditorFontStyle", EditorSettingsService.EditorFontStyle.ToString() },
{ "EditorFontWeight", EditorSettingsService.EditorFontWeight.Weight.ToString() },
{ "IsSessionSnapshotEnabled", EditorSettingsService.IsSessionSnapshotEnabled.ToString() },
{ "ShowStatusBar", AppSettingsService.ShowStatusBar.ToString() },
{ "EditorDefaultLineEnding", AppSettingsService.EditorDefaultLineEnding.ToString() },
{ "EditorDefaultEncoding", EncodingUtility.GetEncodingName(AppSettingsService.EditorDefaultEncoding) },
{ "EditorDefaultTabIndents", AppSettingsService.EditorDefaultTabIndents.ToString() },
{ "EditorDefaultDecoding", AppSettingsService.EditorDefaultDecoding == null ? "Auto" : EncodingUtility.GetEncodingName(AppSettingsService.EditorDefaultDecoding) },
{ "EditorFontFamily", AppSettingsService.EditorFontFamily },
{ "EditorFontSize", AppSettingsService.EditorFontSize.ToString() },
{ "EditorFontStyle", AppSettingsService.EditorFontStyle.ToString() },
{ "EditorFontWeight", AppSettingsService.EditorFontWeight.Weight.ToString() },
{ "IsSessionSnapshotEnabled", AppSettingsService.IsSessionSnapshotEnabled.ToString() },
{ "IsShadowWindow", (!IsFirstInstance && !IsGameBarWidget).ToString() },
{ "IsGameBarWidget", IsGameBarWidget.ToString() },
{ "AlwaysOpenNewWindow", EditorSettingsService.AlwaysOpenNewWindow.ToString() },
{ "IsHighlightMisspelledWordsEnabled", EditorSettingsService.IsHighlightMisspelledWordsEnabled.ToString() },
{ "DisplayLineHighlighter", EditorSettingsService.EditorDisplayLineHighlighter.ToString() },
{ "DisplayLineNumbers", EditorSettingsService.EditorDisplayLineNumbers.ToString() },
{ "EditorDefaultSearchEngine", EditorSettingsService.EditorDefaultSearchEngine.ToString() }
{ "AlwaysOpenNewWindow", AppSettingsService.AlwaysOpenNewWindow.ToString() },
{ "IsHighlightMisspelledWordsEnabled", AppSettingsService.IsHighlightMisspelledWordsEnabled.ToString() },
{ "DisplayLineHighlighter", AppSettingsService.EditorDisplayLineHighlighter.ToString() },
{ "DisplayLineNumbers", AppSettingsService.EditorDisplayLineNumbers.ToString() },
{ "EditorDefaultSearchEngine", AppSettingsService.EditorDefaultSearchEngine.ToString() }
};

LoggingService.LogInfo($"[{nameof(App)}] Launch settings: \n{string.Join("\n", appLaunchSettings.Select(x => x.Key + "=" + x.Value).ToArray())}.");
Expand Down
8 changes: 4 additions & 4 deletions src/Notepads/Controls/Print/PrintArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public static void PreparePrintContent(ITextEditor[] textEditors)
if (!string.IsNullOrEmpty(textDocument))
{
var page = new PrintPageFormat(textDocument,
new FontFamily(EditorSettingsService.EditorFontFamily),
EditorSettingsService.EditorFontSize,
new FontFamily(AppSettingsService.EditorFontFamily),
AppSettingsService.EditorFontSize,
_headerText,
_footerText);

Expand Down Expand Up @@ -246,8 +246,8 @@ private static RichTextBlockOverflow AddOnePrintPreviewPage(RichTextBlockOverflo
{
// Flow content (text) from previous pages
page = new ContinuationPageFormat(lastRTBOAdded,
new FontFamily(EditorSettingsService.EditorFontFamily),
EditorSettingsService.EditorFontSize,
new FontFamily(AppSettingsService.EditorFontFamily),
AppSettingsService.EditorFontSize,
_headerText,
_footerText);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Notepads/Controls/TextEditor/TextEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public void ResetEditorState(TextEditorStateMetaData metadata, string newText =
}

TextEditorCore.TextWrapping = metadata.WrapWord ? TextWrapping.Wrap : TextWrapping.NoWrap;
TextEditorCore.FontSize = metadata.FontZoomFactor * EditorSettingsService.EditorFontSize;
TextEditorCore.FontSize = metadata.FontZoomFactor * AppSettingsService.EditorFontSize;
TextEditorCore.SetTextSelectionPosition(metadata.SelectionStartPosition, metadata.SelectionEndPosition);
TextEditorCore.SetScrollViewerInitPosition(metadata.ScrollViewerHorizontalOffset, metadata.ScrollViewerVerticalOffset);
TextEditorCore.ClearUndoQueue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ public partial class TextEditorCore
{
internal void HookExternalEvents()
{
EditorSettingsService.OnFontFamilyChanged += EditorSettingsService_OnFontFamilyChanged;
EditorSettingsService.OnFontSizeChanged += EditorSettingsService_OnFontSizeChanged;
EditorSettingsService.OnFontStyleChanged += EditorSettingsService_OnFontStyleChanged;
EditorSettingsService.OnFontWeightChanged += EditorSettingsService_OnFontWeightChanged;
EditorSettingsService.OnDefaultTextWrappingChanged += EditorSettingsService_OnDefaultTextWrappingChanged;
EditorSettingsService.OnHighlightMisspelledWordsChanged += EditorSettingsService_OnHighlightMisspelledWordsChanged;
EditorSettingsService.OnDefaultDisplayLineNumbersViewStateChanged += EditorSettingsService_OnDefaultDisplayLineNumbersViewStateChanged;
EditorSettingsService.OnDefaultLineHighlighterViewStateChanged += EditorSettingsService_OnDefaultLineHighlighterViewStateChanged;
AppSettingsService.OnFontFamilyChanged += EditorSettingsService_OnFontFamilyChanged;
AppSettingsService.OnFontSizeChanged += EditorSettingsService_OnFontSizeChanged;
AppSettingsService.OnFontStyleChanged += EditorSettingsService_OnFontStyleChanged;
AppSettingsService.OnFontWeightChanged += EditorSettingsService_OnFontWeightChanged;
AppSettingsService.OnDefaultTextWrappingChanged += EditorSettingsService_OnDefaultTextWrappingChanged;
AppSettingsService.OnHighlightMisspelledWordsChanged += EditorSettingsService_OnHighlightMisspelledWordsChanged;
AppSettingsService.OnDefaultDisplayLineNumbersViewStateChanged += EditorSettingsService_OnDefaultDisplayLineNumbersViewStateChanged;
AppSettingsService.OnDefaultLineHighlighterViewStateChanged += EditorSettingsService_OnDefaultLineHighlighterViewStateChanged;

ThemeSettingsService.OnAccentColorChanged += ThemeSettingsService_OnAccentColorChanged;
}

internal void UnhookExternalEvents()
{
EditorSettingsService.OnFontFamilyChanged -= EditorSettingsService_OnFontFamilyChanged;
EditorSettingsService.OnFontSizeChanged -= EditorSettingsService_OnFontSizeChanged;
EditorSettingsService.OnFontStyleChanged -= EditorSettingsService_OnFontStyleChanged;
EditorSettingsService.OnFontWeightChanged -= EditorSettingsService_OnFontWeightChanged;
EditorSettingsService.OnDefaultTextWrappingChanged -= EditorSettingsService_OnDefaultTextWrappingChanged;
EditorSettingsService.OnHighlightMisspelledWordsChanged -= EditorSettingsService_OnHighlightMisspelledWordsChanged;
EditorSettingsService.OnDefaultDisplayLineNumbersViewStateChanged -= EditorSettingsService_OnDefaultDisplayLineNumbersViewStateChanged;
EditorSettingsService.OnDefaultLineHighlighterViewStateChanged -= EditorSettingsService_OnDefaultLineHighlighterViewStateChanged;
AppSettingsService.OnFontFamilyChanged -= EditorSettingsService_OnFontFamilyChanged;
AppSettingsService.OnFontSizeChanged -= EditorSettingsService_OnFontSizeChanged;
AppSettingsService.OnFontStyleChanged -= EditorSettingsService_OnFontStyleChanged;
AppSettingsService.OnFontWeightChanged -= EditorSettingsService_OnFontWeightChanged;
AppSettingsService.OnDefaultTextWrappingChanged -= EditorSettingsService_OnDefaultTextWrappingChanged;
AppSettingsService.OnHighlightMisspelledWordsChanged -= EditorSettingsService_OnHighlightMisspelledWordsChanged;
AppSettingsService.OnDefaultDisplayLineNumbersViewStateChanged -= EditorSettingsService_OnDefaultDisplayLineNumbersViewStateChanged;
AppSettingsService.OnDefaultLineHighlighterViewStateChanged -= EditorSettingsService_OnDefaultLineHighlighterViewStateChanged;

ThemeSettingsService.OnAccentColorChanged -= ThemeSettingsService_OnAccentColorChanged;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Notepads/Controls/TextEditor/TextEditorCore.FontSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private void IncreaseFontSize(double delta)
}
else
{
FontSize += delta * EditorSettingsService.EditorFontSize;
FontSize += delta * AppSettingsService.EditorFontSize;
}
}
}
Expand All @@ -30,14 +30,14 @@ private void DecreaseFontSize(double delta)
}
else
{
FontSize -= delta * EditorSettingsService.EditorFontSize;
FontSize -= delta * AppSettingsService.EditorFontSize;
}
}
}

private void ResetFontSizeToDefault()
{
FontSize = EditorSettingsService.EditorFontSize;
FontSize = AppSettingsService.EditorFontSize;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async void SearchInWeb()
return;
}

var searchUri = new Uri(string.Format(SearchEngineUtility.GetSearchUrlBySearchEngine(EditorSettingsService.EditorDefaultSearchEngine)
var searchUri = new Uri(string.Format(SearchEngineUtility.GetSearchUrlBySearchEngine(AppSettingsService.EditorDefaultSearchEngine)
, string.Join("+", searchString.Split(null))));
await Launcher.LaunchUriAsync(searchUri);
}
Expand Down
28 changes: 14 additions & 14 deletions src/Notepads/Controls/TextEditor/TextEditorCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public partial class TextEditorCore : RichEditBox
private const string LineIndicatorName = "LineIndicator";
private Border _lineIndicator;

private TextWrapping _textWrapping = EditorSettingsService.EditorDefaultTextWrapping;
private TextWrapping _textWrapping = AppSettingsService.EditorDefaultTextWrapping;

public new TextWrapping TextWrapping
{
Expand All @@ -88,7 +88,7 @@ public partial class TextEditorCore : RichEditBox
}

private double _fontZoomFactor = 100;
private double _fontSize = EditorSettingsService.EditorFontSize;
private double _fontSize = AppSettingsService.EditorFontSize;

public new double FontSize
{
Expand All @@ -100,7 +100,7 @@ public partial class TextEditorCore : RichEditBox
SetDefaultTabStopAndLineSpacing(FontFamily, value);
FontSizeChanged?.Invoke(this, value);

var newZoomFactor = Math.Round((value * 100) / EditorSettingsService.EditorFontSize);
var newZoomFactor = Math.Round((value * 100) / AppSettingsService.EditorFontSize);
if (Math.Abs(newZoomFactor - _fontZoomFactor) >= 1)
{
_fontZoomFactor = newZoomFactor;
Expand All @@ -111,19 +111,19 @@ public partial class TextEditorCore : RichEditBox

public TextEditorCore()
{
IsSpellCheckEnabled = EditorSettingsService.IsHighlightMisspelledWordsEnabled;
TextWrapping = EditorSettingsService.EditorDefaultTextWrapping;
FontFamily = new FontFamily(EditorSettingsService.EditorFontFamily);
FontSize = EditorSettingsService.EditorFontSize;
FontStyle = EditorSettingsService.EditorFontStyle;
FontWeight = EditorSettingsService.EditorFontWeight;
IsSpellCheckEnabled = AppSettingsService.IsHighlightMisspelledWordsEnabled;
TextWrapping = AppSettingsService.EditorDefaultTextWrapping;
FontFamily = new FontFamily(AppSettingsService.EditorFontFamily);
FontSize = AppSettingsService.EditorFontSize;
FontStyle = AppSettingsService.EditorFontStyle;
FontWeight = AppSettingsService.EditorFontWeight;
SelectionHighlightColor = new SolidColorBrush(ThemeSettingsService.AppAccentColor);
SelectionHighlightColorWhenNotFocused = new SolidColorBrush(ThemeSettingsService.AppAccentColor);
SelectionFlyout = null;
HorizontalAlignment = HorizontalAlignment.Stretch;
VerticalAlignment = VerticalAlignment.Stretch;
DisplayLineNumbers = EditorSettingsService.EditorDisplayLineNumbers;
DisplayLineHighlighter = EditorSettingsService.EditorDisplayLineHighlighter;
DisplayLineNumbers = AppSettingsService.EditorDisplayLineNumbers;
DisplayLineHighlighter = AppSettingsService.EditorDisplayLineHighlighter;
HandwritingView.BorderThickness = new Thickness(0);

CopyingToClipboard += OnCopyingToClipboard;
Expand Down Expand Up @@ -247,8 +247,8 @@ private KeyboardCommandHandler GetKeyboardCommandHandler()
new KeyboardCommand<KeyRoutedEventArgs>(VirtualKey.F5, (args) => InsertDateTimeString()),
new KeyboardCommand<KeyRoutedEventArgs>(true, false, false, VirtualKey.E, (args) => SearchInWeb()),
new KeyboardCommand<KeyRoutedEventArgs>(true, false, false, VirtualKey.D, (args) => DuplicateText()),
new KeyboardCommand<KeyRoutedEventArgs>(VirtualKey.Tab, (args) => AddIndentation(EditorSettingsService.EditorDefaultTabIndents)),
new KeyboardCommand<KeyRoutedEventArgs>(false, false, true, VirtualKey.Tab, (args) => RemoveIndentation(EditorSettingsService.EditorDefaultTabIndents)),
new KeyboardCommand<KeyRoutedEventArgs>(VirtualKey.Tab, (args) => AddIndentation(AppSettingsService.EditorDefaultTabIndents)),
new KeyboardCommand<KeyRoutedEventArgs>(false, false, true, VirtualKey.Tab, (args) => RemoveIndentation(AppSettingsService.EditorDefaultTabIndents)),
new KeyboardCommand<KeyRoutedEventArgs>(true, true, true, VirtualKey.D, (args) => ShowEasterEgg(), requiredHits: 10),
new KeyboardCommand<KeyRoutedEventArgs>(true, false, false, VirtualKey.L, (args) => SwitchTextFlowDirection(FlowDirection.LeftToRight)),
new KeyboardCommand<KeyRoutedEventArgs>(true, false, false, VirtualKey.R, (args) => SwitchTextFlowDirection(FlowDirection.RightToLeft)),
Expand Down Expand Up @@ -624,7 +624,7 @@ public void SetFontZoomFactor(double fontZoomFactor)
{
var fontZoomFactorInt = Math.Round(fontZoomFactor);
if (fontZoomFactorInt >= _minimumZoomFactor && fontZoomFactorInt <= _maximumZoomFactor)
FontSize = (fontZoomFactorInt / 100) * EditorSettingsService.EditorFontSize;
FontSize = (fontZoomFactorInt / 100) * AppSettingsService.EditorFontSize;
}

public async Task PastePlainTextFromWindowsClipboard(TextControlPasteEventArgs args)
Expand Down
4 changes: 2 additions & 2 deletions src/Notepads/Core/NotepadsCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ await _dispatcher.CallOnUIThreadAsync(() =>
public void OpenNewTextEditor(string fileNamePlaceholder)
{
var textFile = new TextFile(string.Empty,
EditorSettingsService.EditorDefaultEncoding,
EditorSettingsService.EditorDefaultLineEnding);
AppSettingsService.EditorDefaultEncoding,
AppSettingsService.EditorDefaultLineEnding);
var newEditor = CreateTextEditor(
Guid.NewGuid(),
textFile,
Expand Down
2 changes: 1 addition & 1 deletion src/Notepads/Notepads.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
<Compile Include="Utilities\EncodingUtility.cs" />
<Compile Include="Brushes\HostBackdropAcrylicBrush.cs" />
<Compile Include="Utilities\LineEndingUtility.cs" />
<Compile Include="Services\EditorSettingsService.cs" />
<Compile Include="Services\AppSettingsService.cs" />
<Compile Include="Services\ThemeSettingsService.cs" />
<Compile Include="Controls\Dialog\NotepadsDialog.cs" />
<Compile Include="Utilities\SearchEngineUtility.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Windows.UI.Text;
using Windows.UI.Xaml;

public static class EditorSettingsService
public static class AppSettingsService
{
public static event EventHandler<string> OnFontFamilyChanged;
public static event EventHandler<FontStyle> OnFontStyleChanged;
Expand Down Expand Up @@ -444,7 +444,7 @@ private static void InitializeDecodingSettings()
}
catch (Exception ex)
{
LoggingService.LogError($"[{nameof(EditorSettingsService)}] Failed to get encoding, code page: {decodingCodePage}, ex: {ex.Message}");
LoggingService.LogError($"[{nameof(AppSettingsService)}] Failed to get encoding, code page: {decodingCodePage}, ex: {ex.Message}");
_editorDefaultDecoding = null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Notepads/Utilities/FileSystemUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private static StreamReader CreateStreamReader(Stream stream, byte[] bom, Encodi
}
else // No BOM, need to guess or use default decoding set by user
{
if (EditorSettingsService.EditorDefaultDecoding == null)
if (AppSettingsService.EditorDefaultDecoding == null)
{
var success = TryGuessEncoding(stream, out var autoEncoding);
stream.Position = 0; // Reset stream position
Expand All @@ -313,7 +313,7 @@ private static StreamReader CreateStreamReader(Stream stream, byte[] bom, Encodi
}
else
{
reader = new StreamReader(stream, EditorSettingsService.EditorDefaultDecoding);
reader = new StreamReader(stream, AppSettingsService.EditorDefaultDecoding);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Notepads/Utilities/SearchEngineUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class SearchEngineUtility

public static string GetSearchUrlBySearchEngine(SearchEngine searchEngine)
{
return searchEngine != SearchEngine.Custom ? SearchEngineUrlDictionary[searchEngine] : EditorSettingsService.EditorCustomMadeSearchUrl;
return searchEngine != SearchEngine.Custom ? SearchEngineUrlDictionary[searchEngine] : AppSettingsService.EditorCustomMadeSearchUrl;
}
}
}
Loading

0 comments on commit 63abda3

Please sign in to comment.