示例#1
0
        private void dtgCompetition()
        {
            int X = metroGrid1.ColumnHeadersHeight + metroGrid1.Rows.Cast <DataGridViewRow>().Sum(r => r.Height);

            textBox1.Location   = new Point(metroGrid1.Location.X, X + metroGrid1.Location.Y + 15);
            textBox1.Size       = metroGrid2.Size;
            metroGrid2.Location = new Point(textBox1.Location.X, textBox1.Location.Y + textBox1.Size.Height + 1);
            metroGrid2.Rows.Clear();

            metroGrid2.RowHeadersVisible    = false;
            metroGrid2.ColumnHeadersVisible = false;
            metroGrid2.ColumnCount          = 1;

            metroGrid2.Rows.Add("구분");
            // 구분 색깔
            for (int i = 0; i < 1; i++)
            {
                metroGrid2.Rows[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                metroGrid2.Rows[i].Cells[0].Style.BackColor   = Color.FromArgb(91, 155, 213);
                metroGrid2.Rows[i].Cells[0].Style.ForeColor   = Color.White;
            }
            for (int i = 0; i < mainFrm.selectCompetitionAndSimilarity.Length; i++)
            {
                if (mainFrm.selectCompetitionAndSimilarity[i] == true)
                {
                    metroGrid2.Rows.Add(mainFrm.CompetitionData[0, i]);
                    metroGrid2.Rows[metroGrid2.RowCount - 1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    metroGrid2.Rows[metroGrid2.RowCount - 1].Cells[0].Style.BackColor   = Color.FromArgb(222, 235, 247);
                }
            }

            // 유사무기에 뭐가 있는지 추출해옴
            SimilarData = (string[])mainFrm.SimilarityWeapon.ToArray();

            /*
             * SimilarData = new string[mainFrm.Similar.GetLength(0)];
             * for (int i = 1; i < mainFrm.Similar.GetLength(0); i++)
             * {
             *  SimilarData[i - 1] = mainFrm.Similar[i, 3].ToString();
             * }
             * // 중복을 제거하고 난 뒤, Null 값도 제거하고
             * SimilarData = GetDistinctValues<string>(SimilarData);
             * SimilarData = SimilarData.Where(condition => condition != null).ToArray();
             */
            // 경쟁무기 개수만큼 열을 추가
            for (int i = 0; i < SimilarData.Length; i++)
            {
                metroGrid2.Columns.Add("", "");
                metroGrid2.Rows[0].Cells[i + 1].Style.BackColor = Color.FromArgb(218, 83, 44);
                metroGrid2.Rows[0].Cells[i + 1].Style.ForeColor = Color.White;
                metroGrid2.Rows[0].DefaultCellStyle.Font        = new Font("나눔고딕", 9, FontStyle.Bold);

                // M151을 기준으로 데이터들을 탐색함
                var IndexOf2DArray = ExtensionMethods.CoordinatesOf(mainFrm.CompetitionData, SimilarData[i]);


                int count = 1;
                metroGrid2.Rows[0].Cells[i + 1].Value = SimilarData[i]; // 무기명
                for (int j = 0; j < mainFrm.selectCompetitionAndSimilarity.Length; j++)
                {
                    if (mainFrm.selectCompetitionAndSimilarity[j] == true)
                    {
                        metroGrid2.Rows[count].Cells[i + 1].Value = mainFrm.CompetitionData[IndexOf2DArray.Item1, j];
                        count++;
                    }
                }

                /*
                 * // ★나중에 for문하나로 바꿔야함. 범용성
                 * metroGrid2.Rows[0].Cells[i + 1].Value = SimilarData[i]; // 무기명
                 * metroGrid2.Rows[1].Cells[i + 1].Value = mainFrm.CompetitionData[IndexOf2DArray.Item1, 6];   // 개발국가
                 * metroGrid2.Rows[2].Cells[i + 1].Value = mainFrm.CompetitionData[IndexOf2DArray.Item1, 5];   // 제작사
                 * metroGrid2.Rows[8].Cells[i + 1].Value = mainFrm.CompetitionData[IndexOf2DArray.Item1, 17];   // 선회
                 * metroGrid2.Rows[9].Cells[i + 1].Value = mainFrm.CompetitionData[IndexOf2DArray.Item1, 18];   // 고저
                 * metroGrid2.Rows[10].Cells[i + 1].Value = mainFrm.CompetitionData[IndexOf2DArray.Item1, 26];   // 구동속도
                 * metroGrid2.Rows[11].Cells[i + 1].Value = mainFrm.CompetitionData[IndexOf2DArray.Item1, 39];   // 안정화 정확도
                 * metroGrid2.Rows[12].Cells[i + 1].Value = mainFrm.CompetitionData[IndexOf2DArray.Item1, 38];   // 조준정확도
                 * metroGrid2.Rows[13].Cells[i + 1].Value = mainFrm.CompetitionData[IndexOf2DArray.Item1, 7];   // 단가
                 */
                for (int j = 1; j < metroGrid2.RowCount; j++)
                {
                    metroGrid2.Rows[j].Cells[i + 1].Style.BackColor = Color.White;
                }
            }

            // Design
            metroGrid2.DefaultCellStyle.BackColor = Color.White;

            // 국내무기체계 필요제원
            metroGrid2.Columns.Add("", "");


            metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Value           = "국내무기체계";
            metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Style.BackColor = Color.FromArgb(0, 176, 80);
            metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Style.ForeColor = Color.White;
            for (int j = 1; j < metroGrid2.RowCount; j++)
            {
                metroGrid2.Rows[j].Cells[metroGrid2.ColumnCount - 1].Style.BackColor = Color.White;
            }
            this.metroGrid2.DefaultCellStyle.Font = new Font("나눔고딕", 9);
            for (int i = 0; i < metroGrid2.ColumnCount; i++)
            {
                metroGrid2.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }

            textBox2.Size = metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Size;

            int txtBoxWidth = 0;

            for (int i = 0; i < SimilarData.Length; i++)
            {
                txtBoxWidth += metroGrid2.Columns[i + 1].Width;
            }
            textBox1.Size     = new Size(txtBoxWidth, metroGrid2.Size.Height);
            textBox1.Location = new Point(textBox1.Location.X + metroGrid2.Columns[0].Width, textBox1.Location.Y);

            X = metroGrid2.Columns.Cast <DataGridViewColumn>().Sum(r => r.Width);
            textBox2.Location = new Point(metroGrid2.Location.X + X - metroGrid2.Columns[metroGrid2.ColumnCount - 1].Width + 2, textBox1.Location.Y);

            txtBoxWidth = 0;

            // 단가는 Table의 가장 아래로 들어감
            int PriceIndex = -1;

            for (int i = 0; i < metroGrid2.RowCount; i++)
            {
                if (metroGrid2.Rows[i].Cells[0].Value.ToString().IndexOf("Prices") != -1 ||
                    metroGrid2.Rows[i].Cells[0].Value.ToString().IndexOf("단가") != -1 ||
                    metroGrid2.Rows[i].Cells[0].Value.ToString().IndexOf("가격") != -1)
                {
                    PriceIndex = i; break;
                }
            }
            if (PriceIndex != -1)
            {
                int             _iCurrentRow = PriceIndex;
                DataGridViewRow _dgvRow      = metroGrid2.Rows[_iCurrentRow];
                metroGrid2.Rows.RemoveAt(_iCurrentRow);
                metroGrid2.Rows.Insert(metroGrid2.RowCount, _dgvRow);
            }

            for (int i = 1; i < metroGrid2.RowCount; i++)
            {
                if (mainFrm.DomesticSpec[i - 1] != null)
                {
                    metroGrid2.Rows[i].Cells[metroGrid2.ColumnCount - 1].Value = mainFrm.DomesticSpec[i - 1];
                }
            }
            // metroGrid2.Rows[1].Cells[metroGrid2.ColumnCount - 1].Value = "대한민국";

            metroGrid2.CurrentCell = null;
        }
示例#2
0
        private void dtgCompetition()
        {
            int X = metroGrid1.ColumnHeadersHeight + metroGrid1.Rows.Cast <DataGridViewRow>().Sum(r => r.Height);

            textBox1.Location   = new Point(metroGrid1.Location.X, metroGrid1.Location.Y + X + 20);
            metroGrid2.Location = new Point(metroGrid1.Location.X, textBox1.Location.Y + textBox1.Height);
            metroGrid2.Rows.Clear();

            metroGrid2.RowHeadersVisible    = false;
            metroGrid2.ColumnHeadersVisible = false;
            metroGrid2.ColumnCount          = 1;

            metroGrid2.Rows.Add("구분");
            // 구분 색깔
            for (int i = 0; i < 1; i++)
            {
                metroGrid2.Rows[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                metroGrid2.Rows[i].Cells[0].Style.BackColor   = Color.FromArgb(91, 155, 213);
                metroGrid2.Rows[i].Cells[0].Style.ForeColor   = Color.White;
            }
            for (int i = 0; i < mainFrm.selectSubstitution.Length; i++)
            {
                if (mainFrm.selectSubstitution[i] == true)
                {
                    metroGrid2.Rows.Add(mainFrm.Substitution[0, i]);
                    metroGrid2.Rows[metroGrid2.RowCount - 1].DefaultCellStyle.WrapMode  = DataGridViewTriState.True;
                    metroGrid2.Rows[metroGrid2.RowCount - 1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    metroGrid2.Rows[metroGrid2.RowCount - 1].Cells[0].Style.BackColor   = Color.FromArgb(222, 235, 247);
                }
            }

            #region 대체무기체계 DB에서 추가함

            // 경쟁무기체계를 추가함

            // 경쟁무기에 뭐가 있는지 추출해옴
            SubstitutionData = new string[mainFrm.Substitution.GetLength(0)];
            for (int i = 1; i < mainFrm.Substitution.GetLength(0); i++)
            {
                SubstitutionData[i - 1] = mainFrm.Substitution[i, 3].ToString();
            }
            // 중복을 제거하고 난 뒤, Null 값도 제거하고
            SubstitutionData = GetDistinctValues <string>(SubstitutionData);
            SubstitutionData = SubstitutionData.Where(condition => condition != null).ToArray();

            // 경쟁무기 개수만큼 열을 추가
            for (int i = 0; i < SubstitutionData.Length; i++)
            {
                metroGrid2.Columns.Add("", "");
                metroGrid2.Rows[0].Cells[i + 1].Style.BackColor = Color.FromArgb(227, 162, 26);
                metroGrid2.Rows[0].Cells[i + 1].Style.ForeColor = Color.White;
                metroGrid2.Rows[0].DefaultCellStyle.Font        = new Font("나눔고딕", 9, FontStyle.Bold);

                // M151을 기준으로 데이터들을 탐색함
                var IndexOf2DArray = ExtensionMethods.CoordinatesOf(mainFrm.Substitution, SubstitutionData[i]);

                int count = 1;
                metroGrid2.Rows[0].Cells[i + 1].Value = SubstitutionData[i]; // 무기명
                for (int j = 0; j < mainFrm.selectSubstitution.Length; j++)
                {
                    if (mainFrm.selectSubstitution[j] == true)
                    {
                        metroGrid2.Rows[count].Cells[i + 1].Value = mainFrm.Substitution[IndexOf2DArray.Item1, j];
                        count++;
                    }
                }

                for (int j = 1; j < metroGrid2.RowCount; j++)
                {
                    metroGrid2.Rows[j].Cells[i + 1].Style.BackColor = Color.White;
                }
            }
            #endregion

            // Design
            metroGrid2.DefaultCellStyle.BackColor = Color.White;

            // 국내무기체계 필요제원
            metroGrid2.Columns.Add("", "");

            metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Value           = "국내무기체계";
            metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Style.BackColor = Color.FromArgb(0, 176, 80);
            metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Style.ForeColor = Color.White;
            for (int j = 1; j < metroGrid2.RowCount; j++)
            {
                metroGrid2.Rows[j].Cells[metroGrid2.ColumnCount - 1].Style.BackColor = Color.White;
            }
            this.metroGrid2.DefaultCellStyle.Font = new Font("나눔고딕", 9);

            //DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells
            // 국내무기체계 필요제원
            metroGrid2.Columns.Add("", "");

            metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Value               = "설 명";
            metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Style.BackColor     = Color.FromArgb(255, 242, 204);
            metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 1].Style.ForeColor     = Color.Black;
            metroGrid2.Columns[metroGrid2.ColumnCount - 1].DefaultCellStyle.WrapMode = DataGridViewTriState.True;

            for (int j = 1; j < metroGrid2.RowCount; j++)
            {
                metroGrid2.Rows[j].Cells[metroGrid2.ColumnCount - 1].Style.BackColor = Color.White;
            }
            this.metroGrid2.DefaultCellStyle.Font = new Font("나눔고딕", 9);

            for (int i = 0; i < metroGrid2.ColumnCount - 1; i++)
            {
                metroGrid2.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
                metroGrid2.Columns[i].Width        = (int)(metroGrid2.Columns[i].Width * 1.2);
            }
            metroGrid2.Columns[metroGrid2.ColumnCount - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            textBox2.Size = metroGrid2.Rows[0].Cells[metroGrid2.ColumnCount - 2].Size;

            int txtBoxWidth = 0;
            for (int i = 0; i < SubstitutionData.Length; i++)
            {
                txtBoxWidth += metroGrid2.Columns[i + 1].Width;
            }
            textBox1.Size     = new Size(txtBoxWidth + 1, metroGrid2.Size.Height);
            textBox1.Location = new Point(textBox1.Location.X + metroGrid2.Columns[0].Width, textBox1.Location.Y);

            X = metroGrid2.Columns.Cast <DataGridViewColumn>().Sum(r => r.Width);
            textBox2.Location = new Point(metroGrid2.Location.X + X - metroGrid2.Columns[metroGrid2.ColumnCount - 1].Width - metroGrid2.Columns[metroGrid2.ColumnCount - 2].Width, textBox1.Location.Y);

            // 단가는 Table의 가장 아래로 들어감
            int PriceIndex = -1;
            for (int i = 0; i < metroGrid2.RowCount; i++)
            {
                if (metroGrid2.Rows[i].Cells[0].Value.ToString().IndexOf("Prices") != -1 ||
                    metroGrid2.Rows[i].Cells[0].Value.ToString().IndexOf("단가") != -1 ||
                    metroGrid2.Rows[i].Cells[0].Value.ToString().IndexOf("가격") != -1)
                {
                    PriceIndex = i; break;
                }
            }
            if (PriceIndex != -1)
            {
                int             _iCurrentRow = PriceIndex;
                DataGridViewRow _dgvRow      = metroGrid2.Rows[_iCurrentRow];
                metroGrid2.Rows.RemoveAt(_iCurrentRow);
                metroGrid2.Rows.Insert(metroGrid2.RowCount, _dgvRow);
                // metroGrid2.Rows[_iCurrentRow + 1].Selected = true;
                //  metroGrid2.CurrentCell = metroGrid2[metroGrid2.CurrentCell.ColumnIndex, _iCurrentRow + 1];
            }
            for (int i = 1; i < metroGrid2.RowCount; i++)
            {
                if (mainFrm.SubstituteDomesticSpec != null)
                {
                    if (mainFrm.SubstituteDomesticSpec[i - 1] != null)
                    {
                        metroGrid2.Rows[i].Cells[metroGrid2.ColumnCount - 2].Value = mainFrm.SubstituteDomesticSpec[i - 1];
                    }
                }
            }
            for (int i = 1; i < metroGrid2.RowCount; i++)
            {
                metroGrid2.Rows[i].Cells[metroGrid2.ColumnCount - 1].Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            }
            for (int i = 1; i < metroGrid2.RowCount; i++)
            {
                int SpecIndex = Array.IndexOf(mainFrm.FullSpecSubstitution, metroGrid2.Rows[i].Cells[0].Value.ToString());
                metroGrid2.Rows[i].Cells[metroGrid2.ColumnCount - 1].Value = mainFrm.SubstitutionDescrition[SpecIndex];
            }
            metroGrid2.CurrentCell = null;
        }