@@ -765,6 +765,50 @@ void UpdateOutline()
765
765
SetPixel ( outlineBitmap , x , y , ( int ) c . ColorBGRA ) ;
766
766
}
767
767
}
768
+ } // UpdateOutline()
769
+
770
+ void OnScrollButtonUpClicked ( object sender , RoutedEventArgs e )
771
+ {
772
+ ScrollCanvas ( 0 , - 1 ) ;
773
+ }
774
+ void OnScrollButtonDownClicked ( object sender , RoutedEventArgs e )
775
+ {
776
+ ScrollCanvas ( 0 , 1 ) ;
777
+ }
778
+ void OnScrollButtonRightClicked ( object sender , RoutedEventArgs e )
779
+ {
780
+ ScrollCanvas ( 1 , 0 ) ;
781
+ }
782
+ void OnScrollButtonLeftClicked ( object sender , RoutedEventArgs e )
783
+ {
784
+ ScrollCanvas ( - 1 , 0 ) ;
785
+ }
786
+
787
+ void ScrollCanvas ( int sx , int sy )
788
+ {
789
+ // clone canvas, FIXME not really needed..could just copy pixels to array or so..
790
+ var tempCanvasBitmap = new WriteableBitmap ( canvasResolutionX , canvasResolutionY , dpiX , dpiY , PixelFormats . Bgra32 , null ) ;
791
+ tempCanvasBitmap = canvasBitmap . Clone ( ) ;
792
+
793
+ // TODO add wrap or clamp option?
794
+
795
+ for ( int x = 0 ; x < canvasResolutionX ; x ++ )
796
+ {
797
+ for ( int y = 0 ; y < canvasResolutionY ; y ++ )
798
+ {
799
+ var c = GetPixelColor ( x , y , tempCanvasBitmap ) ;
800
+ int xx = Repeat ( x + sx , canvasResolutionX ) ;
801
+ int yy = Repeat ( y + sy , canvasResolutionY ) ;
802
+ SetPixel ( canvasBitmap , xx , yy , ( int ) c . ColorBGRA ) ;
803
+ }
804
+ }
805
+ }
806
+
807
+ int Repeat ( int val , int max )
808
+ {
809
+ int result = val % max ;
810
+ if ( result < 0 ) result += max ;
811
+ return result ;
768
812
}
769
813
770
814
} // class
0 commit comments