コード例 #1
0
        /// <summary>
        /// Let the editor to update the modified values to the underlying object.
        /// </summary>
        public void UpdateValues()
        {
            if (map == null)
            {
                return;
            }

            if (dirtyFlag)
            {
                dirtyFlag = false;
                // general tab
                if (map.name != this.textBoxName.Text)
                {
                    map.name = this.textBoxName.Text;
                }
                if (map.shapepath != this.textBoxShapePath.Text)
                {
                    map.shapepath = this.textBoxShapePath.Text;
                }
                if (map.web.imagepath != this.textBoxImagepath.Text)
                {
                    map.web.imagepath = this.textBoxImagepath.Text;
                }
                if (map.fontset.filename != this.textBoxFontset.Text)
                {
                    if (this.textBoxFontset.Text != "" &&
                        File.Exists(this.textBoxFontset.Text))
                    {
                        map.setFontSet(this.textBoxFontset.Text);
                    }
                    else
                    {
                        map.setFontSet(null);
                    }
                }
                if (map.symbolset.filename != this.textBoxSymbolset.Text)
                {
                    if (this.textBoxSymbolset.Text != "" &&
                        File.Exists(this.textBoxSymbolset.Text))
                    {
                        try
                        {
                            map.setSymbolSet(this.textBoxSymbolset.Text);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Invalid symbol file, " + ex.Message,
                                            "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            map.setSymbolSet(null);
                        }
                    }
                    else
                    {
                        map.setSymbolSet(null);
                    }
                }

                // image details tab
                this.colorPickerBackColor.ApplyTo(map.imagecolor);
                if (map.imagetype != comboBoxImageType.Text)
                {
                    map.selectOutputFormat(comboBoxImageType.Text);
                }

                map.resolution = Convert.ToDouble(this.textBoxResolution.Text);
                // coordinate space
                // need to recalculate the extent to point to the same visible area
                try
                {
                    // setting up the projection if it have been changed
                    if (map.getProjection() != this.textBoxProjection.Tag.ToString())
                    {
                        if (map.getProjection() != "" && this.textBoxProjection.Tag.ToString() != "" &&
                            map.extent.minx < map.extent.maxx && map.extent.miny < map.extent.maxy)
                        {
                            using (projectionObj oldProj = new projectionObj(map.getProjection()))
                            {
                                using (projectionObj newProj = new projectionObj(this.textBoxProjection.Tag.ToString()))
                                {
                                    using (rectObj rect = new rectObj(map.extent.minx, map.extent.miny, map.extent.maxx, map.extent.maxy, 0))
                                    {
                                        rect.project(oldProj, newProj);
                                        map.units = (MS_UNITS)this.comboBoxUnits.SelectedItem;
                                        if (rect.minx < rect.maxx && rect.miny < rect.maxy)
                                        {
                                            map.setExtent(rect.minx, rect.miny, rect.maxx, rect.maxy);
                                            dirtyFlagExtent = true;
                                            UpdateExtentValues();
                                        }
                                    }
                                }
                            }
                        }

                        if (this.textBoxProjection.Tag.ToString().Trim().StartsWith("+"))
                        {
                            map.setProjection(this.textBoxProjection.Tag.ToString());
                            map.setMetaData("coordsys_name", this.textBoxProjection.Text);
                        }
                        else
                        {
                            map.setProjection("+AUTO");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to set projection value, " + ex.Message, "MapManager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (checkBoxTransparent.Checked)
                {
                    map.outputformat.transparent = mapscript.MS_TRUE;
                    if (map.outputformat.imagemode == (int)MS_IMAGEMODE.MS_IMAGEMODE_RGB)
                    {
                        map.outputformat.imagemode = (int)MS_IMAGEMODE.MS_IMAGEMODE_RGBA;
                    }
                }
                else
                {
                    map.outputformat.transparent = mapscript.MS_FALSE;
                    if (map.outputformat.imagemode == (int)MS_IMAGEMODE.MS_IMAGEMODE_RGBA)
                    {
                        map.outputformat.imagemode = (int)MS_IMAGEMODE.MS_IMAGEMODE_RGB;
                    }
                }

                if (target != null && !dirtyFlagExtent)
                {
                    target.RaisePropertyChanged(this);
                }
                SetDirty(false);
            }
            if (dirtyFlagExtent)
            {
                ApplyExtent();
                dirtyFlagExtent = false;
            }
        }