Ejemplo n.º 1
0
        private void muLoad_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog theDialog = new OpenFileDialog();

            theDialog.Filter      = "DAT Files (*.DAT)|*.DAT";
            theDialog.Multiselect = false;
            theDialog.Title       = "Select an Icon DAT to Load";

            if (theDialog.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(theDialog.FileName))
                {
                    mFileName = theDialog.FileName;
                }
            }
            else
            {
                return;
            }

            FileStream srcStream = new FileStream(mFileName, FileMode.Open, FileAccess.Read);

            myIcons = new FFIcon[srcStream.Length / FFIcon.SIZE_ICON];
            byte[] temp = new byte[FFIcon.SIZE_ICON];
            FFIcon tempIcon;

            int i = 0;

            comboBox1.Items.Clear();
            while (srcStream.Read(temp, 0, FFIcon.SIZE_ICON) == FFIcon.SIZE_ICON)
            {
                tempIcon   = new FFIcon(temp);
                myIcons[i] = tempIcon;
                comboBox1.Items.Add(i.ToString() + " - " + myIcons[i].Description);
                ++i;
            }
            srcStream.Close();

            comboBox1.SelectedIndex = 0;
        }
Ejemplo n.º 2
0
        private void muCompareIcons_Click(object sender, EventArgs e)
        {
            if (myIcons == null)
            {
                MessageBox.Show("You must open an icon dat file before comparing to another file.", "Error");
                return;
            }

            OpenFileDialog theDialog = new OpenFileDialog();
            string         filename  = "";

            theDialog.Filter      = "DAT Files (*.DAT)|*.DAT";
            theDialog.Multiselect = false;
            theDialog.Title       = "Select an Icon DAT to Load";

            if (theDialog.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(theDialog.FileName))
                {
                    filename = theDialog.FileName;
                }
            }
            else
            {
                return;
            }

            FileStream srcStream = new FileStream(filename, FileMode.Open, FileAccess.Read);

            byte[]    temp = new byte[FFIcon.SIZE_ICON];
            FFIcon    tempIcon;
            ArrayList DifferencesList = new ArrayList();
            string    differences     = "Differences:\n";

            int i = 0;

            while (srcStream.Read(temp, 0, FFIcon.SIZE_ICON) == FFIcon.SIZE_ICON)
            {
                tempIcon = new FFIcon(temp);

                if (i >= myIcons.Length ||
                    (!muSmallIcons.Checked && !myIcons[i].BitmapEquals(tempIcon.Bitmap)) ||
                    (muSmallIcons.Checked && !myIcons[i].SmallBitmapEquals(tempIcon.SmallBitmap)))
                {
                    DifferencesList.Add(i);
                    differences += i.ToString() + ", ";
                    if (DifferencesList.Count % 10 == 0)
                    {
                        differences += "\n";
                    }
                }

                ++i;
            }

            srcStream.Close();

            if (DifferencesList.Count > 0)
            {
                // remove trailing commas and new lines
                if (DifferencesList.Count % 10 == 0)
                {
                    differences = differences.Substring(0, differences.Length - 3);
                }
                else
                {
                    differences = differences.Substring(0, differences.Length - 2);
                }

                if (DifferencesList.Count == 1)
                {
                    differences = differences.Replace("s", "");
                }

                // show the differences
                MessageBox.Show(DifferencesList.Count.ToString() + " " + differences);
            }
            else
            {
                MessageBox.Show("All icons match.");
            }
        }