public static void SaveProjectFile(Aggregate aggregator, MapWinControl.MapWinControl mapWinControl, string projectFile) { MapWinProject mapwinProject = new MapWinProject(); // mapwinProject.Name = frmMain.Text.Replace("'", ""); mapwinProject.Type = "projectfile.2"; mapwinProject.Version = "4.8.5"; // Get the mapstate from the ocx string state = mapWinControl.LoadMapState(true, Path.GetDirectoryName(projectFile)); mapwinProject.MapwinGis = state.DeserializeXml <MapWinProject.MapWinGIS>(); // Fill the mapwindos projectSettings string mapwindow = FillMapwindowSettings(aggregator); mapwinProject.MapWindow = mapwindow.DeserializeXml <MapWinProject.MapWindow4>(); string prjSetting = mapwinProject.SerializeXml <MapWinProject>(); using (StreamWriter outfile = new StreamWriter(projectFile)) { // Save settings to file outfile.Write(prjSetting); } }
public static void SaveProjectFile(BaseMainForm frmMain, MapWinControl.MapWinControl mapWinControl, string projectFile) { //frmMain.ContainerToolstrip // welke menu's zijn actief???? //// Todo setting zoals version uit een settingfile oid halen //MapWinProject mapwinProject = new MapWinProject(); //mapwinProject.Name = frmMain.Text.Replace("'", ""); //mapwinProject.Type = "projectfile.2"; //mapwinProject.Version = "4.8.5"; //// Get the mapstate from the ocx //string state = mapWinControl.LoadMapState(true, Path.GetDirectoryName(projectFile)); //mapwinProject.MapwinGis = state.DeserializeXml<MapWinProject.MapWinGIS>(); //// Fill the mapwindos projectSettings //string mapwindow = FillMapwindowSettings(); //mapwinProject.MapWindow = mapwindow.DeserializeXml<MapWinProject.MapWindow4>(); //// Serialize the settings //string prjSetting = mapwinProject.SerializeXml<MapWinProject>(); //// TODO nog even opslaan als een nieuw bestand. //using (StreamWriter outfile = new StreamWriter(projectFile)) //{ // // Save settings to file // outfile.Write(prjSetting); //} }
private static void RestoreMapState(MapWinProject mapWinProject, MapWinControl.MapWinControl mapWinControl, string projectFile) { string aap = mapWinProject.MapwinGis.SerializeXml <MapWinProject.MapWinGIS>(); aap = aap.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n", ""); if (!mapWinControl.RestoreMapState(aap, false, Path.GetFullPath(projectFile))) { MessageBox.Show("Error restoring mapstate."); } }
public static void ReadProjectFile(string projectFile, MapWinControl.MapWinControl mapWinControl, Aggregate aggregator) { // Read the projectfile string projectFileText = File.ReadAllText(projectFile); MapWinProject mapWinProject = projectFileText.DeserializeXml <MapWinProject>(); // Add the layers from the projectfile AddLayers(mapWinProject, mapWinControl, projectFile, aggregator); LoadPlugins(mapWinProject, aggregator); }
private static void AddLayers(MapWinProject mapWinProject, MapWinControl.MapWinControl mapWinControl, string projectFile, Aggregate aggregator) { // List met layers aanmaken // layers met alle data vullen // groups ophalen // layers toevoegen met de group erbij List <Layer> layers = new List <Layer>(); // check if there are layers in the projectfile if (mapWinProject.MapwinGis.Layers != null) { // Loop through all layers foreach (var prjLayer in mapWinProject.MapwinGis.Layers) { // Skip layer if the path to the layer does not exist in the projectfile if (prjLayer.Filename != string.Empty) { // Add layer to ocx int handle = LayerLogic.AddLayer(Path.GetFullPath(prjLayer.Filename), ZoomMode.ZoomToExtents, false, aggregator); if (handle != -1) { // Create the layer-object and add it to the temporary list of layers Layer layer = LayerLogic.FillMapWingisLayerData(handle, prjLayer); layers.Add(layer); // aggregator.Layers.Add(layer); // Restore the state of the layer RestoreLayerState(mapWinControl, prjLayer, handle); } } } // Restore the state of the map RestoreMapState(mapWinProject, mapWinControl, projectFile); // Fill data from the mapwindow-section FillMapWindowData(mapWinProject, aggregator, layers); //// Add the layers to a group //AddLayerToGroup(aggregator, layers); // Give aggregator signal that layer has been added aggregator.LayerAdded(); } }
private static void RestoreLayerState(MapWinControl.MapWinControl mapWinControl, MapWinProject.Layer layer, int handle) { if (handle != -1) { string layerState = layer.SerializeXml <MapWinProject.Layer>(); // Restore the layerstate bool result = mapWinControl.RestorLayerState(handle, layerState); if (!result) { MessageBox.Show("Error restoring layerstate"); } } }
public static void ChangeVisibility(Aggregate aggregate, string itemName, bool isVisible, int handle, MapWinControl.MapWinControl mapWinControl) { Layer layer = aggregate.CollectionLayer.FirstOrDefault(elm => elm.Handle == handle); //// Find the layer //Layer layer = (from grp in aggregate.Groups // from lyr in grp.Layers // where lyr.Handle == handle // select lyr).FirstOrDefault(); if (layer != null) { // Change visibility mapWinControl.LayerVisible(layer.Handle, isVisible); } else { Group group = aggregate.CollectionLayer.GetGroup(itemName); // Group group = aggregate.Groups.FirstOrDefault(elm => elm.Name == itemName); if (group != null) { // } } }