Example #1
0
        /// <summary> 初始化心电图表 </summary>
        void InitData()
        {
            //this.FontSize = 12;
            this.MaxValueY = 2448;
            this.MinValueY = 1848;
            this.MaxValueX = 11;
            this.MinValueX = 0;
            //this.Height = 150;


            int tempIndex = 0;

            // Todo :初始化X网线
            for (double i = this.MinValueX; i <= this.MaxValueX; i = i + 0.25)
            {
                SplitItem s = new SplitItem();
                s.Value = i;
                s.Text  = (i * 80).ToString();
                s.Color = this._gridLineColor;
                int param = (int)(tempIndex % 4);

                s.SpliteType = param == 0 && this.IsShowX ? SplitItemType.Normal : SplitItemType.InnerOnly;

                this.SlpitItemXs.Add(s);
                tempIndex++;
            }

            // Todo :2048基准线
            if (this.IsShowBaseLine)
            {
                SplitItem sbase = new SplitItem();
                sbase.Value      = 2048;
                sbase.Text       = (2048).ToString();
                sbase.Color      = this.Foreground;
                sbase.SpliteType = SplitItemType.HeighLight;
                this.SplitItemYs.Add(sbase);
            }


            tempIndex = 0;
            // Todo :初始化Y网线
            for (double i = this.MinValueY; i <= this.MaxValueY; i = i + 30)
            {
                SplitItem s = new SplitItem();
                s.Value = i;
                s.Text  = i.ToString();
                s.Color = this._gridLineColor;

                int param = (int)(tempIndex % 4);

                s.SpliteType = param == 0 && this.IsShowY ? SplitItemType.Normal : SplitItemType.InnerOnly;

                this.SplitItemYs.Add(s);

                tempIndex++;
            }
        }
Example #2
0
        /// <summary> 刷新标尺线 </summary>
        void RefreshSplitItemY()
        {
            var t = this.TryFindResource("line") as Style;

            var d = this.TryFindResource("dashCapline") as Style;

            var a = this.TryFindResource("pathTrangle") as Style;

            //var rs = this.TryFindResource("MarkBoardRectangle") as Style;

            var color = this.TryFindResource("MaxLineColor") as Brush;


            // Todo :绘制普通网格线
            var ns = this.SplitItemYs.FindAll(l => l.SpliteType == SplitItemType.Normal || l.SpliteType == SplitItemType.InnerOnly);

            foreach (var item in ns)
            {
                Line l = new Line();
                l.X1     = 0;
                l.Y1     = 0;
                l.Y2     = 0;
                l.Height = 5;
                if (item.Color != null)
                {
                    l.Stroke = item.Color;
                }
                l.X2    = ParallelCanvas.ActualWidth;
                l.Style = this.InnerVerticalLineStyle == null ? t : this.InnerVerticalLineStyle;
                l.Style = item.LineStyle == null ? l.Style : item.LineStyle;
                Canvas.SetTop(l, this.GetY(item.Value));
                this.ParallelCanvas.Children.Add(l);
            }

            // Todo :绘制范围网格线
            var hs = this.SplitItemYs.FindAll(l => l.SpliteType == SplitItemType.HeighLight);

            foreach (var item in hs)
            {
                Line l = new Line();
                l.X1     = 0;
                l.Y1     = 0;
                l.Y2     = 0;
                l.Height = 5;
                if (item.Color != null)
                {
                    l.Stroke = item.Color;
                }
                l.Style = item.LineStyle == null ? l.Style : item.LineStyle;

                l.X2    = ParallelCanvas.ActualWidth + ParallelCanvas.ActualWidth / 100;
                l.Style = d;
                Canvas.SetTop(l, this.GetY(item.Value));

                if (!this.IsShowTrangle)
                {
                    continue;
                }

                // Todo :绘制三角箭头
                Path p = new Path();
                p.Width   = 20;
                p.Height  = 6;
                p.Style   = a;
                p.Fill    = item.Color;
                p.Stretch = Stretch.Fill;
                if (item.Color != null)
                {
                    l.Stroke = item.Color;
                }
                Canvas.SetTop(p, this.GetY(item.Value) - p.Height / 2);
                Canvas.SetLeft(p, l.X2 - ParallelCanvas.ActualWidth);

                // Todo :绘制文本
                TextBlock text = new TextBlock();
                text.Text       = item.Text;
                text.FontSize   = this.FontSize;
                text.Foreground = item.Color;
                Canvas.SetLeft(text, l.X2 - ParallelCanvas.ActualWidth);

                if (item.IsShowTrangle)
                {
                    Canvas.SetTop(text, this.GetY(item.Value) + p.Height / 2);
                }
                else
                {
                    Canvas.SetTop(text, this.GetY(item.Value) - this.FontSize / 2);
                }

                Canvas.SetLeft(l, -ParallelCanvas.ActualWidth);

                // Todo :不隐藏
                if (item.IsShowTrangle)
                {
                    this.RightCanvas.Children.Add(p);
                    this.RightCanvas.Children.Add(l);
                }

                if (item.IsShowText)
                {
                    this.RightCanvas.Children.Add(text);
                }
            }

            if (hs.Count < 2)
            {
                return;
            }

            // Todo :增加最大最小蒙版
            //_maxMinRectVisible = true;
            if (_maxMinRectVisible)
            {
                if (!hs.Exists(l => (l.Value - this.MinValueY) < double.Epsilon))
                {
                    SplitItem sMin = new SplitItem();
                    sMin.Color = color;
                    sMin.Value = this.MinValueY;
                    hs.Add(sMin);
                }

                if (!hs.Exists(l => (this.MaxValueY - l.Value) < double.Epsilon))
                {
                    SplitItem sMax = new SplitItem();
                    sMax.Color = color;
                    sMax.Value = this.MaxValueY;
                    hs.Add(sMax);
                }
            }

            hs = hs.OrderByDescending(l => l.Value).ToList();

            var group = hs.GroupBy(l => l.Group);

            foreach (var item in group)
            {
                var collection = item.ToList();

                // Todo :绘制蒙版
                for (int i = 0; i < item.ToList().Count; i++)
                {
                    if (i == 0)
                    {
                        continue;
                    }

                    Rectangle r = new Rectangle();
                    r.Width = this.ParallelCanvas.ActualWidth;
                    var height = this.GetY(collection[i].Value) - this.GetY(collection[i - 1].Value);
                    if (height < 0)
                    {
                        continue;
                    }
                    r.Height  = height;
                    r.Fill    = Brushes.Orange;
                    r.Opacity = this.CoverOpacity;
                    //r.Style = rs;

                    Color color1 = (Color)ColorConverter.ConvertFromString(collection[i - 1].Color.ToString());
                    Color color2 = (Color)ColorConverter.ConvertFromString(collection[i].Color.ToString());

                    LinearGradientBrush brush = new LinearGradientBrush(color1, color2, new Point(0, 0), new Point(0, 1));
                    r.Fill = brush;

                    Canvas.SetTop(r, this.GetY(collection[i - 1].Value));

                    this.ParallelCanvas.Children.Add(r);
                }
            }
        }