Exemplo n.º 1
0
        private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            if (e.RowHandle < 0)
            {
                return;
            }
            AppearanceDefault appfont  = new AppearanceDefault(Color.LightSkyBlue);
            AppearanceDefault appError = new AppearanceDefault(Color.Red);

            DataRow dr = gridView1.GetDataRow(e.RowHandle);

            if (dr == null)
            {
                return;
            }
            if (e.Column.FieldName == "SatisFiyati" && dr["SatisFiyati"].ToString() != "" && dr["Adet"].ToString() != "" && dr["AlisFiyati"].ToString() != "")
            {
                decimal SatisTutar = Convert.ToDecimal(dr["SatisFiyati"].ToString()) * decimal.Parse(dr["Adet"].ToString());
                decimal AlisTutar  = Convert.ToDecimal(dr["AlisFiyati"].ToString()) * decimal.Parse(dr["Adet"].ToString());
                if (SatisTutar - AlisTutar <= 0 && (dr["iade"].ToString() == "False" || dr["iade"].ToString() == ""))
                {
                    AppearanceHelper.Apply(e.Appearance, appError);
                }
            }
            if (e.Column.FieldName == "iskontotutar" && dr["iskontotutar"].ToString() != "0")
            {
                AppearanceHelper.Apply(e.Appearance, appfont);
            }
            if (e.Column.FieldName == "Adet" && dr["Adet"].ToString() == "0")
            {
                AppearanceHelper.Apply(e.Appearance, appError);
            }
        }
Exemplo n.º 2
0
        private void DrawShapeUnsafe(Shape shapeObject)
        {
            if (!ShapesMap.TryGetValue(shapeObject.ShapeType, out var shapeType))
            {
                return;
            }

            var startColumnIndex = _columnsLookup[shapeObject.StartDate.Date] - 1;
            var endColumnIndex   = _columnsLookup[shapeObject.EndDate.AddDays(-1).Date];

            var startRow = _planRows[shapeObject.RowStart];
            var endRow   = _planRows[shapeObject.RowEnd];

            var startRowIndex = startRow.StartExcelRowIndex - 1;
            var endRowIndex   = endRow.EndExcelRowIndex;

            if (shapeType == ShapesMap[LineType])
            {
                startRowIndex += (endRowIndex - startRowIndex) / 2;
                endRowIndex    = startRowIndex;
            }

            var shape = _worksheet.Drawings.AddShape(shapeObject.ID.ToString(), shapeType);

            shape.From.Row    = startRowIndex;
            shape.From.Column = startColumnIndex;
            shape.To.Row      = endRowIndex;
            shape.To.Column   = endColumnIndex;

            var appearance = AppearanceHelper.GetAppearance(shapeObject.Appearance);

            FormatShape(shape, appearance);
            SetRotation(_worksheet.Drawings.DrawingXml, appearance);
        }
Exemplo n.º 3
0
        protected override void PrintBandHeader(IBrickGraphics graph)
        {
            if (!View.OptionsPrint.PrintBandHeader)
            {
                return;
            }
            Rectangle r              = Rectangle.Empty;
            Point     indent         = new Point(Indent, 0);
            bool      usePrintStyles = View.OptionsPrint.UsePrintStyles;

            SetDefaultBrickStyle(graph, (BrickStyle)Bricks["BandPanel"].Clone());
            foreach (PrintBandInfo band in Bands)
            {
                r = band.Bounds;
                r.Offset(indent);
                if (!usePrintStyles && band.Band != null)
                {
                    AppearanceObject temp = new AppearanceObject();
                    AppearanceHelper.Combine(temp, new AppearanceObject[] { band.Band.AppearanceHeader, AppearancePrint.BandPanel });
                    SetDefaultBrickStyle(graph, Bricks.Create(temp, BorderSide.All, temp.BorderColor, 1));
                }
                var brick = DrawTextBrick(graph, band.Band.GetTextCaption(), r);
                brick.Style = (BrickStyle)brick.Style.Clone();
                brick.Style.StringFormat.ChangeFormatFlags(StringFormatFlags.NoWrap | StringFormatFlags.LineLimit);
            }
        }
        private void ActivateMergedCellEditor(GridCellInfo cell)
        {
            if (cell == null)
            {
                return;
            }
            cell = cell.MergedCell.MergedCells[0];
            this.fEditingCell = cell;
            Rectangle bounds = GetMergedEditorBounds(cell);

            if (bounds.IsEmpty)
            {
                return;
            }
            RepositoryItem cellEdit = RequestCellEditor(cell);

            ViewInfo.UpdateCellAppearance(cell);
            ViewInfo.RequestCellEditViewInfo(cell);
            AppearanceObject appearance = new AppearanceObject();

            AppearanceHelper.Combine(appearance, new AppearanceObject[] { GetEditorAppearance(), ViewInfo.PaintAppearance.Row, cell.Appearance });
            if (cellEdit != cell.Editor && cellEdit.DefaultAlignment != HorzAlignment.Default)
            {
                appearance.TextOptions.HAlignment = cellEdit.DefaultAlignment;
            }
            UpdateEditor(cellEdit, new UpdateEditorInfoArgs(GetColumnReadOnly(cell.ColumnInfo.Column), bounds, appearance, cell.CellValue, ElementsLookAndFeel, cell.ViewInfo.ErrorIconText, cell.ViewInfo.ErrorIcon));
            ViewInfo.UpdateCellAppearance(cell);
            if (cell != null)
            {
                InvalidateRow(cell.RowHandle);
            }
        }
        private void DrawPicture(Picture picture, Dictionary <string, Image> imagesLookup)
        {
            var startColumnIndex = _columnsLookup[picture.StartDate.Date] - 1;
            var endColumnIndex   = _columnsLookup[picture.EndDate.AddDays(-1).Date];

            var startRow = _planRows[picture.RowStart];
            var endRow   = _planRows[picture.RowEnd];

            var startRowIndex = startRow.StartExcelRowIndex - 1;
            var endRowIndex   = endRow.StartExcelRowIndex;

            if (!imagesLookup.TryGetValue(picture.ImageUrl, out var image))
            {
                return;
            }

            var shape = _worksheet.Drawings.AddPicture(picture.ID.ToString(), image);

            var appearance = AppearanceHelper.GetAppearance(picture.Appearance);

            CalculateSize(shape, startRowIndex, endRowIndex, startColumnIndex, endColumnIndex, image, appearance);

            FormatPicture(shape, appearance);
            SetTransparency(_worksheet.Drawings.DrawingXml, appearance);
        }
