Skip to content

Commit

Permalink
update localisation. Tidy code
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonyCorbett committed Oct 8, 2021
1 parent 4309b6a commit 9bb7cb1
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,9 @@ dotnet_diagnostic.S3928.severity = silent

# SA1009: Closing parenthesis should be spaced correctly
dotnet_diagnostic.SA1009.severity = silent

# CC0021: Use nameof
dotnet_diagnostic.CC0021.severity = silent

# CC0022: Should dispose object
dotnet_diagnostic.CC0022.severity = silent
4 changes: 3 additions & 1 deletion OnlyM.Core/Services/CommandLine/CommandLineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ public CommandLineService()
}
}
#pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception.
#pragma warning disable CC0004 // Catch block cannot be empty
catch (Exception)
#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception.
{
// ignored
}
#pragma warning restore CC0004 // Catch block cannot be empty
#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception.

return null;
}
Expand Down
4 changes: 3 additions & 1 deletion OnlyM.Core/Services/WebShortcuts/WebShortcutHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ private void Init()
}
}
#pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception.
#pragma warning disable CC0004 // Catch block cannot be empty
catch (Exception)
#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception.
{
// nothing
}
#pragma warning restore CC0004 // Catch block cannot be empty
#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception.
finally
{
_initialised = true;
Expand Down
12 changes: 8 additions & 4 deletions OnlyM.CoreSys/GraphicsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ public static bool AutoRotateIfRequired(string? itemFilePath)
{
AutoRotateIfRequired(itemFilePath);

var settings = new ProcessImageSettings { Width = width, Height = height };
settings.ResizeMode = CropScaleMode.Pad;
settings.MatteColor = System.Drawing.Color.Black;

var settings = new ProcessImageSettings
{
Width = width,
Height = height,
ResizeMode = CropScaleMode.Pad,
MatteColor = System.Drawing.Color.Black
};

using var outStream = new MemoryStream();
MagicImageProcessor.ProcessImage(itemFilePath, outStream, settings);
outStream.Seek(0L, SeekOrigin.Begin);
Expand Down
2 changes: 1 addition & 1 deletion OnlyM/Services/MetaDataQueue/MetaDataQueueProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace OnlyM.Services.MetaDataQueue
{
internal sealed class MetaDataQueueProducer : IDisposable
{
public BlockingCollection<MediaItem> Queue { get; } = new BlockingCollection<MediaItem>();
public BlockingCollection<MediaItem> Queue { get; } = new();

public void Add(MediaItem mediaItem)
{
Expand Down
5 changes: 1 addition & 4 deletions OnlyM/Services/Pages/PageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ public void GotoOperatorPage()

public void GotoSettingsPage()
{
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
var _ = _settingsPage.Value; // ensure created otherwise doesn't receive navigation event
#pragma warning restore SA1312 // Variable names should begin with lower-case letter

_ = _settingsPage.Value; // ensure created otherwise doesn't receive navigation event
_operatorPageScrollerPosition = ScrollViewer?.VerticalOffset ?? 0.0;
OnNavigationEvent(new NavigationEventArgs { PageName = SettingsPageName });
}
Expand Down
2 changes: 1 addition & 1 deletion OnlyM/ViewModel/OperatorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ private void HandleAllowMirrorChangedEvent(object? sender, EventArgs e)
private static bool IsInDesignMode()
{
#if DEBUG
DependencyObject dep = new();
var dep = new DependencyObject();
return DesignerProperties.GetIsInDesignMode(dep);
#else
return false;
Expand Down
2 changes: 2 additions & 0 deletions OnlyM/ViewModel/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,10 +1215,12 @@ private static LanguageItem[] GetSupportedLanguages()
LanguageName = c.EnglishName,
});
}
#pragma warning disable CC0004 // Catch block cannot be empty
catch (CultureNotFoundException)
{
// expected
}
#pragma warning restore CC0004 // Catch block cannot be empty
}
}

Expand Down
2 changes: 1 addition & 1 deletion OnlyM/Windows/OperatorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static void HandleMirrorCheckBoxChanged(object? sender, bool isChecked)

private void OnlyMOperatorPage_SizeChanged(object? sender, SizeChangedEventArgs e)
{
OperatorViewModel vm = (OperatorViewModel)DataContext;
var vm = (OperatorViewModel?)DataContext;

if (vm == null)
{
Expand Down
8 changes: 4 additions & 4 deletions OnlyMSlideManager/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ public MainViewModel(
AddDesignTimeItems();

// init options so that UI locale is set (forces lazy init)
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
var _ = _optionsService.Culture;
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
_ = _optionsService.Culture;

InitCommands();
WeakReferenceMessenger.Default.Register<ReorderMessage>(this, OnReorderMessage);
Expand Down Expand Up @@ -1021,10 +1019,12 @@ private static LanguageItem[] GetSupportedLanguages()
LanguageName = c.EnglishName,
});
}
#pragma warning disable CC0004 // Catch block cannot be empty
catch (CultureNotFoundException)
{
// expected
}
#pragma warning restore CC0004 // Catch block cannot be empty
}
}

Expand All @@ -1050,7 +1050,7 @@ private string GetStandardStatusText()
private static bool IsInDesignMode()
{
#if DEBUG
DependencyObject dep = new();
var dep = new DependencyObject();
return DesignerProperties.GetIsInDesignMode(dep);
#else
return false;
Expand Down
2 changes: 1 addition & 1 deletion SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en-GB")]

[assembly: AssemblyVersion("2.0.0.11")]
[assembly: AssemblyVersion("2.0.0.12")]

0 comments on commit 9bb7cb1

Please sign in to comment.