• 大小: 11.61M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2020-12-26
  • 语言: C#
  • 标签: wpf  MAP  看板  数据展示  

资源简介

WPF 数据可视化 大屏展示 实现地图仿echarts模拟迁移效果 Telerik图表 仪表盘

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Reflection;
using System.Windows.Media.Animation;
using MapData;

namespace WpfMap
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = GetData(12);

            try
            {
                MapGrid.Children.Clear();
                string fullName = "Map.Controls.MapChina";//命名空间.类型名
                UserControl map = (UserControl)Assembly.Load("Map.Controls").CreateInstance(fullName);
                map.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                map.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                map.Margin = new Thickness(0);
                if (map is Map.Controls.MapChina)
                {
                    (map as Map.Controls.MapChina).MapClick = new RoutedPropertyChangedEventHandler<object>(MainWindow_MapClick);
                }
                MapGrid.Children.Add(map);

            }
            catch
            {
                ;
            }
        }
        public static List<ChartData> GetData(int dataSize)
        {
            Random rnd = new Random(0);
            var result = new List<ChartData>();

            for (int i = 0; i < dataSize; i )
            {
                result.Add(new ChartData()
                {
                    Category = i,
                    Value = rnd.Next(1, 100),
                    Color = new SolidColorBrush(
                        Color.FromArgb(255, (byte)rnd.Next(0, 256), (byte)rnd.Next(0, 256), (byte)rnd.Next(0, 256)))
                });
            }

            return result;
        }

        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                MapGrid.Children.Clear();
                ListBoxItem lbi = listBox1.SelectedItem as ListBoxItem;

                string fullName = "Map.Controls." lbi.Tag.ToString();//命名空间.类型名
                UserControl map = (UserControl)Assembly.Load("Map.Controls").CreateInstance(fullName);
                map.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                map.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                map.Margin = new Thickness(0);
                if (map is Map.Controls.MapChina)
                {
                    (map as Map.Controls.MapChina).MapClick = new RoutedPropertyChangedEventHandler<object>(MainWindow_MapClick);
                }
                MapGrid.Children.Add(map);

            }
            catch
            {
                ;
            }
        }

        void MainWindow_MapClick(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            if (sender is Path)
            {

            }
            MapGrid.Children.Clear();
            UserControl map = new Map.Controls.MapHeNan();
            map.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            map.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            map.Margin = new Thickness(0);
            map.Name = "CMap";
            map.Loaded = new RoutedEventHandler(map_Loaded);

            MapGrid.Children.Add(map);
        }

        void map_Loaded(object sender, RoutedEventArgs e)
        {
            //Storyboard storyboard = new Storyboard();
            ////添加X轴方向的动画  
            //ThicknessAnimationUsingKeyFrames doubleAnimation = new ThicknessAnimationUsingKeyFrames();
            //EasingThicknessKeyFrame ef = new EasingThicknessKeyFrame();
            //ef.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1));
            //ef.Value = new Thickness(150);
            //doubleAnimation.KeyFrames.Add(ef);
            //ef = new EasingThicknessKeyFrame();
            //ef.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2));
            //ef.Value = new Thickness(0);
            //doubleAnimation.KeyFrames.Add(ef);
            //Storyboard.SetTarget(doubleAnimation, MapGrid);
            //Storyboard.SetTargetProperty(doubleAnimation, new System.Windows.PropertyPath(MarginProperty));//new PropertyPath("(Canvas.Left)")--(FrameworkElement.Margin)
            //storyboard.Children.Add(doubleAnimation);
            //storyboard.Begin();

        }

        private void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ImageBrush b = new ImageBrush();
            b.ImageSource = (sender as Image).Source;
            b.Stretch = Stretch.Fill;
            RootGrid.Background = b;
        }
    }
}

资源截图

代码片段和文件信息

/*Copyright (c) 2009 T.Evelyn (evescode@gmail.com) 

All rights reserved.

Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions are met:

1.Redistributions of source code must retain the above copyright notice this list of conditions and the following disclaimer.

2.Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in 
 the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ‘‘AS IS‘‘ AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO 

THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE D

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-04-15 09:16  WpfMap\
     目录           0  2020-04-15 09:16  WpfMap\.vs\
     目录           0  2020-04-15 09:16  WpfMap\.vs\WpfMap\
     目录           0  2020-04-15 09:16  WpfMap\.vs\WpfMap\v14\
     文件      174080  2020-04-15 09:16  WpfMap\.vs\WpfMap\v14\.suo
     目录           0  2020-04-15 09:16  WpfMap\Map.Controls\
     文件        4924  2020-04-15 09:16  WpfMap\Map.Controls\Map.Controls.csproj
     文件         228  2020-04-15 09:16  WpfMap\Map.Controls\Map.Controls.csproj.user
     目录           0  2020-04-15 09:16  WpfMap\Map.Controls\MapControl\
     文件       10478  2020-04-15 09:16  WpfMap\Map.Controls\MapControl\Gauge.xaml
     文件       49783  2020-04-15 09:16  WpfMap\Map.Controls\MapControl\Gauge.xaml.cs
     文件      197896  2020-04-15 09:16  WpfMap\Map.Controls\MapControl\MapAnHui.xaml
     文件         626  2020-04-15 09:16  WpfMap\Map.Controls\MapControl\MapAnHui.xaml.cs
     文件      280986  2020-04-15 09:16  WpfMap\Map.Controls\MapControl\MapChina.xaml
     文件        3666  2020-04-15 09:16  WpfMap\Map.Controls\MapControl\MapChina.xaml.cs
     文件      114874  2020-04-15 09:16  WpfMap\Map.Controls\MapControl\MapHeNan.xaml
     文件        5294  2020-04-15 09:16  WpfMap\Map.Controls\MapControl\MapHeNan.xaml.cs
     目录           0  2020-04-15 09:16  WpfMap\Map.Controls\Properties\
     文件        2481  2020-04-15 09:16  WpfMap\Map.Controls\Properties\AssemblyInfo.cs
     文件        2876  2020-04-15 09:16  WpfMap\Map.Controls\Properties\Resources.Designer.cs
     文件        5612  2020-04-15 09:16  WpfMap\Map.Controls\Properties\Resources.resx
     文件        1099  2020-04-15 09:16  WpfMap\Map.Controls\Properties\Settings.Designer.cs
     文件         201  2020-04-15 09:16  WpfMap\Map.Controls\Properties\Settings.settings
     目录           0  2020-04-15 09:16  WpfMap\Map.Controls\Themes\
     文件         448  2020-04-15 09:16  WpfMap\Map.Controls\Themes\Generic.xaml
     文件        8230  2020-04-15 09:16  WpfMap\Map.Controls\TypeConverters.cs
     目录           0  2020-04-15 09:16  WpfMap\Map.Controls\Utils\
     文件       25847  2020-04-15 09:16  WpfMap\Map.Controls\Utils\MapFlow.cs
     目录           0  2020-04-15 09:16  WpfMap\OutBin\
     文件      413696  2020-04-15 09:16  WpfMap\OutBin\Map.Controls.dll
     文件      103936  2020-04-15 09:16  WpfMap\OutBin\Map.Controls.pdb
............此处省略42个文件信息

评论

共有 条评论