Exemplo n.º 6
0
        private void gridView2_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle < 0)
            {
                return;
            }

            AppearanceDefault appLightSkyBlue = new AppearanceDefault(Color.LightSkyBlue);
            AppearanceDefault appGreen        = new AppearanceDefault(Color.LightGreen);
            AppearanceDefault appRed          = new AppearanceDefault(Color.IndianRed);
            AppearanceDefault appRedOrg       = new AppearanceDefault(Color.OrangeRed);

            DataRow dr = gridView2.GetDataRow(e.RowHandle);

            if (dr == null)
            {
                return;
            }
            if (dr["GrupAdi"].ToString() == "Müşteri")
            {
                AppearanceHelper.Apply(e.Appearance, appGreen);
            }
            if (dr["GrupAdi"].ToString() == "Tedarikçi")
            {
                AppearanceHelper.Apply(e.Appearance, appRed);
            }
            if (dr["GrupAdi"].ToString() == "Personel")
            {
                AppearanceHelper.Apply(e.Appearance, appRedOrg);
            }
        }
Exemplo n.º 7
0
        private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            if (e.RowHandle < 0)
            {
                return;
            }
            //AppearanceDefault appfont = new AppearanceDefault(Color.LightSkyBlue);
            AppearanceDefault appError = new AppearanceDefault(Color.Red);

            DataRow dr = gridView1.GetDataRow(e.RowHandle);

            if (dr == null)
            {
                return;
            }

            //if (e.Column.FieldName == "iskontotutar" && dr["iskontotutar"].ToString() != "0,000000")
            //{
            //    AppearanceHelper.Apply(e.Appearance, appfont);
            //}
            if (e.Column.FieldName == "KaraListe" && dr["KaraListe"].ToString() == "True")
            {
                AppearanceHelper.Apply(e.Appearance, appError);
            }
        }
        private void FormatRange(ExcelRange range, CellsAppearance appearance)
        {
            AppearanceHelper.SetFromFont(range.Style.Font.SetFromFont, appearance.FontFamily, appearance.FontSize);
            range.Style.Font.Size   = appearance.FontSize;
            range.Style.Font.Bold   = appearance.Bold;
            range.Style.Font.Italic = appearance.Italic;
            range.Style.Font.Color.SetColor(appearance.TextColor);

            if (appearance.Underline)
            {
                range.Style.Font.UnderLine     = true;
                range.Style.Font.UnderLineType = ExcelUnderLineType.Single;
            }
            else
            {
                range.Style.Font.UnderLine = false;
            }

            if (appearance.UseBackColor)
            {
                range.Style.Fill.PatternType = ExcelFillStyle.Solid;
                range.Style.Fill.BackgroundColor.SetColor(appearance.BackgroundColor);
            }
            else
            {
                range.Style.Fill.PatternType = ExcelFillStyle.None;
            }

            switch (appearance.TextAlignment)
            {
            case eTextAlignment.Left:
                range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                break;

            case eTextAlignment.Right:
                range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                break;

            default:
                range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                break;
            }

            switch (appearance.TextVerticalAlignment)
            {
            case eTextAnchoringType.Top:
                range.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                break;

            case eTextAnchoringType.Bottom:
                range.Style.VerticalAlignment = ExcelVerticalAlignment.Bottom;
                break;

            default:
                range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
                break;
            }
        }
