public void closeWindow() { if (docked)// first do a propper undock... { if (this == DockSpace.WindowFraming[3]) { DockSpace.WindowFraming[3] = LeftCW; } if (this == DockSpace.WindowFraming[2]) { DockSpace.WindowFraming[2] = RightCW; } if (this == DockSpace.WindowFraming[0]) { DockSpace.WindowFraming[0] = TopCW; } if (this == DockSpace.WindowFraming[1]) { DockSpace.WindowFraming[1] = BottomCW; } ObjManager.CWRemoveUpdate(this, TopCW, BottomCW, RightCW, LeftCW); LeftCW = null; RightCW = null; TopCW = null; BottomCW = null; docked = false; dim = undockedDim; pos.X += (pos.X > Globals.screenWidth / 2) ? -20 : 20; pos.Y += (pos.Y > Globals.screenHeight / 2) ? -20 : 20; ObjManager.toFront(this); } else { delete = true; //...then delete } }