示例#1
0
 public void AreEqual(Values0 actual)
 {
     AreEqualWithoutTextureOffsetScale(actual);
     Assert.AreEqual(TextureValue, actual.TextureValue);
     Assert.AreEqual(TextureScale, actual.TextureScale);
     Assert.AreEqual(TextureOffset, actual.TextureOffset);
 }
示例#2
0
 public GraphViewModel(ICollection <KeyValuePair <int, double> > values0, ICollection <KeyValuePair <int, double> > values1, Brush stroke0, Brush stroke1, string title, string decorate, double min, double max, string xtext)
 {
     if (values0 != null && values0.Count > 0)
     {
         this.Values0 = new DoubleCollection();
         foreach (var v0 in values0)
         {
             Values0.Add(v0.Value);
         }
     }
     if (values1 != null && values1.Count > 0)
     {
         this.Values1 = new DoubleCollection();
         foreach (var v1 in values1)
         {
             Values1.Add(v1.Value);
         }
     }
     Stroke0  = stroke0;
     Stroke1  = stroke1;
     Title    = title;
     Decorate = decorate;
     Minimum  = min;
     Maximum  = max;
     XText    = xtext;
 }
示例#3
0
 public void AreEqualWithoutTextureOffsetScale(Values0 actual)
 {
     Assert.NotNull(actual);
     Assert.AreEqual(floatValue, actual.floatValue);
     Assert.AreEqual(intValue, actual.intValue);
     Assert.AreEqual(Vector2Value, actual.Vector2Value);
     Assert.AreEqual(Vector3Value, actual.Vector3Value);
     Assert.AreEqual(Vector4Value, actual.Vector4Value);
 }
示例#4
0
 public void AreNotEqual(Values0 actual)
 {
     Assert.NotNull(actual);
     Assert.AreNotEqual(floatValue, actual.floatValue);
     Assert.AreNotEqual(intValue, actual.intValue);
     Assert.AreNotEqual(Vector2Value, actual.Vector2Value);
     Assert.AreNotEqual(Vector3Value, actual.Vector3Value);
     Assert.AreNotEqual(Vector4Value, actual.Vector4Value);
 }
示例#5
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.PathFigure0 = GetTemplateChild("PathFigure0") as PathFigure;
            this.SubPath     = GetTemplateChild("SubPath") as Path;
            title            = GetTemplateChild("Title") as TextBlock;
            Y0 = GetTemplateChild("Y0") as TextBlock;
            Y1 = GetTemplateChild("Y1") as TextBlock;
            Y2 = GetTemplateChild("Y2") as TextBlock;
            Y3 = GetTemplateChild("Y3") as TextBlock;
            Y4 = GetTemplateChild("Y4") as TextBlock;
            X0 = GetTemplateChild("X0") as TextBlock;
            X1 = GetTemplateChild("X1") as TextBlock;
            X2 = GetTemplateChild("X2") as TextBlock;
            X3 = GetTemplateChild("X3") as TextBlock;
            X4 = GetTemplateChild("X4") as TextBlock;

            if (Values0 == null || Values0.Count < 1)
            {
                return;
            }
            double bottom;
            double top;
            double labelStep;

            if (Values1 == null || Values1.Count < 1)
            {
                SubPath.Visibility = Visibility.Collapsed;
                var max = Values0.Max();
                var min = Values0.Min();
                if (max == min)
                {
                    min -= min * 0.1;
                    max += max * 0.1;
                }

                bottom = min - (max - min) * 0.1;
                top    = max + (max - min) * 0.1;
                bottom = bottom < Minimum ? Minimum : bottom;
                top    = top > Maximum ? Maximum : top;
                var center = (max + min) / 2;
                labelStep = (top - bottom) / 4;
            }
            else
            {
                SubPath.Visibility = Visibility.Visible;
                var max = Math.Max(Values0.Max(), Values1.Max());
                var min = Math.Min(Values0.Min(), Values1.Min());
                if (max == min)
                {
                    min -= min * 0.1;
                    max += max * 0.1;
                }
                bottom = min - (max - min) * 0.1;
                top    = max + (max - min) * 0.1;
                bottom = bottom < Minimum ? Minimum : bottom;
                top    = top > Maximum ? Maximum : top;
                var center = (max + min) / 2;
                labelStep = (top - bottom) / 4;
            }
            var pathFigure1 = ((((SubPath.Data as GeometryGroup).Children[0] as PathGeometry).Figures as PathFigureCollection)[0] as PathFigure);

            PathFigure0.Segments.Clear();
            pathFigure1.Segments.Clear();

            title.Text = Title;
            Y0.Text    = bottom.ToString("0.0") + FormatDecoration;
            Y1.Text    = (bottom + labelStep).ToString("0.0") + FormatDecoration;
            Y2.Text    = (bottom + 2 * labelStep).ToString("0.0") + FormatDecoration;
            Y3.Text    = (bottom + 3 * labelStep).ToString("0.0") + FormatDecoration;
            Y4.Text    = (bottom + 4 * labelStep).ToString("0.0") + FormatDecoration;

            if (!XText.IsNullorEmpty())
            {
                var xTexts = XText.Split(',');
                X0.Text = xTexts[0];
                X1.Text = xTexts[1];
                X2.Text = xTexts[2];
                X3.Text = xTexts[3];
                X4.Text = xTexts[4];
            }

            var actualMin = bottom;
            var actualMax = bottom + 4 * labelStep;

            var length      = actualMax - actualMin;
            var step        = 512 / (Values0.Count + 1);
            var actaulStart = GRAPH_ACTUALSTART - ((Values0[0] - actualMin) / length) * GRAPH_ACTUALHEIGHT;

            PathFigure0.StartPoint = new Windows.Foundation.Point(step, actaulStart);
            for (int i = 0; i < Values0.Count; i++)
            {
                var actaulY = GRAPH_ACTUALSTART - ((Values0[i] - actualMin) / length) * GRAPH_ACTUALHEIGHT;
                PathFigure0.Segments.Add(new LineSegment
                {
                    Point = new Windows.Foundation.Point(step * (i + 1), actaulY)
                });
            }
            if (Values1 != null && Values1.Count > 0)
            {
                var step1        = 512 / (Values1.Count + 1);
                var actaulStart1 = GRAPH_ACTUALSTART - ((Values1[0] - actualMin) / length) * GRAPH_ACTUALHEIGHT;
                pathFigure1.StartPoint = new Windows.Foundation.Point(step1, actaulStart1);
                for (int i = 0; i < Values1.Count; i++)
                {
                    var actaulY = GRAPH_ACTUALSTART - ((Values1[i] - actualMin) / length) * GRAPH_ACTUALHEIGHT;
                    pathFigure1.Segments.Add(new LineSegment
                    {
                        Point = new Windows.Foundation.Point(step1 * (i + 1), actaulY)
                    });
                }
            }
        }