Files
McBitFont/McBitFont/CodeShift.cs
Anton Mukhin 8c08c9a897 TODO features:
Application:
- Change Menu icons
- Re-arranged menu items

Functionality:
- Shift all symbols on code line (change symbol codes)
- Specify starting code (extends the shift)
2025-05-22 06:33:10 +03:00

100 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace McBitFont {
public partial class CodeShift : Form {
private int maxLeft, maxRight, maxSC, count;
public int sc;
public CodeShift(MainForm parent) {
InitializeComponent();
count = parent.frames.Count;
sc = parent.frames.First().code;
maxLeft = sc;
maxRight = 255 - sc - count + 1;
maxSC = sc + maxRight;
}
private void CodeShift_Load(object sender, EventArgs e) {
byte enabled = 7;
string msg = "";
if (maxLeft < 1) {
rbShiftLeft.Enabled = false;
enabled -= 1;
msg += "Cannot shift left: Start code is " + sc.ToString() + ".";
}
if (maxRight < 1) {
rbShiftRight.Enabled = false;
enabled -= 2;
msg += "\nCannot shift right: Last code is " + (sc + count - 1).ToString() + ".";
}
if (maxSC <= 0) {
rbSpecify.Enabled = false;
enabled -= 4;
msg += "\nCannot shift: The font is full." + (sc + count - 1).ToString();
}
lblMessage.Text = msg;
if ((enabled & 1) > 0) rbShiftLeft.Checked = true;
else if ((enabled & 2) > 0) rbShiftRight.Checked = true;
else if ((enabled & 4) > 0) rbSpecify.Checked = true;
else {
btnOK.Enabled = false;
nudValue.Enabled = false;
}
//ModeChanged(rbShiftLeft, null);
//nudValue.Minimum = 1;
//nudValue.Maximum = maxLeft;
}
private void ModeChanged(object sender, EventArgs e) {
if (rbSpecify.Checked) {
lblValue.Text = "New start code:";
nudValue.Minimum = 0;
nudValue.Maximum = maxSC;
nudValue.Value = 0;
lblRange.Text = "min: 0\nmax: " + maxSC.ToString();
} else {
lblValue.Text = "Shift by:";
nudValue.Minimum = 1;
nudValue.Value = 1;
if (rbShiftLeft.Checked) {
nudValue.Maximum = maxLeft;
lblRange.Text = "min: 1\nmax: " + maxLeft.ToString();
}
if (rbShiftRight.Checked) {
nudValue.Maximum = maxRight;
lblRange.Text = "min: 1\nmax: " + maxRight.ToString();
}
}
}
private void nudValue_ValueChanged(object sender, EventArgs e) {
if (rbSpecify.Checked) {
if (nudValue.Value == sc) btnOK.Enabled = false;
else btnOK.Enabled = true;
}
}
private void btnOK_Click(object sender, EventArgs e) {
DialogResult = DialogResult.OK;
}
private void btnCancel_Click(object sender, EventArgs e) {
DialogResult = DialogResult.Cancel;
}
}
}