using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;

namespace 专题图自动化系统
{
    public partial class ColorMap : Form
    {
        double max, min;
        AxMapControl axMapControl1;
        string FindField;
        public ColorMap(double _max,double _min,AxMapControl ax,string findField)
        {
            InitializeComponent();
            max = _max;
            min = _min;
            axMapControl1 = ax;
            FindField = findField;
        }
        IFeatureClass pFeatureClass;
        private void FindCity()
        {
            IFeatureLayer pFeatureLayer = axMapControl1.get_Layer(0) as IFeatureLayer;
            if (pFeatureLayer != null)
                pFeatureClass = pFeatureLayer.FeatureClass;
            int[] index = new int[2];//name字段+查询依据字段
            for (int i = 0; i < index.Length; i++)
            {
                if (i == 0)
                    index[i] = pFeatureClass.Fields.FindField("name");
                else
                    index[i] = pFeatureClass.Fields.FindField(FindField);
            }
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null,false);
            IFeature pFeature = pFeatureCursor.NextFeature();
            object [] value=new object[index.Length];
            while (pFeature != null)
            {
                for (int i = 0; i < index.Length; i++)
                {
                    value[i] = pFeature.get_Value(index[i]);
                    if (i == 1)
                    {
                        double  a = Convert.ToDouble(value[1].ToString());
                        switch (searchCity.Length)
                        {
                            case 2: N1.Add(value[0].ToString()); break;
                            case 3: if (a <= searchCity[1]) { N1.Add(value[0].ToString());}
                            else{N2.Add(value[0].ToString());}break;
                            case 4: if (a <= searchCity[1]) { N1.Add(value[0].ToString()); }
                                if (a > searchCity[1] && a <= searchCity[2]) { N2.Add(value[0].ToString()); }
                                if (a > searchCity[2]) { N3.Add(value[0].ToString()); }break;
                            case 5: if (a <= searchCity[1]) { N1.Add(value[0].ToString()); }
                                if (a > searchCity[1] && a <= searchCity[2]) { N2.Add(value[0].ToString()); }
                                if (a > searchCity[2]&&a<=searchCity[3]) { N3.Add(value[0].ToString()); }
                                if(a>searchCity[3]){N4.Add(value[0].ToString());}break;
                            case 6: if (a <= searchCity[1]) { N1.Add(value[0].ToString()); }
                                if (a > searchCity[1] && a <= searchCity[2]) { N2.Add(value[0].ToString()); }
                                if (a > searchCity[2] && a <= searchCity[3]) { N3.Add(value[0].ToString()); }
                                if (a > searchCity[3]&&a<=searchCity[4]) { N4.Add(value[0].ToString()); }
                                if(a>searchCity[4]){N5.Add(value[0].ToString());}break;
                        }
                    }
                    
                }
                pFeature = pFeatureCursor.NextFeature();
            }
        }
        List<string> N1 = new List<string>();
        List<string> N2 = new List<string>();
        List<string> N3 = new List<string>();
        List<string> N4 = new List<string>();
        List<string> N5 = new List<string>();
        private void DrawCity()
        {
            Bitmap bt = new Bitmap(panel3.Width,panel3.Height);
            Graphics g = Graphics.FromImage(bt);
            Pen pen = new Pen(Color.Black,1);
            string []n1=new string[6];
            if (N1 != null)
            {
                foreach (string a in N1)
                {
                    n1[1] += a + ",";
                }
            }
            if (N2 != null)
            {
                foreach (string a in N2)
                {
                    n1[2] += a + ",";
                }
            }
            if (N3 != null)
            {
                foreach (string a in N3)
                {
                    n1[3] += a + ",";
                }
            }
            if (N4 != null)
            {
                foreach (string a in N4)
                {
                    n1[4] += a + ",";
                }
            }
            if (N5 != null)
            {
                foreach (string a in N5)
                {
                    n1[5] += a + ",";
                }
            }
            for (int i = 1; i <= n; i++)
            {
                g.DrawString("第" + i + "级:" +n1[i], new Font("黑体", 10), new SolidBrush(Color.Black), new PointF(20, 25 * i));
            }
            panel3.BackgroundImage = bt;
        }
        private void DrawString()
        {
            Bitmap bt = new Bitmap(panel2.Width,panel2.Height);
            Graphics g = Graphics.FromImage(bt);
            Pen pen = new Pen(Color.Black,1);
            double fromValue = min;
            searchCity[0] = fromValue;
            double toValue;
            for (int i = 1; i <= n; i++)
            {
                if (i == index)
                    toValue = min + (x2 - temp[1]) * k / flag;
                else
                    toValue=min + i * k;
                searchCity[i] = toValue;
                g.DrawString("第"+i+"级:"+fromValue+"万到"+toValue+"万",new Font("黑体",10),new SolidBrush(Color.Black),new PointF(20,25*i));
                fromValue=toValue;
            }
            panel2.BackgroundImage = bt;
        }
        double k;
        private void DrawZft()
        {
            Bitmap bt = new Bitmap(panel1.Width,panel1.Height);
            Graphics g = Graphics.FromImage(bt);
            Pen pen = new Pen(Color.White,1);
            g.DrawLine(pen,new Point(30,0),new Point(30,panel1.Height-30));
            g.DrawLine(pen,new Point(30,panel1.Height-30),new Point(panel1.Width-4,panel1.Height-30));
            k = (max - min) / n;
            for (int i = 1; i <= n+1; i++)
            {
                if (i == index)
                {
                    g.DrawString((min + (x2-temp[1]) * k/flag).ToString(), new Font("宋体", 9), new SolidBrush(Color.White), new PointF(x2 - 2, panel1.Height-30));
                    g.DrawLine(pen, new PointF(x2, panel1.Height-30), new PointF(x2, 0));
                }
                else
                {
                    g.DrawString((min + (i-1) * k).ToString(), new Font("宋体", 9), new SolidBrush(Color.White), new PointF(temp[i] - 8, panel1.Height-30));
                    g.DrawLine(pen, new PointF(temp[i], panel1.Height-30), new PointF(temp[i], 0));
                }
            }
            panel1.BackgroundImage = bt;
        }
        int n=0;
        float[] temp;
        int flag;
        double []searchCity;
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            n = int.Parse(comboBox1.SelectedItem.ToString());
            temp = new float[n + 2];
            searchCity=new double[n+1];
            flag = (panel1.Width - 4) / (n + 1);
            for (int i = 1; i <= n+1; i++)
            {
                temp[i] = flag * i;
            }
            if (N1 != null)
                N1.Clear();
            if (N2 != null)
                N2.Clear();
            if (N3 != null)
                N3.Clear();
            if (N4 != null)
                N4.Clear();
            if (N5 != null)
                N5.Clear();
            DrawZft();
            DrawString();
            FindCity();
            DrawCity();
        }
        int index=0;
        int x1, x2, x3;
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            x1 = e.X;
            for (int i = 1; i < temp.Length; i++)
            {
                if (Math.Abs(x1 - temp[i]) < 3)
                {
                    index = i;
                }
            }
        }
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            x2=e.X;
            if (index != 0)
            {
                if (N1 != null)
                    N1.Clear();
                if (N2 != null)
                    N2.Clear();
                if (N3 != null)
                    N3.Clear();
                if (N4 != null)
                    N4.Clear();
                if (N5 != null)
                    N5.Clear();
                DrawZft();
                DrawString();
                FindCity();
                DrawCity();
            }
        }
        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            x3 = e.X;
            temp[index] = x3;
            DrawZft();
            index = 0;
        }
    }
}