Exemplo n.º 9
0
    void CalculateAndMove(PointerEventData eventData)
    {
        float xChangeSincePrevious = eventData.position.x - previousDragPosition.x;
        float xChangeInWorldUnits  = AppearanceHelper.ToWorldUnits(xChangeSincePrevious);

        bat.MoveRelative(xChangeInWorldUnits);

        previousDragPosition = eventData.position;
    }
Exemplo n.º 10
0
        public override void UpdatePaintAppearance()
        {
            base.UpdatePaintAppearance();
            AppearanceHelper.Combine(AppearanceColumnHeader,
                                     new[] { Form.Properties.AppearanceColumnHeader, StyleController == null ? null : StyleController.AppearanceDropDownHeader }, ColumnHeaderDefault);

            AppearanceHelper.Combine(AppearanceResults, Form.Properties.AppearanceDropDown, ResultsDefault);

            AppearanceHelper.Combine(AppearanceMatch, new[] { Form.Properties.AppearanceMatch, MatchDefault, AppearanceResults });
        }
        private static void ApplyAppearance(ExcelRange cells, CellsAppearance appearance)
        {
            cells.Merge             = true;
            cells.Style.ShrinkToFit = true;

            switch (appearance.TextAlignment)
            {
            case eTextAlignment.Left:
                cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                break;

            case eTextAlignment.Right:
                cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                break;

            default:
                cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                break;
            }

            switch (appearance.TextVerticalAlignment)
            {
            case eTextAnchoringType.Top:
                cells.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                break;

            case eTextAnchoringType.Bottom:
                cells.Style.VerticalAlignment = ExcelVerticalAlignment.Bottom;
                break;

            default:
                cells.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
                break;
            }

            AppearanceHelper.SetFromFont(cells.Style.Font.SetFromFont, appearance.FontFamily, appearance.FontSize);
            cells.Style.Font.Color.SetColor(appearance.TextColor);
            cells.Style.Font.Size   = appearance.FontSize;
            cells.Style.Font.Bold   = appearance.Bold;
            cells.Style.Font.Italic = appearance.Italic;

            if (appearance.Underline)
            {
                cells.Style.Font.UnderLine     = appearance.Underline;
                cells.Style.Font.UnderLineType = ExcelUnderLineType.Single;
            }

            cells.Style.Fill.PatternType = ExcelFillStyle.Solid;
            cells.Style.Fill.BackgroundColor.SetColor(appearance.BackgroundColor);
        }
Exemplo n.º 12
0
        public override void PrintHeader(DevExpress.XtraPrinting.IBrickGraphics graph)
        {
            if (!View.OptionsPrint.PrintHeader)
            {
                return;
            }
            Point     indent         = new Point(Indent, HeaderY);
            Rectangle r              = Rectangle.Empty;
            bool      usePrintStyles = View.OptionsPrint.UsePrintStyles;

            SetDefaultBrickStyle(graph, Bricks["HeaderPanel"]);
            foreach (PrintColumnInfo col in Columns)
            {
                if (!usePrintStyles)
                {
                    AppearanceObject temp = new AppearanceObject();
                    AppearanceHelper.Combine(temp, new AppearanceObject[] { col.Column.AppearanceHeader, View.Appearance.HeaderPanel, AppearancePrint.HeaderPanel });
                    SetDefaultBrickStyle(graph, Bricks.Create(temp, BorderSide.All, temp.BorderColor, 1));
                }
                r = col.Bounds;
                r.Offset(indent);
                string caption = GetTextCaptionForPrinting(col.Column);
                if (!col.Column.OptionsColumn.ShowCaption)
                {
                    caption = string.Empty;
                }
                ITextBrick itb = DrawTextBrick(graph, caption, r);

                (View as MyGridView).RaiseHeaderPrintEvent(this, new HeaderPrintEventArgs(itb, col));

                if (caption.Contains(Environment.NewLine))
                {
                    itb.Style.StringFormat = BrickStringFormat.Create(itb.Style.TextAlignment, true);
                }
                if (AppearancePrint.HeaderPanel.TextOptions.WordWrap == WordWrap.NoWrap && View.OptionsPrint.UsePrintStyles)
                {
                    using (Graphics g = this.View.GridControl.CreateGraphics())
                    {
                        SizeF s = g.MeasureString(itb.Text, itb.Font, 1000, itb.StringFormat.Value);
                        if (s.Width + 5 >= r.Width)
                        {
                            itb.Text      = "";
                            itb.TextValue = "";
                        }
                    }
                }
            }
        }
        private static void FormatCaption(ExcelShape captionShape, CellsAppearance appearance)
        {
            captionShape.Fill.Transparancy = 30;

            captionShape.TextAlignment = appearance.TextAlignment;
            captionShape.TextAnchoring = appearance.TextVerticalAlignment;

            AppearanceHelper.SetFromFont(captionShape.Font.SetFromFont, appearance.FontFamily, appearance.FontSize);
            captionShape.Font.Color = appearance.TextColor;
            captionShape.Font.Size  = appearance.FontSize;

            captionShape.Font.Bold      = appearance.Bold;
            captionShape.Font.Italic    = appearance.Italic;
            captionShape.Font.UnderLine = appearance.Underline ? eUnderLineType.Single : eUnderLineType.None;

            captionShape.Fill.Color        = appearance.BackgroundColor;
            captionShape.Border.Fill.Color = appearance.CellBorderColor;
        }
