@@ -203,14 +203,7 @@ private void UpdateZones()
203203 /// <inheritdoc />
204204 public CaptureZone RegisterCaptureZone ( int x , int y , int width , int height , int downscaleLevel = 0 )
205205 {
206- if ( _device == null ) throw new ApplicationException ( "ScreenCapture isn't initialized." ) ;
207-
208- if ( x < 0 ) throw new ArgumentException ( "x < 0" ) ;
209- if ( y < 0 ) throw new ArgumentException ( "y < 0" ) ;
210- if ( width <= 0 ) throw new ArgumentException ( "with <= 0" ) ;
211- if ( height <= 0 ) throw new ArgumentException ( "height <= 0" ) ;
212- if ( ( x + width ) > Display . Width ) throw new ArgumentException ( "x + width > Display width" ) ;
213- if ( ( y + height ) > Display . Height ) throw new ArgumentException ( "y + height > Display height" ) ;
206+ CaptureZoneValidityCheck ( x , y , width , height ) ;
214207
215208 int unscaledWidth = width ;
216209 int unscaledHeight = height ;
@@ -252,6 +245,33 @@ public bool UnregisterCaptureZone(CaptureZone captureZone)
252245 }
253246 }
254247
248+ /// <inheritdoc />
249+ public void RepositionCaptureZone ( CaptureZone captureZone , int x , int y )
250+ {
251+ CaptureZoneValidityCheck ( x , y , captureZone . UnscaledWidth , captureZone . UnscaledHeight ) ;
252+
253+ lock ( _captureZones )
254+ {
255+ if ( ! _captureZones . ContainsKey ( captureZone ) )
256+ throw new ArgumentException ( "Non registered CaptureZone" , nameof ( captureZone ) ) ;
257+ }
258+
259+ captureZone . X = x ;
260+ captureZone . Y = y ;
261+ }
262+
263+ private void CaptureZoneValidityCheck ( int x , int y , int width , int height )
264+ {
265+ if ( _device == null ) throw new ApplicationException ( "ScreenCapture isn't initialized." ) ;
266+
267+ if ( x < 0 ) throw new ArgumentException ( "x < 0" ) ;
268+ if ( y < 0 ) throw new ArgumentException ( "y < 0" ) ;
269+ if ( width <= 0 ) throw new ArgumentException ( "with <= 0" ) ;
270+ if ( height <= 0 ) throw new ArgumentException ( "height <= 0" ) ;
271+ if ( ( x + width ) > Display . Width ) throw new ArgumentException ( "x + width > Display width" ) ;
272+ if ( ( y + height ) > Display . Height ) throw new ArgumentException ( "y + height > Display height" ) ;
273+ }
274+
255275 private void InitializeCaptureZone ( in CaptureZone captureZone )
256276 {
257277 Texture2DDescription stagingTextureDesc = new ( )
0 commit comments