Ejemplo n.º 1
0
        //窗体上显示天气信息
        private void ShowWeatherInfo(TomorrowWeatherInfo info)
        {
            this.lbl_Weather.Text     = info.Weather;
            this.lbl_Date.Text        = info.Date;
            this.lbl_Temperature.Text = info.Temperature;
            this.lbl_Wind.Text        = info.Wind;
            string imageFromFile = _imagePath + info.ImageFrom;

            if (!System.IO.File.Exists(imageFromFile))
            {
                imageFromFile = _imagePath + "0.gif";
            }
            this.pb_From.Image = new Bitmap(imageFromFile);

            this.pb_From.Visible = true;
            this.pb_From.Left    = 22;
            this.pb_To.Visible   = true;
            string imageToFile = _imagePath + info.ImageTo;

            if (!System.IO.File.Exists(imageToFile))
            {
                imageToFile = _imagePath + "0.gif";
            }
            this.pb_To.Image = new Bitmap(imageToFile);
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            IFeature pFeatCity = ZoomtoProvince(textBox1.Text.Trim());
            string   city      = textBox1.Text.Trim();

            if (pFeatCity == null)
            {
                return;
            }

            label1.Text = pFeatCity.get_Value(8).ToString();
            label2.Text = "面积有:" + pFeatCity.get_Value(2).ToString();

            //在下面增加弹出标签的测试代码,或者说是调用代码
            //思考一下,如果要创建一个标签,我们需要提供什么函数呢?...
            //标注
            TomorrowWeatherInfo wInfo = new TomorrowWeatherInfo(city);

            ShowWeatherInfo(wInfo);

            Labels lbs       = new Labels();
            IPoint pt        = Utilities.GetFeatureCenterPoint(pFeatCity);// 标签的位置
            string lblString = city + "\r" + wInfo.Weather + "\r" + wInfo.Temperature + "\r" + wInfo.Wind;

            Labels       myLbl      = new Labels();
            ILabelsStyle myLblStyle = lbs as ILabelsStyle;

            myLblStyle.FontSize = 22;
            myLblStyle.style    = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
            myLblStyle.fColor   = 1;
            myLblStyle.tColor   = 255;

            lbs.LabelQueryInfo(city, lblString, pt, axMapControl1.Map, _isRemoveLabels);
        }
Ejemplo n.º 3
0
        //添加字段并赋值
        private void AddField()
        {
            //添加温度字段
            string        HighTemp    = "HighTemperature";
            string        LowTemp     = "LowTemperature";
            IFeatureLayer lyrProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IFeatureLayer;
            IFeatureClass ProClass    = lyrProVince.FeatureClass;;

            if (ProClass.Fields.FindField(HighTemp) < 0)
            {
                IField     pField     = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = HighTemp;
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                IClass pClass = ProClass as IClass;
                pClass.AddField(pFieldEdit);
            }
            if (ProClass.Fields.FindField(LowTemp) < 0)
            {
                IField     pField     = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = LowTemp;
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                IClass pClass = ProClass as IClass;
                pClass.AddField(pFieldEdit);
            }
            //为字段赋值
            string[]            provinces = new string[] { "黑龙江省", "内蒙古自治区", "新疆维吾尔自治区", "吉林省", "甘肃省", "河北省", "北京市", "山西省", "天津市", "陕西省", "宁夏回族自治区", "青海省", "辽宁省", "山东省", "西藏自治区", "河南省", "江苏省", "安徽省", "四川省", "湖北省", "重庆市", "上海市", "浙江省", "湖南省", "江西省", "云南省", "贵州省", "广西壮族自治区", "福建省", "台湾省", "海南省", "广东省", "香港特别行政区", "澳门" };
            TomorrowWeatherInfo weath;

            IFeatureCursor featCursor  = null;
            IQueryFilter   queryFilter = new QueryFilterClass();

            for (int i = 0; i < provinces.Length; i++)
            {
                string selCity     = provinces[i];
                string whereClause = "[NAME] = '" + selCity + "'";
                queryFilter.WhereClause = whereClause;
                featCursor = ProClass.Search(queryFilter, false);
                IFeature pFeature = featCursor.NextFeature();
                string   pcity    = Utilities.getCity(selCity);
                weath = new TomorrowWeatherInfo(pcity);

                Random random = new Random();//测试用随机数产生器
                if (pFeature != null)
                {
                    pFeature.set_Value(pFeature.Fields.FindField("HighTemperature"), random.Next(20, 40));
                    pFeature.set_Value(pFeature.Fields.FindField("LowTemperature"), random.Next(1, 20));
                    pFeature.Store();
                }
            }
            IGeoFeatureLayer geoProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IGeoFeatureLayer;

            setColor(geoProVince);
        }
