Take over

This commit is contained in:
Sven Vogel 2021-06-09 19:53:36 +02:00
parent b9e9312369
commit 6230473ec6
24 changed files with 395 additions and 225 deletions

View File

@ -0,0 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=Matrix_0020App_002FMatrix/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=Matrix_0020App_002FMatrixDesigner/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=Matrix_0020App_002FProperties_002FResources/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -1,49 +1,48 @@
 
namespace MatrixDesigner namespace Matrix_App
{ {
public sealed class Defaults public static class Defaults
{ {
public static readonly int PORT_NAME_UPDATE_INTERVAL = 5000; public const int PortNameUpdateInterval = 5000;
public static readonly int MATRIX_START_WIDTH = 10; public const int MatrixStartWidth = 10;
public static readonly int MATRIX_START_HEIGHT = 10; public const int MatrixStartHeight = 10;
public static readonly int MATRIX_START_FRAMES = 1; public const int MatrixStartFrames = 1;
public static readonly int MATRIX_LIMITED_WIDTH = 512; public const int MatrixLimitedWidth = 512;
public static readonly int MATRIX_LIMITED_HEIGHT = 512; public const int MatrixLimitedHeight = 512;
public static readonly int BAUD_RATE = 9600; public const int BaudRate = 9600;
public static readonly int READ_TIMEOUT_MS = 5500; public const int ReadTimeoutMs = 5500;
public static readonly int WRITE_TIMEOUT_MS = 5500; public const int WriteTimeoutMs = 5500;
/// <summary> /// <summary>
/// Total count of LEDs at start /// Total count of LEDs at start
/// </summary> /// </summary>
public static readonly int MATRIX_START_LED_COUNT = MATRIX_START_WIDTH * MATRIX_START_HEIGHT * BPP; public static readonly int MATRIX_START_LED_COUNT = MatrixStartWidth * MatrixStartHeight * Bpp;
/// <summary> /// <summary>
/// Number of Bytes Per Pixel: 3 cause Red (1 byte) + Blue (1 Byte) + Green (1 byte) = 3 /// Number of Bytes Per Pixel: 3 cause Red (1 byte) + Blue (1 Byte) + Green (1 byte) = 3
/// </summary> /// </summary>
public static readonly int BPP = 3; public const int Bpp = 3;
public static readonly int FILTER_PREVIEW_WIDTH = 32; public const int FilterPreviewWidth = 32;
public static readonly int FILTER_PREVIEW_HEIGHT = 32; public const int FilterPreviewHeight = 32;
public static readonly int ARDUINO_SUCCESS_BYTE = 21; public const int ArduinoSuccessByte = 21;
public static readonly int ARDUINO_COMMAND_QUEUE_SIZE = 5; public const int ArduinoCommandQueueSize = 5;
public static readonly int ARDUINO_RECIVCE_BUFFER_SIZE = 1 + 1 + 1 + MATRIX_LIMITED_WIDTH * MATRIX_LIMITED_HEIGHT; public const int ArduinoReceiveBufferSize = 1 + 1 + 1 + MatrixLimitedWidth * MatrixLimitedHeight;
public static readonly int DEQUEUE_WAIT_TIMEOUT_COUNTER = 2; public const int DequeueWaitTimeoutCounter = 2;
} }
public sealed class ArduinoInstruction public static class ArduinoInstruction
{ {
public static readonly byte OPCODE_SCALE = 0; public const byte OpcodeScale = 0;
// public static readonly byte OPCODE_SINGLE = 1; public const byte OpcodeImage = 2;
public static readonly byte OPCODE_IMAGE = 2; public const byte OpcodeFill = 3;
public static readonly byte OPCODE_FILL = 3;
public static readonly byte OPCODE_CONFIG = 4; public static readonly byte OPCODE_CONFIG = 4;
} }
} }

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using static MatrixDesigner.Defaults; using static Matrix_App.Defaults;
namespace Matrix_App namespace Matrix_App
{ {
@ -94,7 +94,7 @@ namespace Matrix_App
public static void SampleFrame(in byte[][] sampler, int frame, int x, int y, int width, out float r, out float g, out float b) public static void SampleFrame(in byte[][] sampler, int frame, int x, int y, int width, out float r, out float g, out float b)
{ {
var index = (x + y * width) * BPP; var index = (x + y * width) * Bpp;
// normalize pixel value to [0, 1] // normalize pixel value to [0, 1]
r = sampler[frame][index + 0] * 0.00392156862745f; r = sampler[frame][index + 0] * 0.00392156862745f;

View File

@ -27,6 +27,7 @@
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Remove="SplashScreen.Designer.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -34,5 +35,8 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Remove="SplashScreen.resx" />
<None Remove="Resources\pfüsikuh.png" />
<EmbeddedResource Include="Resources\pfüsikuh.png" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -486,7 +486,7 @@ namespace Matrix_App
this.ZeichnenTextBoxRed.TabIndex = 4; this.ZeichnenTextBoxRed.TabIndex = 4;
this.ZeichnenTextBoxRed.Text = "0"; this.ZeichnenTextBoxRed.Text = "0";
this.ZeichnenTextBoxRed.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.ZeichnenTextBoxRed.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.ZeichnenTextBoxRed.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ZeichnenTextBoxRed_KeyUp); this.ZeichnenTextBoxRed.KeyUp += new System.Windows.Forms.KeyEventHandler(this.DrawTextBoxRed_KeyUp);
// //
// ZeichnenTrackBarRed // ZeichnenTrackBarRed
// //
@ -529,7 +529,7 @@ namespace Matrix_App
this.ZeichnenTextBoxBlue.TabIndex = 6; this.ZeichnenTextBoxBlue.TabIndex = 6;
this.ZeichnenTextBoxBlue.Text = "0"; this.ZeichnenTextBoxBlue.Text = "0";
this.ZeichnenTextBoxBlue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.ZeichnenTextBoxBlue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.ZeichnenTextBoxBlue.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ZeichnenTextBoxBlue_KeyUp); this.ZeichnenTextBoxBlue.KeyUp += new System.Windows.Forms.KeyEventHandler(this.DrawTextBoxBlue_KeyUp);
// //
// ZeichnenTextBoxGreen // ZeichnenTextBoxGreen
// //
@ -539,7 +539,7 @@ namespace Matrix_App
this.ZeichnenTextBoxGreen.TabIndex = 5; this.ZeichnenTextBoxGreen.TabIndex = 5;
this.ZeichnenTextBoxGreen.Text = "0"; this.ZeichnenTextBoxGreen.Text = "0";
this.ZeichnenTextBoxGreen.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.ZeichnenTextBoxGreen.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.ZeichnenTextBoxGreen.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ZeichnenTextBoxGreen_KeyUp); this.ZeichnenTextBoxGreen.KeyUp += new System.Windows.Forms.KeyEventHandler(this.DrawTextBoxGreen_KeyUp);
// //
// Clear // Clear
// //
@ -552,7 +552,7 @@ namespace Matrix_App
this.Clear.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.Clear.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.Clear.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.Clear.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
this.Clear.UseVisualStyleBackColor = true; this.Clear.UseVisualStyleBackColor = true;
this.Clear.Click += new System.EventHandler(this.ZeichnenClear_Click); this.Clear.Click += new System.EventHandler(this.DrawClear_Click);
// //
// fill // fill
// //
@ -565,7 +565,7 @@ namespace Matrix_App
this.fill.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.fill.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.fill.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; this.fill.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
this.fill.UseVisualStyleBackColor = true; this.fill.UseVisualStyleBackColor = true;
this.fill.Click += new System.EventHandler(this.ZeichnenFill_Click); this.fill.Click += new System.EventHandler(this.DrawFill_Click);
// //
// ZeichnenFarbRad // ZeichnenFarbRad
// //

View File

@ -3,27 +3,22 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.Diagnostics.CodeAnalysis;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO.Ports; using System.IO.Ports;
using System.Timers; using System.Timers;
using System.Diagnostics;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Runtime.CompilerServices;
using System.IO; using System.IO;
using System.Management; using System.Management;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using static MatrixDesigner.Defaults; using static Matrix_App.Defaults;
using static MatrixDesigner.ArduinoInstruction; using static Matrix_App.ArduinoInstruction;
using static Matrix_App.Utils; using static Matrix_App.Utils;
using Matrix_App.Themes; using Matrix_App.Themes;
using Timer = System.Timers.Timer;
namespace Matrix_App namespace Matrix_App
{ {
@ -35,21 +30,21 @@ namespace Matrix_App
/// Port update Timer /// Port update Timer
/// Reloads available port names at consecutive rates /// Reloads available port names at consecutive rates
/// </summary> /// </summary>
private System.Timers.Timer portNameUpdater; private Timer? portNameUpdater;
private System.Timers.Timer delay; private Timer? delay;
private static SerialPort port = new SerialPort(); private static SerialPort _port = new SerialPort();
private uint portNumber; private uint portNumber;
private bool runningGif = false; private bool runningGif;
private PortCommandQueue commandQueue = new PortCommandQueue(ref port); private readonly PortCommandQueue commandQueue = new PortCommandQueue(ref _port);
private Regex comRegex = new Regex(@"COM[\d]+"); private readonly Regex comRegex = new Regex(@"COM[\d]+");
/// <summary> /// <summary>
/// Gif like frame video buffer /// Gif like frame video buffer
/// </summary> /// </summary>
public byte[][] Gif = CreateImageRGB_NT(MATRIX_START_WIDTH, MATRIX_START_HEIGHT, MATRIX_START_FRAMES); public byte[][] gifBuffer = CreateImageRGB_NT(MatrixStartWidth, MatrixStartHeight, MatrixStartFrames);
#endregion #endregion
@ -64,36 +59,36 @@ namespace Matrix_App
// Generate filter access buttons // Generate filter access buttons
MatrixGifGenerator.GenerateBaseUi(pregeneratedModsBase, matrixView, this); MatrixGifGenerator.GenerateBaseUi(pregeneratedModsBase, matrixView, this);
init(); Init();
// apply lightmode 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
portNameUpdater = new System.Timers.Timer(PORT_NAME_UPDATE_INTERVAL); portNameUpdater = new Timer(PortNameUpdateInterval);
portNameUpdater.Elapsed += updatePortNames; portNameUpdater.Elapsed += UpdatePortNames;
portNameUpdater.AutoReset = true; portNameUpdater.AutoReset = true;
portNameUpdater.Enabled = true; portNameUpdater.Enabled = true;
// create gif playback timer // create gif playback timer
delay = new System.Timers.Timer((int) Delay.Value); delay = new Timer((int) Delay.Value);
delay.Elapsed += timelineupdate; delay.Elapsed += Timelineupdate;
delay.AutoReset = true; delay.AutoReset = true;
// Set color wheel event handler // Set color wheel event handler
ZeichnenFarbRad.handler = new EventHandler(FarbRad_Handler); ZeichnenFarbRad.handler = ColorWheel_Handler!;
// setup port settings // setup port settings
port.BaudRate = BAUD_RATE; _port.BaudRate = BaudRate;
port.ReadTimeout = READ_TIMEOUT_MS; _port.ReadTimeout = ReadTimeoutMs;
port.WriteTimeout = WRITE_TIMEOUT_MS; _port.WriteTimeout = WriteTimeoutMs;
// setup matrix // setup matrix
AdjustMatrixTable(); AdjustMatrixTable();
// search for inital ports // search for initial ports
GatherPortNames(); GatherPortNames();
HideEasterEgg(); HideEasterEgg();
@ -101,32 +96,31 @@ namespace Matrix_App
private void HideEasterEgg() private void HideEasterEgg()
{ {
Random better = new Random(); if (((int) DateTime.Now.DayOfWeek) != 3)
int Brandom = better.Next(0, 9); return;
if (Brandom < 1)
if (new Random().Next(0, 9) <= 1)
return;
using (Bitmap wednesdayFrog = new Bitmap(Properties.Resources.Frosch))
{ {
if (((int)DateTime.Now.DayOfWeek) == 3) matrixWidth.Value = wednesdayFrog.Width;
matrixHeight.Value = wednesdayFrog.Height;
ResizeGif();
for (var x = 0; x < wednesdayFrog.Width; x++)
{ {
matrixWidth.Value = 16; for (var y = 0; y < wednesdayFrog.Height; y++)
matrixHeight.Value = 16;
ResizeGif();
Bitmap WednesdayFrog = new Bitmap(Matrix_App.Properties.Resources.Frosch);
for (int x = 0; x < WednesdayFrog.Width; x++)
{ {
for (int y = 0; y < WednesdayFrog.Height; y++) var pixel = wednesdayFrog.GetPixel(x, y);
{
var pixel = WednesdayFrog.GetPixel(x, y);
int index = x + y * WednesdayFrog.Width; matrixView.SetPixelNoRefresh(x, y, pixel);
matrixView.SetPixelNoRefresh(x, y, pixel);
}
} }
matrixView.Refresh();
} }
} }
matrixView.Refresh();
} }
#endregion #endregion
@ -140,12 +134,12 @@ namespace Matrix_App
/// </summary> /// </summary>
/// <param name="source"></param> /// <param name="source"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void updatePortNames(Object source, ElapsedEventArgs e) private void UpdatePortNames(object source, ElapsedEventArgs e)
{ {
if (Ports.InvokeRequired) if (Ports.InvokeRequired)
{ {
// invoke on the comboboxes thread // invoke on the combo-boxes thread
Ports.Invoke(new Action(() => GatherPortNames())); Ports.Invoke(new Action(GatherPortNames));
} }
else else
{ {
@ -155,8 +149,9 @@ namespace Matrix_App
} }
/// <summary> /// <summary>
/// Gathers all availbale ports and sets them to the combobox <see cref="Ports"/> /// Gathers all available ports and sets them to the combobox <see cref="Ports"/>
/// </summary> /// </summary>
[SuppressMessage("ReSharper", "CoVariantArrayConversion", Justification = "Never got an exception, so seems to be just fine")]
private void GatherPortNames() private void GatherPortNames()
{ {
var ports = SerialPort.GetPortNames(); var ports = SerialPort.GetPortNames();
@ -180,15 +175,15 @@ namespace Matrix_App
Ports.Items.Clear(); Ports.Items.Clear();
Ports.Items.AddRange(newPorts.ToArray()); Ports.Items.AddRange(newPorts.ToArray()!);
// select previously selected port if port is still accessible // select previously selected port if port is still accessible
if (selected != null && this.Ports.Items.Contains(selected)) if (selected != null && Ports.Items.Contains(selected))
{ {
this.Ports.SelectedItem = selected; Ports.SelectedItem = selected;
} else } else
{ {
this.Ports.SelectedIndex = 0; Ports.SelectedIndex = 0;
} }
break; break;
} }
@ -198,20 +193,21 @@ namespace Matrix_App
private static LinkedList<string> GetDeviceNames(string[] ports) private static LinkedList<string> GetDeviceNames(string[] ports)
{ {
ManagementClass processClass = new ManagementClass("Win32_PnPEntity"); ManagementClass processClass = new ManagementClass("Win32_PnPEntity");
ManagementObjectCollection Ports = processClass.GetInstances(); ManagementObjectCollection devicePortNames = processClass.GetInstances();
var newPorts = new LinkedList<string>(); var newPorts = new LinkedList<string>();
for (var x = 0; x < ports.Length; x++) foreach (var currentPort in ports)
{ {
foreach (ManagementObject property in Ports) foreach (var o in devicePortNames)
{ {
var name = property.GetPropertyValue("Name"); var name = ((ManagementObject) o).GetPropertyValue("Name");
if (name != null && name.ToString().Contains(ports[x]))
{ if (name == null || !name.ToString()!.Contains(currentPort))
newPorts.AddLast(name.ToString()); continue;
break;
} newPorts.AddLast(name.ToString()!);
break;
} }
} }
@ -226,9 +222,9 @@ namespace Matrix_App
/// <param name="e"></param> /// <param name="e"></param>
private void Ports_SelectedIndexChanged(object sender, EventArgs e) private void Ports_SelectedIndexChanged(object sender, EventArgs e)
{ {
lock (port) lock (_port)
{ {
if (!port.IsOpen) if (!_port.IsOpen)
{ {
var item = (string)((ComboBox)sender).SelectedItem; var item = (string)((ComboBox)sender).SelectedItem;
if (item != null) if (item != null)
@ -244,18 +240,18 @@ namespace Matrix_App
if (portNumber <= 256) if (portNumber <= 256)
{ {
// set valid port // set valid port
port.PortName = matches[0].Value; _port.PortName = matches[0].Value;
commandQueue.ValidatePort(); commandQueue.ValidatePort();
} else if (portNumber == 257) } else if (portNumber == 257)
{ {
// virtual mode, increase limitations as no real arduino is connected // virtual mode, increase limitations as no real arduino is connected
matrixWidth.Maximum = MATRIX_LIMITED_WIDTH; matrixWidth.Maximum = MatrixLimitedWidth;
matrixHeight.Maximum = MATRIX_LIMITED_HEIGHT; matrixHeight.Maximum = MatrixLimitedHeight;
} else } else
{ {
// no port selected reset settings // no port selected reset settings
matrixWidth.Maximum = MATRIX_START_WIDTH; matrixWidth.Maximum = MatrixStartWidth;
matrixHeight.Maximum = MATRIX_START_HEIGHT; matrixHeight.Maximum = MatrixStartHeight;
} }
} }
} }
@ -283,7 +279,7 @@ namespace Matrix_App
{ {
AdjustMatrixTable(); AdjustMatrixTable();
commandQueue.EnqueueArduinoCommand( commandQueue.EnqueueArduinoCommand(
OPCODE_SCALE, // opcode OpcodeScale, // opcode
(byte)matrixWidth.Value, (byte)matrixWidth.Value,
(byte)matrixHeight.Value (byte)matrixHeight.Value
); );
@ -293,7 +289,7 @@ namespace Matrix_App
{ {
AdjustMatrixTable(); AdjustMatrixTable();
commandQueue.EnqueueArduinoCommand( commandQueue.EnqueueArduinoCommand(
OPCODE_SCALE, // opcode OpcodeScale, // opcode
(byte)matrixWidth.Value, (byte)matrixWidth.Value,
(byte)matrixHeight.Value (byte)matrixHeight.Value
); );
@ -304,7 +300,7 @@ namespace Matrix_App
#region Edit/Draw #region Edit/Draw
#region TextBoxen #region TextBoxen
private void ZeichnenTextBoxRed_KeyUp(object sender, KeyEventArgs e) private void DrawTextBoxRed_KeyUp(object sender, KeyEventArgs e)
{ {
if (int.TryParse(ZeichnenTextBoxRed.Text, out var value) && value < 256 && value >= 0) if (int.TryParse(ZeichnenTextBoxRed.Text, out var value) && value < 256 && value >= 0)
{ {
@ -314,13 +310,13 @@ namespace Matrix_App
else if (value >= 256) else if (value >= 256)
{ {
ZeichnenTrackBarRed.Value = 255; ZeichnenTrackBarRed.Value = 255;
ZeichnenTextBoxRed.Text = "255"; ZeichnenTextBoxRed.Text = @"255";
ZeichnenFarbRad.setRGB((byte)ZeichnenTrackBarRed.Value, (byte)ZeichnenTrackBarGreen.Value, (byte)ZeichnenTrackBarBlue.Value); ZeichnenFarbRad.setRGB((byte)ZeichnenTrackBarRed.Value, (byte)ZeichnenTrackBarGreen.Value, (byte)ZeichnenTrackBarBlue.Value);
} }
matrixView.SetPaintColor(Color.FromArgb(ZeichnenTrackBarRed.Value, ZeichnenTrackBarGreen.Value, ZeichnenTrackBarBlue.Value)); matrixView.SetPaintColor(Color.FromArgb(ZeichnenTrackBarRed.Value, ZeichnenTrackBarGreen.Value, ZeichnenTrackBarBlue.Value));
} }
private void ZeichnenTextBoxGreen_KeyUp(object sender, KeyEventArgs e) private void DrawTextBoxGreen_KeyUp(object sender, KeyEventArgs e)
{ {
if (int.TryParse(ZeichnenTextBoxGreen.Text, out var value) && value < 256 && value >= 0) if (int.TryParse(ZeichnenTextBoxGreen.Text, out var value) && value < 256 && value >= 0)
{ {
@ -330,14 +326,14 @@ namespace Matrix_App
else if (value >= 256) else if (value >= 256)
{ {
ZeichnenTrackBarGreen.Value = 255; ZeichnenTrackBarGreen.Value = 255;
ZeichnenTextBoxGreen.Text = "255"; ZeichnenTextBoxGreen.Text = @"255";
ZeichnenFarbRad.setRGB((byte)ZeichnenTrackBarRed.Value, (byte)ZeichnenTrackBarGreen.Value, (byte)ZeichnenTrackBarBlue.Value); ZeichnenFarbRad.setRGB((byte)ZeichnenTrackBarRed.Value, (byte)ZeichnenTrackBarGreen.Value, (byte)ZeichnenTrackBarBlue.Value);
} }
matrixView.SetPaintColor(Color.FromArgb(ZeichnenTrackBarRed.Value, ZeichnenTrackBarGreen.Value, ZeichnenTrackBarBlue.Value)); matrixView.SetPaintColor(Color.FromArgb(ZeichnenTrackBarRed.Value, ZeichnenTrackBarGreen.Value, ZeichnenTrackBarBlue.Value));
} }
private void ZeichnenTextBoxBlue_KeyUp(object sender, KeyEventArgs e) private void DrawTextBoxBlue_KeyUp(object sender, KeyEventArgs e)
{ {
if (int.TryParse(ZeichnenTextBoxBlue.Text, out var value) && value < 256 && value >= 0) if (int.TryParse(ZeichnenTextBoxBlue.Text, out var value) && value < 256 && value >= 0)
{ {
@ -347,7 +343,7 @@ namespace Matrix_App
else if (value >= 256) else if (value >= 256)
{ {
ZeichnenTrackBarBlue.Value = 255; ZeichnenTrackBarBlue.Value = 255;
ZeichnenTextBoxBlue.Text = "255"; ZeichnenTextBoxBlue.Text = @"255";
ZeichnenFarbRad.setRGB((byte)ZeichnenTrackBarRed.Value, (byte)ZeichnenTrackBarGreen.Value, (byte)ZeichnenTrackBarBlue.Value); ZeichnenFarbRad.setRGB((byte)ZeichnenTrackBarRed.Value, (byte)ZeichnenTrackBarGreen.Value, (byte)ZeichnenTrackBarBlue.Value);
} }
matrixView.SetPaintColor(Color.FromArgb(ZeichnenTrackBarRed.Value, ZeichnenTrackBarGreen.Value, ZeichnenTrackBarBlue.Value)); matrixView.SetPaintColor(Color.FromArgb(ZeichnenTrackBarRed.Value, ZeichnenTrackBarGreen.Value, ZeichnenTrackBarBlue.Value));
@ -400,7 +396,7 @@ namespace Matrix_App
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void FarbRad_Handler(object sender, EventArgs e) private void ColorWheel_Handler(object sender, EventArgs e)
{ {
ZeichnenTrackBarRed.Value = ZeichnenFarbRad.getRed(); ZeichnenTrackBarRed.Value = ZeichnenFarbRad.getRed();
ZeichnenTrackBarGreen.Value = ZeichnenFarbRad.getGreen(); ZeichnenTrackBarGreen.Value = ZeichnenFarbRad.getGreen();
@ -418,14 +414,14 @@ namespace Matrix_App
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void ZeichnenFill_Click(object sender, EventArgs e) private void DrawFill_Click(object sender, EventArgs e)
{ {
var color = Color.FromArgb(ZeichnenTrackBarRed.Value, ZeichnenTrackBarGreen.Value, ZeichnenTrackBarBlue.Value); var color = Color.FromArgb(ZeichnenTrackBarRed.Value, ZeichnenTrackBarGreen.Value, ZeichnenTrackBarBlue.Value);
matrixView.SetPaintColor(color); matrixView.SetPaintColor(color);
matrixView.Fill(color); matrixView.Fill(color);
commandQueue.EnqueueArduinoCommand( commandQueue.EnqueueArduinoCommand(
OPCODE_FILL, // Opcode OpcodeFill, // Opcode
(byte)ZeichnenTrackBarRed.Value, // Red (byte)ZeichnenTrackBarRed.Value, // Red
(byte)ZeichnenTrackBarGreen.Value,// Green (byte)ZeichnenTrackBarGreen.Value,// Green
(byte)ZeichnenTrackBarBlue.Value // Blue (byte)ZeichnenTrackBarBlue.Value // Blue
@ -437,12 +433,12 @@ namespace Matrix_App
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void ZeichnenClear_Click(object sender, EventArgs e) private void DrawClear_Click(object sender, EventArgs e)
{ {
matrixView.Fill(Color.Black); matrixView.Fill(Color.Black);
commandQueue.EnqueueArduinoCommand( commandQueue.EnqueueArduinoCommand(
OPCODE_FILL, // opcode OpcodeFill, // opcode
0, // red 0, // red
0, // green 0, // green
0 // blue 0 // blue
@ -460,19 +456,19 @@ namespace Matrix_App
/// <param name="e"></param> /// <param name="e"></param>
private void DragDrop_Click(object sender, EventArgs e) private void DragDrop_Click(object sender, EventArgs e)
{ {
using (OpenFileDialog openFileDialog = new OpenFileDialog()) using OpenFileDialog openFileDialog = new OpenFileDialog
{ {
openFileDialog.InitialDirectory = "c:\\"; InitialDirectory = "c:\\",
openFileDialog.Filter = "image files (*.PNG;*.JPG;*.GIF)|*.*"; Filter = @"image files (*.PNG;*.JPG;*.GIF)|*.*",
openFileDialog.FilterIndex = 2; FilterIndex = 2,
openFileDialog.RestoreDirectory = true; RestoreDirectory = true
};
if (openFileDialog.ShowDialog() == DialogResult.OK) if (openFileDialog.ShowDialog() == DialogResult.OK)
{ {
string filePath = openFileDialog.FileName; string filePath = openFileDialog.FileName;
loadFromFile(filePath); LoadFromFile(filePath);
}
} }
} }
@ -481,18 +477,18 @@ namespace Matrix_App
/// If the image is an gif, the gif buffer will be set to the gif, as well as the matrix itself. /// If the image is an gif, the gif buffer will be set to the gif, as well as the matrix itself.
/// </summary> /// </summary>
/// <param name="filePath"></param> /// <param name="filePath"></param>
private void loadFromFile(string filePath) private void LoadFromFile(string filePath)
{ {
// load gif // load gif
if (filePath.ToLower().EndsWith(".gif")) if (filePath.ToLower().EndsWith(".gif"))
{ {
var gif = Image.FromFile(filePath); var gif = Image.FromFile(filePath);
int frames = Math.Min(gif.GetFrameCount(FrameDimension.Time), 120); var frames = Math.Min(gif.GetFrameCount(FrameDimension.Time), 120);
if (gif.GetFrameCount(FrameDimension.Time) > 120) if (gif.GetFrameCount(FrameDimension.Time) > 120)
{ {
MessageBox.Show("Das Gif ist zu Groß. Die Maximalgröße sind 120 Frames. Das Gif wird abgeschnitten sein, damit es in die Maximalgröße passt.", "Gif to large"); MessageBox.Show(@"Das Gif ist zu Groß. Die Maximalgröße sind 120 Frames. Das Gif wird abgeschnitten sein, damit es in die Maximalgröße passt.", @"Gif to large");
} }
FrameCount.Value = frames; FrameCount.Value = frames;
@ -501,7 +497,7 @@ namespace Matrix_App
ResizeGif(); ResizeGif();
// fetch and store frames // fetch and store frames
for (int i = 0; i < frames; i++) for (var i = 0; i < frames; i++)
{ {
gif.SelectActiveFrame(FrameDimension.Time, i); gif.SelectActiveFrame(FrameDimension.Time, i);
@ -509,19 +505,19 @@ namespace Matrix_App
var bitmap = ResizeImage(gif, matrixView.matrixWidth(), matrixView.matrixHeight()); var bitmap = ResizeImage(gif, matrixView.matrixWidth(), matrixView.matrixHeight());
// fetch each pixel and store // fetch each pixel and store
for (int x = 0; x < bitmap.Width; x++) for (var x = 0; x < bitmap.Width; x++)
{ {
for (int y = 0; y < bitmap.Height; y++) for (var y = 0; y < bitmap.Height; y++)
{ {
var pixel = bitmap.GetPixel(x, y); var pixel = bitmap.GetPixel(x, y);
int index = x + y * bitmap.Width; var index = x + y * bitmap.Width;
matrixView.SetPixelNoRefresh(x, y, pixel); matrixView.SetPixelNoRefresh(x, y, pixel);
Gif[i][index * 3] = pixel.G; gifBuffer[i][index * 3] = pixel.G;
Gif[i][index * 3 + 1] = pixel.R; gifBuffer[i][index * 3 + 1] = pixel.R;
Gif[i][index * 3 + 2] = pixel.B; gifBuffer[i][index * 3 + 2] = pixel.B;
} }
} }
} }
@ -544,13 +540,13 @@ namespace Matrix_App
int index = x + y * bitmap.Width; int index = x + y * bitmap.Width;
Gif[Timeline.Value][index * 3] = pixel.G; gifBuffer[Timeline.Value][index * 3] = pixel.G;
Gif[Timeline.Value][index * 3 + 1] = pixel.R; gifBuffer[Timeline.Value][index * 3 + 1] = pixel.R;
Gif[Timeline.Value][index * 3 + 2] = pixel.B; gifBuffer[Timeline.Value][index * 3 + 2] = pixel.B;
} }
} }
} }
writeImage(Gif[Timeline.Value]); WriteImage(gifBuffer[Timeline.Value]);
} }
private void DragDrop_DragEnter(object sender, DragEventArgs e) private void DragDrop_DragEnter(object sender, DragEventArgs e)
@ -565,7 +561,7 @@ namespace Matrix_App
{ {
string[] picturePath = (string[])e.Data.GetData(DataFormats.FileDrop); string[] picturePath = (string[])e.Data.GetData(DataFormats.FileDrop);
loadFromFile(picturePath[0]); LoadFromFile(picturePath[0]);
} }
#endregion #endregion
@ -610,13 +606,13 @@ namespace Matrix_App
{ {
int tmp = (index + x) * 3; int tmp = (index + x) * 3;
var color = Color.FromArgb(Gif[Timeline.Value][tmp + 1], Gif[Timeline.Value][tmp], Gif[Timeline.Value][tmp + 2]); var color = Color.FromArgb(gifBuffer[Timeline.Value][tmp + 1], gifBuffer[Timeline.Value][tmp], gifBuffer[Timeline.Value][tmp + 2]);
matrixView.SetPixelNoRefresh(x, y, color); matrixView.SetPixelNoRefresh(x, y, color);
} }
} }
matrixView.Refresh(); matrixView.Refresh();
writeImage(Gif[Timeline.Value]); WriteImage(gifBuffer[Timeline.Value]);
} }
/// <summary> /// <summary>
@ -639,14 +635,14 @@ namespace Matrix_App
var color = matrixView.GetPixel(x, y); var color = matrixView.GetPixel(x, y);
Gif[Timeline.Value][tmp] = color.G; gifBuffer[Timeline.Value][tmp] = color.G;
Gif[Timeline.Value][tmp + 1] = color.R; gifBuffer[Timeline.Value][tmp + 1] = color.R;
Gif[Timeline.Value][tmp + 2] = color.B; gifBuffer[Timeline.Value][tmp + 2] = color.B;
} }
} }
} }
private void timelineupdate(Object source, ElapsedEventArgs e) private void Timelineupdate(Object source, ElapsedEventArgs e)
{ {
if (Timeline.InvokeRequired) if (Timeline.InvokeRequired)
{ {
@ -672,24 +668,28 @@ namespace Matrix_App
/// <param name="e"></param> /// <param name="e"></param>
private void Play_Click(object sender, EventArgs e) private void Play_Click(object sender, EventArgs e)
{ {
if (!(FrameCount.Value == 1)) if (FrameCount.Value != 1)
{ {
if (!runningGif) if (!runningGif)
{ {
Play.Text = "Stop"; Play.Text = @"Stop";
Timeline.Value = 0; Timeline.Value = 0;
runningGif = true; runningGif = true;
delay.Enabled = true;
Play.Image = new Bitmap(Matrix_App.Properties.Resources.Stop); if (delay != null)
delay.Enabled = true;
Play.Image = new Bitmap(Properties.Resources.Stop);
} }
else else
{ {
Play.Image = new Bitmap(Matrix_App.Properties.Resources.Play); Play.Image = new Bitmap(Properties.Resources.Play);
Play.Text = "Play"; Play.Text = @"Play";
runningGif = false; runningGif = false;
delay.Enabled = false;
if (delay != null)
delay.Enabled = false;
} }
} }
} }
@ -698,16 +698,19 @@ namespace Matrix_App
{ {
if (runningGif) if (runningGif)
{ {
Play.Image = new Bitmap(Matrix_App.Properties.Resources.Play); Play.Image = new Bitmap(Properties.Resources.Play);
Play.Text = "Play"; Play.Text = @"Play";
runningGif = false; runningGif = false;
delay.Enabled = false;
if (delay != null)
delay.Enabled = false;
} }
} }
private void Delay_ValueChanged(object sender, EventArgs e) private void Delay_ValueChanged(object sender, EventArgs _)
{ {
delay.Interval = (int)Delay.Value; if (delay != null)
delay.Interval = (int) Delay.Value;
} }
#endregion #endregion
@ -716,28 +719,29 @@ namespace Matrix_App
private void Save_Click(object sender, EventArgs e) private void Save_Click(object sender, EventArgs e)
{ {
SaveFileDialog save = new SaveFileDialog(); SaveFileDialog save = new SaveFileDialog
{
save.InitialDirectory = "c:\\"; InitialDirectory = "c:\\",
save.Filter = "image files (*.PNG;*.JPG;*.GIF)|*.*"; Filter = @"image files (*.PNG;*.JPG;*.GIF)|*.*",
save.FilterIndex = 2; FilterIndex = 2,
save.RestoreDirectory = true; RestoreDirectory = true
};
if (save.ShowDialog() == DialogResult.OK) if (save.ShowDialog() == DialogResult.OK)
{ {
string filePath = save.FileName; string filePath = save.FileName;
Bitmap[] gifBitmap = new Bitmap[Gif.Length]; Bitmap[] gifBitmap = new Bitmap[gifBuffer.Length];
GifWriter writer = new GifWriter(File.Create(filePath)); GifWriter writer = new GifWriter(File.Create(filePath));
for (int i = 0; i < FrameCount.Value; i++) for (var i = 0; i < FrameCount.Value; i++)
{ {
gifBitmap[i] = new Bitmap((int)matrixWidth.Value, (int)matrixHeight.Value); gifBitmap[i] = new Bitmap((int)matrixWidth.Value, (int)matrixHeight.Value);
for (int j = 0; j < Gif[i].Length / 3; j++) for (var j = 0; j < gifBuffer[i].Length / 3; j++)
{ {
int y = j / (int)matrixWidth.Value; var y = j / (int)matrixWidth.Value;
int x = j % (int)matrixWidth.Value; var x = j % (int)matrixWidth.Value;
gifBitmap[i].SetPixel(x, y, Color.FromArgb(Gif[i][j * 3 + 1], Gif[i][j * 3], Gif[i][j * 3 + 2])); gifBitmap[i].SetPixel(x, y, Color.FromArgb(gifBuffer[i][j * 3 + 1], gifBuffer[i][j * 3], gifBuffer[i][j * 3 + 2]));
} }
writer.WriteFrame(gifBitmap[i], (int)Delay.Value); writer.WriteFrame(gifBitmap[i], (int)Delay.Value);
} }
@ -759,9 +763,9 @@ namespace Matrix_App
this.matrixWidth.Value = width; this.matrixWidth.Value = width;
this.matrixHeight.Value = height; this.matrixHeight.Value = height;
for (int x = 0; x < width * height * 3; x++) for (var x = 0; x < width * height * 3; x++)
{ {
Gif[0][x] = data[2 + x]; gifBuffer[0][x] = data[2 + x];
} }
Timeline.Value = 1; Timeline.Value = 1;
Timeline.Value = 0; Timeline.Value = 0;
@ -785,10 +789,10 @@ namespace Matrix_App
private void ResizeGif() private void ResizeGif()
{ {
int frames = (int)FrameCount.Value; int frames = (int)FrameCount.Value;
Gif = new byte[frames + 1][]; gifBuffer = new byte[frames + 1][];
for (int i = 0; i <= frames; i++) for (int i = 0; i <= frames; i++)
{ {
Gif[i] = new byte[matrixView.matrixWidth() * matrixView.matrixHeight() * 3]; gifBuffer[i] = new byte[matrixView.matrixWidth() * matrixView.matrixHeight() * 3];
} }
} }
@ -812,9 +816,9 @@ namespace Matrix_App
#region IO-Utils #region IO-Utils
private void writeImage(byte[] RGBimageData) private void WriteImage(byte[] rgbImageData)
{ {
commandQueue.EnqueueArduinoCommand(OPCODE_IMAGE, RGBimageData); commandQueue.EnqueueArduinoCommand(OpcodeImage, rgbImageData);
} }
/// <summary> /// <summary>
@ -833,7 +837,7 @@ namespace Matrix_App
image[x * 3 + 2] = (byte)(pixels[x] & 0xFF); image[x * 3 + 2] = (byte)(pixels[x] & 0xFF);
} }
writeImage(image); WriteImage(image);
} }
#endregion #endregion

View File

@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using static Matrix_App.Utils; using static Matrix_App.Utils;
using static MatrixDesigner.Defaults; using static Matrix_App.Defaults;
using Timer = System.Windows.Forms.Timer; using Timer = System.Windows.Forms.Timer;
namespace Matrix_App namespace Matrix_App
@ -47,8 +47,8 @@ namespace Matrix_App
{ {
PlaybackTimer.Tick += PlaybackFrame; PlaybackTimer.Tick += PlaybackFrame;
Snapshot = CreateImageRGB_NT(FILTER_PREVIEW_WIDTH, FILTER_PREVIEW_HEIGHT, 1); Snapshot = CreateImageRGB_NT(FilterPreviewWidth, FilterPreviewHeight, 1);
_initialBuffer = CreateImageRGB_NT(FILTER_PREVIEW_WIDTH, FILTER_PREVIEW_HEIGHT, 1); _initialBuffer = CreateImageRGB_NT(FilterPreviewWidth, FilterPreviewHeight, 1);
Renderer = new ThreadQueue("Matrix Gif Renderer", 2); Renderer = new ThreadQueue("Matrix Gif Renderer", 2);
} }
@ -86,7 +86,7 @@ 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.ImageAboveText;
button.Height = FILTER_PREVIEW_HEIGHT * 2; button.Height = FilterPreviewHeight * 2;
anchor.Controls.Add(button); anchor.Controls.Add(button);
} }
@ -96,7 +96,7 @@ namespace Matrix_App
{ {
_generator = new RandomPixels(); _generator = new RandomPixels();
// put some random pixels in as default initial image to operate on for filter // put some random pixels in as default initial image to operate on for filter
SetGlobalArgs(FILTER_PREVIEW_WIDTH, FILTER_PREVIEW_HEIGHT, 1, null, _initialBuffer); SetGlobalArgs(FilterPreviewWidth, FilterPreviewHeight, 1, null, _initialBuffer);
InvokeGenerator(); InvokeGenerator();
BlockBuffer(); BlockBuffer();
@ -104,7 +104,7 @@ namespace Matrix_App
_generator = matrixGifGenerator; _generator = matrixGifGenerator;
// render filter // render filter
SetGlobalArgs(FILTER_PREVIEW_WIDTH, FILTER_PREVIEW_HEIGHT, 1, _initialBuffer, Snapshot); SetGlobalArgs(FilterPreviewWidth, FilterPreviewHeight, 1, _initialBuffer, Snapshot);
InvokeGenerator(); InvokeGenerator();
BlockBuffer(); BlockBuffer();
@ -131,7 +131,7 @@ namespace Matrix_App
if (!ShowEditDialog(matrix)) if (!ShowEditDialog(matrix))
return; return;
FlipColorStoreRG_GR(_animationBuffer, _form.Gif); FlipColorStoreRG_GR(_animationBuffer, _form.gifBuffer);
_form.ResetTimeline(); _form.ResetTimeline();
} }
@ -331,15 +331,15 @@ namespace Matrix_App
private static void Initialize(in Matrix matrix) private static void Initialize(in Matrix matrix)
{ {
// Create new initial buffer and copy what ever was in the Gif buffer to it // Create new initial buffer and copy what ever was in the Gif buffer to it
_initialBuffer = CreateImageRGB_NT(matrix.matrixWidth(), matrix.matrixHeight(), _form.Gif.Length); _initialBuffer = CreateImageRGB_NT(matrix.matrixWidth(), matrix.matrixHeight(), _form.gifBuffer.Length);
FlipColorStoreRG_GR(_form.Gif, _initialBuffer); FlipColorStoreRG_GR(_form.gifBuffer, _initialBuffer);
// Set Generator args // Set Generator args
SetGlobalArgs(matrix.matrixWidth(), SetGlobalArgs(matrix.matrixWidth(),
matrix.matrixHeight(), matrix.matrixHeight(),
_form.Gif.Length - 1, _form.gifBuffer.Length - 1,
_initialBuffer, _initialBuffer,
CreateImageRGB_NT(matrix.matrixWidth(), matrix.matrixHeight(), _form.Gif.Length) CreateImageRGB_NT(matrix.matrixWidth(), matrix.matrixHeight(), _form.gifBuffer.Length)
); );
// Create preview matrix // Create preview matrix

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -8,7 +8,7 @@ using System.Security.Permissions;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using static MatrixDesigner.Defaults; using static Matrix_App.Defaults;
namespace Matrix_App namespace Matrix_App
{ {
@ -28,7 +28,7 @@ namespace Matrix_App
private volatile bool isPortValid = false; private volatile bool isPortValid = false;
private byte[] recived = new byte[ARDUINO_RECIVCE_BUFFER_SIZE]; private byte[] recived = new byte[ArduinoReceiveBufferSize];
private int mark; private int mark;
public PortCommandQueue(ref SerialPort port) public PortCommandQueue(ref SerialPort port)
@ -62,7 +62,7 @@ namespace Matrix_App
int b; int b;
mark = 0; mark = 0;
while((b = port.ReadByte()) != ARDUINO_SUCCESS_BYTE) while((b = port.ReadByte()) != ArduinoSuccessByte)
{ {
recived[mark++] = (byte) b; recived[mark++] = (byte) b;
} }
@ -113,7 +113,7 @@ namespace Matrix_App
portDeliverThread.Start(); portDeliverThread.Start();
} }
if (byteWriteQueue.Count < ARDUINO_COMMAND_QUEUE_SIZE) if (byteWriteQueue.Count < ArduinoCommandQueueSize)
{ {
lock (byteWriteQueue) lock (byteWriteQueue)
{ {
@ -153,7 +153,7 @@ namespace Matrix_App
timeCount++; timeCount++;
Thread.Sleep(500); Thread.Sleep(500);
wait = timeCount == DEQUEUE_WAIT_TIMEOUT_COUNTER; wait = timeCount == DequeueWaitTimeoutCounter;
} }
} }

View File

@ -1,25 +1,27 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace Matrix_App namespace Matrix_App
{ {
static class Program internal static class Program
{ {
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
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);
Application.Run(new MatrixDesignerMain());
var designer = new MatrixDesignerMain();
SplashScreen.CloseForm();
Application.Run(designer);
} }
} }
} }

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// Dieser Code wurde von einem Tool generiert. // This code was generated by a tool.
// Laufzeitversion:4.0.30319.42000 // Runtime Version:4.0.30319.42000
// //
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn // Changes to this file may cause incorrect behavior and will be lost if
// der Code erneut generiert wird. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -13,12 +13,12 @@ namespace Matrix_App.Properties {
/// <summary> /// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. /// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary> /// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert // This class was auto-generated by the StronglyTypedResourceBuilder
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. // class via a tool like ResGen or Visual Studio.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@ -33,7 +33,7 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
@ -47,8 +47,8 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle /// Overrides the current thread's CurrentUICulture property for all
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. /// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture { internal static global::System.Globalization.CultureInfo Culture {
@ -61,7 +61,7 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap Apply { internal static System.Drawing.Bitmap Apply {
get { get {
@ -71,7 +71,7 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap ClearTool { internal static System.Drawing.Bitmap ClearTool {
get { get {
@ -81,7 +81,7 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap FillTool { internal static System.Drawing.Bitmap FillTool {
get { get {
@ -91,7 +91,7 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap Frosch { internal static System.Drawing.Bitmap Frosch {
get { get {
@ -101,7 +101,7 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap Gif { internal static System.Drawing.Bitmap Gif {
get { get {
@ -111,7 +111,17 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Pfüsikuh {
get {
object obj = ResourceManager.GetObject("Pfüsikuh", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap Play { internal static System.Drawing.Bitmap Play {
get { get {
@ -121,7 +131,7 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap Save { internal static System.Drawing.Bitmap Save {
get { get {
@ -131,7 +141,7 @@ namespace Matrix_App.Properties {
} }
/// <summary> /// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap Stop { internal static System.Drawing.Bitmap Stop {
get { get {

View File

@ -142,4 +142,7 @@
<data name="Frosch" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Frosch" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\frosch.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\resources\frosch.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Pfüsikuh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pfüsikuh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

63
Matrix App/SplashScreen.Designer.cs generated Normal file
View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Matrix_App {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class SplashScreen {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal SplashScreen() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Matrix_App.SplashScreen", typeof(SplashScreen).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,59 @@
using System.Threading;
using System.Windows.Forms;
namespace Matrix_App
{
public class SplashScreen : Form
{
//Delegate for cross thread call to close
private delegate void CloseDelegate();
//The type of form to be displayed as the splash screen.
private static SplashScreen? _splashForm;
private SplashScreen()
{
FormBorderStyle = FormBorderStyle.None;
Controls.Add(new Label()
{
Image = Properties.Resources.Pfüsikuh
});
}
public static void ShowSplashScreen()
{
// Make sure it is only launched once.
if (_splashForm != null)
return;
_splashForm = new SplashScreen();
Thread thread = new Thread(ShowForm)
{
IsBackground = true, Name = "Splash screen management thread"
};
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
private static void ShowForm()
{
if (_splashForm != null) Application.Run(_splashForm);
}
public static void CloseForm()
{
_splashForm?.Invoke(new CloseDelegate(CloseFormInternal));
}
private static void CloseFormInternal()
{
if (_splashForm != null)
{
_splashForm.Close();
_splashForm = null;
}
}
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -5,7 +5,7 @@ using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Text; using System.Text;
using static MatrixDesigner.Defaults; using static Matrix_App.Defaults;
namespace Matrix_App namespace Matrix_App
{ {
@ -78,7 +78,7 @@ namespace Matrix_App
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
int index = (x + y * width) * BPP; int index = (x + y * width) * Bpp;
image.SetPixel(x, y, Color.FromArgb( image.SetPixel(x, y, Color.FromArgb(
(byte) buffer[index + 0], (byte) buffer[index + 0],
@ -104,7 +104,7 @@ namespace Matrix_App
for (int frame = 0; frame < frames; frame++) for (int frame = 0; frame < frames; frame++)
{ {
bytes[frame] = new byte[width * height * BPP]; bytes[frame] = new byte[width * height * Bpp];
} }
return bytes; return bytes;

View File

@ -1 +1 @@
33bf45022f7912fceecdbeaf19d1442e0f0a576f ee8b86baf58d13435f960406ec4b0be78d0cc26c