refactor: updated .Net version, removed unused vars, cleanup of code

This commit is contained in:
nikita_ve 2025-01-19 19:35:29 +03:00
parent e8670a252c
commit cc66ee9d0e
4 changed files with 14 additions and 20 deletions

View File

@ -10,7 +10,7 @@ namespace FractalTreeGtk
internal class CairoWindow : Window
{
private int FractalLevels { get; set; } = 2;
readonly DrawingArea _drawing = new DrawingArea();
readonly DrawingArea _drawing = new();
Fractal _fractal = null!;
public CairoWindow(string title) : base(title)
@ -44,9 +44,9 @@ namespace FractalTreeGtk
FractalLevels--;
GenerateFractal();
}
break;
case Key.r: //Regenerate fractal
case Key.R:
GenerateFractal();
break;
}

View File

@ -6,11 +6,10 @@ namespace FractalTreeGtk.Draw
{
private readonly CairoWindow _window;
private double Length { get; set; } = new Random().Next(70, 90);
private int MaxLevels { get; set; }
private int CurrentLevel { get; set; } = 0;
public bool IsDrawing { private set; get; }
private int MaxLevels { get; }
private int CurrentLevel { get; set; }
private double Degree => new Random().Next(30, 50) / 100f;
private double DeltaLength => new Random().Next(0, 50) / 100f;
private double DeltaLength => new Random().Next(0, 20) / (float)Math.Log2(CurrentLevel+1);
public Branch[][] FractalLines { get; }
@ -38,7 +37,7 @@ namespace FractalTreeGtk.Draw
{
_window.QueueDraw();
var len = DeltaLength;
if (Length < DeltaLength)
if (Length < 0)
Length = DeltaLength;
else
Length -= DeltaLength;
@ -94,7 +93,6 @@ namespace FractalTreeGtk.Draw
{
NextLevel();
}
else IsDrawing = false;
}
}
}

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

View File

@ -1,18 +1,14 @@
using Gtk;
namespace FractalTreeGtk
{
namespace FractalTreeGtk;
internal class Program
{
static void Main(string[] args)
static void Main()
{
Application.Init();
//Create the Window
Window myWin = new CairoWindow("My first GTK# Application! ");
_ = new CairoWindow("Fractal window");
Application.Run();
}
}
}