/// <summary> /// Runs the operation /// </summary> private void btnOk_Click(object sender, EventArgs e) { CoordinateSystem cs = ProjectionTreeView1.SelectedCoordinateSystem; if (cs == null) { MessageService.Current.Info("No projection is selected."); return; } if (!LayersControl1.Filenames.Any()) { MessageService.Current.Info("No files are selected."); return; } var projection = new SpatialReference(); if (!projection.ImportFromEpsg(cs.Code)) { MessageService.Current.Info("Failed to initialize the selected projection."); return; } var report = new TesterReportForm(); int count = 0; // number of successfully processed files foreach (string name in LayersControl1.Filenames) { var layer = GeoSource.Open(name) as ILayerSource; if (layer == null) { continue; } string projName = layer.Projection != null ? layer.Projection.Name : ""; if (layer.LayerType != LayerType.Invalid && layer.Projection != null) { layer.Projection.CopyFrom(projection); count++; } else { report.AddFile(name, projName, ProjectionOperation.Skipped, ""); } } if (count > 0) { MessageService.Current.Info(string.Format("The projection was successfully assigned to the files: {0}", count)); } if (report.MismatchedCount > 0) { report.ShowReport(projection, "The following files were not processed:", ReportType.Assignment); } LayersControl1.UpdateProjections(); }
/// <summary> /// Creates a new instance of the frmAssignProjection class /// </summary> public AssignProjectionForm(IAppContext context) : base(context) { InitializeComponent(); if (context == null) { throw new NullReferenceException("No reference to MapWindow was passed"); } var database = context.Projections; if (database == null) { throw new InvalidCastException("Invalid instance of projection database was passed"); } LayersControl1.Initialize(context); LayersControl1.LayerAdded += delegate { RefreshControlState(); }; LayersControl1.LayerRemoved += RefreshControlState; if (ProjectionTreeView1.Initialize(database, context)) { ProjectionTreeView1.RefreshList(); } LayersControl1.ControlType = LayersControl.CustomType.Projection; RefreshControlState(); }
/// <summary> /// Creates a new instance of the frmAssignProjection class /// </summary> public ReprojectForm(IAppContext context, IReprojectingService reprojectingService) : base(context) { _reprojectingService = reprojectingService; InitializeComponent(); if (context == null) { throw new ArgumentException("No reference to MapWindow was passed"); } if (reprojectingService == null) { throw new ArgumentNullException("reprojectingService"); } var database = context.Projections; if (database == null) { throw new InvalidCastException("Invalid instance of projection database was passed"); } LayersControl1.Initialize(context); if (ProjectionTreeView1.Initialize(database, context)) { ProjectionTreeView1.RefreshList(); } LayersControl1.ControlType = LayersControl.CustomType.Projection; }
/// <summary> /// Creates a new instance of the frmAssignProjection class /// </summary> public frmReproject(MapWinGIS.Interfaces.IMapWin mapWin) { InitializeComponent(); if (mapWin == null) { throw new ArgumentException("No reference to MapWinGIS was passed"); } ProjectionDatabase database = mapWin.ProjectionDatabase as ProjectionDatabase; if (database == null) { throw new InvalidCastException("Invalid instance of projection database was passed"); } m_mapWin = mapWin; LayersControl1.Initialize(mapWin); if (ProjectionTreeView1.Initialize(database, mapWin)) { this.ProjectionTreeView1.RefreshList(); } this.LayersControl1.ControlType = LayersControl.CustomType.Projection; }
/// <summary> /// Creates a new instance of the frmAssignProjection class /// </summary> public frmAssignProjection(MapWinGIS.Interfaces.IMapWin mapWin) { InitializeComponent(); if (mapWin == null) { throw new NullReferenceException("No reference to MapWinGIS was passed"); } ProjectionDatabase database = mapWin.ProjectionDatabase as ProjectionDatabase; if (database == null) { throw new InvalidCastException("Invalid instance of projection database was passed"); } m_mapWin = mapWin; LayersControl1.Initialize(mapWin); LayersControl1.LayerAdded += delegate(string filename, DataGridView dgv, int rowIndex) { this.RefreshControlState(); }; LayersControl1.LayerRemoved += delegate() { this.RefreshControlState(); }; if (ProjectionTreeView1.Initialize(database, mapWin)) { this.ProjectionTreeView1.RefreshList(); } this.LayersControl1.ControlType = LayersControl.CustomType.Projection; this.RefreshControlState(); }