コード例 #1
0
        private void dpTable_browseLines_PaintRegion(object sender, PaintRegionArgs e)
        {
            if (e.Action == "query")
            {
                // 测算图像高度
                DpCell cell = e.Item as DpCell;
                // DpRow row = cell.Container;
                ImageCellInfo cell_info = (ImageCellInfo)cell.Tag;
                // string strFileName = (string)cell.Tag;
                if (cell_info == null || string.IsNullOrEmpty(cell_info.FileName) == true)
                    e.Height = 0;
                else
                {
                    try
                    {
                        using (Stream s = File.Open(cell_info.FileName, FileMode.Open))
                        {
                            Image image = Image.FromStream(s);
                            e.Height = image.Height;
                            image.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        // throw new Exception("read image error:" + ex.Message);
                        if (cell_info.RetryCount < 5)
                        {
                            cell_info.RetryCount++;
                            DpRow row = cell.Container;
                            PrepareCoverImage(row, true);
                        }
                        else
                        {

                            e.Height = 0;
                            cell.OwnerDraw = false;
                            cell.Text = "read image error";
                        }
                        return;
                    }

                    if (this.dpTable_browseLines.MaxTextHeight < e.Height)
                        this.dpTable_browseLines.MaxTextHeight = e.Height;
                }
                return;
            }

            {
                Debug.Assert(e.Action == "paint", "");

                DpCell cell = e.Item as DpCell;

                ImageCellInfo cell_info = (ImageCellInfo)cell.Tag;
                // string strFileName = (string)cell.Tag;
                if (cell_info != null && string.IsNullOrEmpty(cell_info.FileName) == false)
                {
                    try
                    {
                        using (Stream s = File.Open(cell_info.FileName, FileMode.Open))
                        {
                            Image image = Image.FromStream(s);

                            // 绘制图像
                            e.pe.Graphics.DrawImage(image,
                                (float)e.X,
                                (float)e.Y);

                            image.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        // throw new Exception("read image error:" + ex.Message);
                        if (cell_info.RetryCount < 5)
                        {
                            cell_info.RetryCount++;
                            DpRow row = cell.Container;
                            PrepareCoverImage(row, true);
                        }
                        else
                        {
                            cell.OwnerDraw = false;
                            cell.Text = "read image error";
                        }
                    }
                }
                else
                {
                    // 绘制文字“正在加载”
                }

            }
        }
コード例 #2
0
        private void dpTable_items_PaintRegion(object sender, PaintRegionArgs e)
        {
            if (e.Action == "query")
            {
                // 测算图像高度
                DpCell cell = e.Item as DpCell;
                // DpRow row = cell.Container;
                ImageCellInfo cell_info = (ImageCellInfo)cell.Tag;
                // string strFileName = (string)cell.Tag;
                if (cell_info == null || string.IsNullOrEmpty(cell_info.FileName) == true)
                {
                    e.Height = 0;
                }
                else
                {
                    try
                    {
                        using (Stream s = File.Open(cell_info.FileName, FileMode.Open))
                        {
                            using (Image image = Image.FromStream(s))
                            {
                                e.Height = image.Height;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // throw new Exception("read image error:" + ex.Message);
                        if (cell_info.RetryCount < 5)
                        {
                            cell_info.RetryCount++;
                            DpRow row = cell.Container;
                            AddTraceItem(row);
                        }
                        else
                        {
                            e.Height       = 0;
                            cell.OwnerDraw = false;
                            cell.Text      = "read image error";
                        }
                        return;
                    }

                    if (this.dpTable_items.MaxTextHeight < e.Height)
                    {
                        this.dpTable_items.MaxTextHeight = e.Height;
                    }
                }
                return;
            }

            {
                Debug.Assert(e.Action == "paint", "");

                DpCell cell = e.Item as DpCell;

                ImageCellInfo cell_info = (ImageCellInfo)cell.Tag;
                // string strFileName = (string)cell.Tag;
                if (cell_info != null && string.IsNullOrEmpty(cell_info.FileName) == false)
                {
                    try
                    {
                        using (Stream s = File.Open(cell_info.FileName, FileMode.Open))
                        {
                            using (Image image = Image.FromStream(s))
                            {
                                // 绘制图像
                                e.pe.Graphics.DrawImage(image,
                                                        (float)e.X,
                                                        (float)e.Y);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // throw new Exception("read image error:" + ex.Message);
                        if (cell_info.RetryCount < 5)
                        {
                            cell_info.RetryCount++;
                            DpRow row = cell.Container;
                            AddTraceItem(row);
                        }
                        else
                        {
                            cell.OwnerDraw = false;
                            cell.Text      = "read image error";
                        }
                    }
                }
                else
                {
                    // 绘制文字“正在加载”
                }
            }
        }
コード例 #3
0
ファイル: QuickChargingForm.cs プロジェクト: renyh1013/dp2
        private void dpTable_tasks_PaintRegion(object sender, PaintRegionArgs e)
        {
            if (e.Action == "query")
            {
                e.Height = 100;
                DpCell cell = e.Item as DpCell;
                DpRow row = cell.Container;
                ChargingTask task = (ChargingTask)row.Tag;

                PatronCardInfo info = new PatronCardInfo();

                string strError = "";

                int nRet = info.SetData(task.ReaderXml, out strError);
                if (nRet == -1)
                {
                    e.Height = 0;
                    return;
                }
                using (Graphics g = Graphics.FromHwnd(this.dpTable_tasks.Handle))
                {
                    info.Layout(g,
    _cardStyle,
    e.Width,
    e.Height);
                }
                cell.Tag = info;
                return;
            }

            {
                Debug.Assert(e.Action == "paint", "");
                PatronCardInfo info = ((DpCell)e.Item).Tag as PatronCardInfo;
                if (info != null)
                {
                    Debug.Assert(info != null, "");

                    info.Paint(e.pe.Graphics,
                        e.X,
                        e.Y,
                        this._cardStyle);
                }
            }
        }
コード例 #4
0
ファイル: RelationDialog.cs プロジェクト: renyh1013/dp2
        private void dpTable1_PaintRegion(object sender, PaintRegionArgs e)
        {
            if (e.Action == "query")
            {
                DpCell cell = e.Item as DpCell;
#if NO
                e.Height = BAR_HEIGHT + TOP_BLANK;
                DpRow row = cell.Container;
#endif
                SizeF size = e.pe.Graphics.MeasureString(cell.Text, this.dpTable1.Font);
                e.Height = (int)size.Height - e.Height;
                return;
            }

#if NO
            {
                DpCell cell = e.Item as DpCell;
                if (cell == null)
                {
                    Debug.Assert(false, "");
                    return;
                }

                int nLevel = Int32.Parse(cell.Container[COLUMN_LEVEL].Text);

                // 绘制带有下划线的分类号文字
                RelationControl.PaintSourceText(e.pe.Graphics,
                    this.dpTable1.Font,
                    this.dpTable1.ForeColor,
                    e.X,
                    e.Y - e.YOffset,
                    cell.Text,
                    nLevel);
            }
#endif
        }