Ejemplo n.º 4
0
        //添加字段并赋值
        private void AddField()
        {
            //添加温度字段
            string HighTemp = "HighTemperature";
            string LowTemp = "LowTemperature";
            IFeatureLayer lyrProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IFeatureLayer;
            IFeatureClass ProClass = lyrProVince.FeatureClass; ;
            if (ProClass.Fields.FindField(HighTemp) < 0)
            {
                IField pField = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = HighTemp;
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                IClass pClass = ProClass as IClass;
                pClass.AddField(pFieldEdit);
            }
            if (ProClass.Fields.FindField(LowTemp) < 0)
            {
                IField pField = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = LowTemp;
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                IClass pClass = ProClass as IClass;
                pClass.AddField(pFieldEdit);

            }
            //为字段赋值
            string[] provinces = new string[] { "黑龙江省", "内蒙古自治区", "新疆维吾尔自治区", "吉林省", "甘肃省", "河北省", "北京市", "山西省", "天津市", "陕西省", "宁夏回族自治区", "青海省", "辽宁省", "山东省", "西藏自治区", "河南省", "江苏省", "安徽省", "四川省", "湖北省", "重庆市", "上海市", "浙江省", "湖南省", "江西省", "云南省", "贵州省", "广西壮族自治区", "福建省", "台湾省", "海南省", "广东省", "香港特别行政区", "澳门" };
            TomorrowWeatherInfo weath;

            IFeatureCursor featCursor = null;
            IQueryFilter queryFilter = new QueryFilterClass();
            for (int i = 0; i < provinces.Length; i++)
            {
                string selCity = provinces[i];
                string whereClause = "[NAME] = '" + selCity + "'";
                queryFilter.WhereClause = whereClause;
                featCursor = ProClass.Search(queryFilter, false);
                IFeature pFeature = featCursor.NextFeature();
                string pcity = Utilities.getCity(selCity);
                weath = new TomorrowWeatherInfo(pcity);

                Random random=new Random();//测试用随机数产生器
                if (pFeature != null)
                {
                    pFeature.set_Value(pFeature.Fields.FindField("HighTemperature"), random.Next(20,40));
                    pFeature.set_Value(pFeature.Fields.FindField("LowTemperature"), random.Next(1,20));
                    pFeature.Store();
                }
            }
            IGeoFeatureLayer geoProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IGeoFeatureLayer;
            setColor(geoProVince);
        }
Ejemplo n.º 5
0
        void qryTool_LabelEvent(string cityName, IFeature pFeatCity)
        {
            ZoomtoProvince(cityName);

            label1.Text = pFeatCity.get_Value(8).ToString();
            label2.Text = "面积有:" + pFeatCity.get_Value(2).ToString();

            //标注天气
            TomorrowWeatherInfo wInfo = new TomorrowWeatherInfo(cityName);

            Labels lbs       = new Labels();
            IPoint pt        = Utilities.GetFeatureCenterPoint(pFeatCity);// 标签的位置
            string lblString = cityName + "\r" + wInfo.Weather + "\r" + wInfo.Temperature + "\r" + wInfo.Wind;

            lbs.LabelQueryInfo(cityName, lblString, pt, axMapControl1.Map, _isRemoveLabels);

            ShowWeatherInfo(wInfo);
        }
Ejemplo n.º 6
0
        private void InitialWeather()
        {
            string fileName = Application.StartupPath + "\\" + _initialCityFile;

            if (!System.IO.File.Exists(fileName))
            {
                return;
            }

            System.IO.StreamReader sr = System.IO.File.OpenText(fileName);
            string city = sr.ReadLine();

            sr.Close();

            if (city == null)
            {
                return;
            }
            TomorrowWeatherInfo info = new TomorrowWeatherInfo(city);

            if (info.Result != TomorrowWeatherInfo.ResultInfo.Success)
            {
                ShowError(info.Result.ToString(), city);
                return;
            }

            ShowWeatherInfo(info);

            IFeature pFeat = ZoomtoProvince(city);

            Labels lbs       = new Labels();
            IPoint pt        = Utilities.GetFeatureCenterPoint(pFeat);
            string lblString = city + "\r" + info.Weather + "\r" + info.Temperature + "\r" + info.Wind;

            lbs.LabelQueryInfo(city, lblString, pt, axMapControl1.Map, _isRemoveLabels);

            TomorrowWeatherInfo wInfo = new TomorrowWeatherInfo(city);

            ShowWeatherInfo(wInfo);
        }
Ejemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            IFeature pFeatCity = ZoomtoProvince(textBox1.Text.Trim());
            string city = textBox1.Text.Trim();
            if (pFeatCity == null)
            {
                return;
            }

            label1.Text = pFeatCity.get_Value(8).ToString();
            label2.Text = "面积有:" + pFeatCity.get_Value(2).ToString();

            //在下面增加弹出标签的测试代码,或者说是调用代码
            //思考一下,如果要创建一个标签,我们需要提供什么函数呢?...
            //标注
            TomorrowWeatherInfo wInfo = new TomorrowWeatherInfo(city);
            ShowWeatherInfo(wInfo);

            Labels lbs = new Labels();
            IPoint pt = Utilities.GetFeatureCenterPoint(pFeatCity);// 标签的位置
            string lblString = city + "\r" + wInfo.Weather + "\r" + wInfo.Temperature + "\r" + wInfo.Wind;

            Labels myLbl = new Labels();
            ILabelsStyle myLblStyle = lbs as ILabelsStyle;
            myLblStyle.FontSize = 22;
            myLblStyle.style = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
            myLblStyle.fColor = 1;
            myLblStyle.tColor = 255;

            lbs.LabelQueryInfo(city, lblString, pt, axMapControl1.Map, _isRemoveLabels);
        }
Ejemplo n.º 8
0
        //窗体上显示天气信息
        private void ShowWeatherInfo(TomorrowWeatherInfo info)
        {
            this.lbl_Weather.Text = info.Weather;
            this.lbl_Date.Text = info.Date;
            this.lbl_Temperature.Text = info.Temperature;
            this.lbl_Wind.Text = info.Wind;
            string imageFromFile = _imagePath + info.ImageFrom;
            if (!System.IO.File.Exists(imageFromFile))
            {
                imageFromFile = _imagePath + "0.gif";
            }
            this.pb_From.Image = new Bitmap(imageFromFile);

            this.pb_From.Visible = true;
            this.pb_From.Left = 22;
            this.pb_To.Visible = true;
            string imageToFile = _imagePath + info.ImageTo;
            if (!System.IO.File.Exists(imageToFile))
            {
                imageToFile = _imagePath + "0.gif";
            }
            this.pb_To.Image = new Bitmap(imageToFile);
        }
Ejemplo n.º 9
0
        void qryTool_LabelEvent(string cityName, IFeature pFeatCity)
        {
            ZoomtoProvince(cityName);

            label1.Text = pFeatCity.get_Value(8).ToString();
            label2.Text = "面积有:" + pFeatCity.get_Value(2).ToString();

            //标注天气
            TomorrowWeatherInfo wInfo = new TomorrowWeatherInfo(cityName);

            Labels lbs = new Labels();
            IPoint pt = Utilities.GetFeatureCenterPoint(pFeatCity);// 标签的位置
            string lblString = cityName + "\r" + wInfo.Weather + "\r" + wInfo.Temperature + "\r" + wInfo.Wind;
            lbs.LabelQueryInfo(cityName, lblString, pt, axMapControl1.Map, _isRemoveLabels);

            ShowWeatherInfo(wInfo);
        }
Ejemplo n.º 10
0
        private void InitialWeather()
        {
            string fileName = Application.StartupPath + "\\" + _initialCityFile;
            if (!System.IO.File.Exists(fileName)) return;

            System.IO.StreamReader sr = System.IO.File.OpenText(fileName);
            string city = sr.ReadLine();
            sr.Close();

            if (city == null) return;
            TomorrowWeatherInfo info = new TomorrowWeatherInfo(city);
            if (info.Result != TomorrowWeatherInfo.ResultInfo.Success)
            {
                ShowError(info.Result.ToString(), city);
                return;
            }

            ShowWeatherInfo(info);

            IFeature pFeat = ZoomtoProvince(city);

            Labels lbs = new Labels();
            IPoint pt = Utilities.GetFeatureCenterPoint(pFeat);
            string lblString = city + "\r" + info.Weather + "\r" + info.Temperature + "\r" + info.Wind;
            lbs.LabelQueryInfo(city, lblString, pt, axMapControl1.Map, _isRemoveLabels);

            TomorrowWeatherInfo wInfo = new TomorrowWeatherInfo(city);
            ShowWeatherInfo(wInfo);
        }