当前位置: 首页>>代码示例>>C#>>正文


C# PlotModel类代码示例

本文整理汇总了C#中PlotModel的典型用法代码示例。如果您正苦于以下问题:C# PlotModel类的具体用法?C# PlotModel怎么用?C# PlotModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PlotModel类属于命名空间,在下文中一共展示了PlotModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Export

 /// <summary>
 /// Exports the specified plot model to a xaml file.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="background">The background.</param>
 public static void Export(PlotModel model, string fileName, double width, double height, OxyColor background)
 {
     using (var w = new StreamWriter(fileName))
     {
         w.Write(ExportToString(model, width, height, background));
     }
 }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:15,代码来源:XamlExporter.cs

示例2: Export

 /// <summary>
 /// Exports the specified model to a file.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="path">
 /// The path.
 /// </param>
 /// <param name="width">
 /// The width (points).
 /// </param>
 /// <param name="height">
 /// The height (points).
 /// </param>
 public static void Export(PlotModel model, string path, double width, double height)
 {
     using (FileStream s = File.Create(path))
     {
         Export(model, s, width, height);
     }
 }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:22,代码来源:PdfExporter.cs

示例3: Render

        /// <summary>
        /// Renders the polygon annotation.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="model">The plot model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);

            this.screenPosition = this.Transform(this.X, this.Y);

            // clip to the area defined by the axes
            var clippingRectangle = this.GetClippingRect();

            rc.DrawMarker(clippingRectangle, this.screenPosition, this.Shape, this.CustomOutline, this.Size, this.Fill, this.Stroke, this.StrokeThickness);

            if (!string.IsNullOrEmpty(this.Text))
            {
                var dx = -(int)this.TextHorizontalAlignment * (this.Size + this.TextMargin);
                var dy = -(int)this.TextVerticalAlignment * (this.Size + this.TextMargin);
                var textPosition = this.screenPosition + new ScreenVector(dx, dy);
                rc.DrawClippedText(
                    clippingRectangle,
                    textPosition,
                    this.Text,
                    this.ActualTextColor,
                    this.ActualFont,
                    this.ActualFontSize,
                    this.ActualFontWeight,
                    this.TextRotation,
                    this.TextHorizontalAlignment,
                    this.TextVerticalAlignment);
            }
        }
开发者ID:Celderon,项目名称:oxyplot,代码行数:34,代码来源:PointAnnotation.cs

示例4: ExportToString_TestPlot_ValidSvgString

 public void ExportToString_TestPlot_ValidSvgString()
 {
     var plotModel = new PlotModel { Title = "Test plot" };
     plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin"));
     var svg = SvgExporter.ExportToString(plotModel, 800, 500, false);
     SvgAssert.IsValidElement(svg);
 }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:7,代码来源:SvgExporterTests.cs

示例5: ExportToString

        /// <summary>
        /// Export the specified plot model to an xaml string.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="background">The background.</param>
        /// <returns>A xaml string.</returns>
        public static string ExportToString(PlotModel model, double width, double height, OxyColor background = null)
        {
            var g = new Grid();
            if (background != null)
            {
                g.Background = background.ToBrush();
            }

            var c = new Canvas();
            g.Children.Add(c);

            var size = new Size(width, height);
            g.Measure(size);
            g.Arrange(new Rect(0, 0, width, height));
            g.UpdateLayout();

            var rc = new ShapesRenderContext(c) { UseStreamGeometry = false };
            model.Update();
            model.Render(rc, width, height);

            var sb = new StringBuilder();
            using (var sw = new StringWriter(sb))
            {
                var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true });
                XamlWriter.Save(c, xw);
            }

            return sb.ToString();
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:37,代码来源:XamlExporter.cs

示例6: Render

        /// <summary>
        /// Renders the polygon annotation.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="model">The plot model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);

            this.screenRectangle = new OxyRect(this.Transform(this.X - (this.Width / 2), this.Y - (this.Height / 2)), this.Transform(this.X + (this.Width / 2), this.Y + (this.Height / 2)));

            // clip to the area defined by the axes
            var clippingRectangle = this.GetClippingRect();

            rc.DrawClippedEllipse(
                clippingRectangle,
                this.screenRectangle,
                this.GetSelectableFillColor(this.Fill),
                this.GetSelectableColor(this.Stroke),
                this.StrokeThickness);

            if (!string.IsNullOrEmpty(this.Text))
            {
                var textPosition = this.GetActualTextPosition(() => this.screenRectangle.Center);
                rc.DrawClippedText(
                    clippingRectangle,
                    textPosition,
                    this.Text,
                    this.ActualTextColor,
                    this.ActualFont,
                    this.ActualFontSize,
                    this.ActualFontWeight,
                    this.TextRotation,
                    this.TextHorizontalAlignment,
                    this.TextVerticalAlignment);
            }
        }
开发者ID:Celderon,项目名称:oxyplot,代码行数:37,代码来源:EllipseAnnotation.cs

示例7: AddAxisTwice

 public void AddAxisTwice()
 {
     var model = new PlotModel();
     var axis = new LinearAxis();
     model.Axes.Add(axis);
     Assert.Throws<InvalidOperationException>(() => model.Axes.Add(axis));
 }
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:7,代码来源:PlotModelTests.cs

示例8: Export

 /// <summary>
 /// Exports the specified plot model to a file.
 /// </summary>
 /// <param name="model">The model to export.</param>
 /// <param name="fileName">The file name.</param>
 /// <param name="width">The width of the output bitmap.</param>
 /// <param name="height">The height of the output bitmap.</param>
 /// <param name="background">The background color. The default value is <c>null</c>.</param>
 /// <param name="resolution">The resolution (resolution). The default value is 96.</param>
 public static void Export(PlotModel model, string fileName, int width, int height, OxyColor background, int resolution = 96)
 {
     using (var s = File.Create(fileName))
     {
         Export(model, s, width, height, background, resolution);
     }
 }
