Skip to content

Commit

Permalink
Небольшие правки
Browse files Browse the repository at this point in the history
1. Методы и свойства, которые не обращаются к данным экземпляра, должны быть статическими
2. Удалил неиспользуемые части кода
  • Loading branch information
SashaXser committed Aug 20, 2024
1 parent ee2f02d commit 171eff3
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 24 deletions.
2 changes: 1 addition & 1 deletion App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public App()
/// <summary>
/// Existing windows registration for windows service.
/// </summary>
private void RegisterWindows()
private static void RegisterWindows()
{
var windowService = GetService<IWindowService>();
windowService.Register<SelectionWindow>();
Expand Down
4 changes: 2 additions & 2 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ private void MainWindowStateChangeRaised(object sender, EventArgs e)
}
}

private void Expander_Expanded(object sender, RoutedEventArgs e)
private static void Expander_Expanded(object sender, RoutedEventArgs e)
{
if (ExpandedArea == null)
return;

Height += ExpandedArea.ActualHeight;
}

private void Expander_Collapsed(object sender, RoutedEventArgs e)
private static void Expander_Collapsed(object sender, RoutedEventArgs e)
{
Height -= ExpandedArea.ActualHeight;
}
Expand Down
4 changes: 2 additions & 2 deletions Models/SettingsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public SettingsModel()
/// <summary>
/// Reset window positions to 0.
/// </summary>
public void ResetWindowPositions()
public static void ResetWindowPositions()
{
SelectionWindowPosition.Left = 0;
SelectionWindowPosition.Top = 0;
Expand All @@ -73,7 +73,7 @@ public void ResetWindowPositions()
/// <summary>
/// Reset settings to default values.
/// </summary>
public void ResetToDefault()
public static void ResetToDefault()
{
FontSize = 21;
Key = new Key(0x7B);
Expand Down
2 changes: 1 addition & 1 deletion Services/ExecutionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void Stop()
/// </summary>
/// <param name="model">Языковая модель.</param>
/// <returns>Модель OCR для указанного языка.</returns>
private FullOcrModel GetOcrModel(Enumerations.Model model)
private static FullOcrModel GetOcrModel(Enumerations.Model model)
{
if (model == Enumerations.Model.English)
{
Expand Down
2 changes: 1 addition & 1 deletion Services/ParametersService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ScreTran;

public partial class ParametersService : ObservableObject, IParametersService
public partial class ParametersService : ObservableObject
{
/// <summary>
/// Translated line.
Expand Down
2 changes: 1 addition & 1 deletion Services/TranslationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private async Task<string> TranslateAsync(string input, Enumerations.Translator
/// </summary>
/// <param name="input">input text.</param>
/// <returns>Translated text.</returns>
public async Task<string> TranslateGoogleAsync(string input)
public static async Task<string> TranslateGoogleAsync(string input)
{
var to = "ru";
var url = $"https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl={to}&dt=t&q={HttpUtility.UrlEncode(input)}";
Expand Down
8 changes: 1 addition & 7 deletions Services/WindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@ public class WindowService : IWindowService
/// </summary>
private readonly Dictionary<string, Window> _createdWindows;

/// <summary>
/// List of windows always on top.
/// </summary>
private readonly List<Window> _onTopWindows;

public WindowService()
{
_owner = null;
_ownerHandle = IntPtr.Zero;
_windows = new();
_createdWindows = new();
_onTopWindows = new();

_timer = new Timer(ProccessByTimerCommands, null, 0, 1000);
}
Expand Down Expand Up @@ -93,7 +87,7 @@ public void Show(string windowName)
_createdWindows[windowName] = (Window)App.GetService(_windows[windowName]);
}

if (_owner?.IsLoaded == true && !Equals(_owner, _createdWindows[windowName]))
if (_owner?.IsLoaded && !Equals(_owner, _createdWindows[windowName]))
_createdWindows[windowName].Owner = _owner;

_createdWindows[windowName].Show();
Expand Down
2 changes: 1 addition & 1 deletion Views/SelectionWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
CaptureMouse();
}

private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
private static void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
ReleaseMouseCapture();
}
Expand Down
2 changes: 1 addition & 1 deletion Views/TranslationWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
CaptureMouse();
}

private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
private static void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
ReleaseMouseCapture();
}
Expand Down
8 changes: 1 addition & 7 deletions XAMLConverters/BoolToInvertedBoolConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ namespace ScreTran;

class BoolToInvertedBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var boolValue = (bool)value;
return !boolValue;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public static object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var boolValue = (bool)value;
return !boolValue;
Expand Down

0 comments on commit 171eff3

Please sign in to comment.