Take over
This commit is contained in:
parent
b9e9312369
commit
6230473ec6
|
@ -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>
|
|
@ -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 static readonly int MATRIX_START_HEIGHT = 10;
|
||||
public static readonly int MATRIX_START_FRAMES = 1;
|
||||
public const int MatrixStartWidth = 10;
|
||||
public const int MatrixStartHeight = 10;
|
||||
public const int MatrixStartFrames = 1;
|
||||
|
||||
public static readonly int MATRIX_LIMITED_WIDTH = 512;
|
||||
public static readonly int MATRIX_LIMITED_HEIGHT = 512;
|
||||
public const int MatrixLimitedWidth = 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 static readonly int WRITE_TIMEOUT_MS = 5500;
|
||||
public const int ReadTimeoutMs = 5500;
|
||||
public const int WriteTimeoutMs = 5500;
|
||||
|
||||
/// <summary>
|
||||
/// Total count of LEDs at start
|
||||
/// </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>
|
||||
/// Number of Bytes Per Pixel: 3 cause Red (1 byte) + Blue (1 Byte) + Green (1 byte) = 3
|
||||
/// </summary>
|
||||
public static readonly int BPP = 3;
|
||||
public const int Bpp = 3;
|
||||
|
||||
public static readonly int FILTER_PREVIEW_WIDTH = 32;
|
||||
public static readonly int FILTER_PREVIEW_HEIGHT = 32;
|
||||
public const int FilterPreviewWidth = 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 static readonly int ARDUINO_RECIVCE_BUFFER_SIZE = 1 + 1 + 1 + MATRIX_LIMITED_WIDTH * MATRIX_LIMITED_HEIGHT;
|
||||
public const int ArduinoCommandQueueSize = 5;
|
||||
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 static readonly byte OPCODE_SINGLE = 1;
|
||||
public static readonly byte OPCODE_IMAGE = 2;
|
||||
public static readonly byte OPCODE_FILL = 3;
|
||||
public const byte OpcodeScale = 0;
|
||||
public const byte OpcodeImage = 2;
|
||||
public const byte OpcodeFill = 3;
|
||||
public static readonly byte OPCODE_CONFIG = 4;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static MatrixDesigner.Defaults;
|
||||
using static Matrix_App.Defaults;
|
||||
|
||||
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)
|
||||
{
|
||||
var index = (x + y * width) * BPP;
|
||||
var index = (x + y * width) * Bpp;
|
||||
|
||||
// normalize pixel value to [0, 1]
|
||||
r = sampler[frame][index + 0] * 0.00392156862745f;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Remove="SplashScreen.Designer.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -34,5 +35,8 @@
|
|||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Remove="SplashScreen.resx" />
|
||||
<None Remove="Resources\pfüsikuh.png" />
|
||||
<EmbeddedResource Include="Resources\pfüsikuh.png" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -486,7 +486,7 @@ namespace Matrix_App
|
|||
this.ZeichnenTextBoxRed.TabIndex = 4;
|
||||
this.ZeichnenTextBoxRed.Text = "0";
|
||||
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
|
||||
//
|
||||
|
@ -529,7 +529,7 @@ namespace Matrix_App
|
|||
this.ZeichnenTextBoxBlue.TabIndex = 6;
|
||||
this.ZeichnenTextBoxBlue.Text = "0";
|
||||
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
|
||||
//
|
||||
|
@ -539,7 +539,7 @@ namespace Matrix_App
|
|||
this.ZeichnenTextBoxGreen.TabIndex = 5;
|
||||
this.ZeichnenTextBoxGreen.Text = "0";
|
||||
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
|
||||
//
|
||||
|
@ -552,7 +552,7 @@ namespace Matrix_App
|
|||
this.Clear.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.Clear.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.Clear.UseVisualStyleBackColor = true;
|
||||
this.Clear.Click += new System.EventHandler(this.ZeichnenClear_Click);
|
||||
this.Clear.Click += new System.EventHandler(this.DrawClear_Click);
|
||||
//
|
||||
// fill
|
||||
//
|
||||
|
@ -565,7 +565,7 @@ namespace Matrix_App
|
|||
this.fill.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.fill.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
|
||||
this.fill.UseVisualStyleBackColor = true;
|
||||
this.fill.Click += new System.EventHandler(this.ZeichnenFill_Click);
|
||||
this.fill.Click += new System.EventHandler(this.DrawFill_Click);
|
||||
//
|
||||
// ZeichnenFarbRad
|
||||
//
|
||||
|
|
|
@ -3,27 +3,22 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.IO.Ports;
|
||||
using System.Timers;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.IO;
|
||||
using System.Management;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using static MatrixDesigner.Defaults;
|
||||
using static MatrixDesigner.ArduinoInstruction;
|
||||
using static Matrix_App.Defaults;
|
||||
using static Matrix_App.ArduinoInstruction;
|
||||
using static Matrix_App.Utils;
|
||||
using Matrix_App.Themes;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace Matrix_App
|
||||
{
|
||||
|
@ -35,21 +30,21 @@ namespace Matrix_App
|
|||
/// Port update Timer
|
||||
/// Reloads available port names at consecutive rates
|
||||
/// </summary>
|
||||
private System.Timers.Timer portNameUpdater;
|
||||
private System.Timers.Timer delay;
|
||||
private Timer? portNameUpdater;
|
||||
private Timer? delay;
|
||||
|
||||
private static SerialPort port = new SerialPort();
|
||||
private static SerialPort _port = new SerialPort();
|
||||
|
||||
private uint portNumber;
|
||||
|
||||
private bool runningGif = false;
|
||||
private bool runningGif;
|
||||
|
||||
private PortCommandQueue commandQueue = new PortCommandQueue(ref port);
|
||||
private Regex comRegex = new Regex(@"COM[\d]+");
|
||||
private readonly PortCommandQueue commandQueue = new PortCommandQueue(ref _port);
|
||||
private readonly Regex comRegex = new Regex(@"COM[\d]+");
|
||||
/// <summary>
|
||||
/// Gif like frame video buffer
|
||||
/// </summary>
|
||||
public byte[][] Gif = CreateImageRGB_NT(MATRIX_START_WIDTH, MATRIX_START_HEIGHT, MATRIX_START_FRAMES);
|
||||
public byte[][] gifBuffer = CreateImageRGB_NT(MatrixStartWidth, MatrixStartHeight, MatrixStartFrames);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -64,36 +59,36 @@ namespace Matrix_App
|
|||
// Generate filter access buttons
|
||||
MatrixGifGenerator.GenerateBaseUi(pregeneratedModsBase, matrixView, this);
|
||||
|
||||
init();
|
||||
// apply lightmode by default
|
||||
Init();
|
||||
// apply light-mode by default
|
||||
new LightMode().ApplyTheme(this);
|
||||
}
|
||||
|
||||
private void init()
|
||||
private void Init()
|
||||
{
|
||||
// Create port name update timer
|
||||
portNameUpdater = new System.Timers.Timer(PORT_NAME_UPDATE_INTERVAL);
|
||||
portNameUpdater.Elapsed += updatePortNames;
|
||||
portNameUpdater = new Timer(PortNameUpdateInterval);
|
||||
portNameUpdater.Elapsed += UpdatePortNames;
|
||||
portNameUpdater.AutoReset = true;
|
||||
portNameUpdater.Enabled = true;
|
||||
|
||||
// create gif playback timer
|
||||
delay = new System.Timers.Timer((int) Delay.Value);
|
||||
delay.Elapsed += timelineupdate;
|
||||
delay = new Timer((int) Delay.Value);
|
||||
delay.Elapsed += Timelineupdate;
|
||||
delay.AutoReset = true;
|
||||
|
||||
// Set color wheel event handler
|
||||
ZeichnenFarbRad.handler = new EventHandler(FarbRad_Handler);
|
||||
ZeichnenFarbRad.handler = ColorWheel_Handler!;
|
||||
|
||||
// setup port settings
|
||||
port.BaudRate = BAUD_RATE;
|
||||
port.ReadTimeout = READ_TIMEOUT_MS;
|
||||
port.WriteTimeout = WRITE_TIMEOUT_MS;
|
||||
_port.BaudRate = BaudRate;
|
||||
_port.ReadTimeout = ReadTimeoutMs;
|
||||
_port.WriteTimeout = WriteTimeoutMs;
|
||||
|
||||
// setup matrix
|
||||
AdjustMatrixTable();
|
||||
|
||||
// search for inital ports
|
||||
// search for initial ports
|
||||
GatherPortNames();
|
||||
|
||||
HideEasterEgg();
|
||||
|
@ -101,33 +96,32 @@ namespace Matrix_App
|
|||
|
||||
private void HideEasterEgg()
|
||||
{
|
||||
Random better = new Random();
|
||||
int Brandom = better.Next(0, 9);
|
||||
if (Brandom < 1)
|
||||
if (((int) DateTime.Now.DayOfWeek) != 3)
|
||||
return;
|
||||
|
||||
if (new Random().Next(0, 9) <= 1)
|
||||
return;
|
||||
|
||||
using (Bitmap wednesdayFrog = new Bitmap(Properties.Resources.Frosch))
|
||||
{
|
||||
if (((int)DateTime.Now.DayOfWeek) == 3)
|
||||
{
|
||||
matrixWidth.Value = 16;
|
||||
matrixHeight.Value = 16;
|
||||
matrixWidth.Value = wednesdayFrog.Width;
|
||||
matrixHeight.Value = wednesdayFrog.Height;
|
||||
ResizeGif();
|
||||
Bitmap WednesdayFrog = new Bitmap(Matrix_App.Properties.Resources.Frosch);
|
||||
|
||||
for (int x = 0; x < WednesdayFrog.Width; x++)
|
||||
for (var x = 0; x < wednesdayFrog.Width; x++)
|
||||
{
|
||||
for (int y = 0; y < WednesdayFrog.Height; y++)
|
||||
for (var y = 0; y < wednesdayFrog.Height; y++)
|
||||
{
|
||||
var pixel = WednesdayFrog.GetPixel(x, y);
|
||||
|
||||
int index = x + y * WednesdayFrog.Width;
|
||||
var pixel = wednesdayFrog.GetPixel(x, y);
|
||||
|
||||
matrixView.SetPixelNoRefresh(x, y, pixel);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matrixView.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -140,12 +134,12 @@ namespace Matrix_App
|
|||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="e"></param>
|
||||
private void updatePortNames(Object source, ElapsedEventArgs e)
|
||||
private void UpdatePortNames(object source, ElapsedEventArgs e)
|
||||
{
|
||||
if (Ports.InvokeRequired)
|
||||
{
|
||||
// invoke on the comboboxes thread
|
||||
Ports.Invoke(new Action(() => GatherPortNames()));
|
||||
// invoke on the combo-boxes thread
|
||||
Ports.Invoke(new Action(GatherPortNames));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -155,8 +149,9 @@ namespace Matrix_App
|
|||
}
|
||||
|
||||
/// <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>
|
||||
[SuppressMessage("ReSharper", "CoVariantArrayConversion", Justification = "Never got an exception, so seems to be just fine")]
|
||||
private void GatherPortNames()
|
||||
{
|
||||
var ports = SerialPort.GetPortNames();
|
||||
|
@ -180,15 +175,15 @@ namespace Matrix_App
|
|||
|
||||
Ports.Items.Clear();
|
||||
|
||||
Ports.Items.AddRange(newPorts.ToArray());
|
||||
Ports.Items.AddRange(newPorts.ToArray()!);
|
||||
|
||||
// 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
|
||||
{
|
||||
this.Ports.SelectedIndex = 0;
|
||||
Ports.SelectedIndex = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -198,22 +193,23 @@ namespace Matrix_App
|
|||
private static LinkedList<string> GetDeviceNames(string[] ports)
|
||||
{
|
||||
ManagementClass processClass = new ManagementClass("Win32_PnPEntity");
|
||||
ManagementObjectCollection Ports = processClass.GetInstances();
|
||||
ManagementObjectCollection devicePortNames = processClass.GetInstances();
|
||||
|
||||
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");
|
||||
if (name != null && name.ToString().Contains(ports[x]))
|
||||
{
|
||||
newPorts.AddLast(name.ToString());
|
||||
var name = ((ManagementObject) o).GetPropertyValue("Name");
|
||||
|
||||
if (name == null || !name.ToString()!.Contains(currentPort))
|
||||
continue;
|
||||
|
||||
newPorts.AddLast(name.ToString()!);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newPorts;
|
||||
}
|
||||
|
@ -226,9 +222,9 @@ namespace Matrix_App
|
|||
/// <param name="e"></param>
|
||||
private void Ports_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
lock (port)
|
||||
lock (_port)
|
||||
{
|
||||
if (!port.IsOpen)
|
||||
if (!_port.IsOpen)
|
||||
{
|
||||
var item = (string)((ComboBox)sender).SelectedItem;
|
||||
if (item != null)
|
||||
|
@ -244,18 +240,18 @@ namespace Matrix_App
|
|||
if (portNumber <= 256)
|
||||
{
|
||||
// set valid port
|
||||
port.PortName = matches[0].Value;
|
||||
_port.PortName = matches[0].Value;
|
||||
commandQueue.ValidatePort();
|
||||
} else if (portNumber == 257)
|
||||
{
|
||||
// virtual mode, increase limitations as no real arduino is connected
|
||||
matrixWidth.Maximum = MATRIX_LIMITED_WIDTH;
|
||||
matrixHeight.Maximum = MATRIX_LIMITED_HEIGHT;
|
||||
matrixWidth.Maximum = MatrixLimitedWidth;
|
||||
matrixHeight.Maximum = MatrixLimitedHeight;
|
||||
} else
|
||||
{
|
||||
// no port selected reset settings
|
||||
matrixWidth.Maximum = MATRIX_START_WIDTH;
|
||||
matrixHeight.Maximum = MATRIX_START_HEIGHT;
|
||||
matrixWidth.Maximum = MatrixStartWidth;
|
||||
matrixHeight.Maximum = MatrixStartHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +279,7 @@ namespace Matrix_App
|
|||
{
|
||||
AdjustMatrixTable();
|
||||
commandQueue.EnqueueArduinoCommand(
|
||||
OPCODE_SCALE, // opcode
|
||||
OpcodeScale, // opcode
|
||||
(byte)matrixWidth.Value,
|
||||
(byte)matrixHeight.Value
|
||||
);
|
||||
|
@ -293,7 +289,7 @@ namespace Matrix_App
|
|||
{
|
||||
AdjustMatrixTable();
|
||||
commandQueue.EnqueueArduinoCommand(
|
||||
OPCODE_SCALE, // opcode
|
||||
OpcodeScale, // opcode
|
||||
(byte)matrixWidth.Value,
|
||||
(byte)matrixHeight.Value
|
||||
);
|
||||
|
@ -304,7 +300,7 @@ namespace Matrix_App
|
|||
#region Edit/Draw
|
||||
|
||||
#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)
|
||||
{
|
||||
|
@ -314,13 +310,13 @@ namespace Matrix_App
|
|||
else if (value >= 256)
|
||||
{
|
||||
ZeichnenTrackBarRed.Value = 255;
|
||||
ZeichnenTextBoxRed.Text = "255";
|
||||
ZeichnenTextBoxRed.Text = @"255";
|
||||
ZeichnenFarbRad.setRGB((byte)ZeichnenTrackBarRed.Value, (byte)ZeichnenTrackBarGreen.Value, (byte)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)
|
||||
{
|
||||
|
@ -330,14 +326,14 @@ namespace Matrix_App
|
|||
else if (value >= 256)
|
||||
{
|
||||
ZeichnenTrackBarGreen.Value = 255;
|
||||
ZeichnenTextBoxGreen.Text = "255";
|
||||
ZeichnenTextBoxGreen.Text = @"255";
|
||||
ZeichnenFarbRad.setRGB((byte)ZeichnenTrackBarRed.Value, (byte)ZeichnenTrackBarGreen.Value, (byte)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)
|
||||
{
|
||||
|
@ -347,7 +343,7 @@ namespace Matrix_App
|
|||
else if (value >= 256)
|
||||
{
|
||||
ZeichnenTrackBarBlue.Value = 255;
|
||||
ZeichnenTextBoxBlue.Text = "255";
|
||||
ZeichnenTextBoxBlue.Text = @"255";
|
||||
ZeichnenFarbRad.setRGB((byte)ZeichnenTrackBarRed.Value, (byte)ZeichnenTrackBarGreen.Value, (byte)ZeichnenTrackBarBlue.Value);
|
||||
}
|
||||
matrixView.SetPaintColor(Color.FromArgb(ZeichnenTrackBarRed.Value, ZeichnenTrackBarGreen.Value, ZeichnenTrackBarBlue.Value));
|
||||
|
@ -400,7 +396,7 @@ namespace Matrix_App
|
|||
/// </summary>
|
||||
/// <param name="sender"></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();
|
||||
ZeichnenTrackBarGreen.Value = ZeichnenFarbRad.getGreen();
|
||||
|
@ -418,14 +414,14 @@ namespace Matrix_App
|
|||
/// </summary>
|
||||
/// <param name="sender"></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);
|
||||
matrixView.SetPaintColor(color);
|
||||
matrixView.Fill(color);
|
||||
|
||||
commandQueue.EnqueueArduinoCommand(
|
||||
OPCODE_FILL, // Opcode
|
||||
OpcodeFill, // Opcode
|
||||
(byte)ZeichnenTrackBarRed.Value, // Red
|
||||
(byte)ZeichnenTrackBarGreen.Value,// Green
|
||||
(byte)ZeichnenTrackBarBlue.Value // Blue
|
||||
|
@ -437,12 +433,12 @@ namespace Matrix_App
|
|||
/// </summary>
|
||||
/// <param name="sender"></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);
|
||||
|
||||
commandQueue.EnqueueArduinoCommand(
|
||||
OPCODE_FILL, // opcode
|
||||
OpcodeFill, // opcode
|
||||
0, // red
|
||||
0, // green
|
||||
0 // blue
|
||||
|
@ -460,19 +456,19 @@ namespace Matrix_App
|
|||
/// <param name="e"></param>
|
||||
private void DragDrop_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
||||
using OpenFileDialog openFileDialog = new OpenFileDialog
|
||||
{
|
||||
openFileDialog.InitialDirectory = "c:\\";
|
||||
openFileDialog.Filter = "image files (*.PNG;*.JPG;*.GIF)|*.*";
|
||||
openFileDialog.FilterIndex = 2;
|
||||
openFileDialog.RestoreDirectory = true;
|
||||
InitialDirectory = "c:\\",
|
||||
Filter = @"image files (*.PNG;*.JPG;*.GIF)|*.*",
|
||||
FilterIndex = 2,
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
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.
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
private void loadFromFile(string filePath)
|
||||
private void LoadFromFile(string filePath)
|
||||
{
|
||||
// load gif
|
||||
if (filePath.ToLower().EndsWith(".gif"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
@ -501,7 +497,7 @@ namespace Matrix_App
|
|||
ResizeGif();
|
||||
|
||||
// fetch and store frames
|
||||
for (int i = 0; i < frames; i++)
|
||||
for (var i = 0; i < frames; i++)
|
||||
{
|
||||
gif.SelectActiveFrame(FrameDimension.Time, i);
|
||||
|
||||
|
@ -509,19 +505,19 @@ namespace Matrix_App
|
|||
var bitmap = ResizeImage(gif, matrixView.matrixWidth(), matrixView.matrixHeight());
|
||||
|
||||
// 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);
|
||||
|
||||
int index = x + y * bitmap.Width;
|
||||
var index = x + y * bitmap.Width;
|
||||
|
||||
matrixView.SetPixelNoRefresh(x, y, pixel);
|
||||
|
||||
Gif[i][index * 3] = pixel.G;
|
||||
Gif[i][index * 3 + 1] = pixel.R;
|
||||
Gif[i][index * 3 + 2] = pixel.B;
|
||||
gifBuffer[i][index * 3] = pixel.G;
|
||||
gifBuffer[i][index * 3 + 1] = pixel.R;
|
||||
gifBuffer[i][index * 3 + 2] = pixel.B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -544,13 +540,13 @@ namespace Matrix_App
|
|||
|
||||
int index = x + y * bitmap.Width;
|
||||
|
||||
Gif[Timeline.Value][index * 3] = pixel.G;
|
||||
Gif[Timeline.Value][index * 3 + 1] = pixel.R;
|
||||
Gif[Timeline.Value][index * 3 + 2] = pixel.B;
|
||||
gifBuffer[Timeline.Value][index * 3] = pixel.G;
|
||||
gifBuffer[Timeline.Value][index * 3 + 1] = pixel.R;
|
||||
gifBuffer[Timeline.Value][index * 3 + 2] = pixel.B;
|
||||
}
|
||||
}
|
||||
}
|
||||
writeImage(Gif[Timeline.Value]);
|
||||
WriteImage(gifBuffer[Timeline.Value]);
|
||||
}
|
||||
|
||||
private void DragDrop_DragEnter(object sender, DragEventArgs e)
|
||||
|
@ -565,7 +561,7 @@ namespace Matrix_App
|
|||
{
|
||||
string[] picturePath = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
||||
loadFromFile(picturePath[0]);
|
||||
LoadFromFile(picturePath[0]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -610,13 +606,13 @@ namespace Matrix_App
|
|||
{
|
||||
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.Refresh();
|
||||
writeImage(Gif[Timeline.Value]);
|
||||
WriteImage(gifBuffer[Timeline.Value]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -639,14 +635,14 @@ namespace Matrix_App
|
|||
|
||||
var color = matrixView.GetPixel(x, y);
|
||||
|
||||
Gif[Timeline.Value][tmp] = color.G;
|
||||
Gif[Timeline.Value][tmp + 1] = color.R;
|
||||
Gif[Timeline.Value][tmp + 2] = color.B;
|
||||
gifBuffer[Timeline.Value][tmp] = color.G;
|
||||
gifBuffer[Timeline.Value][tmp + 1] = color.R;
|
||||
gifBuffer[Timeline.Value][tmp + 2] = color.B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void timelineupdate(Object source, ElapsedEventArgs e)
|
||||
private void Timelineupdate(Object source, ElapsedEventArgs e)
|
||||
{
|
||||
if (Timeline.InvokeRequired)
|
||||
{
|
||||
|
@ -672,23 +668,27 @@ namespace Matrix_App
|
|||
/// <param name="e"></param>
|
||||
private void Play_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!(FrameCount.Value == 1))
|
||||
if (FrameCount.Value != 1)
|
||||
{
|
||||
if (!runningGif)
|
||||
{
|
||||
Play.Text = "Stop";
|
||||
Play.Text = @"Stop";
|
||||
Timeline.Value = 0;
|
||||
|
||||
runningGif = true;
|
||||
|
||||
if (delay != null)
|
||||
delay.Enabled = true;
|
||||
|
||||
Play.Image = new Bitmap(Matrix_App.Properties.Resources.Stop);
|
||||
Play.Image = new Bitmap(Properties.Resources.Stop);
|
||||
}
|
||||
else
|
||||
{
|
||||
Play.Image = new Bitmap(Matrix_App.Properties.Resources.Play);
|
||||
Play.Text = "Play";
|
||||
Play.Image = new Bitmap(Properties.Resources.Play);
|
||||
Play.Text = @"Play";
|
||||
runningGif = false;
|
||||
|
||||
if (delay != null)
|
||||
delay.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
@ -698,15 +698,18 @@ namespace Matrix_App
|
|||
{
|
||||
if (runningGif)
|
||||
{
|
||||
Play.Image = new Bitmap(Matrix_App.Properties.Resources.Play);
|
||||
Play.Text = "Play";
|
||||
Play.Image = new Bitmap(Properties.Resources.Play);
|
||||
Play.Text = @"Play";
|
||||
runningGif = false;
|
||||
|
||||
if (delay != null)
|
||||
delay.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Delay_ValueChanged(object sender, EventArgs e)
|
||||
private void Delay_ValueChanged(object sender, EventArgs _)
|
||||
{
|
||||
if (delay != null)
|
||||
delay.Interval = (int) Delay.Value;
|
||||
}
|
||||
|
||||
|
@ -716,28 +719,29 @@ namespace Matrix_App
|
|||
|
||||
private void Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog save = new SaveFileDialog();
|
||||
|
||||
save.InitialDirectory = "c:\\";
|
||||
save.Filter = "image files (*.PNG;*.JPG;*.GIF)|*.*";
|
||||
save.FilterIndex = 2;
|
||||
save.RestoreDirectory = true;
|
||||
SaveFileDialog save = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = "c:\\",
|
||||
Filter = @"image files (*.PNG;*.JPG;*.GIF)|*.*",
|
||||
FilterIndex = 2,
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
if (save.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string filePath = save.FileName;
|
||||
Bitmap[] gifBitmap = new Bitmap[Gif.Length];
|
||||
Bitmap[] gifBitmap = new Bitmap[gifBuffer.Length];
|
||||
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);
|
||||
|
||||
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;
|
||||
int x = j % (int)matrixWidth.Value;
|
||||
var y = 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);
|
||||
}
|
||||
|
@ -759,9 +763,9 @@ namespace Matrix_App
|
|||
this.matrixWidth.Value = width;
|
||||
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 = 0;
|
||||
|
@ -785,10 +789,10 @@ namespace Matrix_App
|
|||
private void ResizeGif()
|
||||
{
|
||||
int frames = (int)FrameCount.Value;
|
||||
Gif = new byte[frames + 1][];
|
||||
gifBuffer = new byte[frames + 1][];
|
||||
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
|
||||
|
||||
private void writeImage(byte[] RGBimageData)
|
||||
private void WriteImage(byte[] rgbImageData)
|
||||
{
|
||||
commandQueue.EnqueueArduinoCommand(OPCODE_IMAGE, RGBimageData);
|
||||
commandQueue.EnqueueArduinoCommand(OpcodeImage, rgbImageData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -833,7 +837,7 @@ namespace Matrix_App
|
|||
image[x * 3 + 2] = (byte)(pixels[x] & 0xFF);
|
||||
}
|
||||
|
||||
writeImage(image);
|
||||
WriteImage(image);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
|
|||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using static Matrix_App.Utils;
|
||||
using static MatrixDesigner.Defaults;
|
||||
using static Matrix_App.Defaults;
|
||||
using Timer = System.Windows.Forms.Timer;
|
||||
|
||||
namespace Matrix_App
|
||||
|
@ -47,8 +47,8 @@ namespace Matrix_App
|
|||
{
|
||||
PlaybackTimer.Tick += PlaybackFrame;
|
||||
|
||||
Snapshot = CreateImageRGB_NT(FILTER_PREVIEW_WIDTH, FILTER_PREVIEW_HEIGHT, 1);
|
||||
_initialBuffer = CreateImageRGB_NT(FILTER_PREVIEW_WIDTH, FILTER_PREVIEW_HEIGHT, 1);
|
||||
Snapshot = CreateImageRGB_NT(FilterPreviewWidth, FilterPreviewHeight, 1);
|
||||
_initialBuffer = CreateImageRGB_NT(FilterPreviewWidth, FilterPreviewHeight, 1);
|
||||
|
||||
Renderer = new ThreadQueue("Matrix Gif Renderer", 2);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ namespace Matrix_App
|
|||
button.Click += (sender, e) => OpenGeneratorUi(generator, matrix);
|
||||
button.Image = CreateSnapshot(generator);
|
||||
button.TextImageRelation = TextImageRelation.ImageAboveText;
|
||||
button.Height = FILTER_PREVIEW_HEIGHT * 2;
|
||||
button.Height = FilterPreviewHeight * 2;
|
||||
|
||||
anchor.Controls.Add(button);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ namespace Matrix_App
|
|||
{
|
||||
_generator = new RandomPixels();
|
||||
// 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();
|
||||
|
||||
BlockBuffer();
|
||||
|
@ -104,7 +104,7 @@ namespace Matrix_App
|
|||
_generator = matrixGifGenerator;
|
||||
|
||||
// render filter
|
||||
SetGlobalArgs(FILTER_PREVIEW_WIDTH, FILTER_PREVIEW_HEIGHT, 1, _initialBuffer, Snapshot);
|
||||
SetGlobalArgs(FilterPreviewWidth, FilterPreviewHeight, 1, _initialBuffer, Snapshot);
|
||||
InvokeGenerator();
|
||||
|
||||
BlockBuffer();
|
||||
|
@ -131,7 +131,7 @@ namespace Matrix_App
|
|||
if (!ShowEditDialog(matrix))
|
||||
return;
|
||||
|
||||
FlipColorStoreRG_GR(_animationBuffer, _form.Gif);
|
||||
FlipColorStoreRG_GR(_animationBuffer, _form.gifBuffer);
|
||||
_form.ResetTimeline();
|
||||
}
|
||||
|
||||
|
@ -331,15 +331,15 @@ namespace Matrix_App
|
|||
private static void Initialize(in Matrix matrix)
|
||||
{
|
||||
// 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);
|
||||
FlipColorStoreRG_GR(_form.Gif, _initialBuffer);
|
||||
_initialBuffer = CreateImageRGB_NT(matrix.matrixWidth(), matrix.matrixHeight(), _form.gifBuffer.Length);
|
||||
FlipColorStoreRG_GR(_form.gifBuffer, _initialBuffer);
|
||||
|
||||
// Set Generator args
|
||||
SetGlobalArgs(matrix.matrixWidth(),
|
||||
matrix.matrixHeight(),
|
||||
_form.Gif.Length - 1,
|
||||
_form.gifBuffer.Length - 1,
|
||||
_initialBuffer,
|
||||
CreateImageRGB_NT(matrix.matrixWidth(), matrix.matrixHeight(), _form.Gif.Length)
|
||||
CreateImageRGB_NT(matrix.matrixWidth(), matrix.matrixHeight(), _form.gifBuffer.Length)
|
||||
);
|
||||
|
||||
// Create preview matrix
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -8,7 +8,7 @@ using System.Security.Permissions;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
using static MatrixDesigner.Defaults;
|
||||
using static Matrix_App.Defaults;
|
||||
|
||||
namespace Matrix_App
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ namespace Matrix_App
|
|||
|
||||
private volatile bool isPortValid = false;
|
||||
|
||||
private byte[] recived = new byte[ARDUINO_RECIVCE_BUFFER_SIZE];
|
||||
private byte[] recived = new byte[ArduinoReceiveBufferSize];
|
||||
private int mark;
|
||||
|
||||
public PortCommandQueue(ref SerialPort port)
|
||||
|
@ -62,7 +62,7 @@ namespace Matrix_App
|
|||
|
||||
int b;
|
||||
mark = 0;
|
||||
while((b = port.ReadByte()) != ARDUINO_SUCCESS_BYTE)
|
||||
while((b = port.ReadByte()) != ArduinoSuccessByte)
|
||||
{
|
||||
recived[mark++] = (byte) b;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace Matrix_App
|
|||
portDeliverThread.Start();
|
||||
}
|
||||
|
||||
if (byteWriteQueue.Count < ARDUINO_COMMAND_QUEUE_SIZE)
|
||||
if (byteWriteQueue.Count < ArduinoCommandQueueSize)
|
||||
{
|
||||
lock (byteWriteQueue)
|
||||
{
|
||||
|
@ -153,7 +153,7 @@ namespace Matrix_App
|
|||
timeCount++;
|
||||
Thread.Sleep(500);
|
||||
|
||||
wait = timeCount == DEQUEUE_WAIT_TIMEOUT_COUNTER;
|
||||
wait = timeCount == DequeueWaitTimeoutCounter;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Matrix_App
|
||||
{
|
||||
static class Program
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
private static void Main()
|
||||
{
|
||||
|
||||
SplashScreen.ShowSplashScreen();
|
||||
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MatrixDesignerMain());
|
||||
|
||||
var designer = new MatrixDesignerMain();
|
||||
|
||||
SplashScreen.CloseForm();
|
||||
|
||||
Application.Run(designer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
// Laufzeitversion:4.0.30319.42000
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
// der Code erneut generiert wird.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -13,12 +13,12 @@ namespace Matrix_App.Properties {
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||
// 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", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
|
@ -33,7 +33,7 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
/// 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 {
|
||||
|
@ -47,8 +47,8 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
/// 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 {
|
||||
|
@ -61,7 +61,7 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <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 Apply {
|
||||
get {
|
||||
|
@ -71,7 +71,7 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <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 ClearTool {
|
||||
get {
|
||||
|
@ -81,7 +81,7 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <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 FillTool {
|
||||
get {
|
||||
|
@ -91,7 +91,7 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <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 Frosch {
|
||||
get {
|
||||
|
@ -101,7 +101,7 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <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 Gif {
|
||||
get {
|
||||
|
@ -111,7 +111,17 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <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>
|
||||
internal static System.Drawing.Bitmap Play {
|
||||
get {
|
||||
|
@ -121,7 +131,7 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <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 Save {
|
||||
get {
|
||||
|
@ -131,7 +141,7 @@ namespace Matrix_App.Properties {
|
|||
}
|
||||
|
||||
/// <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 Stop {
|
||||
get {
|
||||
|
|
|
@ -142,4 +142,7 @@
|
|||
<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>
|
||||
</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>
|
Binary file not shown.
After Width: | Height: | Size: 439 KiB |
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -5,7 +5,7 @@ using System.Drawing;
|
|||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Text;
|
||||
using static MatrixDesigner.Defaults;
|
||||
using static Matrix_App.Defaults;
|
||||
|
||||
namespace Matrix_App
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ namespace Matrix_App
|
|||
{
|
||||
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(
|
||||
(byte) buffer[index + 0],
|
||||
|
@ -104,7 +104,7 @@ namespace Matrix_App
|
|||
|
||||
for (int frame = 0; frame < frames; frame++)
|
||||
{
|
||||
bytes[frame] = new byte[width * height * BPP];
|
||||
bytes[frame] = new byte[width * height * Bpp];
|
||||
}
|
||||
|
||||
return bytes;
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
33bf45022f7912fceecdbeaf19d1442e0f0a576f
|
||||
ee8b86baf58d13435f960406ec4b0be78d0cc26c
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue