• 大小: 0M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-23
  • 语言: 其他
  • 标签: 其他  

资源简介

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 < Rs.Length; i++)
            {
                List

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       16965  2019-06-12 11:05  IsoHeightCtrl.xaml.cs
     文件         579  2019-06-12 09:10  IsoHeightCtrl.xaml

评论

共有 条评论