Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Jan 12, 2024
1 parent a488951 commit c68b7d7
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 58 deletions.
2 changes: 1 addition & 1 deletion JL.Core/Anki/Mining.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static async Task MineToFile(LookupResult lookupResult, string currentTex
{
_ = lineToMine.Append(CultureInfo.InvariantCulture, $"{jlField.GetDescription()}: ")
.Append(jlFieldContent)
.Append(i < jlFields.Length - 1 ? '\t' : '\n');
.Append(i < (jlFields.Length - 1) ? '\t' : '\n');
}
}

Expand Down
4 changes: 2 additions & 2 deletions JL.Core/Deconjugation/Deconjugator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ internal static class Deconjugator
}

// deconjugated form too much longer than conjugated form
if (myForm.Text.Length > myForm.OriginalText.Length + 10)
if (myForm.Text.Length > (myForm.OriginalText.Length + 10))
{
return null;
}

// impossibly information-dense
if (myForm.Tags.Count > myForm.OriginalText.Length + 6)
if (myForm.Tags.Count > (myForm.OriginalText.Length + 6))
{
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion JL.Core/Dicts/EDICT/JMdict/JmdictRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public string BuildFormattedDefinition(DictOptions? options)
_ = defResult.Append(CultureInfo.InvariantCulture, $": {lSource.OriginalWord}");
}

if (j + 1 < lSources.Length)
if ((j + 1) < lSources.Length)
{
_ = defResult.Append(lSource.IsPart ? " + " : ", ");
}
Expand Down
6 changes: 3 additions & 3 deletions JL.Core/Lookup/LookupFrequencyResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ namespace JL.Core.Lookup;

