private void NewMap(string[] tablePaths) { // Create a new list of tables to hold the tables that need to be mapped. List <ITable> tablelist = new List <ITable>(); // Loop through each table and open it. foreach (string tablepath in tablePaths) { // Open the table Table table = (Table)Table.OpenTable(tablepath); // Add the table to the list. tablelist.Add(table); } // Set the next document parent to the map panel on the form. this.mapPanel.SetAsNextDocumentParent(NextDocumentEnum.WIN_STYLE_CHILD); // Map all the tables in the list. map = MapWindow.MapTables(tablelist); // Now that there is a map, enable the Zoom In and Zoom Out buttons this.buttonZoomIn.Enabled = true; this.buttonZoomOut.Enabled = true; }
public MeasuredDirectGeodInput(MapWindow mw, DirectGeodTaskControl gc) { InitializeComponent(); mainWindow = mw; geodControl = gc; }
private void OnMapElementClick(MapControl sender, MapElementClickEventArgs args) { var mapicon = args.MapElements.FirstOrDefault(x => x is MapIcon) as MapIcon; if (mapicon != null) { if (!IsPetWindowVisible) { if (PetWindow == null) { PetWindow = new MapWindow(Pet); } var position = new BasicGeoposition { Latitude = Pet.Latitude, Longitude = Pet.Longitude }; var point = new Geopoint(position); NativeMap.Children.Add(PetWindow); MapControl.SetLocation(PetWindow, point); MapControl.SetNormalizedAnchorPoint(PetWindow, new Windows.Foundation.Point(0.5, 1.0)); IsPetWindowVisible = true; } else { NativeMap.Children.Remove(PetWindow); IsPetWindowVisible = false; } } }
//METODO PARA MOSTRAR EL RECUADRO CON LA INFO DE LA GASOLINERA EN EL MAPA, AL DAR CLICK AL PIN private void OnMapElementClick(MapControl sender, MapElementClickEventArgs args) { var mapicon = args.MapElements.FirstOrDefault(x => x is MapIcon) as MapIcon; if (mapicon != null) { if (!IsFuelStationWindowVisible) { //MANDA LOS DATOS DE LA GASOLINERA AL MAPWINDOW PARA MOSTRAR EL RECUEADRO CON LA INFO if (FuelStationWindow == null) { FuelStationWindow = new MapWindow(FuelStation); } var position = new BasicGeoposition { Latitude = FuelStation.Latitude, Longitude = FuelStation.Longitude }; var point = new Geopoint(position); NativeMap.Children.Add(FuelStationWindow); MapControl.SetLocation(FuelStationWindow, point); MapControl.SetNormalizedAnchorPoint(FuelStationWindow, new Windows.Foundation.Point(0.5, 1.0)); IsFuelStationWindowVisible = true; } else { NativeMap.Children.Remove(FuelStationWindow); IsFuelStationWindowVisible = false; } } }
public static void Initialize() { // Initialize game window, set's the Global.CurrentScreen var gameWindow = new GameWindow(Constants.GameWindowWidth, Constants.GameWindowHeight); Add(gameWindow); // Initialize map var map = new MapWindow(Constants.Map.Width, Constants.Map.Height); Add(map); map.Initialize(); // Initialize dialog window var dialogWindow = new DialogWindow(Constants.Map.Width, 6); Add(dialogWindow); // Initialize game over window var gameOverWindow = new GameOverWindow(Constants.GameWindowWidth, Constants.GameWindowHeight); Add(gameOverWindow); // Initialize inventory var inventory = new InventoryWindow(Constants.GameWindowWidth / 3, 15); Add(inventory); inventory.Initialize(); var fovWindow = new FovWindow(Constants.GameWindowWidth / 3, 12); Add(fovWindow); IsInitialized = true; }
/// <summary> /// Стандартный конструктор. Инициализирует панель рассчёта дистанций /// </summary> /// <param name="w">Ссылка на главное окно с отображаемой картой</param> public DistanceMeasureControl(MapWindow w) { InitializeComponent(); mapWindow = w; // Создаём делегаты mouseLMBHandler = new MouseButtonEventHandler(MouseLMBDown); mouseRMBHandler = new MouseButtonEventHandler(MouseRMBDown); // Подписываем их на соответствующие события в главном окне mapWindow.MainPanel.MouseLeftButtonDown += mouseLMBHandler; mapWindow.MainPanel.MouseRightButtonDown += mouseRMBHandler; // Инициализируем DistanceLine, добавляем её на главную панель distanceViewer = new DistanceLine(mapWindow.MapPanel, FIRST_MARKER_BRUSH, SECOND_MARKER_BRUSH); distanceViewer.Hide(); // Инициализируем PointMarker-ы, добавляем их на главную панель firstPointMarker = new PointMarker(mapWindow.MapPanel, 0, 0); firstPointMarker.SetStrokeColor(FIRST_MARKER_BRUSH); firstPointMarker.Hide(); secondPointMarker = new PointMarker(mapWindow.MapPanel, 0, 0); secondPointMarker.SetStrokeColor(SECOND_MARKER_BRUSH); secondPointMarker.Hide(); rmbMenu = this.FindResource("rmbMenu") as ContextMenu; rmbMenu.PlacementTarget = mapWindow.MainPanel; mapWindow.SetStatus("Включён режим: \"Измерение расстояний\""); }
private static void CreateRadarWindow() { if (_radarWindow == null) { Logger.Debug("Loading MapUI"); _radarWindow = new MapWindow(); DataModel.PropertyChanged += (sender, args) => { if (args.PropertyName == "IsRadarWindowVisible") { if (DataModel.IsRadarWindowVisible) { _radarWindow.Show(); } else { _radarWindow.Hide(); } } }; _radarWindow.Closed += (a, b) => { DataModel.IsRadarWindowVisible = false; _radarWindow = null; }; } }
public async Task UpdateViewAsync(Engine engine, EngineInput input, CancellationToken token) { // Re-sync the screen bool forceRefresh = await SyncScreenDimensionsAsync() || input == EngineInput.RefreshView; // Process input to re-center map switch (input) { case EngineInput.ModifiedDirectionUp: case EngineInput.ModifiedDirectionUpRight: case EngineInput.ModifiedDirectionRight: case EngineInput.ModifiedDirectionDownRight: case EngineInput.ModifiedDirectionDown: case EngineInput.ModifiedDirectionDownLeft: case EngineInput.ModifiedDirectionLeft: case EngineInput.ModifiedDirectionUpLeft: MoveMapCamera((Direction)((int)input - (int)EngineInput.ModifiedDirectionUp)); break; case EngineInput.ModifiedDirectionCenter: CenterMapCamera(engine.Game.Player.X, engine.Game.Player.Y); break; } // Move camera to keep player on screen var playerBounds = MapWindow.Shift(MapCameraXOffset, MapCameraYOffset).ResizeFromCenter(-1); if (playerBounds.GetRectPart(engine.Game.Player.X, engine.Game.Player.Y) != RectPart.Inside) { // TODO: Centering on player is aggressive but fine for now, replace with smoother pan CenterMapCamera(engine.Game.Player.X, engine.Game.Player.Y); } if (forceRefresh) { await ClearScreenAsync(); } foreach ((int screenX, int screenY) in GetScreenCoordinatesEnumerable()) { T?oldTile = TileBuffer[screenX, screenY]; T?newTile = null; if (MapWindow.Contains(screenX, screenY)) { // Get map tile int mapX = screenX - MapWindow.X + MapCameraXOffset; int mapY = screenY - MapWindow.Y + MapCameraYOffset; newTile = engine.Game.WorldMap.Contains(mapX, mapY) ? GetMapTile(engine.Game.WorldMap[mapX, mapY], engine.Game.Creatures[mapX, mapY]?.Type) : null; } if (forceRefresh || (oldTile is not null && !oldTile.Equals(newTile)) || (newTile is not null && !newTile.Equals(oldTile))) { TileBuffer[screenX, screenY] = newTile; await DrawScreenTileAsync(screenX, screenY); } } }
private void OnOpenMap() { var window = new MapWindow(_model.BleSystemConfiguration); _eventMapper.TransmitterSignalDiscovered += s => window.HandleDiscoveryEvent(s.BleReceiver, s.Transmitter.MacAddress, s.Distance); _eventMapper.TransmitterPositionDiscovered += window.HandleTransmitterLocationEvent; window.Show(); }
public void MapButton() { SoundManager.Click(); MapWindow map = GameHUD.instance.mainMenu.mapWindow; MapWindow.UpdateTexture(map.miniMap.GetComponent <Image> (), Vector2.one / 2); GameHUD.instance.mainMenu.mapWindow.gameObject.SetActive(true); gameObject.SetActive(false); }
public void OnGeoLocationUpdate(string latitude, string longitude) { currentCountdownUntilThrowingError.Abort(); removeSelfFromAllEventHandlerList(); Stations nearestStations = transport.GetStationsByLocation(latitude, longitude); mapWindow = new MapWindow(nearestStations.StationList); mapWindow.Show(); }
/// <summary> /// Once the parameters have been configured the Execute command can be called, it returns true if succesful /// </summary> public bool Execute(MapWindow.Tools.ICancelProgressHandler cancelProgressHandler) { MapWindow.Data.IFeatureSet self=_inputParam[0].Value as MapWindow.Data.IFeatureSet; //self.FillAttributes(); MapWindow.Data.IFeatureSet output = _outputParam[0].Value as MapWindow.Data.IFeatureSet; return Execute(self, output, cancelProgressHandler); }
/// <summary> /// creates a new form /// </summary> /// <param name="IMapWin">reference to the current MapWindow /// GIS application (implements IMapWin interface)</param> public frmShapefile(MapWindow.Interfaces.IMapWin IMapWin) { //called by the winforms designer InitializeComponent(); //set global variables and initial appearance m_MapWin = IMapWin; populateLayers(); }
public Engine(MapWindow mapWindow) { MapWindow = mapWindow; Generator = mapWindow.Generator; Player = new World.Player(this); KeyboardInput = new KeyboardInput(this); Camera = new Camera(this); MiniMap = new MiniMap(new Vector(200, 200), this); }
public void CalculateRoute() { if (ValidateLocations()) { string from = SelectedGebruiker.Postcode + ", " + SelectedGebruiker.Huisnummer; string to = this.PostCode + ", " + this.huisnummer; Window window = new MapWindow(from, to, SelectedGebruiker.Naam); window.Owner = Application.Current.MainWindow; window.Show(); } }
public MainWindow() { InitializeComponent(); var mapWindow = new MapWindow { DataContext = DataContext }; mapWindow.Show(); Closed += (s, e) => mapWindow.Close(); }
// Creates a window that encloses a map console // of a specified height and width // and displays a centered window title // make sure it is added as a child of the UIManager // so it is updated and drawn public void CreateMapWindow(int width, int height, string title) { MapWindow = new MapWindow(width, height, title); // The MapWindow becomes a child console of the UIManager Children.Add(MapWindow); // Add the map console to it MapWindow.CreateMapConsole(); // Without this, the window will never be visible on screen MapWindow.Show(); }
public MudClientForm( CancellationToken cancellationToken, ConnectionClientProducer connectionClientProducer) { _connectionClientProducer = connectionClientProducer; _cancellationToken = cancellationToken; InitializeComponent(); this.KeyPreview = true; DevViewForm = new DevViewForm(); StatusForm = new StatusForm(); MapWindow = new MapWindow(); _aliases.LoadAliases(); }
static void Create() { // Get existing open window or if none, make a new one: MapWindow window = (MapWindow)EditorWindow.GetWindow(typeof(MapWindow)); window.place = FindObjectOfType <SearchPlace>(); if (window.place == null) { SearchPlace search = new GameObject("Searcher").AddComponent <SearchPlace>(); window.place = search; } window.Init(); window.Show(); }
protected override void DoHide() { if (this.mapWindow != null && this.mapWindow.IsActive) { this.mapWindow.Hide(); this.mapWindow = null; } this.menuImpl.Hide(); this.menuImpl.Reset(); if (this.pauseTag != null) { this.pauseTag.Release(); this.pauseTag = null; } EventListener.GamePause(false); // Invoke custom event }
// Display the File Open dialog to let the user choose table(s) to open. private void openToolStripMenuItem_Click(object sender, EventArgs e) { // Prompt the user to open one or more TAB files if (OpenDlg.ShowDialog(this) == DialogResult.OK) { // Close window and tables, if they exist if (map != null) { map.CloseWindow(); CloseAllTables(); map = null; } // Create a new map NewMap(OpenDlg.FileNames); // Enable the tool picker comboBoxMapTool.Enabled = true; } }
private void Maptable(ITable table) { if (map != null) { // Close the exsiting map window. this.CloseWindow(map); } this.mapPanel.SetAsNextDocumentParent(NextDocumentEnum.WIN_STYLE_CHILD); map = MapWindow.MapTable(table); MapInformation.SelectedObject = map; this.comboBoxMapTool.Enabled = true; this.comboBox1.Enabled = true; this.buttonZoomIn.Enabled = true; this.buttonZoomOut.Enabled = true; }
protected override bool DoShow(MenuScreen <PauseMenu> previous) { if (base.Owner._mapWindow.CanShow(base.Owner.currEnt)) { MapWindow pooledWindow = OverlayWindow.GetPooledWindow <MapWindow>(base.Owner._mapWindow); pooledWindow.Show(base.Owner.currEnt, null, new EntityOverlayWindow.OnDoneFunc(this.ClickedBack), null); GuiSelectionHandler component = base.Owner.GetComponent <GuiSelectionHandler>(); if (component != null) { component.enabled = false; } base.Owner.mapWindow = pooledWindow; } else { Debug.LogWarning("No map for " + Utility.GetCurrentSceneName()); base.SwitchToBack(); } return(false); }
/// <summary> /// Creates a new form object for setting properties of the /// new grid /// </summary> /// <param name="IMapWin">The MapWindow interface</param> /// <param name="shpFileName">File name of the shapefile</param> /// <param name="fieldType">Type of field containing data</param> public frmGrid(MapWindow.Interfaces.IMapWin IMapWin, string shpFileName, MapWinGIS.FieldType fieldType) { InitializeComponent(); //setup event handler this.txtCellSize.TextChanged += new EventHandler(txtCellSize_TextChanged); //initialize the global variables and default values m_MapWin = IMapWin; m_ShpFileName = shpFileName; m_FieldType = fieldType; m_DefaultCellSize = calcDefaultCellsize(); m_DefaultNodataValue = -9999F; m_GridHeader = new MapWinGIS.GridHeader(); //populate the combo boxes populateGridList(); populateExtentLayers(); populateDataTypes(); populateFileTypes(); }
/// <summary> /// Executes the Union Opaeration tool programaticaly /// </summary> /// <param name="input">The input are feature sets</param> /// <param name="output">The output feature set</param> /// <param name="CancelProgressHandler">The progress handler</param> /// <returns></returns> public bool Execute(IFeatureSet self, IFeatureSet output, MapWindow.Tools.ICancelProgressHandler cancelProgressHandler) { //Validates the input and output data if (self == null || self.Features == null || self.Features.Count == 0 || output == null) { return false; } IFeature result = self.Features[0]; MapWindow.Main.ProgressMeter pm = new MapWindow.Main.ProgressMeter(cancelProgressHandler, "Unioning Shapes", self.Features.Count); for(int i = 1; i < self.Features.Count; i++) { if (self.Features[i] == null) continue; result = result.Union(self.Features[i]); pm.CurrentValue = i; } pm.Reset(); output.Features.Add(result); output.SaveAs(output.Filename, true); return true; }
bool IsFuelStationWindowVisible = false; //SI EL CUADRO ESTA VISIBLE //LIMPIA LA INFORMACION QUE TENIA POR DEFECTO PARA CENTRAR EL MAPA Y EL PIN PERSONALIZADO protected override void OnElementChanged(ElementChangedEventArgs <Map> e) { base.OnElementChanged(e); if (e.OldElement != null) { NativeMap.MapElementClick -= OnMapElementClick; NativeMap.Children.Clear(); NativeMap = null; FuelStationWindow = null; } if (e.NewElement != null) { this.FuelStation = (e.NewElement as MyMap).FuelStation; var formsMap = (MyMap)e.NewElement; NativeMap = Control as MapControl; NativeMap.Children.Clear(); NativeMap.MapElementClick += OnMapElementClick; //POSICION DEL PIN var position = new BasicGeoposition { Latitude = FuelStation.Latitude, Longitude = FuelStation.Longitude }; var point = new Geopoint(position); //ATRIBUTOS DE NUESTRO MAPICON, SU FILEPATH, LOCACION, ANCHURA, ETC. var mapIcon = new MapIcon(); mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///pin.png")); mapIcon.CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible; mapIcon.Location = point; mapIcon.NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0); NativeMap.MapElements.Add(mapIcon); } }
/// <summary> /// Evento ao clicar no botão de exibição em mapa /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnShowInMap_Click(object sender, RoutedEventArgs e) { //Verificando se ha um cliente selecionado para exibição if (dgUsuarios.SelectedItems.Count > 0) { //Verificando conexao com internet if (!isNetWorkConnection()) { MessageBox.Show( "Você precisa estar conectado a internet para usar esse recurso!", "Erro de Conexão!", MessageBoxButton.OK, MessageBoxImage.Error ); return; } //Recuperando dados do cliente selecionado Employe source = dgUsuarios.SelectedItem as Employe; Employe employe = dao.GetEmployeData(source.id); //Construindo string de endereço employe string location = $"{employe.adress.street}, {employe.adress.number} {employe.adress.neighborhood}, {employe.adress.city}-{employe.adress.UF}"; //Enviando dados e iniciando exibição em mapa MapWindow window = new MapWindow(location); window.Show(); } else { MessageBox.Show( "Selecione um registro para visualizar no mapa!", "Aviso!", MessageBoxButton.OK, MessageBoxImage.Warning ); } }
private void OpenWorldWorkSpace() { if (map != null) { map.CloseWindow(); this.CloseAllTables(); } this.mapPanel.SetAsNextDocumentParent(NextDocumentEnum.WIN_STYLE_CHILD); // Open the workspace that contains the world table. worldworkspace = WorldWorkspace.Open(); this.TabInfoGrid.SelectedObject = worldworkspace.WorldTable; // Get the front map window. map = MapWindow.GetFrontWindow(); this.comboBoxMapTool.Enabled = true; this.comboBox1.Enabled = true; this.buttonZoomIn.Enabled = true; this.buttonZoomOut.Enabled = true; }
protected override void OnElementChanged(ElementChangedEventArgs <Map> e) { base.OnElementChanged(e); if (e.OldElement != null) { NativeMap.MapElementClick -= OnMapElementClick; NativeMap.Children.Clear(); NativeMap = null; PetWindow = null; } if (e.NewElement != null) { this.Pet = (e.NewElement as MyMap).Pet; var formMap = (MyMap)e.NewElement; NativeMap = Control as MapControl; NativeMap.Children.Clear(); NativeMap.MapElementClick += OnMapElementClick; var position = new BasicGeoposition { Latitude = Pet.Latitude, Longitude = Pet.Longitude }; var point = new Geopoint(position); var mapicon = new MapIcon(); mapicon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///pin.png")); mapicon.CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible; mapicon.Location = point; mapicon.NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0); NativeMap.MapElements.Add(mapicon); } }
public void StartGame(bool testGame = false) { IsFocused = true; GameLoop.World = new World(testGame); // Hides the main menu, so that it's possible to interact with the other windows. MainMenu.Hide(); //Message Log initialization MessageLog = new MessageLogWindow(GameLoop.GameWidth / 2, GameLoop.GameHeight / 2, "Message Log"); Children.Add(MessageLog); MessageLog.Show(); MessageLog.Position = new Point(GameLoop.GameWidth / 2, GameLoop.GameHeight / 2); #if DEBUG MessageLog.Add("Test message log works"); #endif // Inventory initialization InventoryScreen = new InventoryWindow(GameLoop.GameWidth / 2, GameLoop.GameHeight / 2, "Inventory Window"); Children.Add(InventoryScreen); InventoryScreen.Hide(); InventoryScreen.Position = new Point(GameLoop.GameWidth / 2, 0); StatusConsole = new StatusWindow(GameLoop.GameWidth / 2, GameLoop.GameHeight / 2, "Status Window"); Children.Add(StatusConsole); StatusConsole.Position = new Point(GameLoop.GameWidth / 2, 0); StatusConsole.Show(); // Build the Window CreateMapWindow(GameLoop.GameWidth / 2, GameLoop.GameHeight, "Game Map"); // Then load the map into the MapConsole MapWindow.LoadMap(GameLoop.World.CurrentMap); // Start the game with the camera focused on the player MapWindow.CenterOnActor(GameLoop.World.Player); }
public static void Initialize() { // Initialize game window, set's the Global.CurrentScreen var gameWindow = new UserInterface.Windows.GameWindow(Constants.GameWindowWidth, Constants.GameWindowHeight); Interfaces.Add(gameWindow); // Initialize map var map = new MapWindow(Constants.Map.Width, Constants.Map.Height); Interfaces.Add(map); map.Initialize(); // Initializing Inventory window var inventory = new InventoryWindow(Constants.GameWindowWidth / 3, 15); Interfaces.Add(inventory); inventory.Initialize(); // Initialize dialog window var dialogWindow = new DialogWindow(Constants.GameWindowWidth / 2, 5); Interfaces.Add(dialogWindow); }
void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (mapWindow != null) { mapWindow.Close(); mapWindow = null; } }
private void CloseWindow(MapWindow mapToClose) { mapToClose.CloseWindow(); }
private void mapButton_Click(object sender, RoutedEventArgs e) { if (mapWindow == null) { mapButton.IsEnabled = false; mapWindow = new MapWindow(); mapWindow.Closing += new System.ComponentModel.CancelEventHandler(mapWindow_Closing); mapWindow.Show(); // we do it after "Show" to ensure that we override default mapper and that the Draw is enabled: mapWindow.mapperViewControl1.CurrentMapper = mapperVicinity; mapWindow.mapperViewControl1.CurrentRoutePlanner = routePlanner; } }
void MapFrame_LayerSelected(object sender, MapWindow.Main.LayerSelectedEventArgs e) { if (e.IsSelected == false && e.Layer == _activeLayer) { if (_moveVertexFunction != null) _moveVertexFunction.UnSelectFeature(); return; } IFeatureLayer fl = e.Layer as IFeatureLayer; _activeLayer = null; if (fl == null) return; _activeLayer = fl; if (_moveVertexFunction == null) return; _moveVertexFunction.UnSelectFeature(); _moveVertexFunction.Layer = fl; }
/// <summary> /// Executes the Erase Opaeration tool programaticaly /// </summary> /// <param name="input1">The input raster</param> /// <param name="input2">The input raster</param> /// <param name="output">The output raster</param> /// <param name="cancelProgressHandler">The progress handler</param> /// <returns></returns> public bool Execute(IRaster input1, IRaster input2, IRaster output, MapWindow.Tools.ICancelProgressHandler cancelProgressHandler) { //Validates the input and output data if (input1 == null || input2 == null || output == null) { return false; } IEnvelope envelope = new Envelope() as IEnvelope; envelope = UnionEnvelope(input1, input2); int noOfCol; int noOfRow; //Figures out which raster has smaller cells IRaster smallestCellRaster; if (input1.CellWidth < input2.CellWidth) smallestCellRaster = input1; else smallestCellRaster = input2; //Given the envelope of the two rasters we calculate the number of columns / rows noOfCol = Convert.ToInt32(Math.Abs(envelope.Width / smallestCellRaster.CellWidth)); noOfRow = Convert.ToInt32(Math.Abs(envelope.Height / smallestCellRaster.CellHeight)); //Create the new raster with the appropriate dimensions Raster Temp = new Raster(); //Temp.CreateNew(output.Filename, noOfRow, noOfCol, input1.DataType); Temp.CreateNew(output.Filename, "", noOfCol, noOfRow, 1, input1.DataType, new string[] { "" }); Temp.CellWidth = smallestCellRaster.CellWidth; Temp.CellHeight = smallestCellRaster.CellHeight; Temp.Xllcenter = envelope.Minimum.X + (Temp.CellWidth / 2); Temp.Yllcenter = envelope.Minimum.Y + (Temp.CellHeight / 2); MapWindow.Geometries.ICoordinate I1 = new MapWindow.Geometries.Coordinate() as MapWindow.Geometries.ICoordinate; RcIndex v1 = new RcIndex(); RcIndex v2 = new RcIndex(); double val1; double val2; int previous=0; int current=0; int max = (Temp.Bounds.NumRows + 1); for (int i = 0; i < Temp.Bounds.NumRows; i++) { for (int j = 0; j < Temp.Bounds.NumColumns; j++) { I1 = Temp.CellToProj(i, j); v1 = input1.ProjToCell(I1); if (v1.Row <= input1.EndRow && v1.Column <= input1.EndColumn && v1.Row > -1 && v1.Column > -1) val1 = input1.Value[v1.Row, v1.Column]; else val1 = input1.NoDataValue; v2 = input2.ProjToCell(I1); if (v2.Row <= input2.EndRow && v2.Column <= input2.EndColumn && v2.Row > -1 && v2.Column > -1) val2 = input2.Value[v2.Row, v2.Column]; else val2 = input2.NoDataValue; if (val1 == input1.NoDataValue && val2 == input2.NoDataValue) { Temp.Value[i, j] = Temp.NoDataValue; } else if (val1 != input1.NoDataValue && val2 == input2.NoDataValue) { Temp.Value[i, j] = val1; } else if (val1 == input1.NoDataValue && val2 != input2.NoDataValue) { Temp.Value[i, j] = val2; } else { Temp.Value[i, j] = val1; } if (cancelProgressHandler.Cancel == true) return false; } current = Convert.ToInt32(Math.Round(i * 100D / max)); //only update when increment in persentage if(current>previous) cancelProgressHandler.Progress("", current, current.ToString() + "% progress completed"); previous = current; } output = Temp; output.Save(); return true; }
/// <summary> /// Executes the threshold operation /// </summary> /// <param name="input1">The input raster</param> /// <param name="threshold">The threshold value</param> /// <param name="output">The output raster</param> /// <param name="cancelProgressHandler">The progress handler</param> /// <returns></returns> public bool Execute(IRaster input, double threshold, IRaster output, MapWindow.Tools.ICancelProgressHandler cancelProgressHandler) { //Validates the input and output data if (input == null || output == null) { return false; } int noOfCol=input.NumColumns; int noOfRow=input.NumRows; int previous = 0; int current = 0; //Create the new raster with the appropriate dimensions output = Raster.Create(output.Filename, "", noOfCol, noOfRow,1 , typeof(int), new string[] { "" }); output.CellWidth = input.CellWidth; output.CellHeight = input.CellHeight; output.Xllcenter = input.Xllcenter; output.Yllcenter = input.Yllcenter; output.NoDataValue = -1; //Loop throug every cell int max = (output.Bounds.NumRows + 1); for (int i = 0; i < output.NumRows; i++) { for (int j = 0; j < output.NumColumns; j++) { if (input.Value[i, j] == input.NoDataValue) output.Value[i,j] = -1; else if (input.Value[i, j] >= threshold) output.Value[i,j] = 1; else output.Value[i,j] = 0; if (cancelProgressHandler.Cancel == true) return false; } //only update when increment in persentage current = Convert.ToInt32(Math.Round(i * 100D / max)); if (current > previous) cancelProgressHandler.Progress("", current, current.ToString() + "% progress completed"); previous = current; } output.Save(); return true; }
void mapWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { mapButton.IsEnabled = true; mapWindow = null; }
/// <summary> /// Executes the slope generation raster. /// </summary> /// <param name="ras">The input altitude raster.</param> /// <param name="output">The output slope raster.</param> /// <param name="cancelProgressHandler">The progress handler.</param> /// <returns></returns> public bool Execute(IRaster ras,double inZFactor, bool slopeInPercent,IRaster output, MapWindow.Tools.ICancelProgressHandler cancelProgressHandler) { //Validates the input and output data if (ras == null || output == null) { return false; } double z1, z2, z3, z4, z5, z6, z7, z8, dZ_dx, dZ_dy, slope; int current, previous; try { int noOfCol = ras.NumColumns; int noOfRow = ras.NumRows; IEnvelope envelope1 = new Envelope() as IEnvelope; envelope1 = ras.Bounds.Envelope; output = Raster.Create(output.Filename, "", noOfCol, noOfRow, 1, typeof(double), new string[] { "" }); output.NoDataValue = ras.NoDataValue; //output.Bounds = ras.Bounds.Copy(); output.Bounds = ras.Bounds; previous = 0; for (int i = 0; i < output.NumRows; i++) { current = Convert.ToInt32(Math.Round(i * 100D / output.NumRows)); //only update when increment in percentage if (current > previous) cancelProgressHandler.Progress("", current, current.ToString() + TextStrings.progresscompleted); previous = current; for (int j = 0; j < output.NumColumns; j++) { if (i > 0 && i < output.NumRows - 1 && j > 0 && j < output.NumColumns - 1) { z1 = ras.Value[i - 1, j - 1]; z2 = ras.Value[i - 1, j]; z3 = ras.Value[i - 1, j + 1]; z4 = ras.Value[i, j - 1]; z5 = ras.Value[i, j + 1]; z6 = ras.Value[i + 1, j - 1]; z7 = ras.Value[i + 1, j]; z8 = ras.Value[i + 1, j + 1]; //3rd Order Finite Difference slope algorithm dZ_dx = inZFactor * ((z3 - z1) + 2 * (z5 - z4) + (z8 - z6)) / (8 * ras.CellWidth); dZ_dy = inZFactor * ((z1 - z6) + 2 * (z2 - z7) + (z3 - z8)) / (8 * ras.CellHeight); slope = Math.Atan(Math.Sqrt((dZ_dx * dZ_dx) + (dZ_dy * dZ_dy))) * (180 / Math.PI); //change to radious and in persentage if (slopeInPercent) slope = (Math.Tan(slope * Math.PI / 180)) * 100; output.Value[i, j] = slope; if (cancelProgressHandler.Cancel == true) return false; } else output.Value[i, j] = output.NoDataValue; if (cancelProgressHandler.Cancel == true) return false; } } //output = Temp; if (output.IsFullyWindowed()) { output.Save(); return true; } else return false; } catch (Exception ex) { //throw new SystemException("Error in Slope: ", ex); throw new SystemException(ex.ToString()); } }
public ChangeProgramMode(MapWindow w) { InitializeComponent(); mapWindow = w; }
/// <summary> /// Creates a new image given the specified file format /// </summary> /// <param name="filename"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="inRam"></param> /// <param name="progHandler"></param> /// <returns></returns> public IImageData Create(string filename, int width, int height, bool inRam, MapWindow.Main.IProgressHandler progHandler) { throw new NotImplementedException(); }
/// <summary> /// Executes the Erase Opaeration tool programaticaly. /// </summary> /// <param name="input1">The input raster.</param> /// <param name="input2">The input raster.</param> /// <param name="output">The output raster.</param> /// <param name="cancelProgressHandler">The progress handler.</param> /// <returns></returns> public bool Execute(IRaster input1, IFeatureSet input2, IRaster output, MapWindow.Tools.ICancelProgressHandler cancelProgressHandler) { //Validates the input and output data if (input1 == null || input2 == null || output == null) { return false; } int noOfCol = input1.NumColumns; int noOfRow = input1.NumRows; //Calculate the Intersect Envelope IEnvelope envelope1 = new Envelope() as IEnvelope; IEnvelope envelope2 = new Envelope() as IEnvelope; envelope1 = input1.Bounds.Envelope; envelope2 = input2.Envelope; envelope1 = envelope1.Intersection(envelope2); //Create the new raster with the appropriate dimensions IRaster Temp = Raster.Create(output.Filename, "", noOfCol, noOfRow, 1, input1.DataType, new string[] { }); //Temp.CreateNew(output.Filename, noOfRow, noOfCol, input1.DataType); Temp.CellWidth = input1.CellWidth; Temp.CellHeight = input1.CellHeight; Temp.Xllcenter = envelope1.Minimum.X + (Temp.CellWidth / 2); Temp.Yllcenter = envelope1.Minimum.Y + (Temp.CellHeight / 2); MapWindow.Geometries.ICoordinate I1 = new MapWindow.Geometries.Coordinate() as MapWindow.Geometries.ICoordinate; RcIndex v1 = new RcIndex(); // MapWindow.Analysis.Topology.Algorithm.PointLocator pointLocator1 = new MapWindow.Analysis.Topology.Algorithm.PointLocator(); double val1; int previous = 0; int current = 0; int max = (Temp.Bounds.NumRows + 1); for (int i = 0; i < Temp.Bounds.NumRows; i++) { for (int j = 0; j < Temp.Bounds.NumColumns; j++) { I1 = Temp.CellToProj(i, j); v1 = input1.ProjToCell(I1); if (v1.Row <= input1.EndRow && v1.Column <= input1.EndColumn && v1.Row > -1 && v1.Column > -1) val1 = input1.Value[v1.Row, v1.Column]; else val1 = Temp.NoDataValue; //test if the coordinate is inside of the polygon bool isInside = false; IFeature pointFeat = new Feature(new Point(I1)) as IFeature; foreach (IFeature f in input2.Features) { if (f.Contains(pointFeat)) { Temp.Value[i, j] = val1; isInside = true; break; } } if (isInside == false) { Temp.Value[i, j] = Temp.NoDataValue; } if (cancelProgressHandler.Cancel == true) return false; } current = Convert.ToInt32(Math.Round(i * 100D / max)); //only update when increment in percentage if (current > previous) cancelProgressHandler.Progress("", current, current.ToString() + "% progress completed"); previous = current; } output = Temp; output.Save(); return true; }
public ShapeGridInfo(MapWindow.Interfaces.IMapWin IMapWin) { m_MapWin = IMapWin; shapeForm = new frmShapefile(m_MapWin); }
private void btnOK_Click(object sender, EventArgs e) { CustomVectorField NewVF; if (tmpargs.VectorField == null) { NewVF = new CustomVectorField(); } else { NewVF = tmpargs.VectorField; } NewVF.koeff = double.Parse(textBoxK.Text); if ((NewVF.koeff > 1.0) || (NewVF.koeff <= 0.0)) { PetrelLogger.ErrorBox("Коэффициент не может быть больше 1 или меньше 0!"); return; } NewVF.gridStep = double.Parse(textBoxStep.Text); NewVF.partition = int.Parse(textBoxN.Text); NewVF.haveGrid = (comboBox1.SelectedItem.Text == "Да"); NewVF.arrowColor = colorPicker1.Color;; NewVF.originX = tmpargs.HeiField.SpatialLattice.OriginalLattice.Single.OriginX; NewVF.originY = tmpargs.HeiField.SpatialLattice.OriginalLattice.Single.OriginY; int sizeI = tmpargs.HeiField.SpatialLattice.OriginalLattice.Single.SizeI, sizeJ = tmpargs.HeiField.SpatialLattice.OriginalLattice.Single.SizeJ; double maxval = 0.0, spacingI = tmpargs.HeiField.SpatialLattice.OriginalLattice.Single.SpacingI, spacingJ = tmpargs.HeiField.SpatialLattice.OriginalLattice.Single.SpacingJ, spaceSizeX = spacingI * (double)sizeI, spaceSizeY = spacingJ * (double)sizeJ; NewVF.sizeX = (int)Math.Floor(spaceSizeX / (double)NewVF.gridStep); NewVF.sizeY = (int)Math.Floor(spaceSizeY / (double)NewVF.gridStep); NewVF.Azimutfieldic = tmpargs.AzField; NewVF.Heigtfieldic = tmpargs.HeiField; double[,] NewHeightSurface = new double[sizeI, sizeJ]; double[,] NewAzimutSurface = new double[sizeI, sizeJ]; foreach (RegularHeightFieldSample prop in tmpargs.HeiField.Samples) { NewHeightSurface[prop.I, prop.J] = prop.Value; } foreach (RegularHeightFieldSample prop in tmpargs.AzField.Samples) { NewAzimutSurface[prop.I, prop.J] = prop.Value; } double[, ,] VectorField = new double[NewVF.sizeX, NewVF.sizeY, 18]; for (int i = 0; i < NewVF.sizeX; i++) { for (int j = 0; j < NewVF.sizeY; j++) { //в каждой ячейке усредняем, берем из нее N значений значений for (int k = 0; k < NewVF.partition; k++) { for (int l = 0; l < NewVF.partition; l++) { int x = (int)Math.Floor(((double)i * NewVF.gridStep + k * NewVF.gridStep / (double)NewVF.partition) / (double)spacingI), y = (int)Math.Floor(((double)j * NewVF.gridStep + l * NewVF.gridStep / (double)NewVF.partition) / (double)spacingJ); VectorField[i, j, 0] += NewHeightSurface[x, y]; VectorField[i, j, 1] += NewAzimutSurface[x, y]; } VectorField[i, j, 0] /= (double)NewVF.partition * (double)NewVF.partition; VectorField[i, j, 1] /= (double)NewVF.partition * (double)NewVF.partition; if (maxval < VectorField[i, j, 0]) { maxval = VectorField[i, j, 0]; } } } } double tan, ctan; for (int i = 0; i < NewVF.sizeX; i++) { for (int j = 0; j < NewVF.sizeY; j++) { VectorField[i, j, 0] /= maxval; tan = Math.Tan(Math.PI / 2.0 - VectorField[i, j, 1]); ctan = 1.0 / Math.Tan(Math.PI / 2.0 - VectorField[i, j, 1]); if (tan > 1.0) { tan = 1.0; } else if (tan < -1.0) { tan = -1.0; } if (ctan > 1.0) { ctan = 1.0; } else if (ctan < -1.0) { ctan = -1.0; } VectorField[i, j, 2] = NewVF.originX + ((i + 0.5 * (1.0 - ctan * NewVF.koeff * VectorField[i, j, 0])) * NewVF.gridStep); VectorField[i, j, 3] = NewVF.originY + ((j + 0.5 * (1.0 - tan * NewVF.koeff * VectorField[i, j, 0])) * NewVF.gridStep); VectorField[i, j, 4] = NewVF.originX + ((i + 0.5 * (1.0 + ctan * NewVF.koeff * VectorField[i, j, 0])) * NewVF.gridStep); VectorField[i, j, 5] = NewVF.originY + ((j + 0.5 * (1.0 + tan * NewVF.koeff * VectorField[i, j, 0])) * NewVF.gridStep); float vx = (float)VectorField[i, j, 4] - (float)VectorField[i, j, 2]; float vy = (float)VectorField[i, j, 5] - (float)VectorField[i, j, 3]; float dist = (float)Math.Sqrt(vx * vx + vy * vy); vx /= dist; vy /= dist; float h = 0.5f * dist; float h1 = 0.35f * dist; float w = h * (float)1 / (float)3.0; float w1 = h1 * (float)1 / (float)10.0; float ox = (float)VectorField[i, j, 4] - h * vx; float oy = (float)VectorField[i, j, 5] - h * vy; float ox1 = (float)VectorField[i, j, 4] - h1 * vx; float oy1 = (float)VectorField[i, j, 5] - h1 * vy; VectorField[i, j, 6] = ox + w * (VectorField[i, j, 3] - VectorField[i, j, 5]) / dist; VectorField[i, j, 7] = oy + w * (VectorField[i, j, 4] - VectorField[i, j, 2]) / dist; VectorField[i, j, 8] = ox - w * (VectorField[i, j, 3] - VectorField[i, j, 5]) / dist; VectorField[i, j, 9] = oy - w * (VectorField[i, j, 4] - VectorField[i, j, 2]) / dist; VectorField[i, j, 10] = ox1 - w1 * (VectorField[i, j, 3] - VectorField[i, j, 5]) / dist; VectorField[i, j, 11] = oy1 - w1 * (VectorField[i, j, 4] - VectorField[i, j, 2]) / dist; VectorField[i, j, 12] = ox1 + w1 * (VectorField[i, j, 3] - VectorField[i, j, 5]) / dist; VectorField[i, j, 13] = oy1 + w1 * (VectorField[i, j, 4] - VectorField[i, j, 2]) / dist; VectorField[i, j, 14] = (float)VectorField[i, j, 2] - w1 * (VectorField[i, j, 3] - VectorField[i, j, 5]) / dist; VectorField[i, j, 15] = (float)VectorField[i, j, 3] - w1 * (VectorField[i, j, 4] - VectorField[i, j, 2]) / dist; VectorField[i, j, 16] = (float)VectorField[i, j, 2] + w1 * (VectorField[i, j, 3] - VectorField[i, j, 5]) / dist; VectorField[i, j, 17] = (float)VectorField[i, j, 3] + w1 * (VectorField[i, j, 4] - VectorField[i, j, 2]) / dist; } } NewVF.VectorField = VectorField; if (tmpargs.VectorField == null) { tmpargs.VectorField = NewVF; using (ITransaction txn = DataManager.NewTransaction()) { Project proj = PetrelProject.PrimaryProject; txn.Lock(proj); proj.Extensions.Add(tmpargs.VectorField); txn.Commit(); } } MapWindow map = PetrelProject.ToggleWindows.Add(WellKnownWindows.Map) as MapWindow; map.ShowObject(tmpargs.HeiField); map.ShowObject(tmpargs.AzField); map.ShowObject(NewVF); this.ParentForm.Close(); }
/// <summary> /// Creates a new form object for setting grid properties /// (field type will be "double" data type) /// </summary> /// <param name="IMapWin"></param> /// <param name="shpFileName"></param> public frmGrid(MapWindow.Interfaces.IMapWin IMapWin, string shpFileName) : this(IMapWin, shpFileName, MapWinGIS.FieldType.DOUBLE_FIELD) { //frmGrid(IMapWin, shpFileName, MapWinGIS.FieldType.DOUBLE_FIELD); }
void Layers_LayerSelected(object sender, MapWindow.Main.LayerSelectedEventArgs e) { SetActiveLayer(e.Layer); }