aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Controls/HiveControl.xaml
blob: 79729914fa6cfb0aed362e71f23301061b27e9c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<UserControl x:Class="Tango.SharedUI.Controls.HiveControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Tango.SharedUI.Controls"
             mc:Ignorable="d" 
             >
    <Grid x:Name="grid">
        <Canvas x:Name="canvas">

        </Canvas>
    </Grid>
</UserControl>
ighlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System.Linq;
using RealTimeGraphEx.ExtensionMethods;

namespace RealTimeGraphEx.DX2D
{
    using SharpDX;
    using SharpDX.Direct2D1;
    using System;
    using System.Collections.Generic;
    using System.Threading;

    public class DXGraphSurfaceMultiScroll : Direct2DControl
    {
        private List<Vector2[]> lastPoints;
        private List<Vector2[]> lastPointsFill;
        private List<System.Windows.Media.Brush> _fill;
        private List<System.Windows.Media.Brush> _stroke;
        private double _strokeWidth;
        private bool _fillGraph;
        private bool _antialiazed;
        private bool updated;

        public DXGraphSurfaceMultiScroll()
        {
            lastPoints = new List<Vector2[]>();
            lastPointsFill = new List<Vector2[]>();
        }

        public void SetProperties(List<Vector2[]> polygonPoints, List<Vector2[]> polygonPointsFill, List<System.Windows.Media.Brush> stroke, double strokeWidth, bool fillGraph, List<System.Windows.Media.Brush> fill, bool antialized)
        {
            _stroke = stroke;
            _fill = fill;
            _fillGraph = fillGraph;
            _strokeWidth = strokeWidth;
            _antialiazed = antialized;


            lock (lastPoints)
            {
                lastPoints = polygonPoints;
                lastPointsFill = polygonPointsFill;
                updated = true;
            }
        }

        /// <summary>
        /// Does the actual rendering. 
        /// BeginDraw and EndDraw are already called by the caller. 
        /// </summary>
        public override void Render(RenderTarget target)
        {
            if (lastPoints.Count > 0 && updated)
            {
                lock (lastPoints)
                {
                    target.AntialiasMode = _antialiazed ? AntialiasMode.PerPrimitive : AntialiasMode.Aliased;

                    if (lastPoints.Count > 0 && lastPoints[0].Length > 0)
                    {
                        target.Clear(Color.Transparent);
                    }

                    for (int i = 0; i < lastPoints.Count; i++)
                    {

                        var stroke = _stroke[i].ToDxBrush(target);
                        var fill = _fill[i].ToDxBrush(target);

                        target.DrawPolygon(m_d2dFactory, stroke, _strokeWidth, lastPoints[i]);

                        if (_fillGraph && fill != null && _fill[i] != null)
                        {
                            target.FillPolygon(m_d2dFactory, fill, lastPointsFill[i]);
                        }
                    }

                    updated = false;
                    GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized, blocking: false);
                }
            }

            DisableRendering();
        }
    }
}