Archive Browser
Download WestwoodPaletteLoader.zip, last updated 26/12/2017 (27.76 KB)
Download- md5: da29ba80301e3fa413c90a973afdaec9
- sha1: 362ce84dba11d8047dc3c1dc3e44ee2f0edee602
- sha256: 2e31cc54ea412623684856d331851c8b213bc6369629c620a2fc2d44aedae2bd
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
// Reading and writing 18-bit RGB VGA Palette (pal) files with C#
// http://www.cyotek.com/blog/reading-and-writing-18-bit-rgb-vga-palette-pal-files-with-csharp
namespace Cyotek.Demonstrations.Rgb18BitPalette
{
internal partial class MainForm : Form
{
#region Fields
private List<FileInfo> _fileInfo;
private WestwoodPalette _loadedPalette;
#endregion
#region Constructors
public MainForm()
{
this.InitializeComponent();
}
#endregion
#region Methods
/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Form.Load"/> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data. </param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.Text = Application.ProductName;
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
_fileInfo = new List<FileInfo>(16);
this.AddFiles("pal");
if (filesListBox.Items.Count != 0)
{
filesListBox.SelectedIndex = 0;
}
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
using (Form dialog = new AboutDialog())
{
dialog.ShowDialog(this);
}
}
private void AddFiles(string extension)
{
string path;
path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data");
foreach (string fileName in Directory.GetFiles(path, "*." + extension))
{
FileInfo info;
info = new FileInfo(fileName);
_fileInfo.Add(info);
filesListBox.Items.Add(info);
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void filesListBox_SelectedIndexChanged(object sender, EventArgs e)
{
FileInfo selectedFile;
selectedFile = filesListBox.SelectedItem as FileInfo;
if (selectedFile != null)
{
_loadedPalette = new WestwoodPalette();
_loadedPalette.Load(selectedFile.FullPath);
this.Text = string.Format("{0} - {1}", Path.GetFileName(selectedFile.FullPath), Application.ProductName);
}
else
{
_loadedPalette = null;
this.Text = Application.ProductName;
}
previewGrid.Palette = _loadedPalette?.ToArray();
}
private void showLabelsCheckBox_CheckedChanged(object sender, EventArgs e)
{
previewGrid.ShowLabels = showLabelsCheckBox.Checked;
}
private void trackBar_ValueChanged(object sender, EventArgs e)
{
previewGrid.CellSize = trackBar.Value;
}
private void writeTestToolStripMenuItem_Click(object sender, EventArgs e)
{
using (WriteTestDialog dialog = new WriteTestDialog(_fileInfo))
{
dialog.ShowDialog(this);
}
}
#endregion
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate