Пример #1
0
        public static PlotModel TextAnnotation()
        {
            var model = new PlotModel {
                Title = "TextAnnotation", Subtitle = "Click the text"
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -20, Maximum = 20
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = -10, Maximum = 10
            });
            var ta = new TextAnnotation
            {
                TextPosition = new DataPoint(4, -2),
                Text         = "Click here"
            };

            // Handle left mouse clicks
            ta.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                ta.Background = ta.Background.IsUndefined() ? OxyColors.LightGreen : OxyColors.Undefined;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            model.Annotations.Add(ta);
            return(model);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //open document
            Document pdfDocument = new Document(dataDir + "input.pdf");

            //create annotation
            TextAnnotation textAnnotation = new TextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600));

            textAnnotation.Title    = "Sample Annotation Title";
            textAnnotation.Subject  = "Sample Subject";
            textAnnotation.State    = AnnotationState.Accepted;
            textAnnotation.Contents = "Sample contents for the annotation";
            textAnnotation.Open     = true;
            textAnnotation.Icon     = TextIcon.Key;

            Border border = new Border(textAnnotation);

            border.Width          = 5;
            border.Dash           = new Dash(1, 1);
            textAnnotation.Border = border;
            textAnnotation.Rect   = new Aspose.Pdf.Rectangle(200, 400, 400, 600);

            //add annotation in the annotations collection of the page
            pdfDocument.Pages[1].Annotations.Add(textAnnotation);

            ////save output file
            pdfDocument.Save(dataDir + "output.pdf");
        }
Пример #3
0
        public DQEGraphAnnotationUI(DQEGraphAnnotation a, Chart chart)
        {
            _underlyingAnnotationObject = a;
            Annotation = new LineAnnotation();
            Annotation.IsSizeAlwaysRelative = false;
            Annotation.AxisX          = chart.ChartAreas[0].AxisX;
            Annotation.AxisY          = chart.ChartAreas[0].AxisY;
            Annotation.AnchorX        = a.EndX;
            Annotation.AnchorY        = a.EndY;
            Annotation.Height         = a.StartY - a.EndY;
            Annotation.Width          = a.StartX - a.EndX;
            Annotation.LineWidth      = 2;
            Annotation.StartCap       = LineAnchorCapStyle.Arrow;
            Annotation.EndCap         = LineAnchorCapStyle.None;
            Annotation.AllowSelecting = true;
            Annotation.Tag            = this;

            TextAnnotation      = new TextAnnotation();
            TextAnnotation.Text = a.Text;
            TextAnnotation.IsSizeAlwaysRelative = false;
            TextAnnotation.AxisX          = chart.ChartAreas[0].AxisX;
            TextAnnotation.AxisY          = chart.ChartAreas[0].AxisY;
            TextAnnotation.AnchorX        = a.StartX;
            TextAnnotation.AnchorY        = a.StartY;
            TextAnnotation.AllowSelecting = true;
            TextAnnotation.Tag            = this;
        }
 public TechnicalCertificateImageProcesser(TextAnnotation textAnnotation,
                                           ITechnicalCertificateService technicalCertificateService,
                                           ITechnicalCertificateValidatior validator,
                                           IList <WordLabel> typeLabels,
                                           IList <WordLabel> markAndModelLabels,
                                           IList <WordLabel> chassisNumLabels,
                                           IList <WordLabel> bodyLabels,
                                           IList <WordLabel> colorLabels,
                                           IList <WordLabel> matriculNumLabels,
                                           IList <WordLabel> firstRegistrationDateLabels,
                                           IList <WordLabel> receptionNumLabels,
                                           IList <WordLabel> soNumLabels)
 {
     this.annotationContext           = textAnnotation;
     this.technicalCertificateService = technicalCertificateService;
     this.validator                   = validator;
     this.typeLabels                  = typeLabels;
     this.markAndModelLabels          = markAndModelLabels;
     this.chassisNumLabels            = chassisNumLabels;
     this.bodyLabels                  = bodyLabels;
     this.colorLabels                 = colorLabels;
     this.matriculNumLabels           = matriculNumLabels;
     this.firstRegistrationDateLabels = firstRegistrationDateLabels;
     this.receptionNumLabels          = receptionNumLabels;
     this.soNumLabels                 = soNumLabels;
 }
Пример #5
0
        public void TextAnnotation()
        {
            var s1 = new TextAnnotation();
            var s2 = new Annotations.TextAnnotation();

            OxyAssert.PropertiesAreEqual(s1, s2);
        }
Пример #6
0
        internal override Annotation Clone(IDocumentEssential owner, Page page)
        {
            if (Page == null)
            {
                ApplyOwner(owner);
                SetPage(page, true);
                return(this);
            }

            PDFDictionary res = AnnotationBase.Copy(Dictionary);

            MarkupAnnotationBase.CopyTo(Dictionary, res);

            IPDFObject name = Dictionary["Name"];

            if (name != null)
            {
                res.AddItem("Name", name.Clone());
            }

            TextAnnotation annot = new TextAnnotation(res, owner);

            annot.SetPage(Page, false);
            annot.SetPage(page, true);

            return(annot);
        }
Пример #7
0
        private static void BuildAnnotations(WidgetBase widget) {
            widget.Annotations.AutoScale = true;

            var annGroup = new AnnotationGroupElement { X = 175, Y = 105 };
            var textAnnotation = new TextAnnotation { X = 0, Y = 0, Label = "Current status" };
            textAnnotation.Color = "666666";
            textAnnotation.FontAttr.FontSize = "11";
            textAnnotation.Align = FusionTextAlign.Center;
            annGroup.Add(textAnnotation);
            widget.Annotations.Add(annGroup);

            annGroup = new AnnotationGroupElement() { Id = "GrpRED", X = 175, Y = 125, Visible = false };
            var circle = new CircleAnnotation { X = 0, Y = 0, Radius = 10, FillPattern = FillMethod.Radial, Color = "FFBFBF,FF0000" };
            circle.Border.Show = false;
            annGroup.Add(circle);
            widget.Annotations.Add(annGroup);

            annGroup = new AnnotationGroupElement() { Id = "GrpYELLOW", X = 175, Y = 125, Visible = false };
            circle = new CircleAnnotation { X = 0, Y = 0, Radius = 10, FillPattern = FillMethod.Radial, Color = "FFFF00,BBBB00" };
            circle.Border.Show = false;
            annGroup.Add(circle);
            widget.Annotations.Add(annGroup);

            annGroup = new AnnotationGroupElement() { Id = "GrpGREEN", X = 175, Y = 125, Visible = false };
            circle = new CircleAnnotation { X = 0, Y = 0, Radius = 10, FillPattern = FillMethod.Radial, Color = "00FF00,339933" };
            circle.Border.Show = false;
            annGroup.Add(circle);
            widget.Annotations.Add(annGroup);
        }
Пример #8
0
        public override object Create(object parent, IParseContext context, XElement element)
        {
            var      localName = element.Name.LocalName;
            Artifact artifact  = null;

            switch (localName)
            {
            case "textAnnotation":
                var item = new TextAnnotation();
                item.Text       = element.Value;
                item.TextFormat = element.GetAttribute("textFormat");
                artifact        = item;
                break;

            case "association":
                var association = context.BpmnFactory.CreateAssociation();
                association.SourceRef            = element.GetAttribute("sourceRef");
                association.TargetRef            = element.GetAttribute("targetRef");
                association.AssociationDirection = element.GetEnum("AssociationDirection", AssociationDirection.None);

                artifact = association;
                break;

            default:
                throw new NotImplementedException();
            }

            //if (artifact != null)
            //    parent.Artifacts.Add(artifact);

            return(artifact);
        }
Пример #9
0
        static void Main(string[] args)
        {
            // Create Watermarker instance
            Watermarker waterMarker = new Watermarker();

            // Initialize library
            waterMarker.InitLibrary("demo", "demo");

            // Set input file name
            string inputFilePath = "my_sample_image.jpg";
            // Set output file title
            string outputFilePath = "my_sample_output.jpg";

            // Add image to apply watermarks to
            waterMarker.AddInputFile(inputFilePath, outputFilePath);

            // Create new watermark
            TextAnnotation preset = new TextAnnotation();

            // Set text
            preset.Text = "Bytescout Watermarking";

            // Add watermark to watermarker
            waterMarker.AddWatermark(preset);

            // Set output directory
            waterMarker.OutputOptions.OutputDirectory = ".";

            // Apply watermarks
            waterMarker.Execute();

            // open generated image file in default image viewer installed in Windows
            Process.Start(outputFilePath);
        }