Exemplo n.º 14
0
        private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle < 0)
            {
                return;
            }

            AppearanceDefault appLightSkyBlue = new AppearanceDefault(Color.LightSkyBlue);
            AppearanceDefault appGreen        = new AppearanceDefault(Color.LightGreen);
            AppearanceDefault appRed          = new AppearanceDefault(Color.IndianRed);

            DataRow dr = gridView1.GetDataRow(e.RowHandle);

            if (dr == null)
            {
                return;
            }
            if (dr["Tipi"].ToString() == "StokDevir")
            {
                AppearanceHelper.Apply(e.Appearance, appLightSkyBlue);
            }
            if (dr["Tipi"].ToString() == "Satış")
            {
                AppearanceHelper.Apply(e.Appearance, appGreen);
            }
            if (dr["Tipi"].ToString() == "Alış")
            {
                AppearanceHelper.Apply(e.Appearance, appRed);
            }

            //else if (e.Column.FieldName == "GirisAdet" && dr["GirisAdet"].ToString() != "0")
            //{
            //    AppearanceHelper.Apply(e.Appearance, appfont);
            //}
            //else if (e.Column.FieldName == "CikisAdet" && dr["CikisAdet"].ToString() != "0")
            //{
            //    AppearanceHelper.Apply(e.Appearance, appError);
            //}
            //else if (e.Column.FieldName == "Fark" && dr["Fark"].ToString() != "0")
            //{
            //    AppearanceHelper.Apply(e.Appearance, appErrorRed);
            //}
        }
        private int DrawFlightUnsafe(FlightHelper flightHelper,
                                     VehicleModel vehicle)
        {
            var flight        = flightHelper.Flight;
            var rowDefinition = _planRows.GetValueOrDefault(flight.RowIndex ?? 0);

            var startDate = flight.StartDate.Date;
            var endDate   = flight.EndDate.AddDays(-1).Date;

            var startColumn = _columnsLookup[startDate] + flightHelper.StartCorrection;
            var endColumn   = _columnsLookup[endDate] + flightHelper.EndCorrection;

            if (startColumn > endColumn)
            {
                return(rowDefinition.EndExcelRowIndex);
            }

            var appearance = AppearanceHelper.GetAppearance(flight, vehicle);

            DrawAboveCaptions(flight, rowDefinition, startColumn, endColumn, appearance);

            var flightCells = _worksheet.Cells[rowDefinition.PrimaryExcelRowIndex,
                                               startColumn,
                                               rowDefinition.PrimaryExcelRowIndex,
                                               endColumn];

            DrawBelowCaptions(flight, rowDefinition, startColumn, endColumn, appearance);

            FormatFlight(flightCells, appearance);

            var insideCaptions = flight.FlightCaption?.Inside ?? new List <FlightCaptionPosition>();
            var captions       = insideCaptions.Select(x =>
            {
                var a = AppearanceHelper.GetAppearance(x.Appearance);
                return(a.GetValue(x.FormattedValue, _currencies));
            });

            flightCells.Value = string.Join(' ', captions);

            return(rowDefinition.EndExcelRowIndex);
        }
        private CellsAppearance GetAppearance(LeftTableColumnValue column, ObjectCell cell = null)
        {
            Appearance appearance = null;

            if (column != null)
            {
                appearance           = column.Appearances ?? new Appearance();
                appearance.TextAlign = appearance.TextAlign ?? "flex-start";

                if (column.Options?.GetValueOrDefault("currency") is long currency)
                {
                    appearance.UseCurrencySymbol     = true;
                    appearance.CurrencySymbol        = (int)currency;
                    appearance.FloatingPointAccuracy = 2;
                }
            }

            var cellAppearance = AppearanceHelper.GetAppearance(cell?.Appearance, appearance);

            return(cellAppearance);
        }
        private void DrawCaptionUnsafe(Text caption)
        {
            var startColumnIndex = _columnsLookup[caption.StartDate.Date] - 1;
            var endColumnIndex   = _columnsLookup[caption.EndDate.AddDays(-1).Date];

            var startRow = _planRows[caption.RowStart];
            var endRow   = _planRows[caption.RowEnd];

            var startRowIndex = startRow.StartExcelRowIndex - 1;
            var endRowIndex   = endRow.EndExcelRowIndex;

            var shape = _worksheet.Drawings.AddShape(caption.ID.ToString(), eShapeStyle.Rect);

            shape.From.Row    = startRowIndex;
            shape.From.Column = startColumnIndex;
            shape.To.Row      = endRowIndex;
            shape.To.Column   = endColumnIndex;

            shape.Text = caption.TextValue;

            var appearance = AppearanceHelper.GetAppearance(caption.Appearance);

            FormatCaption(shape, appearance);
        }
