1+ using Microsoft . AspNetCore . StaticAssets ;
12using Microsoft . JSInterop ;
3+ using System . Net . Http . Headers ;
24using System . Reflection ;
35
46namespace SeeSharp . Blazor ;
57
6- public static class Scripts
7- {
8- static string ReadResourceText ( string filename )
9- {
8+ public static class Scripts {
9+ static string ReadResourceText ( string filename ) {
1010 var assembly = typeof ( Scripts ) . GetTypeInfo ( ) . Assembly ;
1111 var stream = assembly . GetManifestResourceStream ( "SeeSharp.Blazor." + filename )
1212 ?? throw new FileNotFoundException ( "resource file not found" , filename ) ;
@@ -20,14 +20,32 @@ static string ReadResourceText(string filename)
2020 $$ """
2121 <script>
2222 {{ SimpleImageIO . FlipBook . HeaderScript }}
23- function makeFlipBook(jsonArgs, onClickObj, onClickMethodName) {
23+ function makeFlipBook(jsonArgs, onClickObj, onClickMethodName, onWheelObj, onWheelMethodName, onMouseOverObj, onMouseOverMethodName, onKeyObj, onKeyMethodName ) {
2424 let onClick = null;
2525 if (onClickObj && onClickMethodName) {
26- onClick = (col, row, evt ) =>
27- onClickObj.invokeMethodAsync(onClickMethodName, col, row, { ctrlKey: evt.ctrlKey } )
26+ onClick = (mouseButton, mouseX, mouseY, ID, selectedIdx, keysPressed ) =>
27+ onClickObj.invokeMethodAsync(onClickMethodName, mouseButton, mouseX, mouseY, ID, selectedIdx, keysPressed )
2828 }
2929
30- window['flipbook']['MakeFlipBook'](jsonArgs, onClick);
30+ let onWheel = null
31+ if (onWheelObj && onWheelMethodName) {
32+ onWheel = (mouseX, mouseY, deltaY, ID, selectedIdx, keysPressed) =>
33+ onWheelObj.invokeMethodAsync(onWheelMethodName, mouseX, mouseY, deltaY, ID, selectedIdx, keysPressed)
34+ }
35+
36+ let onMouseOver = null
37+ if (onMouseOverObj && onMouseOverMethodName) {
38+ onMouseOver = (mouseX, mouseY, ID, selectedIdx, keysPressed) =>
39+ onMouseOverObj.invokeMethodAsync(onMouseOverMethodName, mouseX, mouseY, ID, selectedIdx, keysPressed)
40+ }
41+
42+ let onKey = null
43+ if (onKeyObj && onKeyMethodName) {
44+ onKey = (mouseX, mouseY, ID, selectedIdx, keysPressed) =>
45+ onKeyObj.invokeMethodAsync(onKeyMethodName, mouseX, mouseY, ID, selectedIdx, keysPressed)
46+ }
47+
48+ window['flipbook']['MakeFlipBook'](jsonArgs, onClick, onWheel, onMouseOver, onKey);
3149 }
3250 </script>
3351 """ ;
@@ -59,7 +77,17 @@ function makeFlipBook(jsonArgs, onClickObj, onClickMethodName) {
5977 </script>
6078 """ ;
6179
62- public static readonly string AllScripts = FlipBookScript + DownloadScript + WidgetScripts ;
80+ public static readonly string UpdateImageScript =
81+ $$ """
82+ <script>
83+ function updateImage(jsonArgs) {
84+ window['flipbook']['UpdateImage'](jsonArgs);
85+ return;
86+ }
87+ </script>
88+ """ ;
89+
90+ public static readonly string AllScripts = FlipBookScript + DownloadScript + WidgetScripts + UpdateImageScript ;
6391
6492 /// <summary>
6593 /// Downloads a stream to the client with the given file name. Requires that <see cref="DownloadScript" />
0 commit comments