public EditEMapWindow(MainFrame mainFrame, EngineeringMap eMap) { _mainFrame = mainFrame; _eMap = eMap; if (_eMap == null) { _eMap = new EngineeringMap(); int count = _mainFrame.views.Count() + 1; _eMap.MapID = "MyView" + count.ToString(); _eMap.MapType = EngineeringMapType.FootPrintMap; _eMap.MinimumResolution = 0.01; } InitializeComponent(); if (_eMap.MapType == EngineeringMapType.FootPrintMap) { MapType.SelectedIndex = 0; } else if (_eMap.MapType == EngineeringMapType.GeneralProfileMap) { MapType.SelectedIndex = 1; } Root.DataContext = _eMap; }
public ProfileView(Project prj, EngineeringMap eMap) { InitializeComponent(); if (eMap.MapID.Contains('右')) { partchar = '右'; } else { partchar = '左'; } Themeinit(); _view = new IS3ProfileView(this, MyMapView); _view.prj = prj; _view.eMap = eMap; _view.LayerToGeofile = LayerToGeofile; MyProgressBar.DataContext = _view; GotFocus += ProfileView_GotFocus; Globals.mainFrame.viewLoaded += initlayerwindow; customrulers = new Dictionary <string, Ruler>(); initMainruler(); MyMapView.ExtentChanged += MyMapView_ExtentChanged; }
private async void LyrSetting_Click(object sender, RoutedEventArgs e) { EngineeringMap emap = EMapsLB.SelectedItem as EngineeringMap; if (emap == null) { return; } GdbLayer gdbLyr = GeoDBLayrLB.SelectedItem as GdbLayer; if (gdbLyr == null) { return; } LayerDef lyrDef = emap.LocalGdbLayersDef.Find(x => x.Name == gdbLyr.Name); LayerDefWindow lyrDefWnd = new LayerDefWindow(lyrDef); lyrDefWnd.Owner = this; lyrDefWnd.WindowStartupLocation = WindowStartupLocation.CenterOwner; bool?success = lyrDefWnd.ShowDialog(); if (success != null && success.Value == true) { Layer lyr = Map.Layers[gdbLyr.Name]; if (lyr != null) { // Reload the layer Map.Layers.Remove(lyr); await GdbHelper.addGeodatabaseLayer(Map, lyrDef, gdbLyr.FeatureTable); } } }
async void LoadGeoDb(EngineeringMap emap) { string file = ProjDef.LocalFilePath + "\\" + emap.LocalGeoDbFileName; if (File.Exists(file)) { Geodatabase gdb = await Geodatabase.OpenAsync(file); IEnumerable <GeodatabaseFeatureTable> featureTables = gdb.FeatureTables; List <GdbLayer> gdbLayers = new List <GdbLayer>(); foreach (var table in featureTables) { GdbLayer layer = new GdbLayer(); layer.Name = table.Name; layer.Visibility = false; layer.FeatureTable = table; gdbLayers.Add(layer); LayerDef lyrDef = emap.LocalGdbLayersDef.Find(x => x.Name == table.Name); if (lyrDef == null) { lyrDef = GdbHelper.GenerateDefaultLayerDef(table); emap.LocalGdbLayersDef.Add(lyrDef); } await GdbHelper.addGeodatabaseLayer(Map, lyrDef, table); } GeoDBLayrList.ItemsSource = gdbLayers; } }
private void LocalGeoDBBtn_Click(object sender, RoutedEventArgs e) { EngineeringMap emap = EMapsLB.SelectedItem as EngineeringMap; if (emap == null) { return; } string file = emap.LocalTileFileName1; string path = ProjDef.LocalFilePath; OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = path; dialog.Filter = "Geo-Database(.geodatabase)|*.geodatabase"; dialog.FileName = file; DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { emap.LocalGeoDbFileName = dialog.SafeFileName; LoadGeoDb(emap); // refresh UI EMapGrd.DataContext = null; EMapGrd.DataContext = emap; } }
private void LayerCB_Click(object sender, RoutedEventArgs e) { System.Windows.Controls.CheckBox chkBox = sender as System.Windows.Controls.CheckBox; // Click => Switch the layer on/off GdbLayer gdbLyr = chkBox.Tag as GdbLayer; Layer lyr = Map.Layers[gdbLyr.Name]; lyr.IsVisible = chkBox.IsChecked.Value; // Update layer definition EngineeringMap emap = EMapsLB.SelectedItem as EngineeringMap; if (emap == null) { return; } LayerDef lyrDef = emap.LocalGdbLayersDef.Find(x => x.Name == gdbLyr.Name); if (lyrDef == null) { return; } lyrDef.IsVisible = chkBox.IsChecked.Value; }
// Find LayoutDocumentPane where IS3View can be add. public LayoutDocumentPane FindViewHolder() { if (_prj == null) { return(null); } EngineeringMap baseMap = _prj.projDef.EngineeringMaps.FirstOrDefault(); if (baseMap == null) { return(null); } LayoutContent layoutContent = FindLayoutContentByID(baseMap.MapID); if (layoutContent == null) { return(null); } LayoutDocumentPane docPane = layoutContent.Parent as LayoutDocumentPane; if (docPane == null) { LayoutRoot root = layoutContent.Root as LayoutRoot; LayoutPanel panel = root.Children.First() as LayoutPanel; LayoutDocumentPaneGroup docPaneGroup = panel.Children.ElementAt(1) as LayoutDocumentPaneGroup; docPane = docPaneGroup.Children.First() as LayoutDocumentPane; } return(docPane); }
public static XElement EngineeringMapToXml(EngineeringMap eMap) { XElement root = new XElement("EngineeringMap", new XAttribute("MapID", eMap.MapID), new XAttribute("LocalTileFileName1", eMap.LocalTileFileName1), new XAttribute("LocalTileFileName2", eMap.LocalTileFileName2), new XAttribute("LocalMapFileName", eMap.LocalMapFileName), new XAttribute("LocalGeoDbFileName", eMap.LocalGeoDbFileName), new XAttribute("MapUrl", eMap.MapUrl), new XAttribute("XMax", eMap.XMax), new XAttribute("XMin", eMap.XMin), new XAttribute("YMax", eMap.YMax), new XAttribute("YMin", eMap.YMin), new XAttribute("MinimumResolution", eMap.MinimumResolution), new XAttribute("MapType", eMap.MapType.ToString()), new XAttribute("Calibrated", eMap.Calibrated), new XAttribute("Scale", eMap.Scale), new XAttribute("ScaleX", eMap.ScaleX), new XAttribute("ScaleY", eMap.ScaleY), new XAttribute("ScaleZ", eMap.ScaleZ) ); //XElement parent = new XElement("ELayers"); //foreach (EngineeringLayer eLayer in eMap.ELayers) //{ // XElement node = EngineeringLayerToXml(eLayer); // parent.Add(node); //} //root.Add(parent); return(root); }
private void import3D_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false;//该值确定是否可以选择多个文件 dialog.Title = "请选择文件夹"; dialog.Filter = ".unity3d(*.*)|*.unity3d"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string file = dialog.FileName; u3dTB.Text = file; //移动目录 MoveFile(_projdef.LocalFilePath + "\\" + dialog.SafeFileName, file); //新建emap EngineeringMap map = new EngineeringMap(); map.LocalMapFileName = dialog.SafeFileName; //添加三维视图-unitywebplayer U3DView u3DView = new U3DView(new Project() { projDef = _projdef }, map); ViewHolder.Children.Add(u3DView); //添加图层获取事件 u3DView.UnityLayerHanlder += UnityLayerListener; u3DView.view.loadPredefinedLayers(); } }
public async Task <IView> addView(EngineeringMap eMap, bool canClose) { LayoutDocumentPane docPane = FindViewHolder(); if (docPane == null) { docPane = ViewPane; } LayoutDocument LayoutDoc = new LayoutDocument(); LayoutDoc.ContentId = eMap.MapID; LayoutDoc.Title = eMap.MapID; LayoutDoc.CanClose = canClose; LayoutDoc.Closed += LayoutDoc_Closed; docPane.Children.Add(LayoutDoc); string datafilePath, filePath; if (_prj != null) { datafilePath = _prj.projDef.LocalFilePath; filePath = datafilePath + "\\" + eMap.MapID + ".xml"; } IView view = null; if (eMap.MapType == EngineeringMapType.FootPrintMap) { PlanView planView = new PlanView(this, _prj, eMap); LayoutDoc.Content = planView; view = planView.view; } else if (eMap.MapType == EngineeringMapType.GeneralProfileMap) { ProfileView profileView = new ProfileView(this, _prj, eMap); LayoutDoc.Content = profileView; view = profileView.view; } else if (eMap.MapType == EngineeringMapType.Map3D) { IS3.Unity.Webplayer.U3DView u3dView = new IS3.Unity.Webplayer.U3DView(_prj, eMap); LayoutDoc.Content = u3dView; view = u3dView.view; } // view is both a trigger and listener of object selection changed event view.objSelectionChangedTrigger += this.objSelectionChangedListener; this.objSelectionChangedTrigger += view.objSelectionChangedListener; view.initializeView(); // Load predefined layers await view.loadPredefinedLayers(); // Sync view graphics with data view.syncObjects(); _views.Add(view); return(view); }
public U3DView(Project prj, EngineeringMap eMap) { InitializeComponent(); panel = new UnityPanel(prj, eMap); FormHost.Child = panel; }
// Reload the specified engineering map, clear the map view at first. // async Task ReloadMap(EngineeringMap emap) { Map.Layers.Clear(); if (emap != null) { LoadTiledLayer1(emap); await ReloadGeoDb(emap); } }
public U3DView(MainFrame mainFrame, Project prj, EngineeringMap eMap) { InitializeComponent(); _mainFrame = mainFrame; _view3D = new IS3View3D(this, u3dPlayerControl); _view3D.prj = prj; _view3D.eMap = eMap; }
public UnityPanel(EngineeringMap eMap) { InitializeComponent(); main = this; _u3dViewModel = new U3DViewModel(this); _u3dViewModel.eMap = eMap; System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; //AsyncActiveWindow(); }
public U3DView(Project prj, EngineeringMap eMap) { InitializeComponent(); _view3D = new U3dViewModel(this, u3dPlayerControl); (_view3D as U3dViewModel).UnityLayerHandler += UnityLayerListener; _view3D.prj = prj; _view3D.eMap = eMap; }
private async void MapsCB_SelectionChanged(object sender, SelectionChangedEventArgs e) { EngineeringMap emap = MapsCB.SelectedItem as EngineeringMap; if (emap == null) { return; } List <LayerDef> lyrsDef = emap.LocalGdbLayersDef; LayerDef lyrDef = lyrsDef.Find(x => x.Name == _lyrName); if (lyrDef == null) { return; } // load tiled layer // string file = _prjDef.LocalTilePath + "\\" + emap.LocalTileFileName1; if (File.Exists(file)) { ArcGISLocalTiledLayer newLayr = new ArcGISLocalTiledLayer(file); newLayr.ID = "TiledLayer1"; newLayr.DisplayName = "TileLayer1"; Map.Layers.Add(newLayr); //if (newLayr.FullExtent != null) //{ // MyMapView.SetView(newLayr.FullExtent); //} } // load the specified layer // file = _prjDef.LocalFilePath + "\\" + emap.LocalGeoDbFileName; if (File.Exists(file)) { // Open geodatabase Geodatabase gdb = await Geodatabase.OpenAsync(file); IEnumerable <GeodatabaseFeatureTable> featureTables = gdb.FeatureTables; foreach (var table in featureTables) { if (table.Name == _lyrName) { // Add the feature layer to the map await GdbHelper.addGeodatabaseLayer(Map, lyrDef, table); MyMapView.SetView(table.Extent); break; } } } }
// Load the specifiled emap's geodatabase, and add all the features layers to the map. // async Task ReloadGeoDb(EngineeringMap emap) { // Clear existing Local GeoDB layers if (GeoDBLayrLB.ItemsSource != null) { foreach (var item in GeoDBLayrLB.ItemsSource) { GdbLayer lyr = item as GdbLayer; Layer mapLyr = Map.Layers[lyr.Name]; if (mapLyr != null) { Map.Layers.Remove(mapLyr); } } GeoDBLayrLB.ItemsSource = null; } // Load new string file = _projDef.LocalFilePath + "\\" + emap.LocalGeoDbFileName; if (File.Exists(file)) { // Open geodatabase Geodatabase gdb = await Geodatabase.OpenAsync(file); IEnumerable <GeodatabaseFeatureTable> featureTables = gdb.FeatureTables; List <GdbLayer> gdbLayers = new List <GdbLayer>(); foreach (var table in featureTables) { // Search LayerDef, use default if not found. LayerDef lyrDef = emap.LocalGdbLayersDef.Find(x => x.Name == table.Name); if (lyrDef == null) { lyrDef = GdbHelper.GenerateDefaultLayerDef(table); emap.LocalGdbLayersDef.Add(lyrDef); } // GdbLayer is used for UI binding and selection operations. GdbLayer layer = new GdbLayer(); layer.Name = table.Name; layer.Visibility = lyrDef.IsVisible; layer.LayerObject = layer; layer.FeatureTable = table; layer.Extent = table.Extent; gdbLayers.Add(layer); // Add the feature layer to the map await GdbHelper.addGeodatabaseLayer(Map, lyrDef, table); } // Refresh UI GeoDBLayrLB.ItemsSource = gdbLayers; } }
public U3DView(MainFrame mainFrame, Project prj, EngineeringMap eMap) { InitializeComponent(); _mainFrame = mainFrame; _view3D = new IS3View3D(this, u3dPlayerControl); _view3D.prj = prj; _view3D.eMap = eMap; _view3D.sendMessageEventHandler += sendMessageEventListener; }
private void ProjEMapDefWindow_Loaded(object sender, RoutedEventArgs e) { EngineeringMap firstEMap = ProjDef.EngineeringMaps.FirstOrDefault(); if (firstEMap != null) { EMapsLB.SelectedIndex = 0; EMapChanged(firstEMap); } }
private void MyMapView_Loaded(object sender, RoutedEventArgs e) { EngineeringMap emap = EMapsLB.SelectedItem as EngineeringMap; if (emap != null) { LoadTiledLayer1(emap); LoadGeoDb(emap); } }
private async void EMapsLB_SelectionChanged(object sender, SelectionChangedEventArgs e) { EngineeringMap emap = EMapsLB.SelectedItem as EngineeringMap; // refresh UI EMapGrd.DataContext = null; EMapGrd.DataContext = emap; // refresh map await ReloadMap(emap); }
private void MyMapView_Loaded(object sender, RoutedEventArgs e) { EngineeringMap firstEMap = _projDef.EngineeringMaps.FirstOrDefault(); if (firstEMap != null) { EMapsLB.SelectedIndex = 0; // refresh UI EMapGrd.DataContext = firstEMap; } }
public PlanView(Project prj, EngineeringMap eMap) { InitializeComponent(); _view = new IS3View2D(this, MyMapView); _view.prj = prj; _view.eMap = eMap; MyProgressBar.DataContext = _view; GotFocus += PlanView_GotFocus; //MyDrawToolControl.drawToolClickEventHandler += _view.drawToolsClickEventListener; //MyDrawToolControl.drawToolClickEventHandler += (o, e) => //{ // if (e.stopDraw) // DrawStrip.Visibility = Visibility.Collapsed; //}; }
private void MyMapView_ExtentChanged(object sender, EventArgs e) { EngineeringMap emap = EMapsLB.SelectedItem as EngineeringMap; if (emap == null) { return; } if (MyMapView.Extent == null) { return; } emap.XMin = MyMapView.Extent.XMin; emap.YMin = MyMapView.Extent.YMin; emap.XMax = MyMapView.Extent.XMax; emap.YMax = MyMapView.Extent.YMax; }
void EMapChanged(EngineeringMap emap) { // refresh UI EMapGrd.DataContext = null; EMapGrd.DataContext = emap; if (emap.MapType == EngineeringMapType.FootPrintMap) { EMapTypeCB.SelectedIndex = 0; } else if (emap.MapType == EngineeringMapType.GeneralProfileMap) { EMapTypeCB.SelectedIndex = 1; } else if (emap.MapType == EngineeringMapType.Map3D) { EMapTypeCB.SelectedIndex = 2; } }
U3DView Load3DModel(string fname) { // new a engineering map for U3DView EngineeringMap map = new EngineeringMap(); map.LocalMapFileName = fname; // add 3d view - unitywebplayer U3DView u3DView = new U3DView(new Project() { projDef = _prjDef }, map); // Add listener to get layers in 3D model u3DView.UnityLayerHanlder += UnityLayerListener; u3DView.view.loadPredefinedLayers(); return(u3DView); }
private async void RemoveEMap_Click(object sender, RoutedEventArgs e) { EngineeringMap emap = EMapsLB.SelectedItem as EngineeringMap; if (emap == null) { return; } // Update project definition _projDef.EngineeringMaps.Remove(emap); // Refresh UI EMapsLB.Items.Remove(emap); EMapGrd.DataContext = null; // Refresh map await ReloadMap(null); }
private async void AddEMap_Click(object sender, RoutedEventArgs e) { // new emap EngineeringMap emap = new EngineeringMap(); emap.MapID = "Map" + _projDef.EngineeringMaps.Count.ToString(); emap.MapType = EngineeringMapType.FootPrintMap; // update project definition _projDef.EngineeringMaps.Add(emap); // refresh UI EMapsLB.Items.Add(emap); EMapsLB.SelectedItem = emap; EMapGrd.DataContext = null; EMapGrd.DataContext = emap; // refresh map await ReloadMap(emap); }
private void NewWindowBtn_Click(object sender, RoutedEventArgs e) { Application curApp = Application.Current; Window mainWindow = curApp.MainWindow; EditEMapWindow window = new EditEMapWindow(_mainFrame, null); window.Owner = mainWindow; Nullable <bool> result = window.ShowDialog(); if (result == true) { EngineeringMap eMap = _mainFrame.ActiveSubProject.NewUserEMap("Default", EngineeringMapType.FootPrintMap); eMap.CopyFrom(window.EMap); _mainFrame.AddView(eMap, true); } }
public ProfileView(MainFrame mainFrame, Project prj, EngineeringMap eMap) { InitializeComponent(); _mainFrame = mainFrame; _view = new IS3ProfileView(this, MyMapView); _view.prj = prj; _view.eMap = eMap; MyProgressBar.DataContext = _view; GotFocus += ProfileView_GotFocus; MyDrawToolControl.drawToolClickEventHandler += _view.drawToolsClickEventListener; MyDrawToolControl.drawToolClickEventHandler += (o, e) => { if (e.stopDraw) { DrawStrip.Visibility = Visibility.Collapsed; } }; }