Exemplo n.º 18
0
        private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle < 0)
            {
                return;
            }
            AppearanceDefault appBlue  = new AppearanceDefault(Color.LightSkyBlue);
            AppearanceDefault appError = new AppearanceDefault(Color.Red);
            //AppearanceDefault appErrorRed = new AppearanceDefault(Color.Red);
            AppearanceDefault appErrorGreen = new AppearanceDefault(Color.GreenYellow);
            //AppearanceDefault appErrorYellowGreen = new AppearanceDefault(Color.YellowGreen);
            //AppearanceDefault appErrorPink = new AppearanceDefault(Color.LightSkyBlue);//, System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal);
            //object val = gridView1.GetRowCellValue(e.RowHandle, e.Column);
            //if ((e.Column.FieldName == "UnitPrice" && !(bool)validationControl1.IsTrueCondition(val)[0])
            //  || (e.Column.FieldName == "Quantity" && !(bool)validationControl2.IsTrueCondition(val)[0])
            //|| (e.Column.FieldName == "Discount" && !(bool)validationControl3.IsTrueCondition(val)[0]))

            DataRow dr = gridView1.GetDataRow(e.RowHandle);

            if (dr == null)
            {
                //yesilisikyeni();
                return;
            }
            if (e.Column.FieldName == "AlisFiyati" && dr["Alisiskontolu"].ToString() != "" && dr["Adet"].ToString() != "" && dr["SatisFiyati"].ToString() != "")
            {
                decimal Alisiskontolu = Convert.ToDecimal(dr["Alisiskontolu"].ToString());
                decimal AlisFiyati_sk = Convert.ToDecimal(dr["AlisFiyati_sk"].ToString());

                decimal SatisTutar = Convert.ToDecimal(dr["SatisFiyati"].ToString()) * decimal.Parse(dr["Adet"].ToString());
                decimal AlisTutar  = Convert.ToDecimal(dr["Alisiskontolu"].ToString()) * decimal.Parse(dr["Adet"].ToString());

                string iade = dr["iade"].ToString();

                if (Alisiskontolu != AlisFiyati_sk)
                {
                    AppearanceHelper.Apply(e.Appearance, appBlue);
                }

                if (SatisTutar - AlisTutar <= 0 && (iade == "False" || iade == ""))
                {
                    AppearanceHelper.Apply(e.Appearance, appError);
                }

                //if (SatisTutar - AlisTutar <= 0 && (iade == "False" || iade == "") && (AlisFiyati != AlisFiyati_sk))
                //    AppearanceHelper.Apply(e.Appearance, appErrorGreen);
            }

            if (e.Column.FieldName == "SatisFiyati" && dr["SatisFiyati"].ToString() != "" && dr["Adet"].ToString() != "" && dr["SatisFiyati"].ToString() != "")
            {
                decimal SatisFiyati    = Convert.ToDecimal(dr["SatisFiyati"].ToString());
                decimal SatisFiyati_sk = Convert.ToDecimal(dr["SatisFiyati_sk"].ToString());

                decimal SatisTutar = Convert.ToDecimal(dr["SatisFiyati"].ToString()) * decimal.Parse(dr["Adet"].ToString());
                decimal AlisTutar  = Convert.ToDecimal(dr["AlisFiyati"].ToString()) * decimal.Parse(dr["Adet"].ToString());

                string iade = dr["iade"].ToString();

                if (SatisFiyati != SatisFiyati_sk)
                {
                    AppearanceHelper.Apply(e.Appearance, appBlue);
                }
            }
            if (e.Column.FieldName == "iskontoyuzdetutar" && dr["iskontoyuzdetutar"].ToString() != "0,000000")
            {
                AppearanceHelper.Apply(e.Appearance, appBlue);
            }
            if (e.Column.FieldName == "Adet" && dr["Adet"].ToString() == "0")
            {
                AppearanceHelper.Apply(e.Appearance, appError);
            }
        }
        private void DrawCaptions(IReadOnlyCollection <FlightCaptionPosition> captions,
                                  int startRowNumber,
                                  int startColumn,
                                  int endColumn,
                                  CellsAppearance appearance,
                                  bool drawBorderAbove)
        {
            var current = startRowNumber;
            var index   = 0;

            captions = captions ?? new List <FlightCaptionPosition>();

            foreach (var caption in captions)
            {
                var cells = _worksheet.Cells[current, startColumn, current, endColumn];
                cells.Style.WrapText = true;

                var captionAppearance = AppearanceHelper.GetAppearance(caption.Appearance);
                if (captionAppearance.UseBackColor)
                {
                    cells.Style.Fill.PatternType = ExcelFillStyle.Solid;
                    cells.Style.Fill.BackgroundColor.SetColor(captionAppearance.BackgroundColor);
                }

                cells.Style.Font.Bold   = captionAppearance.Bold;
                cells.Style.Font.Italic = captionAppearance.Italic;
                if (captionAppearance.Underline)
                {
                    cells.Style.Font.UnderLine     = true;
                    cells.Style.Font.UnderLineType = ExcelUnderLineType.Single;
                }

                cells.Style.Font.Color.SetColor(captionAppearance.TextColor);
                cells.Style.Font.Size = captionAppearance.FontSize;

                cells.Style.Border.Right.Style = ExcelBorderStyle.Thin;
                cells.Style.Border.Right.Color.SetColor(appearance.CellBorderColor);

                cells.Style.Border.Left.Style = ExcelBorderStyle.Thin;
                cells.Style.Border.Left.Color.SetColor(appearance.CellBorderColor);

                if (drawBorderAbove && index == 0)
                {
                    cells.Style.Border.Top.Style = ExcelBorderStyle.Thin;
                    cells.Style.Border.Top.Color.SetColor(appearance.CellBorderColor);
                }
                else if (!drawBorderAbove && index == captions.Count - 1)
                {
                    cells.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
                    cells.Style.Border.Bottom.Color.SetColor(appearance.CellBorderColor);
                }

                var firstCell = _worksheet.Cells[cells.Start.Address];

                captionAppearance.FillValue(caption.FormattedValue, firstCell, _currencies);

                cells.Merge                     = true;
                cells.Style.ShrinkToFit         = true;
                cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

                current++;
                index++;
            }
        }