public sealed class LookupFrequencyResult
{
public string Name { get; }
public int Freq { get; }
internal string Name { get; }
internal int Freq { get; }

public bool HigherValueMeansHigherFrequency { get; }
internal bool HigherValueMeansHigherFrequency { get; }

internal LookupFrequencyResult(string name, int freq, bool higherValueMeansHigherFrequency)
{
Expand Down
6 changes: 3 additions & 3 deletions JL.Core/Lookup/LookupResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public sealed class LookupResult
public List<LookupFrequencyResult>? Frequencies { get; }

// JMdict, JMnedict, KANJIDIC2
public int EdictId { get; }
internal int EdictId { get; }

// Word dictionaries
public string DeconjugatedMatchedText { get; }
internal string DeconjugatedMatchedText { get; }
public string? DeconjugationProcess { get; }
// JMdict, Nazeka EPWING
public string[]? AlternativeSpellings { get; }
public string[]? PrimarySpellingOrthographyInfoList { get; }
public string[]?[]? ReadingsOrthographyInfoList { get; }
public string[]?[]? AlternativeSpellingsOrthographyInfoList { get; }
public string[]?[]? MiscList { get; }
internal string[]?[]? MiscList { get; }

// Kanji
public string[]? OnReadings { get; }
Expand Down
6 changes: 3 additions & 3 deletions JL.Core/Lookup/LookupResultUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Text;

namespace JL.Core.Lookup;
public class LookupResultUtils
public static class LookupResultUtils
{
internal static string? ProcessDeconjugationProcess(List<List<string>>? processList)
{
Expand Down Expand Up @@ -116,7 +116,7 @@ public static string ReadingsToText(string[] readings, string[]?[] rOrthographyI
}
}

if (index != readings.Length - 1)
if (index != (readings.Length - 1))
{
_ = sb.Append(", ");
}
Expand Down Expand Up @@ -144,7 +144,7 @@ public static string AlternativeSpellingsToText(string[] alternativeSpellings, s
}
}

if (index != alternativeSpellings.Length - 1)
if (index != (alternativeSpellings.Length - 1))
{
_ = sb.Append(", ");
}
Expand Down
13 changes: 5 additions & 8 deletions JL.Core/Lookup/LookupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,14 @@ private static List<LookupResult> SortLookupResults(IEnumerable<LookupResult> lo
}
}

if (lookupResult.ReadingsOrthographyInfoList is not null)
string[]? readingsOrthographyInfo = lookupResult.ReadingsOrthographyInfoList?[index];
if (readingsOrthographyInfo is not null)
{
string[]? readingsOrthographyInfo = lookupResult.ReadingsOrthographyInfoList[index];
if (readingsOrthographyInfo is not null)
for (int i = 0; i < readingsOrthographyInfo.Length; i++)
{
for (int i = 0; i < readingsOrthographyInfo.Length; i++)
if (readingsOrthographyInfo[i] is "ok" or "ik" or "rk")
{
if (readingsOrthographyInfo[i] is "ok" or "ik" or "rk")
{
return 2;
}
return 2;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions JL.Core/Utilities/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal static List<string> ListUnicodeCharacters(this string s)
for (int i = 0; i < s.Length; i++)
{
if (char.IsHighSurrogate(s, i)
&& s.Length > i + 1
&& s.Length > (i + 1)
&& char.IsLowSurrogate(s, i + 1))
{
textBlocks.Add(char.ConvertFromUtf32(char.ConvertToUtf32(s, i)));
Expand Down Expand Up @@ -77,7 +77,7 @@ internal static T[] RemoveAt<T>(this T[] source, int index)
Array.Copy(source, destination, index);
}

if (index < source.Length - 1)
if (index < (source.Length - 1))
{
Array.Copy(source, index + 1, destination, index, source.Length - index - 1);
}
Expand Down
10 changes: 5 additions & 5 deletions JL.Core/Utilities/JapaneseUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ internal static List<string> LongVowelMarkToKana(string text)
listSize = stringBuilders.Count;
for (int j = 0; j < listSize; j++)
{
_ = stringBuilders[j].Append(j < listSize / 2 ? vowel : alternativeVowel);
_ = stringBuilders[j].Append(j < (listSize / 2) ? vowel : alternativeVowel);
}
}
}
Expand All @@ -231,7 +231,7 @@ public static List<string> CreateCombinedForm(string text)

for (int i = 0; i < text.Length; i++)
{
if (i + 1 < text.Length
if ((i + 1) < text.Length
&& s_smallCombiningKanaSet.Contains(text[i + 1]))
{
combinedForm.Add(string.Create(CultureInfo.InvariantCulture, $"{text[i]}{text[i + 1]}"));
Expand Down Expand Up @@ -268,7 +268,7 @@ public static int FindExpressionBoundary(string text, int position)
return endPosition;
}

public static string FindSentence(string text, int position)
internal static string FindSentence(string text, int position)
{
int startPosition = -1;
int endPosition = -1;
Expand Down Expand Up @@ -330,7 +330,7 @@ public static string FindSentence(string text, int position)
int numberOfLeftBrackets = sentence.Count(p => p == sentence[0]);
int numberOfRightBrackets = sentence.Count(p => p == rightBracket);

if (numberOfLeftBrackets == numberOfRightBrackets + 1)
if (numberOfLeftBrackets == (numberOfRightBrackets + 1))
{
sentence = sentence[1..];
}
Expand All @@ -350,7 +350,7 @@ public static string FindSentence(string text, int position)
int numberOfLeftBrackets = sentence.Count(p => p == leftBracket);
int numberOfRightBrackets = sentence.Count(p => p == sentence[^1]);

if (numberOfRightBrackets == numberOfLeftBrackets + 1)
if (numberOfRightBrackets == (numberOfLeftBrackets + 1))
{
sentence = sentence[..^1];
}
Expand Down
4 changes: 2 additions & 2 deletions JL.Windows/GUI/EditDictionaryWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
if (oldDottedLinesOption != newDottedLinesOption)
{
PopupWindowUtils.StrokeDashArray = newDottedLinesOption
? new DoubleCollection() { 1, 1 }
: new DoubleCollection() { 1, 0 };
? new DoubleCollection { 1, 1 }
: new DoubleCollection { 1, 0 };
}
}

Expand Down
12 changes: 6 additions & 6 deletions JL.Windows/GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private async Task Precache(string input, CancellationToken cancellationToken)
continue;
}

int endPosition = input.Length - charPosition > ConfigManager.MaxSearchLength
int endPosition = (input.Length - charPosition) > ConfigManager.MaxSearchLength
? JapaneseUtils.FindExpressionBoundary(input[..(charPosition + ConfigManager.MaxSearchLength)], charPosition)
: JapaneseUtils.FindExpressionBoundary(input, charPosition);

Expand Down Expand Up @@ -1099,7 +1099,7 @@ private void DisplaySettingsChanged(object? sender, EventArgs? e)
double ratioX = oldResolution.Width / WindowsUtils.DpiAwareWorkAreaWidth;
double ratioY = oldResolution.Height / WindowsUtils.DpiAwareWorkAreaHeight;

double fontScale = ratioX * ratioY > 1
double fontScale = (ratioX * ratioY) > 1
? Math.Min(ratioX, ratioY) * 0.75
: Math.Max(ratioX, ratioY) / 0.75;

Expand Down Expand Up @@ -1331,7 +1331,7 @@ private void MainTextBox_ContextMenuOpening(object sender, ContextMenuEventArgs
AddWordMenuItem.IsEnabled = customWordDictReady && profileCustomWordDictReady;

int charIndex = MainTextBox.GetCharacterIndexFromPoint(Mouse.GetPosition(MainTextBox), ConfigManager.HorizontallyCenterMainWindowText);
ContextMenuIsOpening = charIndex >= MainTextBox.SelectionStart && charIndex <= MainTextBox.SelectionStart + MainTextBox.SelectionLength;
ContextMenuIsOpening = charIndex >= MainTextBox.SelectionStart && charIndex <= (MainTextBox.SelectionStart + MainTextBox.SelectionLength);

PopupWindowUtils.HidePopups(FirstPopupWindow);

Expand Down Expand Up @@ -1539,14 +1539,14 @@ private void Swipe(Point currentPosition)
{
//Swipe down
if (MainTextBox.VerticalOffset is 0
&& currentPosition.Y > _swipeStartPoint.Y + 50)
&& currentPosition.Y > (_swipeStartPoint.Y + 50))
{
BacklogUtils.ShowPreviousBacklogItem();
}

//Swipe up
else if (MainTextBox.GetLastVisibleLineIndex() == MainTextBox.LineCount - 1
&& currentPosition.Y < _swipeStartPoint.Y - 50)
else if (MainTextBox.GetLastVisibleLineIndex() == (MainTextBox.LineCount - 1)
&& currentPosition.Y < (_swipeStartPoint.Y - 50))
{
BacklogUtils.ShowNextBacklogItem();
}
Expand Down
4 changes: 2 additions & 2 deletions JL.Windows/GUI/ManageAudioSourcesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private static void PrioritizeAudioSource(AudioSource audioSource)
return;
}

AudioUtils.AudioSources.First(f => f.Value.Priority == audioSource.Priority - 1).Value.Priority += 1;
AudioUtils.AudioSources.First(f => f.Value.Priority == (audioSource.Priority - 1)).Value.Priority += 1;
audioSource.Priority -= 1;
}

Expand All @@ -234,7 +234,7 @@ private static void DeprioritizeAudioSource(AudioSource audioSource)
return;
}

AudioUtils.AudioSources.First(a => a.Value.Priority == audioSource.Priority + 1).Value.Priority -= 1;
AudioUtils.AudioSources.First(a => a.Value.Priority == (audioSource.Priority + 1)).Value.Priority -= 1;
audioSource.Priority += 1;
}

Expand Down
4 changes: 2 additions & 2 deletions JL.Windows/GUI/ManageDictionariesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ private static void PrioritizeDict(Dict dict)
return;
}

