示例#1
0
        private void ReprojectOnTheFly(IMapLayer layer)
        {
            if (layer.DataSet == null) return;
            if (!Data.DataSet.ProjectionSupported()) return;

            bool preventReproject = DefineProjection(layer);
            if ((Projection == null || Layers.Count == 1))
            {
                Projection = layer.DataSet.Projection;
                return;
            }

            if (preventReproject) return;

            if (Data.DataSet.ProjectionSupported())
            {
                if (!Projection.Equals(layer.DataSet.Projection))
                {
                    Boolean bReproject = false;
                    if (ProjectionModeReproject == ActionMode.Prompt || ProjectionModeReproject == ActionMode.PromptOnce)
                    {
                        string message = MessageStrings.MapFrame_GlcLayerAdded_ProjectionMismatch;
                        if (ProjectionModeReproject == ActionMode.PromptOnce)
                        {
                            message =
                                "The newly added layer has a coordinate system, but that coordinate system does not match the other layers in the map.  Do you want to reproject new layers on the fly so that they are drawn in the same coordinate system as the other layers?";
                        }
                        DialogResult result = MessageBox.Show(
                            message,
                            MessageStrings.MapFrame_GlcLayerAdded_Projection_Mismatch,
                            MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            bReproject = true;
                        }
                        if (ProjectionModeReproject == ActionMode.PromptOnce)
                        {
                            ProjectionModeReproject = result == DialogResult.Yes ?
                                                                                     ActionMode.Always : ActionMode.Never;
                        }
                    }
                    if (bReproject || ProjectionModeReproject == ActionMode.Always)
                    {
                        layer.Reproject(Projection);
                    }
                }
            }
        }