/// <summary>
        /// Метод для отрисовки расписания
        /// </summary>
        private void DrawSchedule()
        {
            var machines      = (Schedule ?? throw new ArgumentNullException()).Select(m => m.Machine).Distinct().OrderBy(m => m.Name).ToList();
            var y             = 10;
            var timeLinePoint = 0;

            foreach (var machine in machines)
            {
                TextItems.Add(new TextDetails(10, y - 35, 50, 50, machine.Name));
                RectItems.Add(new RectItem(10, y, 50, 50, "Black"));
                var batches = Schedule.Where(m => m.Machine.Id == machine.Id).Select(b => b.Batch).ToList();
                var x       = 65;
                foreach (var b in batches)
                {
                    var color = b.NomenclatureId switch
                    {
                        0 => "Gold",
                        1 => "Silver",
                        2 => "LightSteelBlue",
                        _ => "Black"
                    };
                    timeLinePoint += machine.TimeDictionary[b.NomenclatureId];
                    var widthFromTime = machine.TimeDictionary[b.NomenclatureId] + 15;
                    TextItems.Add(new TextDetails(x + widthFromTime, y + 32, 20, 20, timeLinePoint.ToString()));
                    TextItems.Add(new TextDetails(x, y, widthFromTime, 20, b.Nomenclature.Name.Substring(0, 3)));
                    RectItems.Add(new RectItem(x, y, widthFromTime, 50, color));
                    x += widthFromTime + 2;
                }
                TimeLines.Add(new TimeLine(10, y + 23, x + 10, y + 23));
                y            += 90;
                timeLinePoint = 0;
            }
        }
    }
示例#2
0
 /// <summary>
 /// create new SubtitleText from initial string
 /// </summary>
 /// <param name="initialText"></param>
 public SubtitleText(string initialText)
     : this()
 {
     TextItems.Add(initialText);
     TextDurations.Add(1);
     doReplace = true;
     InitFont();
 }
