private void AnalyzePaletteUsage(bool writeResultFile)
        {
            int filescount = this.listView_MainFileList.SelectedItems.Count;

            if (filescount > 1)
            {
                enhmb = new EnhancedMessageBox();
                enhmb.StartPosition = FormStartPosition.Manual;
                enhmb.Location      = new Point(this.Location.X, this.Location.Y);
                enhmb.SetText("Processing files.\nThis may take a few seconds.");
                enhmb.SetCaption("Processing files.");
                enhmb.ProgressBarVisible(true);
                enhmb.button_OK_text("Abort");
                enhmb.Show();


                Cursor.Current = Cursors.WaitCursor;
                Application.DoEvents(); //finish showing the dialog before starting the cpu-intensive operation

                enhmb.ProgressBarSize(filescount);
            }
            int pb = 0;

            paletteUsage = new long[256];

            foreach (ListViewItem item in this.listView_MainFileList.SelectedItems)
            {
                pb++;
                if (filescount > 1)
                {
                    enhmb.SetText("Processing files.\nThis may take a few seconds.\n\nFile: " + item.Text);
                    enhmb.ProgressBarValue((int)pb);
                    Application.DoEvents();
                    //accept user input and when the messagebox is closed, stop working
                    if (enhmb.Visible == false)
                    {
                        break;
                    }
                }

                int[] shpPaletteUsage = CSHaPer.GetSHPPaletteUsage(item.Tag.ToString());
                for (int i = 0; i < shpPaletteUsage.Length; i++)
                {
                    paletteUsage[i] += shpPaletteUsage[i];
                }
            }//foreach file
            if (filescount > 1)
            {
                enhmb.Close();
                Application.DoEvents(); //finish showing the dialog before starting the cpu-intensive operation
                Cursor.Current = Cursors.Default;
            }
            this.uC_EditorPalette1.PaletteUsage = paletteUsage;
            //create result file
            if (writeResultFile)
            {
                string result = "";
                result  = "Palette Usage Result\r\n";
                result += "Colorindex = Number of pixel using that color\r\n\r\n";
                for (int i = 0; i < paletteUsage.Length; i++)
                {
                    result += string.Format("{0:000}", i) + " = " + paletteUsage[i].ToString() + "\r\n";
                }
                System.IO.File.WriteAllText(defaultPath + "#PaletteUsage.txt", result);
                System.Diagnostics.Process.Start(defaultPath + "#PaletteUsage.txt");
            }
        }