Esempio n. 1
0
        /// <summary>
        /// 清除元素的风格
        /// </summary>
        /// <param name="Element"></param>
        public void DelStyle(GridElement Element)
        {
            if (Element == null)
            {
                return;
            }

            Cell Cell = ReportSheet.GetCellFromTag(null, Element.Index);

            Cell.BackColor = Color.White;
            Cell.ForeColor = Color.Black;
            Cell.Border    = null;

            Element.Style.FormatInfo = null;
        }
Esempio n. 2
0
        /// <summary>
        /// 清除元素的全部
        /// </summary>
        public void DelElement(GridElement Element)
        {
            if (Element == null)
            {
                return;
            }

            Cell Cell = ReportSheet.GetCellFromTag(null, Element.Index);

            Cell.BackColor = Color.White;
            Cell.ForeColor = Color.Black;
            Cell.Border    = null;
            Cell.Value     = null;
            Cell.Tag       = null;
        }
Esempio n. 3
0
 public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
 {
     if (value != null && value is GridElement)
     {
         GridElement Element = value as GridElement;
         if (Element.Value is LiteralText)
         {
             LiteralText literalText = Element.Value as LiteralText;
             base.PaintCell(g, r, appearance, literalText.Text, isSelected, isLocked, zoomFactor);
         }
     }
     else
     {
         base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
     }
 }
Esempio n. 4
0
        public object Clone()
        {
            GridElement Element = new GridElement();

            Element.Index             = this.Index;
            Element.Row               = this.Row;
            Element.Column            = this.Column;
            Element.RowSpan           = this.RowSpan;
            Element.ColumnSpan        = this.ColumnSpan;
            Element.Value             = this.Value;
            Element.Style             = this.Style.Clone() as Style;
            Element.PageBreak         = this.PageBreak.Clone() as PageBreak;
            Element.ExpandOrientation = this.ExpandOrientation.Clone() as ExpandOrientation;

            return(Element);
        }
Esempio n. 5
0
        /// <summary>
        /// 获得某个位置上的报表元素类型
        /// </summary>
        public GridElement GetElement(string Index)
        {
            if (string.IsNullOrEmpty(Index))
            {
                return(null);
            }

            Cell        Cell    = ReportSheet.GetCellFromTag(null, Index);
            GridElement Element = Cell.Value as GridElement;

            if (Element != null)
            {
                Element.Report = ReportSheet;
            }

            return(Element);
        }