示例#3
0
 /// <summary>
 /// create a new multitext, with multiple strings showing at indicated times.
 /// </summary>
 /// <param name="multiText"></param>
 /// <param name="timings">per multiText item, number of seconds that this item should display</param>
 /// <param name="doReplace">if true, only latest item from multiText is displayed.
 ///                         If false, each item is added to the previous one.</param>
 public SubtitleText(string[] multiText, float[] timings, bool doReplace)
 {
     foreach (var t in multiText)
     {
         TextItems.Add(t);
     }
     foreach (var t in timings)
     {
         TextDurations.Add(t);
     }
     this.doReplace = doReplace;
     InitFont();
 }
        private void AddTocToHtm()
        {
            TextItems.Add(new TextItem
            {
                Content     = TocCaption,
                LogicalType = TextItemType.H1
            });

            foreach (var ti in StructuredText.TextItems)
            {
                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (ti.LogicalType)
                {
                case TextItemType.H1:
                    if (TocLevel > 0)
                    {
                        _rowCount++;
                    }
                    break;

                case TextItemType.H2:
                    if (TocLevel > 1)
                    {
                        _rowCount++;
                    }
                    break;

                case TextItemType.H3:
                    if (TocLevel > 2)
                    {
                        _rowCount++;
                    }
                    break;

                case TextItemType.H4:
                    if (TocLevel > 3)
                    {
                        _rowCount++;
                    }
                    break;
                }
            }

            _rowCount++;

            var row = -1;

            foreach (var ti in StructuredText.TextItems)
            {
                row++;

                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (ti.LogicalType)
                {
                case TextItemType.H1:
                    if (TocLevel > 0)
                    {
                        //Debug.Print("<p class=\"{2}\"><a href=\"#H{1}\">{0}</a></p>\r\n",
                        //    ti.Content, _rowCount,
                        //    CssToc1);
                        TextItems.Add(new TextItem
                        {
                            Content = string.Format("<p class=\"{2}\"><a href=\"#H{1}\">{0}</a></p>\r\n",
                                                    ti.Content, row + _rowCount + 1,
                                                    CssToc1),
                            LogicalType = TextItemType.Plain
                        });
                    }

                    break;

                case TextItemType.H2:
                    if (TocLevel > 1)
                    {
                        TextItems.Add(new TextItem
                        {
                            Content = string.Format("<p class=\"{2}\"><a href=\"#H{1}\">{0}</a></p>\r\n",
                                                    ti.Content, row + _rowCount + 1,
                                                    CssToc2),
                            LogicalType = TextItemType.Plain
                        });
                    }
                    break;

                case TextItemType.H3:
                    if (TocLevel > 2)
                    {
                        TextItems.Add(new TextItem
                        {
                            Content = string.Format("<p class=\"{2}\"><a href=\"#H{1}\">{0}</a></p>\r\n",
                                                    ti.Content, row + _rowCount + 1,
                                                    CssToc3),
                            LogicalType = TextItemType.Plain
                        });
                    }
                    break;

                case TextItemType.H4:
                    if (TocLevel > 3)
                    {
                        TextItems.Add(new TextItem
                        {
                            Content = string.Format("<p class=\"{2}\"><a href=\"#H{1}\">{0}</a></p>\r\n",
                                                    ti.Content, row + _rowCount + 1,
                                                    CssToc4),
                            LogicalType = TextItemType.Plain
                        });
                    }
                    break;
                }
            }

            foreach (var ti in StructuredText.TextItems)
            {
                TextItems.Add(ti);
            }
        }
        /// <summary>
        /// Draws the graph
        /// </summary>
        private void DrawGraph()
        {
            if (CanvasHeight == 0 || CanvasWidth == 0)
            {
                return;
            }

            //clear the containers
            RectangleItems.Clear();
            LineItems.Clear();
            TextItems.Clear();
            PointCollection points = new PointCollection();

            //set some stuff
            int numPoints = 100;
            int ticks     = 8;

            //get the max an min of the efficieny points
            double maxOrd = EfficiencyMeasurements.Max(e => e.Efficiency);
            double minOrd = EfficiencyMeasurements.Min(e => e.Efficiency);

            //get ordinate graph bounds that look nice
            double ordTickRange = GetTickRange(maxOrd - minOrd, ticks);
            double ordTickMag   = Math.Log10(ordTickRange) > 0 ? Math.Ceiling(Math.Log10(ordTickRange)) : Math.Floor(Math.Log10(ordTickRange));

            maxOrd = ordTickRange * Math.Round(1 + maxOrd / ordTickRange);
            minOrd = ordTickRange * (Math.Round(minOrd / ordTickRange - 1));

            double minAbsc = 0;// Properties.Settings.Default.LOWERELIMT * 0.75;
            double maxAbsc = Properties.Settings.Default.UPPERENERGY;

            //get abscissa graph bounds that look nice
            double abscTickRange = GetTickRange(maxAbsc - minAbsc, ticks);
            double abscTickMag   = Math.Log10(abscTickRange) > 0 ? Math.Ceiling(Math.Log10(abscTickRange)) : Math.Floor(Math.Log10(abscTickRange));

            maxAbsc = abscTickRange * Math.Round(maxAbsc / abscTickRange);
            minAbsc = abscTickRange * (Math.Round(minAbsc / abscTickRange));


            int       seperation = 20;
            Rectangle chart      = new Rectangle(0.2 * CanvasWidth - seperation, seperation, (int)(0.8F * CanvasWidth), (int)(0.8F * CanvasHeight));

            //Rectangle chart = new Rectangle();
            RectangleItems.Add(chart);

            //get the energy limit
            double lowE  = minAbsc;// Properties.Settings.Default.LOWERELIMT * 0.75;
            double highE = maxAbsc;

            //get the position converstion factors.
            double xconv = chart.Width / (highE - lowE);
            double xoff  = chart.Right - (xconv * highE);

            double yconv = chart.Height / (minOrd - maxOrd);
            double yoff  = chart.Bottom - (yconv * minOrd);


            //build a formatting string
            StringBuilder format = new StringBuilder("0");

            format.Append(ordTickMag >= 0 ? "" : ".");
            for (int j = 0; j < Math.Abs(ordTickMag); j++)
            {
                format.Append(0);
            }
            //loop through and add lables
            int    tickLength = 10;
            double ord = minOrd, absc = minAbsc;

            while (Math.Round(ord, (int)Math.Abs(ordTickMag)) <= maxOrd)
            {
                //draw the y-axis
                double y;// = (yconv * (ord) + yoff);
                if (Math.Abs(ord - minOrd) < 1e-6)
                {
                    y = chart.Bottom - chart.StrokeWeight / 2;
                }
                else if (Math.Abs(ord - maxOrd) < 1e-6)
                {
                    y = chart.Top + chart.StrokeWeight / 2;
                }
                else
                {
                    y = (yconv * (ord) + yoff);
                    LineItems.Add(new Line(chart.Left, y, chart.Right, y)
                    {
                        LineDashArray = { 2, 1 },
                    });
                }

                LineItems.Add(new Line(chart.Left - tickLength, y, chart.Left + tickLength, y));
                //create the label
                string    label     = (ord).ToString(format.ToString());
                ChartText labelText = new ChartText(label)
                {
                    //position the label
                    //X = chart.Left - 2 - 0.2*CanvasWidth,
                    X      = 0,
                    Y      = y + (ordTickRange * yconv) / 2,
                    Width  = chart.Left - tickLength - 2,
                    Height = Math.Abs(ordTickRange * yconv),
                    TextHorizontalAlignment = HorizontalAlignment.Right,
                    TextVerticalAlignment   = VerticalAlignment.Center
                };

                TextItems.Add(labelText);
                ord += ordTickRange;
            }
            while (Math.Round(absc, (int)Math.Abs(abscTickMag)) <= maxAbsc)
            {
                //draw the x-axis
                double x;// = (xconv * (absc) + xoff);
                if (Math.Abs(absc - minAbsc) < 1e-6)
                {
                    x = chart.Left + chart.StrokeWeight / 2;
                }
                else if (Math.Abs(absc - maxAbsc) < 1e-6)
                {
                    x = chart.Right - chart.StrokeWeight / 2;
                }
                else
                {
                    x = (xconv * (absc) + xoff);
                    LineItems.Add(new Line(x, chart.Bottom, x, chart.Top)
                    {
                        LineDashArray = { 2, 1 },
                    });
                }

                LineItems.Add(new Line(x, chart.Bottom + tickLength, x, chart.Bottom - tickLength));

                string    label     = (absc).ToString();
                ChartText labelText = new ChartText(label)
                {
                    Width  = abscTickRange * xconv,
                    Height = 0.2 * CanvasHeight - tickLength - 2 - seperation,
                    //position the label
                    X = x - (abscTickRange * xconv) / 2,
                    Y = chart.Bottom + tickLength + 2,
                    TextHorizontalAlignment = HorizontalAlignment.Center,
                    TextVerticalAlignment   = VerticalAlignment.Top
                };

                TextItems.Add(labelText);
                absc += abscTickRange;
            }

            //fill the an array of points that represents the curve
            double eJump = (highE - lowE) / numPoints;
            //CurvePoints = new Point[numPoints];
            double ene = lowE;

            for (int i = 0; i < numPoints; i++)
            {
                ene += eJump;
                double eff = data.GetEfficiency(ene);
                int    x   = Convert.ToInt32(ene * xconv + xoff);
                double y   = yoff + eff * yconv;
                if (y > chart.Bottom || double.IsNaN(y))
                {
                    y = chart.Bottom;
                }
                else if (y < chart.Top || double.IsInfinity(y))
                {
                    y = chart.Top;
                }

                points.Add(new Point(x, y));
            }
            this.CurvePoints = points;
            //make the graph thick
            //put the efficiency points on the chart
            for (int i = 0; i < EfficiencyMeasurements.Count; i++)
            {
                int x      = Convert.ToInt32(EfficiencyMeasurements[i].Energy * xconv + xoff);
                int y      = Convert.ToInt32(yoff + EfficiencyMeasurements[i].Efficiency * yconv);
                int ptSize = 2;
                RectangleItems.Add(new Rectangle(x - ptSize, y - ptSize, 2 * ptSize, 2 * ptSize));
                //add the error bars
                LineItems.Add(new Line(x, y - EfficiencyMeasurements[i].EfficiencyUncertainty * yconv,
                                       x, y + EfficiencyMeasurements[i].EfficiencyUncertainty * yconv));
            }
            WriteEfficiencyEquation();
        }