コード例 #1
0
        public RetValue(mbWebView mbWebView, IntPtr param, mbJsExecState mbJsExecState, mbJsValue mbJsValue)
        {
            WebView   = mbWebView;
            ValueType = NativeMethods.mbGetJsValueType(mbJsExecState, mbJsValue);
            switch (ValueType)
            {
            default:
            case mbJsType.kMbJsTypeUndefined:
            case mbJsType.kMbJsTypeNull:
                Result = null;
                break;

            case mbJsType.kMbJsTypeNumber:
                Result = NativeMethods.mbJsToDouble(mbJsExecState, mbJsValue);
                break;

            case mbJsType.kMbJsTypeBool:
                Result = NativeMethods.mbJsToBoolean(mbJsExecState, mbJsValue);
                break;

            case mbJsType.kMbJsTypeString:
                Result = NativeMethods.mbJsToString(mbJsExecState, mbJsValue);
                break;
            }
        }
コード例 #2
0
 internal static void GetSourceCallback(mbWebView webview, IntPtr token, string mhtml)
 {
     if (s_getStringCallbackDict.TryRemove(token, out TaskCompletionSource <string> taskCompletionSource))
     {
         taskCompletionSource.SetResult(mhtml);
     }
 }
コード例 #3
0
 public void OnPaintUpdate(mbWebView webview, IntPtr param, IntPtr hdc, int x, int y, int cx, int cy)
 {
     if (!IsDisposed)
     {
         Bitmap bitmap = _image;
         int    cw     = x + cx;
         int    ch     = y + cy;
         if (bitmap == default || bitmap.Width < cw || bitmap.Height < ch)
         {
             bitmap = new Bitmap(Width > cw ? Width : cw, Height > ch ? Height : ch);
             _image = bitmap;
         }
         using (Graphics graphics = Graphics.FromImage(bitmap))
         {
             IntPtr ptr = graphics.GetHdc();
             try
             {
                 BitBlt(ptr, x, y, cx, cy, hdc, x, y, 0xcc0020);
             }
             finally
             {
                 graphics.ReleaseHdc(ptr);
             }
             graphics.Save();
         }
     }
 }
コード例 #4
0
 internal static void GetCookieCallback(mbWebView webview, IntPtr token, MbAsynRequestState state, string cookie)
 {
     if (s_getStringCallbackDict.TryRemove(token, out TaskCompletionSource <string> taskCompletionSource))
     {
         taskCompletionSource.SetResult(state == MbAsynRequestState.kMbAsynRequestStateOk ? cookie : null);
     }
 }
コード例 #5
0
 public bool RegWebsocketHookCallbacks(mbWebView mbWebView, ref mbWebsocketHookCallbacks mbWebsocketHookCallbacks, IntPtr param)
 {
     if (mbWebsocketHookCallbacks.CanUse)
     {
         NativeMethods.mbNetSetWebsocketCallback(mbWebView, ref mbWebsocketHookCallbacks, param);
     }
     return(true);
 }
コード例 #6
0
        internal static void RunJsCallback(mbWebView webview, IntPtr token, mbJsExecState es, mbJsValue v)
        {
            RetValue retValue = new RetValue(webview, token, es, v);

            if (s_runJsCallbackDict.TryRemove(token, out TaskCompletionSource <RetValue> taskCompletionSource))
            {
                taskCompletionSource.SetResult(retValue);
            }
        }
コード例 #7
0
        public static Task <string> GetSource(this IMiniblinkProxy miniblinkProxy)
        {
            mbWebView mbWebView  = miniblinkProxy.WebView;
            IntPtr    token      = CreateToken();
            var       taskSource = new TaskCompletionSource <string>();

            s_getStringCallbackDict.TryAdd(token, taskSource);
            mbWebView.GetSource(s_mbGetSourceCallback, token);
            return(taskSource.Task);
        }
コード例 #8
0
        public void mbPaintBitUpdated(mbWebView webview, IntPtr param, IntPtr buffer, ref mbRect r, int width, int height)
        {
            Bitmap image;

            if (_image == null || _image.Width < width || _image.Height < height)
            {
                lock (this)
                {
                    _image    = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                    _drawSize = new Size(width, height);
                    image     = _image;
                }
            }
            else
            {
                image = _image;
            }
            unsafe
            {
                //计算更新区域
                var rect = new Rectangle
                {
                    X = r.x >= width ? width - 1 : r.x,
                    Y = r.y >= height ? height - 1 : r.y
                };
                rect.Width  = rect.X + r.w > width ? width - rect.X : r.w;
                rect.Height = rect.Y + r.h > height ? height - rect.Y : r.h;

                BitmapData bitmapData = image.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
                IntPtr     ptr        = bitmapData.Scan0;

                int  targetStride = image.Width;
                int  sourceStride = width;
                int *target       = (int *)ptr;
                int *source       = (int *)buffer;
                int  targetPix;
                int  sourcePix;
                for (int h = 0; h < rect.Height; h++)
                {
                    for (int w = 0; w < rect.Width; w++)
                    {
                        targetPix             = targetStride * h + w;
                        sourcePix             = sourceStride * (rect.Y + h) + (rect.X + w);
                        *(target + targetPix) = *(source + sourcePix);
                    }
                }
                _image.UnlockBits(bitmapData);

                Invalidate(rect);
            }
        }
