This commit is contained in:
Sven Vogel 2021-06-09 21:19:30 +02:00
parent 6230473ec6
commit eaa39704b4
19 changed files with 77 additions and 40 deletions

View File

@ -37,6 +37,6 @@
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Remove="SplashScreen.resx" /> <EmbeddedResource Remove="SplashScreen.resx" />
<None Remove="Resources\pfüsikuh.png" /> <None Remove="Resources\pfüsikuh.png" />
<EmbeddedResource Include="Resources\pfüsikuh.png" /> <None Remove="Utils.cs~" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -63,7 +63,7 @@ namespace Matrix_App
// apply light-mode by default // apply light-mode by default
new LightMode().ApplyTheme(this); new LightMode().ApplyTheme(this);
} }
private void Init() private void Init()
{ {
// Create port name update timer // Create port name update timer
@ -99,7 +99,7 @@ namespace Matrix_App
if (((int) DateTime.Now.DayOfWeek) != 3) if (((int) DateTime.Now.DayOfWeek) != 3)
return; return;
if (new Random().Next(0, 9) <= 1) if (new Random().Next(0, 9) >= 1)
return; return;
using (Bitmap wednesdayFrog = new Bitmap(Properties.Resources.Frosch)) using (Bitmap wednesdayFrog = new Bitmap(Properties.Resources.Frosch))
@ -646,7 +646,7 @@ namespace Matrix_App
{ {
if (Timeline.InvokeRequired) if (Timeline.InvokeRequired)
{ {
// invoke on the comboboxes thread // invoke on the combo-boxes thread
Timeline.Invoke(new Action(() => Timeline.Invoke(new Action(() =>
{ {
if (Timeline.Value < Timeline.Maximum) if (Timeline.Value < Timeline.Maximum)

View File

@ -1,5 +1,6 @@
using Matrix_App.PregeneratedMods; using Matrix_App.PregeneratedMods;
using System; using System;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -85,8 +86,8 @@ namespace Matrix_App
}; };
button.Click += (sender, e) => OpenGeneratorUi(generator, matrix); button.Click += (sender, e) => OpenGeneratorUi(generator, matrix);
button.Image = CreateSnapshot(generator); button.Image = CreateSnapshot(generator);
button.TextImageRelation = TextImageRelation.ImageAboveText; button.TextImageRelation = TextImageRelation.ImageBeforeText;
button.Height = FilterPreviewHeight * 2; button.Height = FilterPreviewHeight * 3 / 2;
anchor.Controls.Add(button); anchor.Controls.Add(button);
} }
@ -179,7 +180,7 @@ namespace Matrix_App
PlaybackTimer.Interval = _form.GetDelayTime(); PlaybackTimer.Interval = _form.GetDelayTime();
PlaybackTimer.Enabled = true; PlaybackTimer.Enabled = true;
CreateDivider(controlPanel); CreateDivider(controlPanel, 2);
foreach (var field in fields) foreach (var field in fields)
{ {
if (field.IsStatic || !field.IsPublic) if (field.IsStatic || !field.IsPublic)
@ -187,23 +188,11 @@ namespace Matrix_App
var fieldValue = field.GetValue(_generator); var fieldValue = field.GetValue(_generator);
controlPanel.Controls.Add(GetFieldUi(field, fieldValue, _generator)); controlPanel.Controls.AddRange(GetFieldUi(field, _generator.GetType(), fieldValue, _generator));
} CreateDivider(controlPanel, 1);
if (controlPanel.Controls.Count > 1)
{
CreateDivider(controlPanel);
var label = new Label() { Text = "Settings" };
label.Font = new Font(label.Font, FontStyle.Bold);
controlPanel.Controls.Add(label);
} }
controlPanel.Controls.Add(_preview); controlPanel.Controls.Add(_preview);
CreateDivider(controlPanel);
var playLabel = new Label() { Text = "Playback preview" };
playLabel.Font = new Font(playLabel.Font, FontStyle.Bold);
controlPanel.Controls.Add(playLabel);
FlowLayoutPanel southPane = new FlowLayoutPanel FlowLayoutPanel southPane = new FlowLayoutPanel
{ {
@ -229,7 +218,7 @@ namespace Matrix_App
return success; return success;
} }
private static Control GetFieldUi(FieldInfo field, object? fieldValue, MatrixGifGenerator generator) private static Control[] GetFieldUi(FieldInfo field, Type clazz, object? fieldValue, MatrixGifGenerator generator)
{ {
var panel = new FlowLayoutPanel var panel = new FlowLayoutPanel
{ {
@ -237,11 +226,24 @@ namespace Matrix_App
Anchor = AnchorStyles.Top | AnchorStyles.Left, Anchor = AnchorStyles.Top | AnchorStyles.Left,
AutoSize = true AutoSize = true
}; };
var title = GetBetterFieldName(field.Name);
var description = new Label();
if (Attribute.GetCustomAttribute(field, typeof(UiDescriptionAttribute)) is UiDescriptionAttribute desc)
{
title = desc.title;
description.Text = desc.description;
description.ForeColor = Color.Gray;
description.Height += 10;
description.AutoSize = true;
}
panel.Controls.Add(new Label panel.Controls.Add(new Label
{ {
TextAlign = System.Drawing.ContentAlignment.MiddleLeft, TextAlign = ContentAlignment.MiddleLeft,
Text = GetBetterFieldName(field.Name), Text = title,
Dock = DockStyle.Left, Dock = DockStyle.Left,
Anchor = AnchorStyles.Top | AnchorStyles.Left, Anchor = AnchorStyles.Top | AnchorStyles.Left,
Width = 100 Width = 100
@ -305,7 +307,7 @@ namespace Matrix_App
} }
} }
return panel; return new Control[] {description, panel};
} }
/// <summary> /// <summary>
@ -354,13 +356,13 @@ namespace Matrix_App
/// Adds a separating line to the controls /// Adds a separating line to the controls
/// </summary> /// </summary>
/// <param name="controlPanel"></param> /// <param name="controlPanel"></param>
private static void CreateDivider(Control controlPanel) private static void CreateDivider(Control controlPanel, int height)
{ {
var divider = new Label var divider = new Label
{ {
BorderStyle = BorderStyle.Fixed3D, BorderStyle = BorderStyle.Fixed3D,
AutoSize = false, AutoSize = false,
Height = 2, Height = height,
Width = 500 Width = 500
}; };

View File

@ -1,12 +1,11 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using static Matrix_App.GifGeneratorUtils; using static Matrix_App.GifGeneratorUtils;
namespace Matrix_App.PregeneratedMods namespace Matrix_App.PregeneratedMods
{ {
public class Boxblur : MatrixGifGenerator public sealed class Boxblur : MatrixGifGenerator
{ {
[UiDescriptionAttribute(title: "Blur size", description: "The side length of the bounding square used to blur in pixels")]
public int blurSize = 2; public int blurSize = 2;
protected override void ColorFragment(in int x, in int y, in float u, in float v, in int frame, out float r, out float g, out float b) protected override void ColorFragment(in int x, in int y, in float u, in float v, in int frame, out float r, out float g, out float b)

View File

@ -7,12 +7,18 @@ namespace Matrix_App.PregeneratedMods
{ {
public sealed class ColorAdjust : MatrixGifGenerator public sealed class ColorAdjust : MatrixGifGenerator
{ {
[UiDescriptionAttribute(title: "Tone offset", description: "Sets an additional offset to the pixels hue")]
public float hueOffset = 0.0f; public float hueOffset = 0.0f;
[UiDescriptionAttribute(title: "Saturation boost", description: "Decreases or increases saturation")]
public float saturationBoost = 0.5f; public float saturationBoost = 0.5f;
[UiDescriptionAttribute(title: "Brightness boost", description: "Decreases or increases brightness")]
public float valueBoost = 0.5f; public float valueBoost = 0.5f;
[UiDescriptionAttribute(title: "Red boost", description: "Decreases or increases Red")]
public float redBoost = 0.5f; public float redBoost = 0.5f;
[UiDescriptionAttribute(title: "Green boost", description: "Decreases or increases Green")]
public float greenBoost = 0.5f; public float greenBoost = 0.5f;
[UiDescriptionAttribute(title: "Blue boost", description: "Decreases or increases Blue")]
public float blueBoost = 0.5f; public float blueBoost = 0.5f;
private float boost(float x, float y) private float boost(float x, float y)

View File

@ -7,6 +7,7 @@ namespace Matrix_App.PregeneratedMods
{ {
public sealed class Grayscale : MatrixGifGenerator public sealed class Grayscale : MatrixGifGenerator
{ {
[UiDescriptionAttribute(title: "use Luminance", description: "Use luminance as defined by ITU-R BT.709 as grayscale output")]
public bool byLuminance = false; public bool byLuminance = false;
protected override void ColorFragment(in int x, in int y, in float u, in float v, in int frame, out float r, out float g, out float b) protected override void ColorFragment(in int x, in int y, in float u, in float v, in int frame, out float r, out float g, out float b)

View File

@ -4,6 +4,7 @@ namespace Matrix_App.PregeneratedMods
{ {
public class RandomPixels : MatrixGifGenerator public class RandomPixels : MatrixGifGenerator
{ {
[UiDescriptionAttribute(title: "Seed", description: "Just a seed for a bad deterministic random function")]
public int seed = 0; public int seed = 0;
protected override void ColorFragment(in int x, in int y, in float u, in float v, in int frame, out float r, out float g, out float b) protected override void ColorFragment(in int x, in int y, in float u, in float v, in int frame, out float r, out float g, out float b)

View File

@ -1,17 +1,18 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using static Matrix_App.GifGeneratorUtils; using static Matrix_App.GifGeneratorUtils;
namespace Matrix_App namespace Matrix_App.PregeneratedMods
{ {
public class SimpleRainbow : MatrixGifGenerator public class SimpleRainbow : MatrixGifGenerator
{ {
[UiDescription(title: "Radial", description: "Uses the angle to alter hues")]
public bool radial = false; public bool radial = false;
[UiDescription(title: "Saturation", description: "Overall saturation")]
public float saturation = 1.0f; public float saturation = 1.0f;
[UiDescription(title: "Brightness", description: "Overall brightness")]
public float value = 1.0f; public float value = 1.0f;
[UiDescription(title: "Hue rotation", description: "Offset for hue calculation")]
public float rotation = 0.0f; public float rotation = 0.0f;
protected override void ColorFragment(in int x, in int y, protected override void ColorFragment(in int x, in int y,

View File

@ -0,0 +1,17 @@
using System;
namespace Matrix_App.PregeneratedMods
{
[AttributeUsage(AttributeTargets.Field)]
public class UiDescriptionAttribute : Attribute
{
public string title;
public string description;
public UiDescriptionAttribute(string title, string description)
{
this.title = title;
this.description = description;
}
}
}

View File

@ -10,17 +10,22 @@ namespace Matrix_App
/// </summary> /// </summary>
[STAThread] [STAThread]
private static void Main() private static void Main()
{ {
SplashScreen.ShowSplashScreen();
Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
SplashScreen.ShowSplashScreen();
var designer = new MatrixDesignerMain(); var designer = new MatrixDesignerMain();
SplashScreen.CloseForm(); SplashScreen.CloseForm();
designer.StartPosition = FormStartPosition.CenterScreen;
designer.WindowState = FormWindowState.Minimized;
designer.Show();
designer.WindowState = FormWindowState.Normal;
Application.Run(designer); Application.Run(designer);
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View File

@ -1,4 +1,5 @@
using System.Threading; using System.Drawing;
using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
namespace Matrix_App namespace Matrix_App
@ -17,8 +18,12 @@ namespace Matrix_App
Controls.Add(new Label() Controls.Add(new Label()
{ {
Image = Properties.Resources.Pfüsikuh Image = Properties.Resources.Pfüsikuh,
Size = new Size(Properties.Resources.Pfüsikuh.Width, Properties.Resources.Pfüsikuh.Height)
}); });
Size = new Size(Properties.Resources.Pfüsikuh.Width, Properties.Resources.Pfüsikuh.Height);
StartPosition = FormStartPosition.CenterScreen;
} }
public static void ShowSplashScreen() public static void ShowSplashScreen()

View File

@ -1 +1 @@
ee8b86baf58d13435f960406ec4b0be78d0cc26c 0e5f843b45897d8b4a3e6250399d748fbf87d606