Пример #10
0
        private static void updateAnnotationPosition(TextAnnotation watermarkAnnotation, ChartControl chartControl)
        {
            var pos = watermarkAnnotation.ShapePosition.DowncastTo <FreePosition>();

            pos.InnerIndents.Left = (chartControl.Size.Width - watermarkAnnotation.Width) / 2;
            pos.InnerIndents.Top  = (chartControl.Size.Height - watermarkAnnotation.Height) / 2;
        }
Пример #11
0
        public LoadProgressAnnotation(LoadProgress lp, DataTable dt, Chart chart)
        {
            _lp = lp;
            _dt = dt;

            LineAnnotation line;
            TextAnnotation text;

            GetAnnotations("OriginDate", 0.9, lp.OriginDate, chart, out line, out text);
            LineAnnotationOrigin = line;
            TextAnnotationOrigin = text;


            LineAnnotation line2;
            TextAnnotation text2;

            GetAnnotations("Progress", 0.7, lp.DataLoadProgress, chart, out line2, out text2);
            LineAnnotationFillProgress = line2;
            TextAnnotationFillProgress = text2;

            var cp = lp.CacheProgress;

            if (cp != null)
            {
                LineAnnotation line3;
                TextAnnotation text3;
                GetAnnotations("Cache Fill", 0.50, cp.CacheFillProgress, chart, out line3, out text3);
                LineAnnotationCacheProgress = line3;
                TextAnnotationCacheProgress = text3;
            }
        }
        public static void Run()
        {
            // ExStart:AddAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            // Open document
            Document pdfDocument = new Document(dataDir + "AddAnnotation.pdf");

            // Create annotation
            TextAnnotation textAnnotation = new TextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600));
            textAnnotation.Title = "Sample Annotation Title";
            textAnnotation.Subject = "Sample Subject";
            textAnnotation.State = AnnotationState.Accepted;
            textAnnotation.Contents = "Sample contents for the annotation";
            textAnnotation.Open = true;
            textAnnotation.Icon = TextIcon.Key;
           
            Border border = new Border(textAnnotation);
            border.Width = 5;
            border.Dash = new Dash(1, 1);
            textAnnotation.Border = border;
            textAnnotation.Rect = new Aspose.Pdf.Rectangle(200, 400, 400, 600);
           
            // Add annotation in the annotations collection of the page
            pdfDocument.Pages[1].Annotations.Add(textAnnotation);
            dataDir = dataDir + "AddAnnotation_out.pdf";
            // Save output file
            pdfDocument.Save(dataDir);
            // ExEnd:AddAnnotation
            Console.WriteLine("\nAnnotation added successfully.\nFile saved at " + dataDir);
        }
        public void DetectDocumentText()
        {
            Image image = LoadResourceImage("DocumentText.png");
            // Snippet: DetectDocumentText
            ImageAnnotatorClient client = ImageAnnotatorClient.Create();
            TextAnnotation       text   = client.DetectDocumentText(image);

            Console.WriteLine($"Text: {text.Text}");
            foreach (var page in text.Pages)
            {
                foreach (var block in page.Blocks)
                {
                    string box = string.Join(" - ", block.BoundingBox.Vertices.Select(v => $"({v.X}, {v.Y})"));
                    Console.WriteLine($"Block {block.BlockType} at {box}");
                    foreach (var paragraph in block.Paragraphs)
                    {
                        box = string.Join(" - ", paragraph.BoundingBox.Vertices.Select(v => $"({v.X}, {v.Y})"));
                        Console.WriteLine($"  Paragraph at {box}");
                        foreach (var word in paragraph.Words)
                        {
                            Console.WriteLine($"    Word: {string.Join("", word.Symbols.Select(s => s.Text))}");
                        }
                    }
                }
            }
            // End snippet
            var lines = text.Pages[0].Blocks
                        .Select(b => b.Paragraphs[0].Words.Select(w => string.Join("", w.Symbols.Select(s => s.Text))))
                        .ToList();

            Assert.Equal(new[] { "Sample", "text", "line", "1", }, lines[0]);
            Assert.Equal(new[] { "Text", "near", "the", "middle", }, lines[1]);
            Assert.Equal(new[] { "Text", "near", "bottom", "right", }, lines[2]);
        }
Пример #14
0
        public static void Run()
        {
            // ExStart:AddAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            // Open document
            Document pdfDocument = new Document(dataDir + "AddAnnotation.pdf");

            // Create annotation
            TextAnnotation textAnnotation = new TextAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(200, 400, 400, 600));

            textAnnotation.Title    = "Sample Annotation Title";
            textAnnotation.Subject  = "Sample Subject";
            textAnnotation.State    = AnnotationState.Accepted;
            textAnnotation.Contents = "Sample contents for the annotation";
            textAnnotation.Open     = true;
            textAnnotation.Icon     = TextIcon.Key;

            Border border = new Border(textAnnotation);

            border.Width          = 5;
            border.Dash           = new Dash(1, 1);
            textAnnotation.Border = border;
            textAnnotation.Rect   = new Aspose.Pdf.Rectangle(200, 400, 400, 600);

            // Add annotation in the annotations collection of the page
            pdfDocument.Pages[1].Annotations.Add(textAnnotation);
            dataDir = dataDir + "AddAnnotation_out.pdf";
            // Save output file
            pdfDocument.Save(dataDir);
            // ExEnd:AddAnnotation
            Console.WriteLine("\nAnnotation added successfully.\nFile saved at " + dataDir);
        }
Пример #15
0
        private void beNavigate_EditValueChanged(object sender, EventArgs e)
        {
            if (NavigatableArray == null)
            {
                return;
            }
            try {
                int index = Convert.ToInt32(this.beNavigate.EditValue);
                if (index < 0)
                {
                    index = 0;
                }
                if (index >= NavigatableArray.Count)
                {
                    index = NavigatableArray.Count - 1;
                }
                NavigatableIndex = index;
            }
            catch (Exception) {
                return;
            }
            ResizeableArray <TextAnnotation> annotations = NavigatableInfo.DataSource as ResizeableArray <TextAnnotation>;

            if (annotations != null)
            {
                TextAnnotation ann  = annotations[NavigatableIndex];
                DateTime       time = (DateTime)((PaneAnchorPoint)ann.AnchorPoint).AxisXCoordinate.AxisValue;
                NavigateTo(time);
                SelectedAnnotation = ann;
            }
            else
            {
                NavigateTo(NavigatableArray.GetItem(NavigatableIndex));
            }
        }
Пример #16
0
        private void BtnAddText_Click(object sender, EventArgs e)
        {
            isPan = false;
            //CalloutAnnotation a = new CalloutAnnotation();
            //a.Text = "My Annotation";
            //a.ToolTip = "Annotation tool tip";
            //a.ForeColor = Color.Green;
            //a.AnchorDataPoint = chart1.Series[0].Points[0];
            //a.Visible = true;
            //a.LineWidth = 2;
            //chart1.Annotations.Add(a);

            var annotation = new frmAnnotation();
            var result     = annotation.ShowDialog();

            if (result == DialogResult.OK)
            {
                // this one is not anchored on a point:
                TextAnnotation TA = new TextAnnotation();
                TA.Text      = annotation.AnnotationText;
                TA.ForeColor = Color.White;
                TA.AnchorX   = 50; // 50% of chart width
                TA.AnchorY   = 20; // 20% of chart height, from top!
                chart1.Annotations.Add(TA);
                annotationList.Add(annotation.AnnotationText);
            }
        }
Пример #17
0
        /// <summary>
        /// Refresh the graph.
        /// </summary>
        public override void Refresh()
        {
            this.plot1.Model.DefaultFontSize         = FontSize;
            this.plot1.Model.PlotAreaBorderThickness = new OxyThickness(0);
            this.plot1.Model.LegendBorder            = OxyColors.Transparent;
            this.plot1.Model.LegendBackground        = OxyColors.White;

            if (this.LeftRightPadding != 0)
            {
                this.plot1.Model.Padding = new OxyThickness(10, 10, this.LeftRightPadding, 10);
            }

            foreach (OxyPlot.Axes.Axis axis in this.plot1.Model.Axes)
            {
                this.FormatAxisTickLabels(axis);
            }

            this.plot1.Model.LegendFontSize = FontSize;

            foreach (OxyPlot.Annotations.Annotation annotation in this.plot1.Model.Annotations)
            {
                TextAnnotation textAnnotation = annotation as TextAnnotation;
                if (textAnnotation != null)
                {
                    textAnnotation.FontSize = FontSize;
                }
            }

            this.plot1.Model.InvalidatePlot(true);
        }