Esempio n. 6
0
        public override void PaintCell(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
        {
            if (value is GridElement)
            {
                GridElement Element = value as GridElement;
                if (Element.Value is Slash) //绘出一个斜线单元格
                {
                    ReportElementDrawing.PaintSlash(g, r, appearance, Element);
                }
                else if (Element.Value is DataColumn) //绘出一个数据列
                {
                    ReportElementDrawing.PaintDataColumn(g, r, appearance, Element);
                }
                else if (Element.Value is Formula) //绘出一个公式
                {
                    ReportElementDrawing.PaintFormula(g, r, appearance, Element);
                }
                else if (Element.Value is Picture) //绘出一个图片
                {
                    ReportElementDrawing.PaintImage(g, r, appearance, Element);
                }
                else if (Element.Value is LiteralText)//绘出文本
                {
                    LiteralText literalText = Element.Value as LiteralText;
                    base.PaintCell(g, r, appearance, literalText.Text, isSelected, isLocked, zoomFactor);
                }
                else if (Element.Value is Variable)//绘出一个变量
                {
                    ReportElementDrawing.PaintVariable(g, r, appearance, Element);
                }
                else if (Element.Value is ChartPainter)//绘出一个图表
                {
                    ReportElementDrawing.PaintChart(g, r, appearance, Element);
                }
                else
                {
                    base.PaintCell(g, r, appearance, "", isSelected, isLocked, zoomFactor);
                }

                ReportElementDrawing.PaintPageBreak(g, r, appearance, Element);
            }
            else
            {
                base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
            }
        }
Esempio n. 7
0
        public Object[,] InitElements(SheetView Report)
        {
            int Column = Report.GetLastNonEmptyColumn(NonEmptyItemFlag.Data) + 1;
            int Row    = Report.GetLastNonEmptyRow(NonEmptyItemFlag.Data) + 1;

            Elements = new Object[Row, Column];

            for (int i = 0; i < Row; i++)
            {
                for (int j = 0; j < Column; j++)
                {
                    if (Report.Cells[i, j].Value is GridElement)
                    {
                        GridElement Element = Report.Cells[i, j].Value as GridElement;
                        Element.Report = Report;
                        Elements[i, j] = Element;
                    }
                }
            }

            return(Elements);
        }
Esempio n. 8
0
        public Boolean HasReportParameters()
        {
            Boolean Result = false;

            Object[,] Elements = InitElements(Panel);
            for (int i = 0; i < Elements.GetLength(0); i++)
            {
                for (int j = 0; j < Elements.GetLength(1); j++)
                {
                    if (Elements[i, j] is GridElement)
                    {
                        GridElement Element = Elements[i, j] as GridElement;
                        if (Element.Value is DataColumn)
                        {
                            DataColumn DataColumn = Element.Value as DataColumn;
                            if (DataColumn.DataFilter != null)
                            {
                                foreach (FilterCondition Condition in DataColumn.DataFilter.FilterConditions)
                                {
                                    if (Condition.RightItem != null && Condition.RightItem.Style == FilterStyle.Parameter)
                                    {
                                        Result = true;
                                        break;
                                    }
                                }
                            }
                        }
                        else if (Element.Value is Formula)
                        {
                        }
                    }
                }
            }

            return(Result);
        }
Esempio n. 9
0
 public override void SetEditorValue(object value)
 {
     Element = value as GridElement;
 }
Esempio n. 10
0
        public static void PaintChart(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, GridElement Element)
        {
            ChartPainter chartPainter = Element.Value as ChartPainter;

            chartPainter.UpdateDataSource();
            IPainter Painter = chartPainter as IPainter;
            Image    image   = Painter.Paint(r.Width, r.Height);

            g.DrawImage(image, r.X, r.Y, r.Width, r.Height);
        }
Esempio n. 11
0
        public static void PaintVariable(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, GridElement Element)
        {
            Variable variable = Element.Value as Variable;

            using (Brush brush = new SolidBrush(appearance.ForeColor))
            {
                Brush BackColorBrush = new SolidBrush(appearance.BackColor);
                g.FillRectangle(BackColorBrush, r);
                BackColorBrush.Dispose();

                g.DrawString("=" + variable.Name, appearance.Font, brush, r, Format);
            }
        }
Esempio n. 12
0
        public static void PaintPageBreak(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, GridElement Element)
        {
            PageBreak pageBreak = Element.PageBreak;

            if (pageBreak.IsAfterRow)
            {
                g.DrawRectangle(Pens.Transparent, r.X, r.Y, 5, 5);
                g.FillRectangle(Brushes.Green, r.X, r.Y, 5, 5);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 画图片
        /// </summary>
        public static void PaintImage(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, GridElement Element)
        {
            Picture image = Element.Value as Picture;

            Brush BackColorBrush = new SolidBrush(appearance.BackColor);

            g.FillRectangle(BackColorBrush, r);
            BackColorBrush.Dispose();

            g.DrawImage(image.Image, r.X, r.Y, r.Width, r.Height);
        }
Esempio n. 14
0
        /// <summary>
        /// 画公式
        /// </summary>
        public static void PaintFormula(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, GridElement Element)
        {
            Formula formula = Element.Value as Formula;

            using (Brush brush = new SolidBrush(appearance.ForeColor))
            {
                Brush BackColorBrush = new SolidBrush(appearance.BackColor);
                g.FillRectangle(BackColorBrush, r);
                BackColorBrush.Dispose();

                g.DrawString("=" + formula.Expression, appearance.Font, brush, r, Format);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 画数据列
        /// </summary>
        public static void PaintDataColumn(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, GridElement Element)
        {
            DataColumn dataColumn = Element.Value as DataColumn;

            using (Brush brush = new SolidBrush(appearance.ForeColor))
            {
                Brush BackColorBrush = new SolidBrush(appearance.BackColor);
                g.FillRectangle(BackColorBrush, r);
                BackColorBrush.Dispose();

                String Prefix = "";
                switch (dataColumn.DataSetting)
                {
                case DataSetting.Group:
                    Prefix = "Group(";
                    break;

                case DataSetting.List:
                    Prefix = "List(";
                    break;

                case DataSetting.Aggregation:
                    Prefix = "Aggregation(" + dataColumn.FunctionInfo.Text + ",";
                    break;
                }

                String Text = Prefix + dataColumn.TableText + "." + dataColumn.FieldText + ")";
                g.DrawString(Text, appearance.Font, brush, r, Format);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 画斜线
        /// </summary>
        public static void PaintSlash(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, GridElement Element)
        {
            using (Brush brush = new SolidBrush(appearance.ForeColor))
            {
                g.SmoothingMode     = SmoothingMode.HighQuality;
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

                Brush BackColorBrush = new SolidBrush(appearance.BackColor);
                g.FillRectangle(BackColorBrush, r);
                BackColorBrush.Dispose();

                Pen myPen = new System.Drawing.Pen(Color.Black);

                int   count = 0;
                float Angle, radians;
                int   rightX, rightY;

                Slash    slash  = Element.Value as Slash;
                string[] sArray = slash.Text.Split('|');
                if (sArray.Length != 0)
                {
                    count = sArray.Length - 1;
                }
                int sum = count + 1;

                if (slash.RotationStyle == RotationStyle.Counterclockwise)
                {
                    if (count == 1)
                    {
                        g.DrawLine(myPen, r.X, r.Y + r.Height, r.X + r.Width, r.Y);
                    }
                    else if (count == 2)
                    {
                        g.DrawLine(myPen, r.X, r.Y + r.Height, r.X + (2.0f / 3) * r.Width, r.Y);
                        g.DrawLine(myPen, r.X, r.Y + r.Height, r.X + r.Width, r.Y + (1.0f / 3) * r.Height);
                    }
                    else if (count > 2)
                    {
                        float height;
                        for (int j = 1; j <= count; j++)
                        {
                            Angle  = (90 / sum) * j;
                            height = r.Width / (float)(Math.Tan(Angle * Math.PI / 180.0f));
                            rightX = r.X + r.Width;
                            rightY = r.Y + (int)height;

                            g.DrawLine(myPen, r.X, r.Y, rightX, rightY);
                        }
                    }

                    for (int i = 0; i < sArray.Length; i++)
                    {
                        if (i == 0)
                        {
                            Rectangle _rect = new Rectangle(r.X, r.Y, Convert.ToInt32(((sum - count + 1.0f) / sum) * (r.Width / sum)), Convert.ToInt32(count * 1.0 / sum * r.Height));
                            g.DrawString(sArray[i], appearance.Font, brush, _rect, Format);
                        }
                        else if (i == sArray.Length - 1)
                        {
                            Rectangle _rect = new Rectangle(Convert.ToInt32(r.X + (1.0f / sum) * r.Width), Convert.ToInt32(r.Y + r.Height - 1.0f / sum * r.Height), Convert.ToInt32((sum - count * 1.0f) * r.Width / sum), Convert.ToInt32((sum - count * 1.0f) / sum * r.Height));
                            g.DrawString(sArray[i], appearance.Font, brush, _rect, Format);
                        }
                        else
                        {
                            if (count == 2)
                            {
                                radians = Convert.ToSingle(Math.Atan(r.Height * 1.0 / r.Width));
                                Angle   = Convert.ToSingle(radians * 180 / Math.PI);
                            }
                            else
                            {
                                Angle = (1 + 2 * i) * (45.0f / (count + 1));
                            }

                            g.TranslateTransform(r.X + 3, r.Y + r.Height - 7);
                            g.RotateTransform(-(float)Angle);
                            g.DrawString(sArray[i], appearance.Font, brush, r.Width / 3f, 0);
                            g.ResetTransform();
                        }
                    }
                }
                else
                {
                    if (count == 1)
                    {
                        g.DrawLine(myPen, r.X, r.Y, r.X + r.Width, r.Y + r.Height);
                    }
                    else if (count == 2)
                    {
                        g.DrawLine(myPen, r.X, r.Y, r.X + (2.0f / 3) * r.Width, r.Y + r.Height);
                        g.DrawLine(myPen, r.X, r.Y, r.X + r.Width, r.Y + (2.0f / 3) * r.Height);
                    }
                    else if (count > 2)
                    {
                        float height;
                        for (int j = 1; j <= count; j++)
                        {
                            Angle  = (90 / sum) * j;
                            height = r.Width / (float)(Math.Tan(Angle * Math.PI / 180.0f));
                            rightX = r.X + r.Width;
                            rightY = r.Y + (int)height;

                            g.DrawLine(myPen, r.X, r.Y, rightX, rightY);
                        }
                    }

                    for (int i = 0; i < sArray.Length; i++)
                    {
                        if (i == 0)
                        {
                            Rectangle _rect = new Rectangle(Convert.ToInt32(r.X + r.Width / sum * 1.0), r.Y, Convert.ToInt32(count * r.Width / sum * 1.0), Convert.ToInt32(((sum - count + 1.0f) / sum) * (r.Height / sum)));
                            g.DrawString(sArray[i], appearance.Font, brush, _rect, Format);
                        }
                        else if (i == sArray.Length - 1)
                        {
                            Rectangle _rect = new Rectangle(r.X, Convert.ToInt32(r.Y + r.Height / sum * 1.0), Convert.ToInt32((sum - count + 1.0f) * r.Width / sum / sum), Convert.ToInt32(count * 1.0 * r.Height / sum));
                            g.DrawString(sArray[i], appearance.Font, brush, _rect, Format);
                        }
                        else
                        {
                            if (count == 2)
                            {
                                radians = Convert.ToSingle(Math.Atan(r.Height * 1.0 / r.Width));
                                Angle   = Convert.ToSingle(radians * 180 / Math.PI);
                            }
                            else
                            {
                                Angle = (1 + 2 * i) * (45 / (count + 1));
                            }

                            g.TranslateTransform(r.X + 3, r.Y - 4);
                            g.RotateTransform((float)Angle);
                            g.DrawString(sArray[i], appearance.Font, brush, r.Width / 2.8f, 0);
                            g.ResetTransform();
                        }
                    }
                }

                myPen.Dispose();
            }
        }