Download AdobeSwatchExchangeLoader-v2.zip version 2.0.0.0, last updated 21/10/2015 (72.79 KB)

Download
  • md5: 3591debc1f6749c23ad9bbd113dd760a
  • sha1: 9b8b0e53179b0b8d04c14324125ae5452df58305
  • sha256: 152c5051abec694120031b4b0ed923608627b0081994f99cf6d043cc1663ed20
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

// Writing Adobe Swatch Exchange (ase) files using C#
// http://www.cyotek.com/blog/writing-adobe-swatch-exchange-ase-files-using-csharp

namespace AdobeSwatchExchangeLoader
{
  public partial class CompareResultsDialog : Form
  {
    #region Constructors

    public CompareResultsDialog()
    {
      this.InitializeComponent();
    }

    public CompareResultsDialog(string sourceFileName)
      : this()
    {
      string destinationFileName;

      destinationFileName = Path.GetTempFileName();

      try
      {
        AseDocument document;
        AseCompareResult compareResult;

        document = new AseDocument();
        document.Load(sourceFileName);

        document.Save(destinationFileName);

        compareResult = AseComparer.Compare(sourceFileName, destinationFileName);

        if (compareResult == AseCompareResult.Mismatch)
        {
          resultLabel.Text = "Files do not match.";
          resultLabel.BackColor = Color.Red;
        }
        else if (compareResult == AseCompareResult.ColorMatch)
        {
          resultLabel.Text = "Byte data of files does not match, but colour information is a match.";
          resultLabel.BackColor = Color.Orange;
          resultLabel.ForeColor = Color.Black;
        }

        sourceAseHexViewer.FileName = sourceFileName;
        destinationAseHexViewer.FileName = destinationFileName;
      }
      finally
      {
        File.Delete(destinationFileName);
      }
    }

    #endregion

    #region Methods

    private void closeButton_Click(object sender, EventArgs e)
    {
      this.Close();
    }

    private void destinationAseHexViewer_TopRowChanged(object sender, EventArgs e)
    {
      this.SyncRow(destinationAseHexViewer, sourceAseHexViewer);
    }

    private void sourceAseHexViewer_TopRowChanged(object sender, EventArgs e)
    {
      this.SyncRow(sourceAseHexViewer, destinationAseHexViewer);
    }

    private void SyncRow(AseHexViewer source, AseHexViewer dest)
    {
      int row;

      row = source.TopRow;
      if (dest.Rows > row)
      {
        dest.TopRow = row;
        dest.Refresh();
      }
    }

    #endregion
  }
}

Donate

Donate