Пример #18
0
        public static PlotModel TextAnnotation()
        {
            var model = new PlotModel("TextAnnotation", "Click the text");

            model.Axes.Add(new LinearAxis(AxisPosition.Bottom, -20, 20));
            model.Axes.Add(new LinearAxis(AxisPosition.Left, -10, 10));
            var ta = new TextAnnotation
            {
                Position = new DataPoint(4, -2),
                Text     = "Click here"
            };

            // Handle left mouse clicks
            ta.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                ta.Background = ta.Background == null ? OxyColors.LightGreen : null;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            model.Annotations.Add(ta);
            return(model);
        }
        public static void DrawAnnotations(Chart chart1, int signalLength, bool addBeatType = true)
        {
            chart1.Annotations.Clear();
            List <int>    RPeaks          = LoadRPeaksInds("R_Peaks.txt");
            List <string> classifications = new List <string>();

            if (addBeatType)
            {
                classifications = LoadClassifications("beats_Classes.txt");
            }
            //MessageBox.Show(RPeaks.Count.ToString());
            //MessageBox.Show(classifications.Count.ToString());

            for (int i = 0; i < RPeaks.Count; i++)
            {
                if (RPeaks[i] >= signalLength)
                {
                    break;
                }
                if (addBeatType)
                {
                    TextAnnotation ann = new TextAnnotation();
                    ann.Text = classifications[i];
                    ann.SetAnchor(chart1.Series[0].Points[RPeaks[i]]);
                    chart1.Annotations.Add(ann);
                }

                chart1.Series[0].Points[RPeaks[i]].MarkerStyle = MarkerStyle.Cross;
                chart1.Series[0].Points[RPeaks[i]].MarkerColor = Color.Red;
            }
        }
Пример #20
0
        public SCChart AddPaneAnnotation(string name, string text, string pane, string valueX, string valueY,
                                         string axisX = null, string axisY = null,
                                         AnnotationOptions options = null)
        {
            options ??= new AnnotationOptions();
            options.AnchorDockPane = pane;
            var annotation = new TextAnnotation();

            options.SetupXtraChartAnnotation(this, name, text, annotation);

            if (Chart.Diagram is not XYDiagram diagramXY)
            {
                throw new Exception("Panes are available only in 2D XY charts.");
            }

            var anchor = new PaneAnchorPoint();

            if (!string.IsNullOrWhiteSpace(pane))
            {
                var chartPane = diagramXY.Panes[pane];
                anchor.Pane = chartPane ?? throw new Exception($"Cannot find pane '{pane}'.");
            }

            var axX = !string.IsNullOrWhiteSpace(axisX) ? diagramXY.FindAxisXByName(axisX) : diagramXY.AxisX;
            var axY = !string.IsNullOrWhiteSpace(axisY) ? diagramXY.FindAxisYByName(axisY) : diagramXY.AxisY;

            anchor.AxisXCoordinate.Axis      = axX;
            anchor.AxisXCoordinate.AxisValue = valueX;

            anchor.AxisYCoordinate.Axis      = axY;
            anchor.AxisYCoordinate.AxisValue = valueY;

            return(this);
        }
Пример #21
0
        public void SetDistAnnotation(List <LevelAndValue> seriesList, double percent)
        {
            this.PlotModel.Annotations.Clear();

            int indexMin = this.EnergyHistogramDatum.HistogramData
                           .FindIndex(a => a.Level == seriesList.Min(b => b.Level));
            int indexMax = this.EnergyHistogramDatum.HistogramData
                           .FindIndex(a => a.Level == seriesList.Max(b => b.Level));

            RectangleAnnotation rectAannotation = new RectangleAnnotation();

            rectAannotation.Fill     = OxyColor.FromArgb(100, OxyColors.Orange.R, OxyColors.Orange.G, OxyColors.Orange.B);
            rectAannotation.MinimumX = indexMin - 0.5;
            rectAannotation.MaximumX = indexMax + 0.5;
            rectAannotation.Layer    = AnnotationLayer.BelowSeries;

            this.PlotModel.Annotations.Add(rectAannotation);

            var textAnnotation = new TextAnnotation();

            textAnnotation.TextPosition = new DataPoint((float)(indexMax + indexMin) / 2, this.PlotModel.Axes[1].ActualMaximum / 2);
            textAnnotation.Text         = String.Format("{0:f1}%", percent);
            textAnnotation.TextColor    = OxyColors.Orange;
            textAnnotation.FontSize     = 50;
            textAnnotation.FontWeight   = FontWeights.Bold;
            textAnnotation.Stroke       = OxyColors.Transparent;

            this.PlotModel.Annotations.Add(textAnnotation);

            this.PlotModel.InvalidatePlot(true);
        }
Пример #22
0
        private void loadAnnotationsFromSignalView(Boolean filterOutSolutions = false)
        {
            if (_ecgSignal == null || !_areAnnotationsDisplayed)
            {
                return;
            }

            _annotationsView.Clear();

            _ecgSignal.Annotations.ForEach(
                ecgannotation =>
            {
                if (!_areCustomSolutionAnnotationsDisplayed && ecgannotation.Type == ANNOTATION_TYPE.SOLUTION)
                {
                    return;
                }

                double lowerTimeIndex = _plotModel.Axes[0].ActualMinimum;
                double upperTimeIndex = _plotModel.Axes[0].ActualMaximum;

                String text    = ecgannotation.Text;
                OxyColor color = OxyColors.White;

                // ignore invisible annotations
                if (ecgannotation.TimeIndex < lowerTimeIndex || ecgannotation.TimeIndex > upperTimeIndex)
                {
                    return;
                }

                DataPoint positionForAnnotation;
                switch (ecgannotation.Type)
                {
                case  ANNOTATION_TYPE.PHYSIONET_STANDARD:
                    positionForAnnotation = new DataPoint(ecgannotation.TimeIndex, -1.8);
                    break;

                case  ANNOTATION_TYPE.SOLUTION:
                    color = OxyColors.LightGreen;
                    text  = "Solution: \n" + text;
                    positionForAnnotation = new DataPoint(ecgannotation.TimeIndex, -1.3);
                    break;

                default:
                    color = OxyColors.LightBlue;
                    text  = "Answer: \n" + text;
                    positionForAnnotation = new DataPoint(ecgannotation.TimeIndex, 1.5);
                    break;
                }

                TextAnnotation textAnnotation = new TextAnnotation()
                {
                    Text         = text,
                    TextPosition = positionForAnnotation,
                    Background   = color
                };

                _annotationsView.Add(textAnnotation);
            });
        }
Пример #23
0
        private void update_TrafficChart()
        {
            List <float>       inboundPoints      = new List <float>();
            List <float>       outboundPoints     = new List <float>();
            TextAnnotation     inboundAnnotation  = new TextAnnotation();
            TextAnnotation     outboundAnnotation = new TextAnnotation();
            BandwidthScaleInfo bandwidthScale;
            const long         minScale = 50;
            long maxSpeed = 0;
            long lastInbound, lastOutbound;

            lock (_lock)
            {
                if (traffic.Count == 0)
                {
                    return;
                }
                foreach (var trafficPerSecond in traffic)
                {
                    inboundPoints.Add(trafficPerSecond.inbound);
                    outboundPoints.Add(trafficPerSecond.outbound);
                    maxSpeed = Math.Max(maxSpeed, Math.Max(trafficPerSecond.inbound, trafficPerSecond.outbound));
                }
                lastInbound  = traffic.Last().inbound;
                lastOutbound = traffic.Last().outbound;
            }

            if (maxSpeed > 0)
            {
                lastMaxSpeed -= lastMaxSpeed / 32;
                maxSpeed      = Math.Max(minScale, Math.Max(maxSpeed, lastMaxSpeed));
                lastMaxSpeed  = maxSpeed;
            }
            else
            {
                maxSpeed = lastMaxSpeed = minScale;
            }

            bandwidthScale = Utils.GetBandwidthScale(maxSpeed);

            //rescale the original data points, since it is List<float>, .ForEach does not work
            inboundPoints  = inboundPoints.Select(p => p / bandwidthScale.unit).ToList();
            outboundPoints = outboundPoints.Select(p => p / bandwidthScale.unit).ToList();

            if (trafficChart.IsHandleCreated)
            {
                trafficChart.Series["Inbound"].Points.DataBindY(inboundPoints);
                trafficChart.Series["Outbound"].Points.DataBindY(outboundPoints);
                trafficChart.ChartAreas[0].AxisY.LabelStyle.Format = "{0:0.##} " + bandwidthScale.unit_name;
                trafficChart.ChartAreas[0].AxisY.Maximum           = bandwidthScale.value;
                inboundAnnotation.AnchorDataPoint  = trafficChart.Series["Inbound"].Points.Last();
                inboundAnnotation.Text             = Utils.FormatBandwidth(lastInbound);
                outboundAnnotation.AnchorDataPoint = trafficChart.Series["Outbound"].Points.Last();
                outboundAnnotation.Text            = Utils.FormatBandwidth(lastOutbound);
                trafficChart.Annotations.Clear();
                trafficChart.Annotations.Add(inboundAnnotation);
                trafficChart.Annotations.Add(outboundAnnotation);
            }
        }