DictUtils.Dicts.First(d => d.Value.Priority == dict.Priority - 1).Value.Priority += 1;
DictUtils.Dicts.First(d => d.Value.Priority == (dict.Priority - 1)).Value.Priority += 1;
dict.Priority -= 1;
}

Expand All @@ -381,7 +381,7 @@ private static void DeprioritizeDict(Dict dict)
return;
}

DictUtils.Dicts.First(d => d.Value.Priority == dict.Priority + 1).Value.Priority -= 1;
DictUtils.Dicts.First(d => d.Value.Priority == (dict.Priority + 1)).Value.Priority -= 1;
dict.Priority += 1;
}

Expand Down
4 changes: 2 additions & 2 deletions JL.Windows/GUI/ManageFrequenciesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private static void PrioritizeFreq(Freq freq)
return;
}

FreqUtils.FreqDicts.First(f => f.Value.Priority == freq.Priority - 1).Value.Priority += 1;
FreqUtils.FreqDicts.First(f => f.Value.Priority == (freq.Priority - 1)).Value.Priority += 1;
freq.Priority -= 1;
}

Expand All @@ -281,7 +281,7 @@ private static void DeprioritizeFreq(Freq freq)
return;
}

FreqUtils.FreqDicts.First(f => f.Value.Priority == freq.Priority + 1).Value.Priority -= 1;
FreqUtils.FreqDicts.First(f => f.Value.Priority == (freq.Priority + 1)).Value.Priority -= 1;
freq.Priority += 1;
}