Exemplo n.º 20
0
        private void DrawFormulasUnsafe(ChartData chartData)
        {
            var subtotalRowsLookup = (chartData.Objects
                                      .SubtotalRows ?? new List <SubtotalRow>())
                                     .GroupBy(x => x.Id)
                                     .ToDictionary(x => x.Key, x => x.First());

            var cellsLookup = BuildCellsLookup(chartData);

            string formulaType = null;

            switch (_viewMode)
            {
            case FormattedPlanViewMode.Daily:
                formulaType = "formulaDaily";
                break;

            case FormattedPlanViewMode.Weekly:
                formulaType = "formulaWeekly";
                break;
            }

            if (formulaType == null)
            {
                return;
            }


            var formulasLookup = (chartData.Objects
                                  .Formulas ?? new List <Formula>())
                                 .Where(x => x.FormulaType == formulaType)
                                 .GroupBy(x => x.RowIndex)
                                 .ToDictionary(x => x.Key,
                                               x => x.GroupBy(y => y.ColumnIndex + _columnsOffset)
                                               .ToDictionary(y => y.Key, y => y.First()));

            foreach (var currentCells in cellsLookup)
            {
                var rowIndex      = currentCells.Key;
                var rowDefinition = _planRows.GetValueOrDefault(rowIndex);

                var cells = currentCells.Value;

                var formulas = formulasLookup.GetValueOrDefault(rowIndex);
                foreach (var cell in cells)
                {
                    var startColumnIndex = cell.ColumnIndex;
                    var formula          = formulas?.GetValueOrDefault(startColumnIndex);
                    if (formula == null)
                    {
                        continue;
                    }

                    startColumnIndex = _columnsLookup[formula.StartDate.Date];
                    var endColumnIndex = _columnsLookup[formula.EndDate.AddDays(-1).Date];

                    var ranges = new List <ExcelRange>();

                    var previousStartColumn = startColumnIndex;
                    for (var columnIndex = startColumnIndex; columnIndex <= endColumnIndex; columnIndex++)
                    {
                        var excelCell = _worksheet.Cells[rowDefinition.PrimaryExcelRowIndex, columnIndex];
                        if (!excelCell.Merge)
                        {
                            if (endColumnIndex == columnIndex)
                            {
                                ranges.Add(_worksheet.Cells[rowDefinition.PrimaryExcelRowIndex,
                                                            previousStartColumn,
                                                            rowDefinition.PrimaryExcelRowIndex,
                                                            columnIndex]);
                            }

                            continue;
                        }

                        if (previousStartColumn == columnIndex)
                        {
                            previousStartColumn++;
                            continue;
                        }

                        ranges.Add(_worksheet.Cells[rowDefinition.PrimaryExcelRowIndex,
                                                    previousStartColumn,
                                                    rowDefinition.PrimaryExcelRowIndex,
                                                    columnIndex - 1]);

                        previousStartColumn = columnIndex + 1;
                    }

                    if (!ranges.Any())
                    {
                        continue;
                    }

                    Appearance subtotalRowAppearance = null;
                    if (formula.SubtotalId.HasValue)
                    {
                        var subtotalRow = subtotalRowsLookup.GetValueOrDefault(formula.SubtotalId.Value);
                        subtotalRowAppearance = subtotalRow?.Appearance;
                    }

                    var appearance = AppearanceHelper.GetAppearance(formula.Appearance, subtotalRowAppearance);

                    var firstRange       = ranges.First();
                    var firstCellAddress = firstRange.Address;
                    var firstCell        = _worksheet.Cells[firstCellAddress];

                    appearance.FillValue(cell.Value.FormattedValue != null? cell.Value.FormattedValue : cell.Value.Value
                                         , firstCell, _currencies, onlyFirstInRangeValue: true);

                    foreach (var range in ranges)
                    {
                        ApplyAppearance(range, appearance);
                    }
                }
            }
        }