Пример #24
0
        /// <summary>Draws the specified series definition on the view.</summary>
        /// <param name="annotations">The list of annotations</param>
        private void DrawOnView(List <Annotation> annotations)
        {
            double minimumX         = graphView.AxisMinimum(Axis.AxisType.Bottom) * 1.01;
            double maximumX         = graphView.AxisMaximum(Axis.AxisType.Bottom);
            double minimumY         = graphView.AxisMinimum(Axis.AxisType.Left);
            double maximumY         = graphView.AxisMaximum(Axis.AxisType.Left);
            double lowestAxisScale  = Math.Min(minimumX, minimumY);
            double largestAxisScale = Math.Max(maximumX, maximumY);

            for (int i = 0; i < annotations.Count; i++)
            {
                if (annotations[i] is TextAnnotation)
                {
                    TextAnnotation textAnnotation = annotations[i] as TextAnnotation;
                    if (textAnnotation.x is double && ((double)textAnnotation.x) == double.MinValue)
                    {
                        double interval = (largestAxisScale - lowestAxisScale) / 10; // fit 10 annotations on graph.

                        double yPosition = largestAxisScale - (i * interval);
                        graphView.DrawText(
                            textAnnotation.text,
                            minimumX,
                            yPosition,
                            textAnnotation.leftAlign,
                            textAnnotation.textRotation,
                            Axis.AxisType.Bottom,
                            Axis.AxisType.Left,
                            Utility.Configuration.Settings.DarkTheme ? Color.White : textAnnotation.colour);
                    }
                    else
                    {
                        graphView.DrawText(
                            textAnnotation.text,
                            textAnnotation.x,
                            textAnnotation.y,
                            textAnnotation.leftAlign,
                            textAnnotation.textRotation,
                            Axis.AxisType.Bottom,
                            Axis.AxisType.Left,
                            Utility.Configuration.Settings.DarkTheme ? Color.White : textAnnotation.colour);
                    }
                }
                else
                {
                    LineAnnotation lineAnnotation = annotations[i] as LineAnnotation;

                    graphView.DrawLine(
                        lineAnnotation.x1,
                        lineAnnotation.y1,
                        lineAnnotation.x2,
                        lineAnnotation.y2,
                        lineAnnotation.type,
                        lineAnnotation.thickness,
                        Utility.Configuration.Settings.DarkTheme ? Color.White : lineAnnotation.colour,
                        lineAnnotation.InFrontOfSeries,
                        lineAnnotation.ToolTip);
                }
            }
        }
        private void CreateAnnotation(SeriesPoint sp)
        {
            TickerEvent    ev = (TickerEvent)sp.Tag;
            TextAnnotation ta = this.chartControl1.Annotations.AddTextAnnotation("Event" + ev.Time.Ticks, ev.Text);

            ta.AnchorPoint   = new SeriesPointAnchorPoint(sp);
            ta.ShapePosition = new RelativePosition(90, 100);
        }
Пример #26
0
    private void InitData(string projectId, string projectName, string projectSyscode, string projectType)
    {
        projectType = projectType.ToLower();

        //机构类型 h 总公司;hd 总公司部门;b 分公司;bd 分公司部门;zgxmb 直管项目部;fgsxmb 分公司项目部

        #region 安全预警

        IList listWarningTarget = MGWBS.GWBSSrv.GetProjectWarningTargetInfo(projectId, projectSyscode, projectType);

        Color warningTargetBySafeColor     = (Color)listWarningTarget[0];
        Color warningTargetByQualityColor  = (Color)listWarningTarget[1];
        Color warningTargetByDurationColor = (Color)listWarningTarget[2];
        Color warningTargetByCostColor     = (Color)listWarningTarget[3];

        int    projectCount          = Convert.ToInt32(listWarningTarget[4]);
        string projectConstractstage = listWarningTarget[5].ToString();


        Chart2.Series[0].Points[0].Color = warningTargetBySafeColor;                        //安全
        Chart2.Series[0].Points[1].Color = warningTargetByQualityColor;                     //质量
        Chart2.Series[0].Points[2].Color = warningTargetByCostColor;                        //成本
        Chart2.Series[0].Points[3].Color = warningTargetByDurationColor;                    //工期

        Chart2.Series[0].Points[0].ToolTip = ModelToolTip(1, warningTargetBySafeColor);     //安全
        Chart2.Series[0].Points[1].ToolTip = ModelToolTip(2, warningTargetByQualityColor);  //质量
        Chart2.Series[0].Points[2].ToolTip = ModelToolTip(3, warningTargetByCostColor);     //成本
        Chart2.Series[0].Points[3].ToolTip = ModelToolTip(4, warningTargetByDurationColor); //工期

        TextAnnotation t = (TextAnnotation)Chart2.Annotations["txtProjectCount"];

        if (projectType == "h" || projectType == "b")
        {
            t.Text = "在建项目" + projectCount + "个";
        }
        else
        {
            string projectConstractstageStr = "施工阶段:" + projectConstractstage;

            string projectConstractstageStr1 = "";
            if (projectConstractstageStr.Length > 12)
            {
                projectConstractstageStr1 = projectConstractstageStr.Substring(12);
                projectConstractstageStr  = projectConstractstageStr.Substring(0, 12) + "\n\n";
            }

            while (projectConstractstageStr1.Length > 12)
            {
                projectConstractstageStr += projectConstractstageStr1.Substring(0, 12) + "\n\n";
                projectConstractstageStr1 = projectConstractstageStr1.Substring(12);
            }

            projectConstractstageStr += projectConstractstageStr1;

            t.Text = projectConstractstageStr;
        }
        #endregion
    }
        private PlotModel DrawPdf(MsDataScan msDataScan, PropertyInfo[] properties, PsmFromTsv psm, bool redraw)
        {
            if (redraw)
            {
                this.Model = Draw(msDataScan, psm);
            }

            var y    = Model.DefaultYAxis.ActualMaximum - Model.DefaultYAxis.ActualMaximum * 0.03;
            var x    = Model.DefaultXAxis.ActualMaximum - Model.DefaultXAxis.ActualMaximum * 0.01;
            var diff = (y - (Model.DefaultYAxis.ActualMaximum * 0.1)) / properties.Length;

            // properties to include
            string[] propertiesToWrite =
            {
                "Filename",
                "PrecursorCharge",
                "PrecursorMass",
                "PeptideMonoMass",
                "MassDiffDa",
                "MassDiffPpm",
                "Score",
                "DeltaScore",
                "ProteinAccession",
                "ProteinName",
                "GeneName",
                "DecoyContamTarget",
                "QValue",
                "QValueNotch"
            };

            var propertiesList = properties.Where(p => propertiesToWrite.Contains(p.Name)).OrderBy(p => Array.IndexOf(propertiesToWrite, p.Name)).ToList();

            var displayedProperties = propertiesList.Where(p => p.GetValue(psm) != null); // only display non-null properties

            foreach (PropertyInfo property in displayedProperties)
            {
                // trim property values > 50 characters
                var val = "" + property.GetValue(psm);
                if (val.Length > 50)
                {
                    val = val.Substring(0, 50) + "...";
                }

                var propertyAnnotation = new TextAnnotation
                {
                    Text                    = property.Name + ": " + val,
                    TextPosition            = new DataPoint(x, y),
                    FontSize                = 9,
                    StrokeThickness         = 0,
                    TextHorizontalAlignment = HorizontalAlignment.Right
                };

                y -= diff;
                Model.Annotations.Add(propertyAnnotation);
            }

            return(Model);
        }