Expand Down
20 changes: 10 additions & 10 deletions JL.Windows/GUI/PopupWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public async Task LookupOnCharPosition(TextBox tb, int charPosition, bool enable
return;
}

int endPosition = tb.Text.Length - charPosition > ConfigManager.MaxSearchLength
int endPosition = (tb.Text.Length - charPosition) > ConfigManager.MaxSearchLength
? JapaneseUtils.FindExpressionBoundary(tb.Text[..(charPosition + ConfigManager.MaxSearchLength)], charPosition)
: JapaneseUtils.FindExpressionBoundary(tb.Text, charPosition);

Expand Down Expand Up @@ -350,8 +350,8 @@ private void UpdatePosition(Point cursorPosition)
double mouseX = cursorPosition.X / WindowsUtils.Dpi.DpiScaleX;
double mouseY = cursorPosition.Y / WindowsUtils.Dpi.DpiScaleY;

bool needsFlipX = ConfigManager.PopupFlipX && mouseX + ActualWidth > WindowsUtils.ActiveScreen.Bounds.X + WindowsUtils.DpiAwareWorkAreaWidth;
bool needsFlipY = ConfigManager.PopupFlipY && mouseY + ActualHeight > WindowsUtils.ActiveScreen.Bounds.Y + WindowsUtils.DpiAwareWorkAreaHeight;
bool needsFlipX = ConfigManager.PopupFlipX && (mouseX + ActualWidth) > (WindowsUtils.ActiveScreen.Bounds.X + WindowsUtils.DpiAwareWorkAreaWidth);
bool needsFlipY = ConfigManager.PopupFlipY && (mouseY + ActualHeight) > (WindowsUtils.ActiveScreen.Bounds.Y + WindowsUtils.DpiAwareWorkAreaHeight);

double newLeft;
double newTop;
Expand Down Expand Up @@ -389,17 +389,17 @@ private void UpdatePosition(Point cursorPosition)
}

// stick to edges if +OOB
if (newLeft + ActualWidth > WindowsUtils.ActiveScreen.Bounds.X + WindowsUtils.DpiAwareWorkAreaWidth)
if ((newLeft + ActualWidth) > (WindowsUtils.ActiveScreen.Bounds.X + WindowsUtils.DpiAwareWorkAreaWidth))
{
newLeft = WindowsUtils.ActiveScreen.Bounds.X + WindowsUtils.DpiAwareWorkAreaWidth - ActualWidth;
}