开发者ID:apmKrauser,项目名称:RCUModulTest,代码行数:16,代码来源:PngExporter.cs

示例9: Print

        /// <summary>
        ///     Prints the specified plot model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="width">The width (using the actual media width if not specified).</param>
        /// <param name="height">The height (using the actual media height if not specified).</param>
        public static void Print(PlotModel model, double width = double.NaN, double height = double.NaN)
        {
            PrintDocumentImageableArea area = null;
            var xpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(ref area);
            if (xpsDocumentWriter != null)
            {
                if (double.IsNaN(width))
                {
                    width = area.MediaSizeWidth;
                }

                if (double.IsNaN(height))
                {
                    height = area.MediaSizeHeight;
                }

                var canvas = new Canvas { Width = width, Height = height };
                canvas.Measure(new Size(width, height));
                canvas.Arrange(new Rect(0, 0, width, height));

                var rc = new ShapesRenderContext(canvas);
                model.Update();
                model.Render(rc, width, height);

                canvas.UpdateLayout();

                xpsDocumentWriter.Write(canvas);
            }
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:35,代码来源:XpsExporter.cs

示例10: Save

 public static void Save(PlotModel model, string path, double width, double height)
 {
     using (var s = File.OpenWrite(path))
     {
         Save(model, s, width, height);
     }
 }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:7,代码来源:PdfPlotWriter.cs

示例11: B11_Backgrounds

        public void B11_Backgrounds()
        {
            var plot = new PlotModel("Backgrounds");
            plot.Axes.Add(new LinearAxis(AxisPosition.Bottom, "X-axis"));
            var yaxis1 = new LinearAxis(AxisPosition.Left, "Y1") { Key = "Y1", StartPosition = 0, EndPosition = 0.5 };
            var yaxis2 = new LinearAxis(AxisPosition.Left, "Y2") { Key = "Y2", StartPosition = 0.5, EndPosition = 1 };
            plot.Axes.Add(yaxis1);
            plot.Axes.Add(yaxis2);

            Action<LineSeries> addExamplePoints = ls =>
                {
                    ls.Points.Add(new DataPoint(3, 13));
                    ls.Points.Add(new DataPoint(10, 47));
                    ls.Points.Add(new DataPoint(30, 23));
                    ls.Points.Add(new DataPoint(40, 65));
                    ls.Points.Add(new DataPoint(80, 10));
                };

            var ls1 = new LineSeries { Background = OxyColors.LightSeaGreen, YAxisKey = "Y1" };
            addExamplePoints(ls1);
            plot.Series.Add(ls1);

            var ls2 = new LineSeries { Background = OxyColors.LightSkyBlue, YAxisKey = "Y2" };
            addExamplePoints(ls2);
            plot.Series.Add(ls2);

            // OxyAssert.AreEqual(plot, "B11");
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:28,代码来源:PlotModelTests.cs

示例12: AreEqual

        /// <summary>
        /// Asserts that a plot is equal to the plot stored in the "baseline" folder.
        /// 1. Renders the plot to file.svg
        /// 2. If the baseline does not exist, the current plot is copied to the baseline folder.
        /// 3. Checks that the svg file is equal to a baseline svg.
        /// </summary>
        /// <param name="plot">The plot.</param>
        /// <param name="name">The name of the baseline file.</param>
        public static void AreEqual(PlotModel plot, string name)
        {
            // string name = new System.Diagnostics.StackFrame(1).GetMethod().Name;
            string path = name + ".svg";
            string baseline = @"baseline\" + path;
            using (var s = File.Create(path))
            {
                var rc = new ShapesRenderContext(null);
                SvgExporter.Export(plot, s, 800, 500, false, rc);
            }

            if (!Directory.Exists("baseline"))
            {
                Directory.CreateDirectory("baseline");
            }

            if (!File.Exists(baseline))
            {
                File.Copy(path, baseline);
                return;
            }

            var baselineSvg = File.ReadAllText(baseline);
            var actualSvg = File.ReadAllText(path);

            Assert.IsTrue(string.Equals(baselineSvg, actualSvg), "Actual svg is not equal to baseline (" + Path.GetFullPath(baseline) + ")");
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:35,代码来源:OxyAssert.cs

示例13: Export

 /// <summary>
 /// Exports the specified plot model to a xaml file.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="background">The background.</param>
 public static void Export(PlotModel model, string fileName, double width, double height, OxyColor background)
 {
     using (var sw = new StreamWriter(fileName))
     {
         var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true });
         Export(model, xw, width, height, background);
     }
 }
开发者ID:apmKrauser,项目名称:RCUModulTest,代码行数:16,代码来源:XamlExporter.cs

示例14: AddAxisToDifferentModels

 public void AddAxisToDifferentModels()
 {
     var model1 = new PlotModel();
     var model2 = new PlotModel();
     var axis = new LinearAxis();
     model1.Axes.Add(axis);
     Assert.Throws<InvalidOperationException>(() => model2.Axes.Add(axis));
 }
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:8,代码来源:PlotModelTests.cs

示例15: ExportToString_TestPlot_ValidSvgString

 public void ExportToString_TestPlot_ValidSvgString()
 {
     var plotModel = new PlotModel("Test plot");
     plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin"));
     var rc = new ShapesRenderContext(null);
     var svg = SvgExporter.ExportToString(plotModel, 800, 500, false, rc);
     SvgAssert.IsValidElement(svg);
 }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:8,代码来源:SvgExporterTests.cs


注:本文中的PlotModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。