Esempio n. 1
0
        private void buttonNew_Click(object sender, EventArgs e)
        {
            FormMain formNext = new FormMain(true);

            formNext.Show( );
        }
Esempio n. 2
0
        bool open(FormMain form)
        {
            string path = openFileDialog.FileName;
            int    i, j;
            int    rowCount, colCount;

            listBoxResult.Items.Add("Открытие ...");

            try {
                using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open))) {
                    form.maxCols   = reader.ReadInt32( );
                    form.centerCol = reader.ReadInt32( );
                    form.selectCol = reader.ReadInt32( );
                    int textLength = reader.ReadInt32( );
                    form.textBoxAlphabet.Text = reader.ReadString( );
                    colCount = reader.ReadInt32( );
                    form.addAlphabet( );

                    for (j = 0; j < colCount; j++)
                    {
                        form.dataGridViewTapeTittle.Columns.Add(new DataGridViewTextBoxColumn( )
                        {
                            Width    = colWidth,
                            SortMode = DataGridViewColumnSortMode.NotSortable
                        });

                        form.dataGridViewTape.Columns.Add(new DataGridViewComboBoxColumn( )
                        {
                            Width    = colWidth,
                            SortMode = DataGridViewColumnSortMode.NotSortable
                        });
                    }

                    int col;
                    form.dataGridViewTapeTittle.RowCount = 1;
                    form.dataGridViewTape.RowCount       = 1;
                    form.dataGridViewTapeTittle.Rows[0].DefaultCellStyle.BackColor = Color.Gainsboro;
                    form.dataGridViewTape.RowCount = 1;
                    form.dataGridViewTapeTittle.Rows[0].ReadOnly = true;

                    for (j = 0; j < form.centerCol; j++)
                    {
                        col = form.centerCol + j;
                        form.dataGridViewTapeTittle[j, 0].Value = form.centerCol - j;
                        (( DataGridViewComboBoxColumn )form.dataGridViewTape.Columns[j]).Items.AddRange(form.alphabet);
                        form.dataGridViewTapeTittle[col, 0].Value = j;
                        (( DataGridViewComboBoxColumn )form.dataGridViewTape.Columns[col]).Items.AddRange(form.alphabet);
                    }

                    col = colCount - 1;
                    form.dataGridViewTapeTittle[col, 0].Value = j;
                    (( DataGridViewComboBoxColumn )form.dataGridViewTape.Columns[col]).Items.AddRange(form.alphabet);

                    for (j = 0; j < colCount; j++)
                    {
                        form.dataGridViewTape[j, 0].Value = reader.ReadString( );
                    }

                    form.dataGridViewTapeTittle.CurrentCell = form.dataGridViewTapeTittle[form.selectCol, 0];
                    form.dataGridViewTape.CurrentCell       = form.dataGridViewTape[form.selectCol, 0];
                    form.dataGridViewTapeTittle.Columns[form.selectCol].HeaderText = "";
                    form.dataGridViewTapeTittle.FirstDisplayedCell = form.dataGridViewTapeTittle[form.selectCol - 5, 0];
                    form.dataGridViewTape.FirstDisplayedCell       = form.dataGridViewTape[form.selectCol - 5, 0];

                    rowCount = reader.ReadInt32( );
                    colCount = reader.ReadInt32( );
                    form.addRows(rowCount);
                    form.dataGridViewTableTittle.ColumnCount = reader.ReadInt32( );

                    for (j = col = 0; j < form.dataGridViewTableTittle.ColumnCount; j++, col += 3)
                    {
                        form.dataGridViewTableTittle.Columns[j].HeaderText = form.textBoxAlphabet.Text.Substring(j, 1);
                        form.dataGridViewTableTittle.Columns[j].Width      = colWidth * 3;
                        form.dataGridViewTableTittle.Columns[j].SortMode   = DataGridViewColumnSortMode.NotSortable;
                        form.dataGridViewTableTittle.Columns[j].HeaderText = reader.ReadString( );

                        for (i = 0; i < 3; i++)
                        {
                            form.dataGridViewTable.Columns.Add(new DataGridViewComboBoxColumn( )
                            {
                                Width    = colWidth,
                                SortMode = DataGridViewColumnSortMode.NotSortable
                            });
                        }

                        (( DataGridViewComboBoxColumn )form.dataGridViewTable.Columns[col]).Items.AddRange(form.alphabet);
                        form.dataGridViewTable.Columns[col].HeaderText = "A";
                        (( DataGridViewComboBoxColumn )form.dataGridViewTable.Columns[col + 1]).Items.AddRange(form.direct);
                        form.dataGridViewTable.Columns[col + 1].HeaderText = "D";
                        (( DataGridViewComboBoxColumn )form.dataGridViewTable.Columns[col + 2]).Items.AddRange(form.rows);
                        form.dataGridViewTable.Columns[col + 2].HeaderText = "Q";
                    }

                    form.dataGridViewTable.RowCount = rowCount;

                    for (i = 0; i < rowCount; i++)
                    {
                        for (j = 0; j < colCount; j++)
                        {
                            form.dataGridViewTable[j, i].Value = reader.ReadString( );
                        }
                        form.dataGridViewTable.Rows[i].HeaderCell.Value = (i + 1).ToString( );
                    }

                    form.dataGridViewTable.Rows[rowCount].HeaderCell.Value = (i + 1).ToString( );

                    int itemsCount = reader.ReadInt32( );
                    for (i = 0; i < itemsCount; i++)
                    {
                        form.listBoxResult.Items.Add(reader.ReadString( ));
                    }
                }

                listBoxResult.Items.Add(" ОК");
            } catch (Exception e) {
                listBoxResult.Items.Add(" Ошибка : " + e.Message);
            }

            listBoxResult.Items.Add("");
            form.textBoxAlphabet.Focus( );
            return(true);
        }