Skip to content

Commit

Permalink
Misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 committed Jun 5, 2024
1 parent f490971 commit f852baa
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion QRCoder/PayloadGenerator/SlovenianUpnQr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public SlovenianUpnQr(string payerName, string payerAddress, string payerPlace,
private string FormatAmount(double amount)
{
int _amt = (int)Math.Round(amount * 100.0);
return String.Format("{0:00000000000}", _amt);
return string.Format("{0:00000000000}", _amt);
}

/// <summary>
Expand Down
4 changes: 1 addition & 3 deletions QRCoder/QRCodeGenerator/Polynom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ public void Sort(Func<PolynomItem, PolynomItem, int> comparer)
if (comparer == null)
throw new ArgumentNullException(nameof(comparer));

var items = _polyItems;
if (items == null)
throw new ObjectDisposedException(nameof(Polynom));
var items = _polyItems ?? throw new ObjectDisposedException(nameof(Polynom));

if (Count <= 1)
{
Expand Down
10 changes: 5 additions & 5 deletions QRCoderConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ namespace QRCoderConsole;

#if NET6_0_WINDOWS
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
internal
#endif
class MainClass
internal class MainClass
{
public static void Main(string[] args)
{
var friendlyName = AppDomain.CurrentDomain.FriendlyName;
var newLine = Environment.NewLine;
var setter = new OptionSetter();

String fileName = null, outputFileName = null, payload = null;
string fileName = null, outputFileName = null, payload = null;

var eccLevel = QRCodeGenerator.ECCLevel.L;
var imageFormat = SupportedImageFormat.Png;
Expand All @@ -39,7 +40,7 @@ public static void Main(string[] args)
},
{ "f|output-format=",
$"Image format for outputfile. Possible values: {string.Join(", ", Enum.GetNames(typeof(SupportedImageFormat)))} (default: png)",
value => { Enum.TryParse(value, true, out imageFormat); }
value => Enum.TryParse(value, true, out imageFormat)
},
{
"i|in=",
Expand Down Expand Up @@ -229,9 +230,8 @@ public class OptionSetter
{
public QRCodeGenerator.ECCLevel GetECCLevel(string value)
{
QRCodeGenerator.ECCLevel level;

Enum.TryParse(value, out level);
Enum.TryParse(value, out QRCodeGenerator.ECCLevel level);

return level;
}
Expand Down
23 changes: 11 additions & 12 deletions QRCoderDemo/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ private Bitmap GetIconBitmap()

private void selectIconBtn_Click(object sender, EventArgs e)
{
var openFileDlg = new OpenFileDialog();
openFileDlg.Title = "Select icon";
openFileDlg.Multiselect = false;
openFileDlg.CheckFileExists = true;
var openFileDlg = new OpenFileDialog
{
Title = "Select icon",
Multiselect = false,
CheckFileExists = true
};
if (openFileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
iconPath.Text = openFileDlg.FileName;
Expand All @@ -82,9 +84,11 @@ private void btn_save_Click(object sender, EventArgs e)
{

// Displays a SaveFileDialog so the user can save the Image
var saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "Bitmap Image|*.bmp|PNG Image|*.png|JPeg Image|*.jpg|Gif Image|*.gif";
saveFileDialog1.Title = "Save an Image File";
var saveFileDialog1 = new SaveFileDialog
{
Filter = "Bitmap Image|*.bmp|PNG Image|*.png|JPeg Image|*.jpg|Gif Image|*.gif",
Title = "Save an Image File"
};
saveFileDialog1.ShowDialog();

// If the file name is not an empty string open it for saving.
Expand All @@ -109,11 +113,6 @@ private void btn_save_Click(object sender, EventArgs e)
}
}

public void ExportToBmp(string path)
{

}

private void textBoxQRCode_TextChanged(object sender, EventArgs e)
{
RenderQrCode();
Expand Down
4 changes: 2 additions & 2 deletions QRCoderDemo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

namespace QRCoderDemo;

static class Program
internal static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Expand Down
9 changes: 4 additions & 5 deletions QRCoderDemoUWP/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -20,7 +20,7 @@ namespace QRCoderDemoUWP
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
internal sealed partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
Expand All @@ -45,11 +45,10 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
DebugSettings.EnableFrameRateCounter = true;
}
#endif
var rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
if (!(Window.Current.Content is Frame rootFrame))
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
Expand Down Expand Up @@ -84,7 +83,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
Expand Down
2 changes: 2 additions & 0 deletions QRCoderTests/Helpers/CategoryDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace QRCoderTests.Helpers.XUnitExtenstions;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class CategoryAttribute : Attribute
{
#pragma warning disable IDE0060 // Remove unused parameter
public CategoryAttribute(string category) { }
#pragma warning restore IDE0060 // Remove unused parameter
}
#else
public class CategoryDiscoverer : ITraitDiscoverer
Expand Down

0 comments on commit f852baa

Please sign in to comment.