Exemplo n.º 21
0
        private static void ApplyAppearance(ExcelRange range, CellsAppearance appearance)
        {
            range.Merge                     = true;
            range.Style.ShrinkToFit         = true;
            range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

            var backColor = appearance.UseBackColor
                                ? appearance.BackgroundColor
                                : Colors.DefaultFormulaBackgroundColor;

            range.Style.Fill.PatternType = ExcelFillStyle.Solid;
            range.Style.Fill.BackgroundColor.SetColor(backColor);

            range.Style.Border.BorderAround(ExcelBorderStyle.Thin,
                                            appearance.UseCellBorderColor
                                                ? appearance.CellBorderColor
                                                : Colors.DefaultFormulaBorderColor);

            AppearanceHelper.SetFromFont(range.Style.Font.SetFromFont, appearance.FontFamily, appearance.FontSize);
            range.Style.Font.Size   = appearance.FontSize;
            range.Style.Font.Bold   = appearance.Bold;
            range.Style.Font.Italic = appearance.Italic;
            range.Style.Font.Color.SetColor(appearance.TextColor);
            if (appearance.Underline)
            {
                range.Style.Font.UnderLine     = true;
                range.Style.Font.UnderLineType = ExcelUnderLineType.Single;
            }
            else
            {
                range.Style.Font.UnderLine = false;
            }

            switch (appearance.TextAlignment)
            {
            case eTextAlignment.Left:
                range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
                break;

            case eTextAlignment.Right:
                range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                break;

            default:
                range.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
                break;
            }

            switch (appearance.TextVerticalAlignment)
            {
            case eTextAnchoringType.Top:
                range.Style.VerticalAlignment = ExcelVerticalAlignment.Top;
                break;

            case eTextAnchoringType.Bottom:
                range.Style.VerticalAlignment = ExcelVerticalAlignment.Bottom;
                break;

            default:
                range.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
                break;
            }
        }
        public override void PrintHeader(IBrickGraphics graph)
        {
            if (!View.OptionsPrint.PrintHeader)
            {
                return;
            }

            Point     indent         = new Point(Indent, HeaderY);
            Rectangle r              = Rectangle.Empty;
            bool      usePrintStyles = View.OptionsPrint.UsePrintStyles;

            SetDefaultBrickStyle(graph, Bricks["HeaderPanel"]);

            foreach (PrintColumnInfo col in Columns)
            {
                if (!usePrintStyles)
                {
                    AppearanceObject temp = new AppearanceObject();
                    AppearanceHelper.Combine(temp, new AppearanceObject[] { col.Column.AppearanceHeader, View.Appearance.HeaderPanel, AppearancePrint.HeaderPanel });
                    SetDefaultBrickStyle(graph, Bricks.Create(temp, BorderSide.All, temp.BorderColor, 1));
                }
                r = col.Bounds;
                r.Offset(indent);
                string caption = col.Column.GetTextCaption();
                if (!ColumnsInfo[Columns.IndexOf(col)].Column.OptionsColumn.ShowCaption)
                {
                    caption = string.Empty;
                }

                DevExpress.XtraGrid.Drawing.GridColumnInfoArgs columnsInfo = ColumnsInfo[Columns.IndexOf(col)];
                DrawElementInfoCollection innerElements   = columnsInfo.InnerElements;
                DrawElementInfo           columnImageInfo = null;
                GlyphElementInfoArgs      elementInfo     = null;
                this.ViewViewInfo.Painter.ElementsPainter.Column.CalcObjectBounds(columnsInfo);
                for (int i = 0; i < innerElements.Count; i++)
                {
                    if (innerElements[i].ElementInfo is DevExpress.Utils.Drawing.GlyphElementInfoArgs)
                    {
                        columnImageInfo = innerElements[i];
                        elementInfo     = columnImageInfo.ElementInfo as GlyphElementInfoArgs;
                        break;
                    }
                }

                ITextBrick tBrick = null;
                if (elementInfo.Glyph == null && elementInfo.ImageIndex < 0)
                {
                    tBrick = DrawTextBrick(graph, caption, r);
                }
                else
                {
                    IPanelBrick panelBrick      = new XETextPanelBrick(graph.DefaultBrickStyle);
                    float       offsetForBorder = panelBrick.BorderWidth;

                    if (columnImageInfo.Alignment != StringAlignment.Center)
                    {
                        tBrick       = new TextBrick();
                        tBrick.Rect  = new RectangleF(offsetForBorder, offsetForBorder, r.Width, r.Height);
                        tBrick.Text  = caption;
                        tBrick.Style = graph.DefaultBrickStyle;
                        tBrick.Sides = BorderSide.None;
                        panelBrick.Bricks.Add(tBrick);
                    }

                    panelBrick.Value = caption;
                    Rectangle columnRect = r;
                    Rectangle imageRect  = new Rectangle(new Point((int)offsetForBorder, (int)offsetForBorder), elementInfo.GlyphSize);
                    imageRect.Y = r.Y + columnImageInfo.ElementInterval;

                    switch (columnImageInfo.Alignment)
                    {
                    case StringAlignment.Near:
                        tBrick.Rect = new RectangleF(new PointF(imageRect.Location.X + imageRect.Size.Width, tBrick.Rect.Y), tBrick.Rect.Size);
                        MakeInflate(ref tBrick, 2 * offsetForBorder, 2 * offsetForBorder);
                        break;

                    case StringAlignment.Center:
                    {
                        imageRect.X += (r.Width - imageRect.Width) / 2;
                    }
                    break;

                    case StringAlignment.Far:
                        tBrick.Rect = new RectangleF(tBrick.Rect.Location, new SizeF(tBrick.Rect.Width - imageRect.Width, tBrick.Rect.Height));
                        MakeInflate(ref tBrick, 2 * offsetForBorder, 2 * offsetForBorder);
                        imageRect.X = (int)tBrick.Rect.Right;
                        break;
                    }


                    ImageBrick iBrick = GetImageBrick(imageRect, columnImageInfo);
                    if (iBrick != null)
                    {
                        panelBrick.Bricks.Add(iBrick);
                    }

                    graph.DrawBrick(panelBrick, columnRect);
                }


                if (tBrick == null)
                {
                    continue;
                }

                if (AppearancePrint.HeaderPanel.TextOptions.WordWrap == WordWrap.NoWrap && View.OptionsPrint.UsePrintStyles)
                {
                    using (Graphics g = this.View.GridControl.CreateGraphics())
                    {
                        SizeF s = g.MeasureString(tBrick.Text, tBrick.Font, 1000, tBrick.StringFormat.Value);
                        if (s.Width + 5 >= r.Width)
                        {
                            tBrick.Text      = "";
                            tBrick.TextValue = "";
                        }
                    }
                }
            }
        }
