資源簡介
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個文件信息
- 上一篇:C# 動態繪制曲線
- 下一篇:仿QQ界面(非常不錯的 winform UI界面)
評論
共有 條評論