資源簡介
介紹三種繪制云圖或等高線圖的算法。點(diǎn)距離反比插值、雙線性插值和面距離反比+雙線性插值。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.IO;
using?System.Windows;
using?System.Windows.Controls;
using?System.Windows.Media;
using?System.Windows.Media.Imaging;
namespace?WPFCtrlLib
{
????///?
????///?云圖控件
????///?
????public?partial?class?CloudGraphCtrl?:?UserControl
????{
????????private?int?DataX?DataY;
????????private?int?GraphWidth?GraphHeight;
????????private?WriteableBitmap?GraphBitmap;
????????private?double?MinValue?MaxValue;
????????private?double[]?MapData;
????????private?List?ColorByteList;
????????private?byte[]?Rs?Gs?Bs;
????????public?CloudGraphCtrl()
????????{
????????????InitializeComponent();
????????}
????????///?
????????///?數(shù)據(jù)源
????????///?
????????public?double[]?DataSource
????????{
????????????get?{?return?(double[])GetValue(DataSourceProperty);?}
????????????set?{?SetValue(DataSourceProperty?value);?}
????????}
????????public?static?readonly?DependencyProperty?DataSourceProperty?=
????????????DependencyProperty.Register(“DataSource“?typeof(double[])?typeof(CloudGraphCtrl)?new?Propertymetadata(null?(s?e)?=>
????????????{
????????????????(s?as?CloudGraphCtrl).Draw();
????????????}));
????????///?
????????///?顏色列表
????????///?
????????public?string?ColorList
????????{
????????????get?{?return?(string)GetValue(ColorListProperty);?}
????????????set?{?SetValue(ColorListProperty?value);?}
????????}
????????public?static?readonly?DependencyProperty?ColorListProperty?=
????????????DependencyProperty.Register(“ColorList“?typeof(string)?typeof(CloudGraphCtrl)?new?Propertymetadata(“#FA1207#FAAD07#ECFA07#07FAA7#07C4FA#072FFA“));
????????///?
????????///?顏色跨度
????????///?
????????public?int?ColorGap
????????{
????????????get?{?return?(int)GetValue(ColorGapProperty);?}
????????????set?{?SetValue(ColorGapProperty?value);?}
????????}
????????public?static?readonly?DependencyProperty?ColorGapProperty?=
????????????DependencyProperty.Register(“ColorGap“?typeof(int)?typeof(CloudGraphCtrl)?new?Propertymetadata(10));
????????///?
????????///?使用算法,取值1、2、3
????????///?
????????public?int?Method
????????{
????????????get?{?return?(int)GetValue(MethodProperty);?}
????????????set?{?SetValue(MethodProperty?value);?}
????????}
????????public?static?readonly?DependencyProperty?MethodProperty?=
????????????DependencyProperty.Register(“Method“?typeof(int)?typeof(CloudGraphCtrl)?new?Propertymetadata(1));
????????private?void?UserControl_SizeChanged(object?sender?RoutedEventArgs?e)
????????{
????????????Draw();
????????}
????????private?void?Draw()
????????{
????????????if?(DataSource?==?null)
????????????{
????????????????return;
????????????}
????????????DataX?=?DataSource.GetLength(0);
????????????DataY?=?DataSource.GetLength(1);
????????????GraphWidth?=?(int)this.ActualWidth?-?90;
????????????Grap
評(píng)論
共有 條評(píng)論