public object Create (RectangleF rectangle, Color startColor, Color endColor, float angle)
		{
			var brush = new sd2.LinearGradientBrush (rectangle.ToSD (), startColor.ToSD (), endColor.ToSD (), angle, true);
			return new BrushObject {
				Brush = brush,
				InitialMatrix = brush.Transform
			};
		}
Пример #2
0
		public object Create (Color color, float thickness)
		{
			var pen = new sd.Pen (color.ToSD (), thickness);
			pen.StartCap = pen.EndCap = PenLineCap.Square.ToSD ();
			pen.DashCap = sd2.DashCap.Flat;
			pen.MiterLimit = 10f;
			return pen;
		}
		public object Create (Color startColor, Color endColor, PointF startPoint, PointF endPoint)
		{
			var brush = new sd2.LinearGradientBrush (startPoint.ToSD (), endPoint.ToSD (), startColor.ToSD (), endColor.ToSD ());
			return new BrushObject {
				Brush = brush,
				InitialMatrix = brush.Transform
			};
		}
Пример #4
0
        public object Create(Color color, float thickness)
        {
            var pen = new sd.Pen(color.ToSD(), thickness);

            pen.StartCap   = pen.EndCap = PenLineCap.Square.ToSD();
            pen.DashCap    = sd2.DashCap.Flat;
            pen.MiterLimit = 10f;
            return(pen);
        }
Пример #5
0
        public object Create(RectangleF rectangle, Color startColor, Color endColor, float angle)
        {
            var brush = new sd2.LinearGradientBrush(rectangle.ToSD(), startColor.ToSD(), endColor.ToSD(), angle, true);

            return(new BrushObject {
                Brush = brush,
                InitialMatrix = brush.Transform
            });
        }
Пример #6
0
 public object Create(Color startColor, Color endColor, PointF startPoint, PointF endPoint)
 {
     return(new BrushObject
     {
         StartPoint = startPoint,
         EndPoint = endPoint,
         StartColor = startColor.ToSD(),
         EndColor = endColor.ToSD()
     });
 }
Пример #7
0
		public void SetColor(SolidBrush widget, Color color)
		{
			((sd.SolidBrush)widget.ControlObject).Color = color.ToSD();
		}
Пример #8
0
		public object Create(Color color)
		{
			return new sd.SolidBrush(color.ToSD());
		}
Пример #9
0
		public void SetColor (Pen widget, Color color)
		{
			widget.ToSD ().Color = color.ToSD ();
		}