Exemplo n.º 23
0
        public override void PrintHeader(IBrickGraphics graph)
        {
            vert = new BrickStyle(Bricks["HeaderPanel"]);
            vert.StringFormat = vert.StringFormat.ChangeFormatFlags(StringFormatFlags.DirectionVertical | StringFormatFlags.DirectionRightToLeft);
            base.PrintHeader(graph);
            if (!View.OptionsPrint.PrintHeader)
            {
                return;
            }
            Point     indent         = new Point(Indent, HeaderY);
            Rectangle r              = Rectangle.Empty;
            bool      usePrintStyles = View.OptionsPrint.UsePrintStyles;

            SetDefaultBrickStyle(graph, Bricks["HeaderPanel"]);

            int HeaderHeight = (this.View as CustomBandedGridView).HeaderHeightOnExport;

            Dictionary <PrintColumnInfo, ITextBrick> columnBricks = new Dictionary <PrintColumnInfo, ITextBrick>();

            foreach (PrintColumnInfo col in Columns)
            {
                if (!usePrintStyles)
                {
                    AppearanceObject temp = new AppearanceObject();
                    AppearanceHelper.Combine(temp, new AppearanceObject[] { col.Column.AppearanceHeader, View.Appearance.HeaderPanel, AppearancePrint.HeaderPanel });
                    SetDefaultBrickStyle(graph, Bricks.Create(temp, BorderSide.All, temp.BorderColor, 1));
                }
                r = col.Bounds;
                r = new Rectangle(r.Location, new Size(r.Width, HeaderHeight));
                r.Offset(indent);
                MethodInfo mi      = typeof(GridColumn).GetMethod("GetTextCaptionForPrinting", BindingFlags.NonPublic | BindingFlags.Instance);
                string     caption = (string)mi.Invoke(col.Column, new object[] { });//col.Column.GetTextCaptionForPrinting();
                if (!col.Column.OptionsColumn.ShowCaption)
                {
                    caption = string.Empty;
                }
                ITextBrick itb = DrawTextBrick(graph, caption, r);
                if ((col.Column is CustomBandedColumn) && ((col.Column as CustomBandedColumn).CaptionVerticalOnExport))
                {
                    itb.Style = vert;
                }
                else
                {
                    SetDefaultBrickStyle(graph, Bricks["HeaderPanel"]);
                }
                if (caption.Contains(Environment.NewLine))
                {
                    itb.Style.StringFormat = BrickStringFormat.Create(itb.Style.TextAlignment, true);
                }

                if (AppearancePrint.HeaderPanel.TextOptions.WordWrap == WordWrap.NoWrap && View.OptionsPrint.UsePrintStyles)
                {
                    using (Graphics g = this.View.GridControl.CreateGraphics()) {
                        SizeF s = g.MeasureString(itb.Text, itb.Font, 1000, itb.StringFormat.Value);
                        if (s.Width + 5 >= r.Width)
                        {
                            itb.Text      = "";
                            itb.TextValue = "";
                        }
                    }
                }
                columnBricks.Add(col, itb);
                using (Graphics g = this.View.GridControl.CreateGraphics()) {
                    SizeF s = g.MeasureString(itb.Text, itb.Font, 1000, itb.StringFormat.Value);
                    if (s.Height + 5 >= r.Height)
                    {
                        itb.Text      = "";
                        itb.TextValue = "";
                    }
                }
            }
        }