Пример #28
0
        private void DrawAnnotation(string text, int index, string columnName, double[] valores)
        {
            TextAnnotation textAnnotation = new TextAnnotation();

            textAnnotation.Text            = text + valores[index].ToString();
            textAnnotation.AnchorDataPoint = boxPlot.Series[columnName].Points[0];
            textAnnotation.AnchorY         = valores[index];
            boxPlot.Annotations.Add(textAnnotation);
        }
Пример #29
0
        public override BaseElement Clone()
        {
            TextAnnotation clone = new TextAnnotation
            {
                Values = this
            };

            return(clone);
        }
Пример #30
0
        private void ratingSearch_Click(object sender, EventArgs e)
        {
            int numItems = 0;

            foreach (var series in scatterChart.Series)
            {
                series.Points.Clear();
            }
            scatterChart.Annotations.Clear();
            warningLabel.Visible = false;

            int    rating   = int.Parse(ratingUpDown.Text);
            string filePath = @"Resources\movielist.xml";

            XDocument xDoc = null;

            xDoc = XDocument.Load(filePath);
            var titleQuery = from x in xDoc.Descendants("movie")
                             select x;

            foreach (XElement y in titleQuery)
            {
                if (int.Parse((y.Element("rating").Value)) == rating)
                {
                    TextAnnotation newAnnot = new TextAnnotation();
                    newAnnot.Name    = y.Element("title").Value.ToString();
                    newAnnot.Text    = y.Element("title").Value.ToString();
                    newAnnot.ToolTip = y.Element("title").Value.ToString();
                    newAnnot.Visible = true;
                    newAnnot.AnchorX = (int.Parse(y.Element("year").Value));
                    newAnnot.AnchorY = (int.Parse(y.Element("rating").Value));
                    if (scatterChart.Annotations.FindByName(y.Element("title").Value.ToString()) == null)
                    {
                        scatterChart.Annotations.Add(newAnnot);
                    }
                    numItems++;
                    scatterChart.Series[y.Element("genre").Value.ToString().ToLower()].Points.AddXY(int.Parse(y.Element("year").Value), int.Parse(y.Element("rating").Value));
                }
            }

            xTrackBar.Value = 10;
            yTrackBar.Value = 10;

            if (scatterChart.Annotations.Count < 40)
            {
                foreach (Annotation text in scatterChart.Annotations)
                {
                    text.AxisX = scatterChart.ChartAreas[0].AxisX;
                    text.AxisY = scatterChart.ChartAreas[0].AxisY;
                }
            }
            else
            {
                warningLabel.Visible = true;
            }
            numItemsLabel.Text = "Number of movies shown: " + numItems.ToString();
        }
Пример #31
0
        public void CreateNewStarAnnotation()

        {
            // Create annotation group and add it to the chart annotations collection
            AnnotationGroup star = new AnnotationGroup();

            star.X              = 20;
            star.Y              = 20;
            star.Width          = 30;
            star.Height         = 20;
            star.AllowSelecting = true;
            star.AllowMoving    = true;
            star.AllowResizing  = true;

            Chart1.Annotations.Add(star);

            // Add star shaped polygon annotation into the group

            PointF[] starPolygon = new PointF[] {
                new PointF(1, 6), new PointF(27, 23), new PointF(33, 5), new PointF(44, 22), new PointF(58, 0),
                new PointF(57, 19), new PointF(75, 11), new PointF(70, 28), new PointF(100, 37), new PointF(81, 53),
                new PointF(99, 65), new PointF(75, 67), new PointF(87, 98), new PointF(63, 69), new PointF(60, 94),
                new PointF(47, 69), new PointF(34, 100), new PointF(32, 69), new PointF(23, 74), new PointF(26, 61),
                new PointF(4, 72), new PointF(22, 49), new PointF(0, 39), new PointF(23, 32), new PointF(1, 6)
            };

            GraphicsPath starPath = new GraphicsPath();

            starPath.AddPolygon(starPolygon);
            PolygonAnnotation poly = new PolygonAnnotation();

            poly.Name         = "Star";
            poly.GraphicsPath = starPath;
            star.Annotations.Add(poly);

            // Set star polygon annotation position and appearance
            star.Annotations["Star"].X            = 0;
            star.Annotations["Star"].Y            = 0;
            star.Annotations["Star"].Width        = 100;
            star.Annotations["Star"].Height       = 100;
            star.Annotations["Star"].LineColor    = Color.FromArgb(64, 64, 64);
            star.Annotations["Star"].BackColor    = Color.FromArgb(220, 255, 255, 192);
            star.Annotations["Star"].ShadowOffset = 2;

            // Add text in the middle of the star shape
            TextAnnotation textAnnotation = new TextAnnotation();

            textAnnotation.Name   = "StarText";
            textAnnotation.Text   = "New !!!";
            textAnnotation.X      = 20;
            textAnnotation.Y      = 20;
            textAnnotation.Width  = 60;
            textAnnotation.Height = 60;
            star.Annotations.Add(textAnnotation);
            star.Annotations["StarText"].Font      = new Font("MS Sans Serif", 10, FontStyle.Bold | FontStyle.Italic);
            star.Annotations["StarText"].ForeColor = Color.FromArgb(26, 59, 105);
        }
Пример #32
0
 public static int SearchWordCount(TextAnnotation text, string term)
 {
     return(text.Pages
            .SelectMany(p => p.Blocks
                        .SelectMany(b => b.Paragraphs
                                    .SelectMany(p => p.Words
                                                .Select(w => string.Join("", w.Symbols.Select(s => s.Text))
                                                        )))).Where(s => s.ToLower() == term).ToList().Count);
 }
Пример #33
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="features">List of features</param>
        /// <param name="title">Plot title</param>
        /// <param name="minMass">Minimum mass</param>
        /// <param name="maxMass">Maximum mass</param>
        /// <param name="minTime">Minimum time (minutes)</param>
        /// <param name="maxTime">Maximum time (minutes)</param>
        public LcMsFeatureMap(IEnumerable<LcMsFeature> features, string title, double minMass, double maxMass, double minTime, double maxTime)
        {
      
            _features = features;
            
            // Initialize x and y axes.
            var yAxis = new LinearAxis
            {
                Position = AxisPosition.Left,
                Title = "Monoisotopic Mass [Da]",
                StringFormat = "0.###",
                FontSize = 20,
                Minimum = minMass,
                Maximum = maxMass
            };

            var xAxis = new LinearAxis
            {
                Position = AxisPosition.Bottom,
                Title = "Elution Time [Minute]",
                StringFormat = "0.###",
                FontSize = 20,
                Minimum = minTime,
                Maximum = maxTime
            };


            // Initialize feature map.
            _featureMap = new PlotModel { Title = title, TitleFontSize = 30 };
            _featureMap.Axes.Add(xAxis);
            _featureMap.Axes.Add(yAxis);

            var txtX = minTime + (maxTime - minTime) * 0.2;
            var txtY = maxMass - (maxMass - minMass) * 0.1;

            var annotation = new TextAnnotation
            {
                TextPosition = new DataPoint(txtX, txtY),
                Text = string.Format("Number of LCMS features = {0}", _features.Count()),
                FontSize = 25,
            };
            
            _featureMap.Annotations.Add(annotation);
        }
Пример #34
0
 private void addAnnotation(SeriesPoint point, int zIndex)
 {
     TextAnnotation annotation = new TextAnnotation(point.Tag.ToString(), point.Tag.ToString());
     if (annotation != null)
     {
         //annotation.Font = new Font(annotation.Font.FontFamily, annotation.Font.Size);
         //Specify the text annotation position.
         annotation.AnchorPoint = new SeriesPointAnchorPoint(point);
         annotation.ShapePosition = new RelativePosition();
         RelativePosition position = annotation.ShapePosition as RelativePosition;
         position.ConnectorLength = 0;
         position.Angle = 270;
         //annotation.RuntimeMoving = true;
         annotation.BackColor = Color.Transparent;
         annotation.ConnectorStyle = AnnotationConnectorStyle.None;
         annotation.AutoSize = false;
         annotation.Width = 20;
         annotation.Border.Color = Color.Transparent;
         annotation.ZOrder = zIndex;
         //Add an annotaion to the annotation repository.
         this.chartControl1.AnnotationRepository.Add(annotation);
     }
 }
