Archive Browser
Download CorelDrawPalPaletteWriter.zip, last updated 05/08/2018 (30.38 KB)
Download- md5: 5dc2a39ffc96357d70d670fae102a69c
- sha1: 87cd30771c13132db0584ebbc03986265fa278dc
- sha256: 9cc4800ea9713c1d7f95660b1deba20f3c13e9f317171b2cbc0ff358ace10f7e
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
// Working with CorelDRAW Palettes part 1, reading .pal files
// https://www.cyotek.com/blog/reading-coreldraw-palettes-part-1-pal-files
// Copyright © 2018 Cyotek Ltd. All Rights Reserved.
// Working with CorelDRAW Palettes part 2, writing .pal files
// https://www.cyotek.com/blog/working-with-coreldraw-palettes-part-2-writing-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.CorelDrawPaletteWriter
{
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;
}
private void writeTestToolStripMenuItem_Click(object sender, EventArgs e)
{
using (WriteTestDialog dialog = new WriteTestDialog(_fileInfo))
{
dialog.ShowDialog();
}
}
#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