private void Clear_units_Button_Click(object sender, RoutedEventArgs e) { Scena scn = Gl.curr_scena; //Thread newWindowThread = Gl.CreateProgressWindow("Clearing..."); #region get rect int sx = 0; int sy = 0; int ex = scn.size_map_x; int ey = scn.size_map_y; //if (!(bool)AllMap_toggleButton.IsChecked) if (Gl.main.select_land_mode) { sx = (int)Canvas.GetLeft(Gl.main.rectangle_select_land); //Gl.main.rectangle_select_land. ; sy = (int)Canvas.GetTop(Gl.main.rectangle_select_land);; ex = (int)(Gl.main.rectangle_select_land.Width - 1); ey = (int)(Gl.main.rectangle_select_land.Height - 1); sx /= 32; sy /= 32; ex /= 32; ey /= 32; ex += sx; ey += sy; } #endregion get rect for (int i = sx; i < ex; i++) { for (int j = sy; j < ey; j++) { while (scn.map_units[i, j] != null && scn.map_units[i, j].Count > 0) { scn.unit_delete(scn.map_units[i, j][0], true); } } } Gl.main.HistoryWrite(); //newWindowThread.Abort(); }
private void Resize_Button_Click(object sender, RoutedEventArgs e) { int w; int h; if (!Int32.TryParse(Width_TextBox.Text, out w)) { return; } if (!Int32.TryParse(Height_TextBox.Text, out h)) { return; } if (w < 0 || h < 0) { return; } // Create a thread Thread newWindowThread = Gl.CreateProgressDetWindow("Resizing..."); Scena scn = Gl.curr_scena; Gl.ProgressDetProgressChange(0); Gl.ProgressDetStatusChange("Delete excess units.."); for (int x = 0; x < scn.size_map_x; x++) { for (int y = 0; y < scn.size_map_y; y++) { if (x >= w || y >= h) { while (scn.map_units[x, y] != null && scn.map_units[x, y].Count > 0) { scn.unit_delete(scn.map_units[x, y][0], false); } } } } Gl.ProgressDetProgressInc(2); Gl.ProgressDetStatusChange("Resizing arrays.."); scn.size_map_x = w; scn.size_map_y = h; scn.size_map_x_pixels = w * 32; scn.size_map_y_pixels = h * 32; scn.map = Utils.ResizeArray <Tile>(scn.map, w, h, scn.tileSet[0]); scn.map_res = Utils.ResizeArray <int>(scn.map_res, w, h, 0); scn.map_units = Utils.ResizeArray <List <Unit> >(scn.map_units, w, h, null); Gl.ProgressDetProgressInc(3); Gl.ProgressDetStatusChange("Full update.."); scn.Close_Scene_without_spr(); scn.FullUpdate(); Gl.ProgressDetProgressChange(100); Gl.ProgressDetStatusChange("All done!"); Gl.CloseProgressDetWindow(newWindowThread); }