Пример #35
0
        public static PlotModel TextAnnotation()
        {
            var model = new PlotModel { Title = "TextAnnotation", Subtitle = "Click the text" };
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -20, Maximum = 20 });
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -10, Maximum = 10 });
            var ta = new TextAnnotation
            {
                TextPosition = new DataPoint(4, -2),
                Text = "Click here"
            };

            // Handle left mouse clicks
            ta.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                ta.Background = ta.Background.IsUndefined() ? OxyColors.LightGreen : OxyColors.Undefined;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            model.Annotations.Add(ta);
            return model;
        }
Пример #36
0
 public void DrawText(
     string text, 
     double x, 
     double y,
     Models.Graph.Axis.AxisType xAxisType, 
     Models.Graph.Axis.AxisType yAxisType,
     Color colour)
 {
     TextAnnotation annotation = new TextAnnotation();
     annotation.Text = text;
     annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left;
     annotation.TextVerticalAlignment = VerticalAlignment.Top;
     annotation.Stroke = OxyColors.White;
     annotation.TextPosition = new DataPoint(x, y);
     //annotation.XAxis = this.GetAxis(xAxisType);
     //annotation.YAxis = this.GetAxis(yAxisType);
     annotation.TextColor = ConverterExtensions.ToOxyColor(colour);
     annotation.FontSize = FontSize - 1;
     this.plot1.Model.Annotations.Add(annotation);
 }
        public void SetLevelAnnotation(double level)
        {
            this.PlotModel.Annotations.Clear();

            int index = this.EnergyHistogramDatum.HistogramData
                .FindIndex(v => v.Level == Math.Ceiling(level / this.EnergyHistogramDatum.ClassWidth) * this.EnergyHistogramDatum.ClassWidth);

            RectangleAnnotation rectAannotation = new RectangleAnnotation();
            rectAannotation.Fill = OxyColor.FromArgb(100, OxyColors.Orange.R, OxyColors.Orange.G, OxyColors.Orange.B);
            rectAannotation.MinimumX = index - 0.5;
            rectAannotation.MaximumX = index + 0.5;
            rectAannotation.Layer = AnnotationLayer.BelowSeries;

            this.PlotModel.Annotations.Add(rectAannotation);

            // TODO アルゴリズム考えよう
            int x;
            if (index < 2)
            {
                x = 2;
            }
            else if (index > 8)
            {
                x = 8;
            }
            else
            {
                x = index;
            }

            var textAnnotation = new TextAnnotation();
            textAnnotation.TextPosition = new DataPoint(x, this.PlotModel.Axes[1].ActualMaximum / 2);
            textAnnotation.Text = String.Format("{0:f3}kWh", level);
            textAnnotation.TextColor = OxyColors.Orange;
            textAnnotation.FontSize = 50;
            textAnnotation.FontWeight = FontWeights.Bold;
            textAnnotation.Stroke = OxyColors.Transparent;

            this.PlotModel.Annotations.Add(textAnnotation);
            
            this.PlotModel.InvalidatePlot(true);
        }
Пример #38
0
        public static PlotModel LabelPlacementCategoryAxisWhenAxisAngleIs45()
        {
            var plotModel1 = new PlotModel { Title = "Wrong label placement for category axis when Angle = 45", Subtitle = "The labels should not be clipped. Click on text annotation to change the angle." };

            Action<AxisPosition> createAxis = (AxisPosition position) =>
            {
                var categoryAxis = new CategoryAxis() { Position = position, Angle = 45 };

                categoryAxis.Labels.Add("Very looooong and big label");
                categoryAxis.Labels.Add("Very looooong and big label");
                categoryAxis.Labels.Add("Very looooong and big label");
                categoryAxis.Labels.Add("Very looooong and big label");
                plotModel1.Axes.Add(categoryAxis);
            };

            createAxis(AxisPosition.Bottom);
            createAxis(AxisPosition.Left);
            createAxis(AxisPosition.Right);
            createAxis(AxisPosition.Top);

            var textAnnotation = new TextAnnotation() { Text = "Hold mouse button here to increase angle", TextPosition = new DataPoint(0, 6), TextHorizontalAlignment = HorizontalAlignment.Left, TextVerticalAlignment = VerticalAlignment.Top };
            plotModel1.Annotations.Add(textAnnotation);

            var abort = new ManualResetEvent(false);

            Action action = () =>
            {
                do
                {
                    // Angles are the same for all axes.
                    double angle = 0;

                    foreach (var axis in plotModel1.Axes)
                    {
                        angle = (axis.Angle + 181) % 360 - 180;
                        axis.Angle = angle;
                    }

                    plotModel1.Subtitle = string.Format("Current angle is {0}", angle);
                    plotModel1.InvalidatePlot(false);
                }
                while (!abort.WaitOne(50));
            };

            textAnnotation.MouseDown += (o, e) => { abort.Reset(); Task.Factory.StartNew(action); };
            plotModel1.MouseUp += (o, e) => { abort.Set(); };

            var columnSeries = new ColumnSeries();
            columnSeries.Items.Add(new ColumnItem(5));
            columnSeries.Items.Add(new ColumnItem(3));
            columnSeries.Items.Add(new ColumnItem(7));
            columnSeries.Items.Add(new ColumnItem(2));
            plotModel1.Series.Add(columnSeries);
            return plotModel1;
        }
Пример #39
0
 public void TextAnnotation()
 {
     var s1 = new TextAnnotation();
     var s2 = new Annotations.TextAnnotation();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }
        public void SetDistAnnotation(List<LevelAndValue> seriesList, double percent)
        {
            this.PlotModel.Annotations.Clear();

            int indexMin = this.EnergyHistogramDatum.HistogramData
                .FindIndex(a => a.Level == seriesList.Min(b => b.Level));
            int indexMax = this.EnergyHistogramDatum.HistogramData
                .FindIndex(a => a.Level == seriesList.Max(b => b.Level));

            RectangleAnnotation rectAannotation = new RectangleAnnotation();
            rectAannotation.Fill = OxyColor.FromArgb(100, OxyColors.Orange.R, OxyColors.Orange.G, OxyColors.Orange.B);
            rectAannotation.MinimumX = indexMin - 0.5;
            rectAannotation.MaximumX = indexMax + 0.5;
            rectAannotation.Layer = AnnotationLayer.BelowSeries;

            this.PlotModel.Annotations.Add(rectAannotation);

            var textAnnotation = new TextAnnotation();
            textAnnotation.TextPosition = new DataPoint((float)(indexMax + indexMin) / 2, this.PlotModel.Axes[1].ActualMaximum / 2);
            textAnnotation.Text = String.Format("{0:f1}%", percent);
            textAnnotation.TextColor = OxyColors.Orange;
            textAnnotation.FontSize = 50;
            textAnnotation.FontWeight = FontWeights.Bold;
            textAnnotation.Stroke = OxyColors.Transparent;

            this.PlotModel.Annotations.Add(textAnnotation);

            this.PlotModel.InvalidatePlot(true);
        }
