This project is read-only.

How to control HexControl properties?

The best available option is to create "options" form to tweak the HexControl at the run-time.

    [DesignTimeVisible(false)]
    public sealed partial class HexOptionsForm1 : Form
    {
        private HexControl hexControl;

        public HexOptionsForm1(HexControl hexView)
        {
            InitializeComponent();

            this.hexControl = hexView;

            domainUpDown1.SelectedItemChanged -= domainUpDown1_SelectedItemChanged;
            numericUpDown1.ValueChanged -= numericUpDown1_ValueChanged;
            checkBox1.CheckedChanged -= checkBox1_CheckedChanged;

            domainUpDown1.SelectedIndex = domainUpDown1.Items.IndexOf(hexControl.Model.BytesPerColumn.ToString());
            numericUpDown1.Value = hexControl.Model.ColumnsPerRow;

            checkBox1.Checked = hexControl.Model.DrawLegend;
            domainUpDown1.SelectedItemChanged += domainUpDown1_SelectedItemChanged;
            numericUpDown1.ValueChanged += numericUpDown1_ValueChanged;
            checkBox1.CheckedChanged += checkBox1_CheckedChanged;
        }

        private HexOptionsForm1()
        {
            InitializeComponent();
        }

        private void UpdateView()
        {
            hexControl.Model.BytesPerColumn = int.Parse((string)domainUpDown1.SelectedItem);
            hexControl.Model.ColumnsPerRow = (int)numericUpDown1.Value;
            hexControl.Model.DrawLegend = checkBox1.Checked;
            hexControl.UpdateView();
        }

        private void domainUpDown1_SelectedItemChanged(object sender, EventArgs e)
        {
            UpdateView();
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            UpdateView();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            UpdateView();
        }
    }
}

Example

        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HexOptionsForm1 hexOptionsForm1 = new HexOptionsForm1(bottom0);
            hexOptionsForm1.ShowDialog(this);
        }

Last edited May 1, 2012 at 3:22 AM by hack2root, version 2

Comments

No comments yet.