void MapCanvas_PointerReleased(object sender, PointerRoutedEventArgs e) { Windows.UI.Xaml.Input.Pointer ptr = e.Pointer; // If event source is mouse or touchpad and the pointer is still // over the MapCanvas, retain pointer and pointer details. // Return without removing pointer from pointers dictionary. // For this example, we assume a maximum of one mouse pointer. if (ptr.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Mouse) { // Update MapCanvas UI. // Remove contact from dictionary. if (contacts.ContainsKey(ptr.PointerId)) { contacts[ptr.PointerId] = null; contacts.Remove(ptr.PointerId); --numActiveContacts; } // Release the pointer from the MapCanvas. MapCanvas.ReleasePointerCapture(e.Pointer); // Prevent most handlers along the event route from handling the same event again. e.Handled = true; } else { } }
private void OnMinimapTileDone(object sender, EventArgs e) { MinimapTileReadyArgs args = (MinimapTileReadyArgs)e; // Ensure we're using the correct runner. if (args.RunnerIndex != buildRunnerIndex) { return; } if (canvas == null) { int sizeX = (args.Bounds.HighX - args.Bounds.LowX) + 1; int sizeY = (args.Bounds.HighY - args.Bounds.LowY) + 1; canvas = new MapCanvas(sizeX, sizeY); } int posX = (args.Position.X - args.Bounds.LowX) * 256; int posY = (args.Position.Y - args.Bounds.LowY) * 256; canvas.DrawToCanvas(args.Image, posX, posY); UI_Map.Invalidate(); tileDone++; if (tileTotal > tileDone) { UI_TileDisplay.Text = string.Format(Constants.MAP_VIEWER_TILE_STATUS, tileDone, tileTotal); } else { UI_TileDisplay.Hide(); UI_ExportTip.Show(); } }
//https://docs.microsoft.com/de-de/windows/uwp/input-and-devices/handle-pointer-input // PointerPressed and PointerReleased events do not always occur in pairs. // Your app should listen for and handle any event that might conclude a pointer down action // (such as PointerExited, PointerCanceled, and PointerCaptureLost). // For this example, we track the number of contacts in case the // number of contacts has reached the maximum supported by the device. // Depending on the device, additional contacts might be ignored // (PointerPressed not fired). void MapCanvas_PointerPressed(object sender, PointerRoutedEventArgs e) { Windows.UI.Xaml.Input.Pointer ptr = e.Pointer; // Prevent most handlers along the event route from handling the same event again. e.Handled = true; // Lock the pointer to the MapCanvas. MapCanvas.CapturePointer(e.Pointer); if ((MapModeEnum)MapMode == MapModeEnum.Set) { SetTree(e.GetCurrentPoint(mapImage), e.GetCurrentPoint(MapCanvas)); } if ((MapModeEnum)MapMode == MapModeEnum.Move) { MoveTree(e.GetCurrentPoint(mapImage), e.GetCurrentPoint(MapCanvas)); } // Check if pointer already exists (for example, enter occurred prior to press). if (contacts.ContainsKey(ptr.PointerId)) { return; } // Add contact to dictionary. contacts[ptr.PointerId] = ptr; ++numActiveContacts; }
/// <summary> /// Constructor. /// </summary> public ViewModel(Dispatcher uiDispatcher, string baseContentDir, Isometry iso) { // Reference to the UIDispatcher for thread-safe collection manipulation _uiDispatcher = uiDispatcher; Factions = new ObservableCollection<FactionList> { new FactionList("AI"), new FactionList("Player 1"), new FactionList("Player 2") }; // Map setup Map = new MapDefinition(new ZTile(baseContentDir + "tiles\\Generic Tiles\\Generic Floors\\DirtSand\\Waste_Floor_Gravel_SandDirtCentre_F_1_NE.til"), iso, baseContentDir); MapCanvas = new MapCanvas(Map, uiDispatcher, baseContentDir + "tiles\\", iso, Factions); _useAltEditLayer = false; // Create the available TileSets and collection views TileSets = new Dictionary<string, ObservableCollection<ZTile>>(); TileSetViews = new Dictionary<string, ListCollectionView>(); foreach (var di in new DirectoryInfo(baseContentDir + "tiles\\").GetDirectories()) { TileSets.Add(di.Name, new ObservableCollection<ZTile>()); TileSetViews.Add(di.Name, new ListCollectionView(TileSets[di.Name])); } // Start a new thread to load in the tile images ThreadPool.QueueUserWorkItem(GetWholeTileSet, baseContentDir + "tiles\\"); }
private void InstanceOnInvalidateMap() { if (MapCanvas == null) { return; } MapCanvas.Invalidate(); }
public MapBrowser() { mapCanvas = new MapCanvas(); Global.mapCanvas = mapCanvas; mapCanvas.Dock = DockStyle.Fill; mapCanvas.mainForm = (MainForm)this.ParentForm; InitializeComponent(); }
private void MainPage_OnLoaded(object sender, RoutedEventArgs e) { var display = DisplayInformation.GetForCurrentView(); display.DpiChanged += Display_DpiChanged; Display_DpiChanged(display, null); MapCanvas.Focus(FocusState.Programmatic); SetTheme(); }
//Initialise les modes de rendus des canvas private void Form1_Load(object sender, EventArgs e) { mapG = MapCanvas.CreateGraphics(); tileG = TileCanvas.CreateGraphics(); mapG.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; mapG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; tileG.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; tileG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; }
private void OnPointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { var currentPoint = e.GetCurrentPoint(MapCanvas); HighlightedTile = ScreenToMap( new Vector2((float)currentPoint.Position.X, (float)currentPoint.Position.Y)); MapCanvas.Invalidate(); e.Handled = true; }
private void UI_FileList_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode selected = UI_FileList.SelectedNode; if (selected != null) { // Clean up previous excursions. TerminateRunners(); // Terminate runners that be running. if (canvas != null) { canvas.Dispose(); } canvas = null; overlay.ClearPoints(); UI_PreviewStatus.Hide(); UI_Map.Invalidate(); UI_ExportButton.Enabled = true; UI_ExportImageButton.Enabled = true; drawOffsetX = lastOffsetX = 0; drawOffsetY = lastOffsetY = 0; // Detatch mouse control (this shouldn't ever be an issue, really). isMovingMap = false; string mapName = selected.Text; selectedMapName = mapName; tileTotal = maps[mapName].Count; tileDone = 0; UI_TileDisplay.Text = string.Format(Constants.MAP_VIEWER_TILE_STATUS, 0, 0); UI_TileDisplay.Show(); UI_ExportTip.Hide(); buildRunner = new RunnerBuildMinimap(maps[mapName].ToArray()); buildRunnerIndex = buildRunner.Index; buildRunner.Begin(); } }
private void OnKeyDown(object sender, KeyEventArgs e) { if (e.VirtualKey == Windows.System.VirtualKey.Up) { ScrollMap(new Vector2(0.0f, -1.0f)); } else if (e.VirtualKey == Windows.System.VirtualKey.Down) { ScrollMap(new Vector2(0.0f, +1.0f)); } else if (e.VirtualKey == Windows.System.VirtualKey.Left) { ScrollMap(new Vector2(-1.0f, 0.0f)); } else if (e.VirtualKey == Windows.System.VirtualKey.Right) { ScrollMap(new Vector2(+1.0f, 0.0f)); } MapCanvas.Invalidate(); e.Handled = true; }
void Start() { MapCanvas.SetActive(true); TimerCanvas.SetActive(false); }
public RunnerExport2DMap(string fileName, MapCanvas canvas) { this.canvas = canvas; this.fileName = fileName; }
public MapCanvasAction(MapCanvas canvas) { this.canvas = canvas; }