if (newTop + ActualHeight > WindowsUtils.ActiveScreen.Bounds.Y + WindowsUtils.DpiAwareWorkAreaHeight)
if ((newTop + ActualHeight) > (WindowsUtils.ActiveScreen.Bounds.Y + WindowsUtils.DpiAwareWorkAreaHeight))
{
newTop = WindowsUtils.ActiveScreen.Bounds.Y + WindowsUtils.DpiAwareWorkAreaHeight - ActualHeight;
}

if (mouseX >= newLeft && mouseX <= newLeft + ActualWidth && mouseY >= newTop && mouseY <= newTop + ActualHeight)
if (mouseX >= newLeft && mouseX <= (newLeft + ActualWidth) && mouseY >= newTop && mouseY <= (newTop + ActualHeight))
{
UnavoidableMouseEnter = true;
}
Expand Down Expand Up @@ -1123,9 +1123,9 @@ public StackPanel PrepareResultStackPanel(LookupResult result, int index, int re
_ = bottom.Children.Add(kanjiStatsTextBlock);
}

if (index != resultsCount - 1)
if (index != (resultsCount - 1))
{
_ = bottom.Children.Add(new Separator()
_ = bottom.Children.Add(new Separator
{
Height = 2,
Background = ConfigManager.SeparatorColor,
Expand Down Expand Up @@ -1291,7 +1291,7 @@ private async void Window_PreviewKeyDown(object sender, KeyEventArgs e)

private void SelectNextLookupResult()
{
int nextItemIndex = PopupListView.SelectedIndex + 1 < PopupListView.Items.Count
int nextItemIndex = (PopupListView.SelectedIndex + 1) < PopupListView.Items.Count
? PopupListView.SelectedIndex + 1
: 0;

Expand All @@ -1302,7 +1302,7 @@ private void SelectNextLookupResult()

private void SelectPreviousLookupResult()
{
int nextItemIndex = PopupListView.SelectedIndex - 1 > -1
int nextItemIndex = (PopupListView.SelectedIndex - 1) > -1
? PopupListView.SelectedIndex - 1
: PopupListView.Items.Count - 1;

Expand Down
1 change: 0 additions & 1 deletion JL.Windows/GUI/UserControls/DictOptionsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ public void GenerateDictOptionsElements(DictType dictType)
showDictOptions = true;
}

ShowPitchAccentWithDottedLines? showPitchAccentWithDottedLines = null;
if (ShowPitchAccentWithDottedLines.ValidDictTypes.Contains(dictType))
{
ShowPitchAccentWithDottedLinesCheckBox.IsChecked = true;
Expand Down
6 changes: 3 additions & 3 deletions JL.Windows/Utilities/BacklogUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public static void ShowNextBacklogItem()
return;
}

if (s_currentTextIndex < Backlog.Count - 1)
if (s_currentTextIndex < (Backlog.Count - 1))
{
++s_currentTextIndex;
mainWindow.MainTextBox.Foreground = ConfigManager.MainWindowBacklogTextColor;
}

if (s_currentTextIndex == Backlog.Count - 1)
if (s_currentTextIndex == (Backlog.Count - 1))
{
mainWindow.MainTextBox.Foreground = ConfigManager.MainWindowTextColor;
}
Expand Down Expand Up @@ -84,7 +84,7 @@ public static void DeleteCurrentLine()
--s_currentTextIndex;
}

mainTextBox.Foreground = s_currentTextIndex < Backlog.Count - 1
mainTextBox.Foreground = s_currentTextIndex < (Backlog.Count - 1)
? ConfigManager.MainWindowBacklogTextColor
: ConfigManager.MainWindowTextColor;

Expand Down
Loading

0 comments on commit c68b7d7

Please sign in to comment.