Пример #41
0
        private void SetAnnotationType()
        {
            Chart1.Annotations.Clear();

            if(Annotation.SelectedItem.Value == "Line")
            {
                LineAnnotation annotation = new LineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Vertical Line")
            {
                VerticalLineAnnotation annotation = new VerticalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = new HorizontalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Polyline")
            {
                PolylineAnnotation annotation = new PolylineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width = 30;

                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 0;
                points[2].Y = 100;

                points[3].X = 100;
                points[3].Y = 100;

                points[4].X = 0;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Text")
            {
                TextAnnotation annotation = new TextAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a TextAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Rectangle")
            {
                RectangleAnnotation annotation = new RectangleAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a\nRectangleAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Ellipse")
            {
                EllipseAnnotation annotation = new EllipseAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am an EllipseAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.LineWidth = 2;
                annotation.Height = 35;
                annotation.Width = 60;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Arrow")
            {
                ArrowAnnotation annotation = new ArrowAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Border3D")
            {
                Border3DAnnotation annotation = new Border3DAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a Border3DAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.Height = 40;
                annotation.Width = 50;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Callout")
            {
                CalloutAnnotation annotation = new CalloutAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text = "I am a\nCalloutAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 10);;
                annotation.Height = 35;
                annotation.Width = 50;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = new PolygonAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width = 30;

                annotation.BackColor = Color.FromArgb(128, Color.Orange);

                // define relative value points for a polygon
                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 100;
                points[2].Y = 100;

                points[3].X = 0;
                points[3].Y = 100;

                points[4].X = 50;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Image")
            {
                if (Chart1.Images.IndexOf("MyBmp") < 0)
                {
                    Bitmap Bmp = new Bitmap(200, 75);
                    Graphics g = Graphics.FromImage(Bmp);
                    g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Bmp.Width, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleGoldenrod), Bmp.Width/2, 0, Bmp.Width/2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleVioletRed), 0, 0, Bmp.Width/2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.DarkOrange)), 0, Bmp.Height/2, Bmp.Width, Bmp.Height/2);
                    g.DrawString("I am an ImageAnnotation", new Font("Arial", 12),
                        new SolidBrush(Color.Black),
                        new Rectangle( 0, 0, Bmp.Width, Bmp.Height));

                    g.Dispose();

                    Chart1.Images.Add(new NamedImage("MyBmp", Bmp));
                }

                ImageAnnotation annotation = new ImageAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Image = "MyBmp";

                Chart1.Annotations.Add(annotation);
            }
        }
        public void SetCompAnnotation(double low, double high, bool isAbsolute)
        {
            this.PlotModel.Annotations.Clear();

            int indexLow = this.EnergyHistogramDatum.HistogramData
                .FindIndex(v => v.Level == Math.Ceiling(low / this.EnergyHistogramDatum.ClassWidth) * this.EnergyHistogramDatum.ClassWidth);

            int indexHigh = this.EnergyHistogramDatum.HistogramData
                .FindIndex(v => v.Level == Math.Ceiling(high / this.EnergyHistogramDatum.ClassWidth) * this.EnergyHistogramDatum.ClassWidth);

            RectangleAnnotation rectAannotationMin = new RectangleAnnotation();
            rectAannotationMin.Fill = OxyColor.FromArgb(100, OxyColors.Orange.R, OxyColors.Orange.G, OxyColors.Orange.B);
            rectAannotationMin.MinimumX = indexLow - 0.5;
            rectAannotationMin.MaximumX = indexLow + 0.5;
            rectAannotationMin.Layer = AnnotationLayer.BelowSeries;

            this.PlotModel.Annotations.Add(rectAannotationMin);

            RectangleAnnotation rectAannotationMax = new RectangleAnnotation();
            rectAannotationMax.Fill = OxyColor.FromArgb(100, OxyColors.Orange.R, OxyColors.Orange.G, OxyColors.Orange.B);
            rectAannotationMax.MinimumX = indexHigh - 0.5;
            rectAannotationMax.MaximumX = indexHigh + 0.5;
            rectAannotationMax.Layer = AnnotationLayer.BelowSeries;

            this.PlotModel.Annotations.Add(rectAannotationMax);

            var textAnnotation = new TextAnnotation();
            textAnnotation.TextPosition = new DataPoint((float)(indexHigh + indexLow) / 2, this.PlotModel.Axes[1].ActualMaximum / 2);

            if (isAbsolute)
                textAnnotation.Text = String.Format("{0:f3}kWh", high - low);
            else
                textAnnotation.Text = String.Format("{0:f0}%", high * 100 / low);

            textAnnotation.TextColor = OxyColors.Orange;
            textAnnotation.FontSize = 50;
            textAnnotation.FontWeight = FontWeights.Bold;
            textAnnotation.Stroke = OxyColors.Transparent;

            this.PlotModel.Annotations.Add(textAnnotation);

            this.PlotModel.InvalidatePlot(true);
        }
Пример #43
0
        public static BaseAnnotation Translate(ImageDoc.Annotation annotation, float scale, ColourFormat colourFormat, PointF controlOffset, PointF imageOffset)
        {
            BaseAnnotation imagingAnnotation = null;
            ImageDoc.ImagingAnnotationTypes annType = (ImageDoc.ImagingAnnotationTypes)
                Enum.Parse(typeof(ImageDoc.ImagingAnnotationTypes), annotation.AnnotationType);
            switch (annType) {
                case ImageDoc.ImagingAnnotationTypes.FreeLine: {
                    imagingAnnotation
                        = new FreeLineAnnotation(SimpleTypeToColor(annotation.LineColor), annotation.LineThickness, scale, colourFormat, controlOffset, imageOffset);
                    break;

                }
                case ImageDoc.ImagingAnnotationTypes.Highlighter: case ImageDoc.ImagingAnnotationTypes.Polygon: {
                    imagingAnnotation = new PolygonAnnotation(SimpleTypeToColor(annotation.LineColor), annotation.LineThickness, scale, colourFormat, controlOffset, imageOffset);
                }
                    break;
                case ImageDoc.ImagingAnnotationTypes.Stamp: {
                        imagingAnnotation = new StampAnnotation(annotation.LineThickness, scale, colourFormat, controlOffset, imageOffset);
                    }
                    break;
                case ImageDoc.ImagingAnnotationTypes.StraightLine: {
                    imagingAnnotation = new StraightLineAnnotation(SimpleTypeToColor(annotation.LineColor), annotation.LineThickness, scale, colourFormat, controlOffset, imageOffset);
                    }
                    break;
                case ImageDoc.ImagingAnnotationTypes.TextAnnotation: {
                    // Top left of the text
                    Point topLeft = new Point((int)annotation.Rect.TopLeft.X, (int)annotation.Rect.TopLeft.Y);
                    imagingAnnotation = new TextAnnotation(topLeft, controlOffset, imageOffset, scale, colourFormat);
                    }
                    break;
                case ImageDoc.ImagingAnnotationTypes.Svg: {
                        // Top left of the text
                    Point topLeft = new Point((int)annotation.Rect.TopLeft.X, (int)annotation.Rect.TopLeft.Y);
                        imagingAnnotation = new SvgAnnotation(topLeft, controlOffset, imageOffset, scale, colourFormat);
                        (imagingAnnotation as SvgAnnotation).ImageName = annotation.SvgImageName;
                    }
                    break;
            }
            if ((imagingAnnotation is PolygonAnnotation)) {
                (imagingAnnotation as PolygonAnnotation).ShapeName = annotation.SvgImageName;
                foreach (ImageDoc.Point point in annotation.Points) {
                    Point intPoint = new Point((int)point.X, (int)point.Y);
                    (imagingAnnotation as PolygonAnnotation).AddPoint(intPoint);
                }
                // This forces the initialisation of some required objects
                (imagingAnnotation as PolygonAnnotation).EndDrawing();
            }
            if ((imagingAnnotation is StampAnnotation)) {
                foreach (ImageDoc.Point point in annotation.Points) {
                    Point intPoint = new Point((int)point.X, (int)point.Y);
                    (imagingAnnotation as StampAnnotation).Points.Add(intPoint);
                }
            }
            if ((imagingAnnotation is TextAnnotation)) {
                (imagingAnnotation as TextAnnotation).Text = annotation.Text;
                (imagingAnnotation as TextAnnotation).TextFont = annotation.Font.ToFont();
                (imagingAnnotation as TextAnnotation).TextColor = SimpleTypeToColor(annotation.TextColor);
            }
            imagingAnnotation.Rect = SimpleTypeToRect(annotation.Rect);
            imagingAnnotation.Filled = true;
            imagingAnnotation.FillColor = SimpleTypeToColor(annotation.FillColor);
            imagingAnnotation.FillOpacity = annotation.FillOpacity;
            //imagingAnnotation.Outline = annotation.Outline;
            return imagingAnnotation;
        }
        /// <summary>
        /// Add text annotation to chart.
        /// </summary>
        /// <param name="sender">Source Chart.</param>
        /// <param name="text">Text to display.</param>
        /// <param name="x">Text box upper left X Coordinate.</param>
        /// <param name="y">Text box upper left Y coordinate.</param>
        /// <param name="textColor">Text color.</param>
        /// <param name="name">Annotation name.</param>
        /// <param name="textStyle">Style of text.</param>
        /// <param name="chartArea">Target ChartArea where annotation should be displayed. Default to first ChartArea if not defined.</param>
        public static Annotation AddText(this Chart sender, string text,
            double x, double y,
            Drawing.Color textColor, string name = "",
            TextStyle textStyle = TextStyle.Default, ChartArea chartArea = null)
        {
            TextAnnotation textAnn = new TextAnnotation();
            string chartAreaName = (chartArea == null) ? sender.ChartAreas[0].Name : chartArea.Name;
            textAnn.ClipToChartArea = chartAreaName;
            textAnn.AxisXName = chartAreaName + "\\rX";
            textAnn.YAxisName = chartAreaName + "\\rY";
            textAnn.IsSizeAlwaysRelative = false;

            textAnn.Text = text;
            textAnn.ForeColor = textColor;
            textAnn.X = x;
            textAnn.Y = y;
            textAnn.TextStyle = textStyle;

            sender.Annotations.Add(textAnn);
            if (!string.IsNullOrEmpty(name)) textAnn.Name = name;

            return textAnn;
        }
Пример #45
0
        /// <summary>
        /// Function to add text as an annotation to the chart.
        /// </summary>
        /// <param name="text">The text that we wish to display.</param>
        /// <param name="AxisX">X-Axis that the text annotation is to use for co-ordinates.</param>
        /// <param name="AxisY">Y-Axis that the text annotation is to use for co-ordinates.</param>
        /// <param name="X">X value for the start of the text.</param>
        /// <param name="Y">Y value for the start of the text.</param>
        /// <param name="output">The chart that the line annotation is being added to.</param>
        private void addTextAnnotation(string text, Axis AxisX, Axis AxisY, double X, double Y, Chart output)
        {
            //Create a new line annotation.
            TextAnnotation textAnnotation = new TextAnnotation();

            //Set each property to the parameters passed in.
            textAnnotation.AxisX = AxisX;
            textAnnotation.AxisY = AxisY;
            textAnnotation.Y = Y;
            textAnnotation.X = X;
            textAnnotation.Text = text;

            //Turn off relative size to get graph-oriented co-ordinates and set the aesthetic properties.
            textAnnotation.IsSizeAlwaysRelative = false;
            textAnnotation.ForeColor = myForeColor;
            textAnnotation.Font = myFont;

            //Add the annotation to the chart.
            output.Annotations.Add(textAnnotation);
        }
Пример #46
0
        // Draw sub piece range and annotation
        private void DrawSubPiece()
        {
            // get current using unit
            NowUnit ucd = _units.Find(x => x.ComponentName == "Flaw Map CD");

            _totalScore = 0;
            DataRow[] flawRows = _dtbFlaws.Select(_dtbFlaws.DefaultView.RowFilter);

            ConfigHelper ch = new ConfigHelper();
            string gradeConfigFile = ch.GetDefaultGradeConfigName();
            DataTable gradeColumn = ch.GetDataTableOfdgvColumns(gradeConfigFile);
            DataTable gradeRow = ch.GetDataTableOfdgvRows(gradeConfigFile);
            string roiMode = ch.GetGradeNoRoiMode(gradeConfigFile);
            bool showScore = ch.IsGradePointEnable(gradeConfigFile);
            bool showGrade = ch.IsGradeMarksEnable(gradeConfigFile);

            if (roiMode == "Symmetrical")
            {
                foreach (DataRow drCol in gradeColumn.Rows)
                {
                    foreach (DataRow drRow in gradeRow.Rows)
                    {
                        // Add rangearea
                        string rangeName = String.Format("{0}{1}", drCol["Name"], drRow["Name"]);
                        Series range = new Series(rangeName, ViewType.RangeArea);
                        range.ShowInLegend = false;
                        range.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.False;
                        range.ArgumentScaleType = ScaleType.Numerical;

                        range.Points.Add(new SeriesPoint(drCol["Start"], drRow["Start"], drRow["End"]));
                        range.Points.Add(new SeriesPoint(drCol["End"], drRow["Start"], drRow["End"]));

                        RangeAreaSeriesView view = (RangeAreaSeriesView)range.View;
                        view.Color = Color.Red;
                        view.Transparency = 230;
                        view.Marker1.Visible = false;
                        view.Marker2.Visible = false;
                        view.Border1.Color = Color.Transparent;
                        view.Border2.Color = Color.Transparent;

                        chartControl.Series.Add(range);

                        int subPieceScore = 0;
                        string subPieceGrade = "F";
                        if (showScore)
                        {
                            string subPieceFilter = String.Format("(CD >= {0} AND CD <= {1}) AND (MD > {2} AND MD < {3})", Convert.ToDouble(drCol["Start"]) / ucd.Conversion, Convert.ToDouble(drCol["End"]) / ucd.Conversion, (Convert.ToDouble(drRow["Start"]) / ucd.Conversion + _topOfPart), (Convert.ToDouble(drRow["End"]) / ucd.Conversion + _topOfPart));
                            DataRow[] subFlawRows = _dtbFlaws.Select(subPieceFilter);
                            foreach (DataRow dr in subFlawRows)
                            {
                                string pointFilter = String.Format("SubpieceName = 'ROI-{0}' AND ClassName = '{1}'", rangeName, dr["FlawClass"]);
                                subPieceScore += Convert.ToInt32(_dtbPoints.Select(pointFilter).First()["Score"]);
                            }
                        }
                        if (showGrade)
                        {
                            string gradeFilter = String.Format("SubpieceName = 'ROI-{0}' AND Score >= {1}", rangeName, subPieceScore);
                            DataRow[] r = _dtbGrades.Select(gradeFilter);
                            if (_dtbGrades.Select(gradeFilter).Length > 0)
                            {
                                subPieceGrade = _dtbGrades.Select(gradeFilter).First()["GradeName"].ToString();
                            }
                        }

                        // Add annotation
                        TextAnnotation annotation = new TextAnnotation();
                        PaneAnchorPoint paPoint = new PaneAnchorPoint();
                        RelativePosition relPosition = new RelativePosition();

                        annotation.LabelMode = true;
                        annotation.BackColor = System.Drawing.Color.Transparent;
                        annotation.Border.Visible = false;
                        annotation.ConnectorStyle = AnnotationConnectorStyle.None;
                        annotation.Font = new System.Drawing.Font("Tahoma", 8F, FontStyle.Bold);
                        annotation.TextColor = Color.Blue;
                        annotation.Name = rangeName;
                        string annotationScore = "";
                        if (showScore)
                        {
                            annotationScore = String.Format(" - {0}", subPieceScore);
                        }
                        string annotationGrade = "";
                        if (showGrade)
                        {
                            annotationGrade = String.Format("({0})", subPieceGrade);
                        }
                        annotation.Text = String.Format("{0}{1}{2}", rangeName, annotationScore, annotationGrade);
                        string annotationX = Convert.ToString(Convert.ToDouble(drCol["Start"]) + (Convert.ToDouble(drCol["End"]) - Convert.ToDouble(drCol["Start"])) * 0.3);
                        string annotationY = Convert.ToString(Convert.ToDouble(drRow["End"]) - (Convert.ToDouble(drRow["End"]) - Convert.ToDouble(drRow["Start"])) * 0.1);
                        paPoint.AxisXCoordinate.AxisValueSerializable = annotationX;
                        paPoint.AxisYCoordinate.AxisValueSerializable = annotationY;
                        annotation.AnchorPoint = paPoint;
                        relPosition.Angle = 0;
                        relPosition.ConnectorLength = 0;
                        annotation.ShapePosition = relPosition;
                        chartControl.AnnotationRepository.AddRange(new Annotation[] { annotation });

                        _totalScore += subPieceScore;
                    }
                }
            }
            DrawDummyPoint();

            // Calculate flaw quantity
            Dictionary<string, int> flawLegendRefDic = new Dictionary<string, int>();
            int i = 0;
            foreach (DataGridViewRow dgvr in dgvFlawLegendDetial.Rows)
            {
                dgvr.Cells["PieceDoffNum"].Value = "0";
                flawLegendRefDic.Add(dgvr.Cells["Name"].Value.ToString(), i);
                i++;
            }
            if (flawRows.Length > 0)
            {
                foreach (DataRow dr in flawRows)
                {
                    string flawName = dr["FlawClass"].ToString();
                    int rowPosition = flawLegendRefDic[flawName];
                    int flawQuantity = Convert.ToInt32(dgvFlawLegendDetial.Rows[rowPosition].Cells["PieceDoffNum"].Value) + 1;
                    dgvFlawLegendDetial.Rows[rowPosition].Cells["PieceDoffNum"].Value = flawQuantity.ToString();
                }
            }
        }
        public static PlotModel TextAnnotation()
        {
            var model = new PlotModel("TextAnnotation", "Click the text");
            model.Axes.Add(new LinearAxis(AxisPosition.Bottom, -20, 20));
            model.Axes.Add(new LinearAxis(AxisPosition.Left, -10, 10));
            var ta = new TextAnnotation
            {
                Position = new DataPoint(4, -2),
                Text = "Click here"
            };

            // Handle left mouse clicks
            ta.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                ta.Background = ta.Background == null ? OxyColors.LightGreen : null;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            model.Annotations.Add(ta);
            return model;
        }