private void cbxCodePage_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.lbxText.Items.Clear();
            CodePageWrapper cpw = this.cbxCodePage.SelectedItem as CodePageWrapper;

            if (cpw != null)
            {
                foreach (int ansiCharPosition in this._ansiCharPositions)
                {
                    int           p0 = Math.Max(0, ansiCharPosition - 10);
                    int           p1 = Math.Min(this._dataBytes.Length - 1, ansiCharPosition + 10);
                    StringBuilder sb = new StringBuilder();
                    if (p0 > 0)
                    {
                        sb.Append("...");
                    }
                    sb.Append(Encoding.GetEncoding(cpw.CodePage).GetString(this._dataBytes, p0, p1 - p0 + 1));
                    if (p1 < (this._dataBytes.Length - 1))
                    {
                        sb.Append("...");
                    }
                    this.lbxText.Items.Add(sb.ToString());
                }
            }
            this.btnOk.Enabled = (cpw != null);
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            CodePageWrapper cpw = this.cbxCodePage.SelectedItem as CodePageWrapper;

            if (cpw == null)
            {
                return;
            }
            this._selectedCodePage = cpw.CodePage;
            this.DialogResult      = DialogResult.OK;
            this.Close();
        }
 public frmSelectCodePage(Dictionary<int, string> availableCodePages, int defaultCodePage, byte[] dataBytes, int[] ansiCharPositions)
 {
     InitializeComponent();
     Utils.Gfx.SetFormIcon(this);
     this._selectedCodePage = 0;
     this._dataBytes = dataBytes;
     this._ansiCharPositions = ansiCharPositions;
     this.cbxCodePage.Items.Clear();
     CodePageWrapper selectedCP = null;
     foreach (KeyValuePair<int, string> availableCodePage in availableCodePages)
     {
         CodePageWrapper cpw = new CodePageWrapper(availableCodePage);
         if ((selectedCP == null) || (cpw.CodePage == defaultCodePage))
             selectedCP = cpw;
         this.cbxCodePage.Items.Add(cpw);
     }
     this.cbxCodePage.SelectedItem = selectedCP;
 }
        public frmSelectCodePage(Dictionary <int, string> availableCodePages, int defaultCodePage, byte[] dataBytes, int[] ansiCharPositions)
        {
            InitializeComponent();
            Utils.Gfx.SetFormIcon(this);
            this._selectedCodePage  = 0;
            this._dataBytes         = dataBytes;
            this._ansiCharPositions = ansiCharPositions;
            this.cbxCodePage.Items.Clear();
            CodePageWrapper selectedCP = null;

            foreach (KeyValuePair <int, string> availableCodePage in availableCodePages)
            {
                CodePageWrapper cpw = new CodePageWrapper(availableCodePage);
                if ((selectedCP == null) || (cpw.CodePage == defaultCodePage))
                {
                    selectedCP = cpw;
                }
                this.cbxCodePage.Items.Add(cpw);
            }
            this.cbxCodePage.SelectedItem = selectedCP;
        }