Пример #10
0
        internal ExcelPackage GenerateExcelFieldplan(ProtocolTransfer trans, ExcelPackage pack)
        {
            ExcelWorksheet ws         = pack.Workbook.Worksheets.Add(title);
            int            cols       = 0;
            int            rowcounter = 1;

            ws.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
            for (int i = 0; i < trans.dominoes.Length; i++) // foreach row
            {
                if (trans.dominoes[i] == null)
                {
                    throw new InvalidOperationException("Object not valid!");
                }
                int        cellcounter = 1;
                ExcelRange cell1       = ws.Cells[++rowcounter, cellcounter++];
                cell1.Value = ((trans.orientation == Orientation.Horizontal) ? "Row" : "Column") + " " + (i + 1);
                cell1.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
                cell1.Style.Border.Bottom.Color.SetColor(System.Drawing.Color.Black);
                for (int j = 0; j < trans.dominoes[i].Count; j++) // foreach block
                {
                    if (trans.dominoes[i][j] == null)
                    {
                        throw new InvalidOperationException("Field not valid!");
                    }
                    for (int k = 0; k < trans.dominoes[i][j].Count; k++)
                    {
                        if (trans.dominoes[i][j][k] != null && trans.dominoes[i][j][k].Item1 >= 0) // for all non-empty dominoes
                        {
                            using (ExcelRange cell = ws.Cells[rowcounter, cellcounter++])
                            {
                                cell.Style.Border.BorderAround(ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                                Color b = Colors.Black;
                                switch (backColorMode)
                                {
                                case ColorMode.Normal: b = trans.colors[trans.dominoes[i][j][k].Item1].mediaColor; break;            // normal color

                                case ColorMode.Inverted: b = trans.colors[trans.dominoes[i][j][k].Item1].mediaColor.Invert(); break; // inverted color

                                case ColorMode.Fixed: b = fixedBackColor; break;                                                     // fixed
                                }
                                if ((trans.colors[trans.dominoes[i][j][k].Item1] is EmptyDomino))
                                {
                                    cell.Style.Fill.PatternType = ExcelFillStyle.DarkUp;
                                    cell.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.White);
                                    cell.Style.Fill.PatternColor.SetColor(System.Drawing.Color.Black);
                                }
                                else
                                {
                                    cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
                                }
                                var background = b.ToSD(true);
                                cell.Style.Fill.BackgroundColor.SetColor(background);

                                if (k == trans.dominoes[i][j].Count - 1) // if end of block, draw right border in intelligent black/white
                                {
                                    System.Drawing.Color border = trans.colors[trans.dominoes[i][j][k].Item1].mediaColor.IntelligentBW().ToSD();
                                    cell.Style.Border.Right.Style = ExcelBorderStyle.Thick;
                                    cell.Style.Border.Right.Color.SetColor(border);
                                }
                                Color f = Colors.Black;
                                switch (foreColorMode)
                                {
                                case ColorMode.Normal: f = trans.colors[trans.dominoes[i][j][k].Item1].mediaColor; break;            // normal color

                                case ColorMode.Inverted: f = trans.colors[trans.dominoes[i][j][k].Item1].mediaColor.Invert(); break; // inverted color

                                case ColorMode.Intelligent: f = b.IntelligentBW(); break;                                            // intelligent BW
                                }
                                cell.Style.Font.Color.SetColor(f.ToSD());


                                string parsed = ParseFormatString(trans.colors[trans.dominoes[i][j][k].Item1].name, trans.dominoes[i][j][k].Item2);
                                // Bugfix für Warnung "Zahl als Text" in Excel
                                if (parsed.Trim().All(char.IsDigit))
                                {
                                    cell.Value = Int32.Parse(parsed);
                                }
                                else
                                {
                                    cell.Value = parsed;
                                }
                            }
                        }
                    }
                }
                if (cellcounter > cols)
                {
                    cols = cellcounter;
                }
            }
            // those two assignments are needed for whatever reason (see http://stackoverflow.com/questions/38860557/strange-behavior-in-autofitcolumns-using-epplus)
            ws.Cells[1, 1].Value = "a";
            ws.Cells[1, 2].Value = "b";
            // apply font scheme to all cells
            ws.Cells[1, 1, rowcounter, cols].Style.Font.SetFromFont(StringToFont(textFormat));
            // resize cells
            ws.Cells.AutoFitColumns(0);
            // add title
            ws.Cells[1, 2].Clear();
            ws.Cells[1, 1].Value                   = title;
            ws.Cells[1, 1].Style.Font.Size         = 15;
            ws.Cells[1, 1].Style.VerticalAlignment = ExcelVerticalAlignment.Top;
            ws.Row(1).Height = 27;
            // add small summary
            if (summaryMode != SummaryMode.None)
            {
                ExcelRange cell1 = ws.Cells[rowcounter + 2, 1];
                cell1.Value = "Rows: " + trans.rows + ", Columns: " + trans.columns;
                ws.Cells[rowcounter + 3, 1].Value = "Total Number of dominoes: " + trans.counts.Sum();
                ws.Cells[rowcounter + 2, 1, rowcounter + 3, 1].Style.Font.SetFromFont(StringToFont(textFormat));
            }
            rowcounter += 4;
            // set footer
            ws.HeaderFooter.FirstFooter.CenteredText     = string.Format("Page {0} of {1}", ExcelHeaderFooter.PageNumber, ExcelHeaderFooter.NumberOfPages);
            ws.HeaderFooter.EvenFooter.CenteredText      = string.Format("Page {0} of {1}", ExcelHeaderFooter.PageNumber, ExcelHeaderFooter.NumberOfPages);
            ws.HeaderFooter.OddFooter.CenteredText       = string.Format("Page {0} of {1}", ExcelHeaderFooter.PageNumber, ExcelHeaderFooter.NumberOfPages);
            ws.HeaderFooter.OddHeader.RightAlignedText   = DateTime.Today.ToShortDateString();
            ws.HeaderFooter.EvenHeader.RightAlignedText  = DateTime.Today.ToShortDateString();
            ws.HeaderFooter.FirstHeader.LeftAlignedText  = "Project: " + project;
            ws.HeaderFooter.OddHeader.LeftAlignedText    = title;
            ws.HeaderFooter.EvenHeader.LeftAlignedText   = title;
            ws.HeaderFooter.FirstHeader.RightAlignedText = "Go to View -> Page Break Preview for page overview";
            ws.HeaderFooter.OddHeader.CenteredText       = "Project: " + project;
            ws.HeaderFooter.EvenHeader.CenteredText      = "Project: " + project;
            ws.PrinterSettings.TopMargin    = (decimal)0.5;
            ws.PrinterSettings.LeftMargin   = (decimal)0.4;
            ws.PrinterSettings.RightMargin  = (decimal)0.4;
            ws.PrinterSettings.BottomMargin = (decimal)0.5;
            ws.PrinterSettings.HeaderMargin = (decimal)0.2;
            ws.PrinterSettings.FooterMargin = (decimal)0.2;
            if (summaryMode == SummaryMode.Large)
            {
                var orderedList = OrderedColorBalance(trans);
                // The list is first stored to a new workbook to get the minimum size of each column.
                ExcelWorksheet summary = pack.Workbook.Worksheets.Add("Summary");
                summary.Cells[1, 1].Value = " ";
                summary.Cells[1, 2].Value = "Color";
                summary.Cells[1, 3].Value = "Total";
                summary.Cells[1, 4].Value = "Used";
                int non_empty_cols = 0;
                for (int i = 0; i < orderedList.Count; i++)
                {
                    if (orderedList[i].count != 0)
                    {
                        summary.Cells[i + 2, 2].Value = orderedList[i].color.name;
                        if (orderedList[i].color is DominoColor)
                        {
                            summary.Cells[i + 2, 3].Value = orderedList[i].color.count;
                        }
                        summary.Cells[i + 2, 4].Value = orderedList[i].count;
                        non_empty_cols++;
                    }
                }
                summary.Cells[1, 1, trans.counts.Length, 4].Style.Font.SetFromFont(StringToFont(textFormat));
                summary.Cells.AutoFitColumns(0);
                double[] widths = new double[] { summary.Column(1).Width, summary.Column(2).Width, summary.Column(3).Width, summary.Column(4).Width };
                // the sheet is not needed anymore
                pack.Workbook.Worksheets.Delete(summary);

                ws.Cells[rowcounter + 1, 1].Value = "Overview of used dominoes:";
                int[] indices = new int[3]; // fist item: end index of name column,...
                for (int i = 0; i < 3; i++)
                {
                    int    endindex = (i == 0) ? 2 : indices[i - 1] + 1;
                    double width    = ws.Column(endindex).Width;
                    while (width < widths[i + 1])
                    {
                        endindex++;
                        width += ws.Column(endindex).Width;
                    }
                    indices[i] = endindex;
                }
                System.Drawing.Font textfont = StringToFont(textFormat);
                ws.Cells[rowcounter + 1, 1].Style.Font.SetFromFont(textfont);
                rowcounter += 2;
                using (ExcelRange Color_Header = ws.Cells[rowcounter, 2, rowcounter, indices[0]])
                {
                    Color_Header.Merge = true;
                    Color_Header.Value = "Color";
                    Color_Header.Style.Font.SetFromFont(textfont);
                    SetAllBorders(Color_Header, ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                    Color_Header.Style.Border.Bottom.Style = ExcelBorderStyle.Thick;
                }
                using (ExcelRange Count_Header = ws.Cells[rowcounter, indices[0] + 1, rowcounter, indices[1]])
                {
                    Count_Header.Merge = true;
                    Count_Header.Value = "Count";
                    Count_Header.Style.Font.SetFromFont(textfont);
                    SetAllBorders(Count_Header, ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                    Count_Header.Style.Border.Bottom.Style = ExcelBorderStyle.Thick;
                }
                using (ExcelRange Used_Header = ws.Cells[rowcounter, indices[1] + 1, rowcounter, indices[2]])
                {
                    Used_Header.Merge = true;
                    Used_Header.Value = "Used";
                    Used_Header.Style.Font.SetFromFont(textfont);
                    SetAllBorders(Used_Header, ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                    Used_Header.Style.Border.Bottom.Style = ExcelBorderStyle.Thick;
                }
                for (int i = 0; i < orderedList.Count; i++)
                {
                    if (orderedList[i].count != 0)
                    {
                        rowcounter++;
                        using (ExcelRange color_cell = ws.Cells[rowcounter, 1])
                        {
                            color_cell.Value = " ";
                            color_cell.Style.Fill.PatternType = ExcelFillStyle.Solid;
                            color_cell.Style.Fill.BackgroundColor.SetColor(orderedList[i].color.mediaColor.ToSD());
                            SetAllBorders(color_cell, ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                        }
                        using (ExcelRange name_cell = ws.Cells[rowcounter, 2, rowcounter, indices[0]])
                        {
                            name_cell.Merge = true;
                            name_cell.Value = orderedList[i].color.name;
                            SetAllBorders(name_cell, ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                            name_cell.Style.Font.SetFromFont(textfont);
                        }
                        using (ExcelRange count_cell = ws.Cells[rowcounter, indices[0] + 1, rowcounter, indices[1]])
                        {
                            count_cell.Merge = true;
                            if (orderedList[i].color is DominoColor)
                            {
                                count_cell.Value = orderedList[i].color.count;
                            }
                            SetAllBorders(count_cell, ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                            count_cell.Style.Font.SetFromFont(textfont);
                        }
                        using (ExcelRange used_cell = ws.Cells[rowcounter, indices[1] + 1, rowcounter, indices[2]])
                        {
                            used_cell.Merge = true;
                            used_cell.Value = orderedList[i].count;
                            SetAllBorders(used_cell, ExcelBorderStyle.Thin, System.Drawing.Color.Black);
                            used_cell.Style.Font.SetFromFont(textfont);
                        }
                    }
                }
                ws.Cells[rowcounter + 1, 1, rowcounter + non_empty_cols + 1, indices[2]].Style.Font.SetFromFont(StringToFont(textFormat));
            }
            return(pack);
        }
Пример #11
0
 public void SetColor(SolidBrush widget, Color color)
 {
     ((sd.SolidBrush)widget.ControlObject).Color = color.ToSD();
 }
Пример #12
0
 public object Create(Color color)
 {
     return(new sd.SolidBrush(color.ToSD()));
 }
Пример #13
0
        public object Create(Color startColor, Color endColor, PointF startPoint, PointF endPoint)
        {
            var brush = new sd2.LinearGradientBrush(startPoint.ToSD(), endPoint.ToSD(), startColor.ToSD(), endColor.ToSD());

            return(new BrushObject {
                Brush = brush,
                InitialMatrix = brush.Transform
            });
        }
Пример #14
0
 public void SetColor(Pen widget, Color color)
 {
     GetPen(widget).Color = color.ToSD();
 }
Пример #15
0
 public void SetColor(Pen widget, Color color)
 {
     widget.ToSD().Color = color.ToSD();
 }
Пример #16
0
 public void SetForeground(Range <int> range, Color color)
 {
     SetAttribute(range, () => Control.SelectionColor = color.ToSD());
 }
Пример #17
0
		public object Create(Color startColor, Color endColor, PointF startPoint, PointF endPoint)
		{
			return new BrushObject
			{
				StartPoint = startPoint,
				EndPoint = endPoint,
				StartColor = startColor.ToSD(),
				EndColor = endColor.ToSD()
			};
		}