Archive Browser
Download CorelDrawPalPaletteLoader.zip, last updated 21/07/2018 (17.87 KB)
Download- md5: d087b521549c15bead0178e98453caf8
- sha1: 1d576767f47ca15976ccba8a56922da4793e7e5a
- sha256: 24bdc574d1725993cae5543da51745037853dbf72c7e60e5ecf4f635d9374858
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
// Reading CorelDRAW Palettes Part 1, .pal files
// https://www.cyotek.com/blog/reading-coreldraw-palettes-part-1-pal-files
// Copyright © 2018 Cyotek Ltd. All Rights Reserved.
// This work is licensed under the Creative Commons Attribution 4.0 International License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
// Found this example useful?
// https://www.paypal.me/cyotek
namespace Cyotek.Demonstrations.CorelDrawPaletteLoader
{
internal partial class MainForm : Form
{
#region Fields
private List<FileInfo> _fileInfo;
private CorelDrawPalette _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 CorelDrawPalette();
_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;
}
#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