コード例 #1
0
ファイル: frmCellQuery.cs プロジェクト: dongdong-2009/AAA
 private void pnlChart_Paint(object sender, PaintEventArgs e)
 {
     try
     {
         if (needDraw)
         {
             for (int i = 1; i <= 2; i++)
             {
                 string    shelfCode = "001" + i.ToString().PadLeft(3, '0');
                 DataRow[] drs       = cellTable.Select(string.Format("ShelfCode='{0}'", shelfCode), "CellCode desc");
                 int       left      = 0;
                 if (i == 2)
                 {
                     left = 5 + (int)adjustWidth + 6 * cellWidth + 200;
                 }
                 DrawShelf(drs, e.Graphics, top, font, adjustWidth, left, i.ToString());
             }
         }
         PColor.Refresh();
         IsWheel = false;
     }
     catch (Exception ex)
     {
         string str = ex.Message;
     }
 }
コード例 #2
0
ファイル: frmCellQuery.cs プロジェクト: qq5013/ROBO
        private void pnlChart_Paint(object sender, PaintEventArgs e)
        {
            try
            {
                if (needDraw)
                {
                    for (int i = 0; i <= 1; i++)
                    {
                        int key = currentPage * 2 + i - 1;
                        if (!shelf.ContainsKey(key))
                        {
                            DataRow[] rows = cellTable.Select(string.Format("ShelfCode='{0}'", ShelfCode[key]), "CellCode desc");
                            shelf.Add(key, rows);
                            ShelfRow.Add(key, int.Parse(rows[0]["Rows"].ToString()));
                            ShelfColumn.Add(key, int.Parse(rows[0]["Columns"].ToString()));

                            SetCellSize(ShelfColumn[key], ShelfRow[key]);
                        }
                        Font  font         = new Font("微软雅黑", 10);
                        SizeF size         = e.Graphics.MeasureString("第1排第5层", font);
                        float adjustHeight = Math.Abs(size.Height - cellHeight) / 2;
                        size = e.Graphics.MeasureString("13", font);
                        float adjustWidth = (cellWidth - size.Width) / 2;

                        DrawShelf(shelf[key], e.Graphics, top[i], font, adjustWidth);

                        int tmpLeft = left + ShelfColumn[key] * cellWidth + 5;

                        for (int j = 0; j < Rows[currentPage - 1]; j++)
                        {
                            string s = string.Format("第{0}排第{1}层", key, Convert.ToString(ShelfRow[key] - j).PadLeft(2, '0'));
                            e.Graphics.DrawString(s, font, Brushes.DarkCyan, tmpLeft, top[i] + (j + 1) * cellHeight);
                        }
                    }

                    if (filtered)
                    {
                        int i = currentPage * 2;
                        foreach (DataGridViewRow gridRow in dgvMain.Rows)
                        {
                            DataRowView cellRow = (DataRowView)gridRow.DataBoundItem;
                            int         shelf   = 0;
                            for (int j = 1; j <= ShelfCode.Count; j++)
                            {
                                if (ShelfCode[j].CompareTo(cellRow["ShelfCode"].ToString()) >= 0)
                                {
                                    shelf = j;
                                    break;
                                }
                            }
                            if (shelf == i || shelf == i - 1)
                            {
                                int top = 0;
                                if (shelf % 2 == 0)
                                {
                                    top = pnlContent.Height / 2;
                                }

                                int column   = Convert.ToInt32(cellRow["CellColumn"]);
                                int row      = Rows[currentPage - 1] - Convert.ToInt32(cellRow["CellRow"]) + 1;
                                int quantity = ReturnColorFlag(cellRow["PalletBarCode"].ToString(), cellRow["IsActive"].ToString(), cellRow["IsLock"].ToString(), cellRow["ErrorFlag"].ToString());
                                //FillCell(e.Graphics, top, row, column, quantity);
                                FillCell(e.Graphics, top, row, column, quantity, cellRow["ShelfCode"].ToString());
                            }
                        }
                    }
                }
                PColor.Refresh();
                IsWheel = false;
            }
            catch (Exception ex)
            {
                string str = ex.Message;
            }
        }