資源簡介
IsoHeightCtrl.zip

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Drawing;
using?System.Runtime.InteropServices;
using?System.Windows;
using?System.Windows.Controls;
using?System.Windows.Interop;
using?System.Windows.Media.Imaging;
namespace?WPFCtrlLib
{
????///?
????///?等高線圖控件
????///?
????public?partial?class?IsoHeightCtrl?:?UserControl
????{
????????private?const?int?grid_w?=?10;
????????private?const?int?grid_h?=?10;
????????private?double?w;
????????private?double?h;
????????private?int?bitmap_w;
????????private?int?bitmap_h;
????????private?int?x_num;
????????private?int?y_num;
????????private?float[]?data;
????????private?float?min;
????????private?float?max;
????????private?byte[]?Rs?Gs?Bs;
????????private?Bitmap?bitmap;
????????private?Graphics?graphics;
????????public?IsoHeightCtrl()
????????{
????????????InitializeComponent();
????????}
????????private?void?UserControl_SizeChanged(object?sender?SizeChangedEventArgs?e)
????????{
????????????Draw();
????????}
????????///?
????????///?離散高度點列表
????????///?XY總長為單位1
????????///?
????????public?MeasureData[]?HeightDots
????????{
????????????get?{?return?(MeasureData[])GetValue(HeightDotsProperty);?}
????????????set?{?SetValue(HeightDotsProperty?value);?}
????????}
????????public?static?readonly?DependencyProperty?HeightDotsProperty?=
????????????DependencyProperty.Register(“HeightDots“?typeof(MeasureData[])?typeof(IsoHeightCtrl)?new?Propertymetadata(null?(s?e)?=>
????????????{
????????????????IsoHeightCtrl?ihc?=?s?as?IsoHeightCtrl;
????????????????ihc.Draw();
????????????}));
????????///?
????????///?顏色列表
????????///?其數量決定了等高線的層數
????????///?
????????public?string?ColorList
????????{
????????????get?{?return?(string)GetValue(ColorListProperty);?}
????????????set?{?SetValue(ColorListProperty?value);?}
????????}
????????public?static?readonly?DependencyProperty?ColorListProperty?=
????????????DependencyProperty.Register(“ColorList“?typeof(string)?typeof(IsoHeightCtrl)?new?Propertymetadata(“#072FFA#0779FA#07C4FA#07DFD0#07FAA7#79FA57#ECFA07#F3D307#FAAD07#F67207#FA1207“?(s?e)?=>
????????????{
????????????????IsoHeightCtrl?ihc?=?s?as?IsoHeightCtrl;
????????????????ihc.ParseColor();
????????????}));
????????///?
????????///?繪制圖形
????????///?
????????private?void?Draw()
????????{
????????????if?(HeightDots?==?null)
????????????{
????????????????return;
????????????}
????????????w?=?this.ActualWidth;
????????????h?=?this.ActualHeight;
????????????if?(w?<=?0?||?h?<=?0)
????????????{
????????????????return;
????????????}
????????????if?(Rs?==?null)
????????????{
????????????????ParseColor();
????????????}
????????????InitData();
????????????CreateBitmap();
????????????float?gap?=?(max?-?min)?/?Rs.Length;
????????????for?(int?i?=?0;?i?????????????{
????????????????List
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????16965??2019-06-12?11:05??IsoHeightCtrl.xaml.cs
?????文件?????????579??2019-06-12?09:10??IsoHeightCtrl.xaml
- 上一篇:掃雷qmlc程序
- 下一篇:383C開發大全(提高卷)源碼.rar
評論
共有 條評論