コード例 #9
0
        public void mbPaintBitUpdated(mbWebView webview, IntPtr param, IntPtr buffer, ref mbRect r, int width, int height)
        {
            int stride = width * 4;

            if (_image == null || _image.PixelWidth < width || _image.PixelHeight < height)
            {
                _image = new WriteableBitmap(width, height, 96, 96, PixelFormats.Pbgra32, BitmapPalettes.WebPaletteTransparent);
                InvalidateVisual();
            }
            //计算更新区域
            var rect = new Int32Rect();

            rect.X      = r.x >= width ? width - 1 : r.x;
            rect.Y      = r.y >= height ? height - 1 : r.y;
            rect.Width  = rect.X + r.w > width ? width - rect.X : r.w;
            rect.Height = rect.Y + r.h > height ? height - rect.Y : r.h;

            _image.WritePixels(rect, buffer, stride * (rect.Height + rect.Y), stride, r.x, r.y);
            _drawSize = new Size(width, height);
        }
コード例 #10
0
        public static void SetCookie(mbWebView mbWebView, string url, System.Net.Cookie cookie)
        {
            if (string.IsNullOrEmpty(cookie.Name) || string.IsNullOrEmpty(cookie.Value))
            {
                return;
            }
            StringBuilder builder = new StringBuilder();

            builder.Append(cookie.Name);
            builder.Append('=');
            builder.Append(cookie.Value);
            if (cookie.Expires != default)
            {
                builder.Append("; expires=");
                builder.Append(cookie.Expires.ToString("r"));
            }
            if (!string.IsNullOrEmpty(cookie.Path))
            {
                builder.Append("; path=");
                builder.Append(cookie.Path);
            }
            if (!string.IsNullOrEmpty(cookie.Domain))
            {
                builder.Append("; domain=");
                builder.Append(cookie.Domain);
            }
            if (cookie.HttpOnly)
            {
                builder.Append("; HttpOnly");
            }
            if (cookie.Secure)
            {
                builder.Append("; Secure");
            }
            mbWebView.SetCookie(url, builder.ToString());
        }
コード例 #11
0
 public bool RegSocketOnWillConnect(mbWebView mbWebView, onWillConnect onWillConnect, IntPtr param)
 {
     _mbWebsocketHookCallbacks.onWillConnect = onWillConnect;
     return(RegWebsocketHookCallbacks(mbWebView, ref _mbWebsocketHookCallbacks, param));
 }
コード例 #12
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbLoadHtmlWithBaseUrl(mbWebView webView, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Tnelab.MiniBlinkV.Utf8Marshaler))] utf8 html, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Tnelab.MiniBlinkV.Utf8Marshaler))] utf8 baseUrl);
コード例 #13
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static HDC mbGetLockedViewDC(mbWebView webView);
コード例 #14
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbRunJs(mbWebView webView, mbWebFrameHandle frameId, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Tnelab.MiniBlinkV.Utf8Marshaler))] utf8 script, bool isInClosure, mbRunJsCallback callback, IntPtr param, IntPtr unuse);
コード例 #15
0
 public bool RegSocketOnError(mbWebView mbWebView, onError onError, IntPtr param)
 {
     _mbWebsocketHookCallbacks.onError = onError;
     return(RegWebsocketHookCallbacks(mbWebView, ref _mbWebsocketHookCallbacks, param));
 }
コード例 #16
0
 public bool RegSocketOnReceive(mbWebView mbWebView, onReceive onReceive, IntPtr param)
 {
     _mbWebsocketHookCallbacks.onReceive = onReceive;
     return(RegWebsocketHookCallbacks(mbWebView, ref _mbWebsocketHookCallbacks, param));;
 }
コード例 #17
0
        public static Task <RetValue> RunJs(this IMiniblinkProxy miniblinkProxy, string js, bool isInClosure)
        {
            mbWebView mbWebView = miniblinkProxy.WebView;

            return(RunJs(miniblinkProxy, mbWebView.GetMainFrame(), js, isInClosure));
        }
コード例 #18
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbShowWindow(mbWebView webWindow, bool show);
コード例 #19
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbUtilSerializeToMHTML(mbWebView webView, mbGetMHTMLCallback calback, IntPtr param);
コード例 #20
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static bool mbIsMainFrame(mbWebView webView, mbWebFrameHandle frameId);
コード例 #21
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static mbWebFrameHandle mbWebFrameGetMainFrame(mbWebView webView);
コード例 #22
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static mbJsValue mbRunJsSync(mbWebView webView, mbWebFrameHandle frameId, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Tnelab.MiniBlinkV.Utf8Marshaler))] utf8 script, bool isInClosure);
コード例 #23
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbLoadURL(mbWebView webView, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Tnelab.MiniBlinkV.Utf8Marshaler))] utf8 url);
コード例 #24
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbOnJsQuery(mbWebView webView, mbJsQueryCallback callback, IntPtr param);
コード例 #25
0
 public bool RegSocketOnConnected(mbWebView mbWebView, onConnected onConnected, IntPtr param)
 {
     _mbWebsocketHookCallbacks.onConnected = onConnected;
     return(RegWebsocketHookCallbacks(mbWebView, ref _mbWebsocketHookCallbacks, param));
 }
コード例 #26
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbWake(mbWebView webView);
コード例 #27
0
 public bool RegSocketOnSend(mbWebView mbWebView, onSend onSend, IntPtr param)
 {
     _mbWebsocketHookCallbacks.onSend = onSend;
     return(RegWebsocketHookCallbacks(mbWebView, ref _mbWebsocketHookCallbacks, param));
 }
コード例 #28
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbUnlockViewDC(mbWebView webView);
コード例 #29
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbKillFocus(mbWebView webView);
コード例 #30
0
ファイル: MbvApi.cs プロジェクト: tnelab/TMiniblink
 public extern static void mbResponseQuery(mbWebView webView, int64_t queryId, int customMsg, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Tnelab.MiniBlinkV.Utf8Marshaler))] utf8 response);