private void leftFileComboBox_SelectedIndexChanged(object sender, EventArgs e) { FileInfo leftFile = leftFileComboBox.SelectedItem as FileInfo; foreach (FileInfo f in leftFilesList) { if (!rightFilesList.Contains(f)) { rightFilesList.Add(f); break; } } rightFilesList.Remove(leftFile); int index = (LeftSelectedIndex < RightSelectedIndex) ? RightSelectedIndex : LeftSelectedIndex; ByteBlock.Load(leftFile, leftBlocksList); if (LeftSelectedIndex == index) { UpdateLineOverLine(); } else { LeftSelectedIndex = index; } }
private void rightFileComboBox_SelectedIndexChanged(object sender, EventArgs e) { FileInfo rightFile = rightFileComboBox.SelectedItem as FileInfo; foreach (FileInfo f in rightFilesList) { if (!leftFilesList.Contains(f)) { leftFilesList.Add(f); break; } } leftFilesList.Remove(rightFile); int index = (RightSelectedIndex < LeftSelectedIndex) ? LeftSelectedIndex : RightSelectedIndex; ByteBlock.Load(rightFile, rightBlocksList); if (RightSelectedIndex == index) { UpdateLineOverLine(); } else { RightSelectedIndex = index; } }
internal int InitializeComponents(int tabIndex) { leftFilesBindingSource.DataSource = leftFilesList; leftBlocksBindingSource.DataSource = leftBlocksList; rightFilesBindingSource.DataSource = rightFilesList; rightBlocksBindingSource.DataSource = rightBlocksList; AutoSize = true; Text = "Bytes"; outerTableLayoutPanel.AutoSize = true; outerTableLayoutPanel.Dock = DockStyle.Fill; splitContainer.AutoSize = true; splitContainer.Dock = DockStyle.Fill; splitContainer.TabIndex = tabIndex++; // #region rightTableLayoutPanel leftTableLayoutPanel.AutoSize = true; leftTableLayoutPanel.Dock = DockStyle.Fill; leftFileLabel.Anchor = AnchorStyles.Top | AnchorStyles.Right; leftFileLabel.Margin = new Padding(3, 3, 0, 3); leftFileLabel.AutoSize = true; leftFileLabel.Font = new Font(leftFileLabel.Font, FontStyle.Bold); leftFileLabel.Text = "First File:"; leftFileComboBox.Dock = DockStyle.Top; leftFileComboBox.Margin = new Padding(0, 3, 3, 3); leftFileComboBox.DataSource = leftFilesBindingSource; leftFileComboBox.DisplayMember = "Name"; leftBlocksDataGridView.Dock = DockStyle.Fill; leftBlocksDataGridView.ReadOnly = true; leftBlocksDataGridView.AutoGenerateColumns = false; leftBlocksDataGridView.AllowUserToAddRows = false; leftBlocksDataGridView.AllowUserToDeleteRows = false; leftBlocksDataGridView.DataSource = leftBlocksBindingSource; leftBlocksDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; leftBlocksDataGridView.MultiSelect = false; leftBlocksDataGridView.Columns.AddRange(new DataGridViewColumn[] { new DataGridViewTextBoxColumn() { DataPropertyName = "DWord0", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, ReadOnly = true }, new DataGridViewTextBoxColumn() { DataPropertyName = "DWord1", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, ReadOnly = true }, new DataGridViewTextBoxColumn() { DataPropertyName = "DWord2", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, ReadOnly = true }, new DataGridViewTextBoxColumn() { DataPropertyName = "DWord3", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, ReadOnly = true } }); // #endregion // #region rightTableLayoutPanel rightTableLayoutPanel.AutoSize = true; rightTableLayoutPanel.Dock = DockStyle.Fill; rightFileLabel.Anchor = AnchorStyles.Top | AnchorStyles.Right; rightFileLabel.Margin = new Padding(3, 3, 0, 3); rightFileLabel.AutoSize = true; rightFileLabel.Font = new Font(rightFileLabel.Font, FontStyle.Bold); rightFileLabel.Text = "Second File:"; rightFileComboBox.Dock = DockStyle.Top; rightFileComboBox.Margin = new Padding(0, 3, 3, 3); rightFileComboBox.DataSource = rightFilesBindingSource; rightFileComboBox.DisplayMember = "Name"; rightBlocksDataGridView.ReadOnly = true; rightBlocksDataGridView.AutoGenerateColumns = false; rightBlocksDataGridView.AllowUserToAddRows = false; rightBlocksDataGridView.AllowUserToDeleteRows = false; rightBlocksDataGridView.Dock = DockStyle.Fill; rightBlocksDataGridView.DataSource = rightBlocksBindingSource; rightBlocksDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; rightBlocksDataGridView.MultiSelect = false; rightBlocksDataGridView.Columns.AddRange(new DataGridViewColumn[] { new DataGridViewTextBoxColumn() { DataPropertyName = "DWord0", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, ReadOnly = true }, new DataGridViewTextBoxColumn() { DataPropertyName = "DWord1", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, ReadOnly = true }, new DataGridViewTextBoxColumn() { DataPropertyName = "DWord2", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, ReadOnly = true }, new DataGridViewTextBoxColumn() { DataPropertyName = "DWord3", AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, ReadOnly = true } }); // #endregion lineNumberHeadingLabel.Anchor = AnchorStyles.Top | AnchorStyles.Right; lineNumberHeadingLabel.Margin = new Padding(3, 3, 0, 3); lineNumberHeadingLabel.AutoSize = true; lineNumberHeadingLabel.Font = new Font(rightFileLabel.Font, FontStyle.Bold); lineNumberHeadingLabel.Text = "Byte:"; lineNumberValueLabel.Anchor = AnchorStyles.Top | AnchorStyles.Left; lineNumberValueLabel.Margin = new Padding(0, 3, 3, 3); lineNumberValueLabel.AutoSize = true; lineNumberValueLabel.Text = "0"; lineOverLineTextBox.Dock = DockStyle.Fill; lineOverLineTextBox.Multiline = true; Font font = new Font(FontFamily.GenericMonospace, 10.0f); lineOverLineTextBox.Font = font; lineOverLineTextBox.MinimumSize = new Size(1, (font.Height * 3) + 6); lineOverLineTextBox.ScrollBars = ScrollBars.Horizontal; lineOverLineTextBox.ReadOnly = true; lineOverLineTextBox.WordWrap = false; FileInfo leftFile, rightFile; if (rightFilesList.Count > 1) { leftFileComboBox.SelectedItem = leftFile = leftFilesList[0]; leftFileComboBox.TabIndex = tabIndex++; leftBlocksDataGridView.TabIndex = tabIndex++; rightFileComboBox.SelectedItem = rightFile = rightFilesList[0]; rightFileComboBox.TabIndex = tabIndex++; rightBlocksDataGridView.TabIndex = tabIndex++; leftFileComboBox.SelectedIndexChanged += leftFileComboBox_SelectedIndexChanged; rightFileComboBox.SelectedIndexChanged += rightFileComboBox_SelectedIndexChanged; } else { if (rightFilesList.Count > 0) { leftFileComboBox.SelectedItem = leftFile = leftFilesList[0]; rightFileComboBox.SelectedItem = rightFile = rightFilesList[0]; } else { rightFile = null; if (leftFilesList.Count > 0) { leftFileComboBox.SelectedItem = leftFile = leftFilesList[0]; } else { leftFile = null; } } leftFileComboBox.TabStop = rightFileComboBox.TabStop = false; leftFileLabel.Visible = leftFileComboBox.Visible = rightFileLabel.Visible = rightFileComboBox.Visible = false; leftFileComboBox.Enabled = rightFileComboBox.Enabled = false; leftBlocksDataGridView.TabIndex = tabIndex++; rightBlocksDataGridView.TabIndex = tabIndex++; } lineOverLineTextBox.TabIndex = tabIndex++; ByteBlock.Load(leftFile, leftBlocksList); ByteBlock.Load(rightFile, rightBlocksList); if (leftBlocksList.Count > 0) { leftBlocksDataGridView.Rows[0].Selected = true; } if (rightBlocksList.Count > 0) { rightBlocksDataGridView.Rows[0].Selected = true; } leftBlocksDataGridView_SelectionChanged(leftBlocksDataGridView, EventArgs.Empty); leftBlocksDataGridView.SelectionChanged += leftBlocksDataGridView_SelectionChanged; rightBlocksDataGridView.SelectionChanged += rightBlocksDataGridView_SelectionChanged; return(tabIndex); }