Beispiel #1
0
        public BlurryTest()
        {
            InitializeComponent();
            Grid grid = new Grid();

            this.Content = grid;
            var    uri   = $"/wallpaper_mikael_gustafsson.png";
            Canvas grid2 = new Canvas();
            Canvas grid3 = new Canvas();

            grid.Children.Add(grid2);
            grid.Children.Add(grid3);
            grid2.Children.Add(new Image()
            {
                Source = new BitmapImage(new Uri(uri, UriKind.Relative))
            });
            BlurryUserControl b = new BlurryUserControl()
            {
            };

            b.BorderBrush     = Brushes.White;
            b.BorderThickness = new Thickness(2);
            b.Background      = Brushes.Transparent;
            b.BlurContainer   = grid2;
            b.Width           = 300;
            b.Height          = 300;
            b.Magnification   = 0.25;
            b.BlurRadius      = 45;
            grid3.Children.Add(b);
            Panel.SetZIndex(b, 100);
        }
        public WindowCharting2()
        {
            InitializeComponent();
            Grid grid = new Grid();
            var  host = new MyVisualHost();

            grid.Children.Add(host);
            this.Content = grid;
            BlurryUserControl b = new BlurryUserControl()
            {
            };

            b.BorderBrush     = Brushes.White;
            b.BorderThickness = new Thickness(2);
            b.Background      = Brushes.Transparent;
            b.BlurContainer   = host;
            b.Width           = 300;
            b.Height          = 300;
            b.Magnification   = 0.25;
            b.BlurRadius      = 45;
            Panel.SetZIndex(b, 100);
            grid.Children.Add(b);
        }
        public WindowCharting3()
        {
            Background = new SolidColorBrush()
            {
                Color = ColorHelper.StringToColor("#FF1C1D21")
            };
            var uri = $"/wallpaper_mikael_gustafsson.png";

            InitializeComponent();
            Grid grid = new Grid()
            {
            };

            axisX.IsInterregional = false;

            ContinuousAxis axisY = new ContinuousAxis(AxisPosition.Left)
            {
                ValueFormat = "G4", SplitValueFormat = "G4", ShowGridLine = true, AxisPen = new Pen(Brushes.Green, 1), Unit = "万"
            };

            //axisY.Range = new Range() { Max = new Value<double>(5000000), Min = new Value<double>(40000) };
            chart.Offsets = new PaddingOffset(60, 20, 10, 20);

            canvasContainer.DrawingCanvas.AddChild(chart);
            canvasContainer.DrawingCanvas.DataSource = chart.DataSource;
            AxisInteractionCanvas interaction = new AxisInteractionCanvas();

            RectInteractionGroup container = new RectInteractionGroup(interaction, 1, 1, canvasContainer);

            //container.Background = Brushes.GreenYellow;
            chart.AddAsixY(axisY);
            chart.AddAsixX(axisX);

            chart.AddSeries(lineSeries);
            chart.AddSeries(lineSeries2);

            grid.Children.Add(container);
            canvasContainer.DrawingCanvas.Visuals.Add(CreateDrawingImage());

            BlurryUserControl b = new BlurryUserControl()
            {
                Background = new SolidColorBrush(ColorHelper.StringToColor("#BE323337")).OfStrength(0.2d)
            };

            b.BlurContainer = canvasContainer;
            b.Magnification = 0.25;
            b.BlurRadius    = 30;

            interaction.Tip.Layers.Children.Insert(0, b);
            interaction.Tip.TextContainer.Margin   = new Thickness(10);
            interaction.Tip.FontSize               = 11;
            interaction.Tip.Border.BorderThickness = new Thickness(1);
            interaction.Tip.Border.Padding         = new Thickness(0);
            interaction.Tip.Border.BorderBrush     = Brushes.Black;
            interaction.Tip.Foreground             = Brushes.White;
            //interaction.Tip.Border.BorderBrush = Brushes.White;
            //interaction.Tip.Border.BorderThickness = new Thickness(2);
            Content           = grid;
            IsVisibleChanged += WindowCharting3_IsVisibleChanged;
            SizeChanged      += WindowCharting3_SizeChanged;
            //StartDataFeed();
            //Timer timer = new Timer(200);
            //timer.Elapsed += Timer_Elapsed;
            //timer.Start();
        }
        public WindowCharting()
        {
            chartCanvas.Background = Brushes.White;
            Timer timer = new Timer(1000);

            timer.Elapsed += Timer_Elapsed;
            timer.Start();

            DockPanel grid = new DockPanel()
            {
            };

            axisY3.Offsets = new PaddingOffset(0, 0, 50, 0);
            axisX3.Offsets = new PaddingOffset(0, 0, 0, 60);
            var ratios = new List <double>()
            {
                0.2, 0.3, 0.3, 0.2
            };

            ratios.Insert(0, 0);
            axisX.Ratios  = ratios;
            axisX2.Ratios = ratios;
            axisX3.Ratios = ratios;

            axisX.IsInterregional = false;
            axisX.AxisPen         = new Pen(Brushes.Red, 1);
            axisX2.AxisPen        = new Pen(Brushes.PeachPuff, 1);
            axisX3.AxisPen        = new Pen(Brushes.DarkCyan, 1);

            AxisInteractionCanvas interaction = new AxisInteractionCanvas();

            chartCanvas.DrawingCanvas.AddChild(chart); chartCanvas.DrawingCanvas.DataSource = chart.DataSource;
            RectInteractionGroup container = new RectInteractionGroup(interaction, 1, 1, chartCanvas);

            BlurryUserControl b = new BlurryUserControl()
            {
                Background = new SolidColorBrush(ColorHelper.StringToColor("#BE323337")).OfStrength(0.2d)
            };

            b.BlurContainer = container.ContainerGrid;
            b.Magnification = 0.25;
            b.BlurRadius    = 30;

            interaction.Tip.Layers.Children.Insert(0, b);

            interaction.Cross.IsCrossShow = true;
            chart.AddAsixX(axisX);
            chart.AddAsixX(axisX2);
            chart.AddAsixX(axisX3);
            //ValueAxis axisY2 = new ValueAxis(AxisPosition.Left) { ValueFormat = "F1" };
            //axisY2.Offsets.Left = new GridLength(50);
            //asix.AddAsixY(axisY2);
            chart.AddAsixY(axisY);
            chart.AddAsixY(axisY2);
            chart.AddAsixY(axisY3);

            StraightLineSeriesVisual lineSeries = new StraightLineSeriesVisual()
            {
            };
            StraightLineSeriesVisual lineSeries2 = new StraightLineSeriesVisual()
            {
            };

            chart.AddSeries(lineSeries);
            chart.AddSeries(lineSeries2);
            //asix.PaddingOffset.Left = new GridLength(0.1, GridUnitType.Star);
            //asix.PaddingOffset.Top = new GridLength(0.1, GridUnitType.Star);
            //asix.PaddingOffset.Right = new GridLength(0.1, GridUnitType.Star);
            //asix.PaddingOffset.Buttom = new GridLength(0.1, GridUnitType.Star);
            chart.Offsets = new PaddingOffset(50);

            var    now    = DateTime.Now;
            Random random = new Random();
            var    max    = 1000;
            Dictionary <DateTime, double> dic  = new Dictionary <DateTime, double>();
            Dictionary <DateTime, double> dic2 = new Dictionary <DateTime, double>();

            for (int i = 0; i < 4; i++)
            {
                dic.Add(now.AddDays(i), random.NextDouble() * max);
            }
            for (int i = 0; i < 3; i++)
            {
                dic2.Add(now.AddDays(i), random.NextDouble() * max);
            }

            lineSeries2.LinePen.Brush = Brushes.Red;
            lineSeries2.VisualData    = dic2.ToFormatVisualData();
            lineSeries.VisualData     = dic.ToFormatVisualData();


            //Dictionary<DateTime, double> dic3 = new Dictionary<DateTime, double>();
            chart.Plot();

            //TestVisual test = new TestVisual(axisRect);
            //chartCanvas.AddChild(test);
            //test.VisualData = null;

            grid.AddChild(container, Dock.Left);
            //grid.Children.Add(new TextBlock() { Text = "123"});
            Content = grid;

            this.SizeChanged += WindowCharting_SizeChanged;
        }