模仿ArcGIS用Graphics重绘的直方图分级调节器的更多相关文章

  1. windform 重绘Treeview "+-"号图标

    模仿wind系统界面,重绘Treeview + - 号图标 一,首先需要图片 ,用于替换原有的 +-号 二.新建Tree扩展类 TreeViewEx继承TreeView using System; u ...

  2. WinForm中重绘TabControl选项卡标题

    最近开发WinForm频繁使用了TabControl控件,这个控件的选项卡没有BackgroundImage这个属性,那么如何为其各个选项卡添加背景图片呢?(这里说的是每个TabPage的头部,也就是 ...

  3. java中的重绘

    void java.awt.Container.validate()Validates this container and all of its subcomponents.这个函数更新容器及其全部 ...

  4. android 之 surfaceView和普通View的重绘使用

    !自定义控件式需要实现AttrbuteSet   可在xml文件中配置略过创建该对象 普通的View只能在主线程中绘制界面,适用于简单的被动绘制 SurfaceView则可以在新线程中绘制界面,不会阻 ...

  5. C# 重绘tabControl,添加关闭按钮(续)

    在上一篇随笔中,添加关闭按钮是可以实现 ,但细心一点就会发现,每次关闭一个选项卡,tableControl都会自动跳到第一个页面,显然 这不是我们想要的,为此,我修改了部分的代码.除此之外,我还添加了 ...

  6. C# 重绘tabControl,添加关闭按钮(页签)

    C# 重绘tabControl,添加关闭按钮(页签) 调用方法 参数: /// <summary> /// 初始化 /// </summary> /// <param n ...

  7. iOS之UI--Quartz2D的入门应用--重绘下载圆形进度条

    *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...

  8. 【转】【C#】C#重绘windows窗体标题栏和边框

    摘要 windows桌面应用程序都有标准的标题栏和边框,大部分程序也默认使用这些样式,一些对视觉效果要求较高的程序,如QQ, MSN,迅雷等聊天工具的样式则与传统的windows程序大不相同,其中迅雷 ...

  9. 『转载』C# winform 中dataGridView的重绘(进度条,虚线,单元格合并等)

    原文转载自:http://hi.baidu.com/suming/item/81e45b1ab9b4585f2a3e2243 最近比较浅的研究了一下dataGridView的重绘,发现里面还是有很多东 ...

随机推荐

  1. Go语言基础之5--数组(array)和切片(slince)

    一.数组(array) 1.1 数组定义 1)含义: 数组是同一类型的元素集合. 数组是具有固定长度并拥有零个或者多个相同数据类型元素的序列. 2)定义一个数组的方法: var 变量名[len] ty ...

  2. IntelliJ Save Action

    https://blog.csdn.net/hustzw07/article/details/82824713

  3. 进入wordpress中的模板文件

    Wordpress的页面结构 一个简单的wordpress由 头部.内容.页脚组成,每个块中的每一个都由当前wordpress主题中模板文件生成. eg: 头:包含重要的信息,一般都是网页的头部. 内 ...

  4. Spring Boot 实现ErrorController接口处理404、500等错误页面

    在项目中我们遇到404找不到的错误.或者500服务器错误都需要配置相应的页面给用户一个友好的提示,而在Spring Boot中我们需要如何设置. 我们需要实现ErrorController接口,重写h ...

  5. javascript中typeof与instanceof的区别

    JavaScript 中 typeof 和 instanceof 常用来判断一个变量是否为空,或者是什么类型的.但它们之间还是有区别的: typeof typeof 是一个一元运算,放在一个运算数之前 ...

  6. 快速排序算法的实现 && 随机生成区间里的数 && O(n)找第k小 && O(nlogk)找前k大

    思路:固定一个数,把这个数放到合法的位置,然后左边的数都是比它小,右边的数都是比它大 固定权值选的是第一个数,或者一个随机数 因为固定的是左端点,所以一开始需要在右端点开始,找一个小于权值的数,从左端 ...

  7. 性能测试工具LoadRunner24-LR之Analysis 系统资源分析

    1.内存分析方法 内存分析方法主要是用于判断系统有无遇到内存瓶颈,是否需要通过增加内存等手段提高系统性能表现.主要计数器包括Memory和Physical Disk类别的计数器 内存分析的主要步骤和方 ...

  8. [转]jQuery AJAX pagination plugin with ASP.NET Server Side

    本文转自:http://do-web.com/jpaging/usage How does it work? 1. In order to implement the plugin, you need ...

  9. 在rails 中返回 zip 文件

    在平日的开发当中我们一般只返回html,json 等等,但是偶尔情况下也会使用到其他文件的返回,比如 pdf ,csv 文件 今天在开发中使用的是将大量的文字返回给用户. ## 知识点 `Tempfi ...

  10. java 日志框架的选择Log4j->SLF4j->Logback

    Log4j->SLF4j->Logback是同一个人开发的 import lombok.extern.slf4j.Slf4j; import org.junit.Test; import ...