当前位置: 首页>>代码示例>>C#>>正文


C# Memory.WriteStringAtAddress方法代码示例

本文整理汇总了C#中Memory.WriteStringAtAddress方法的典型用法代码示例。如果您正苦于以下问题:C# Memory.WriteStringAtAddress方法的具体用法?C# Memory.WriteStringAtAddress怎么用?C# Memory.WriteStringAtAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memory的用法示例。


在下文中一共展示了Memory.WriteStringAtAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WebView

            //the contructor
            public WebView()
            {
                mWebBrowser = new Microsoft.Phone.Controls.WebBrowser();
                mView = mWebBrowser;
                mWebBrowser.IsScriptEnabled = true;

                fillSpaceHorizontalyEnabled = false;
                fillSpaceVerticalyEnabled = false;

                //adding an event handler for the script notify
                mWebBrowser.ScriptNotify += new EventHandler<NotifyEventArgs>(
                    delegate(object from, NotifyEventArgs args)
                    {
                        String str = args.Value;
                        MoSync.Util.Log(str + "\n");

                        int hookType = 0;

                        //determine the hook type
                        if (Regex.IsMatch(str, mHardHook))
                        {
                            hookType = MoSync.Constants.MAW_CONSTANT_HARD;
                        }
                        else if (Regex.IsMatch(str, mSoftHook))
                        {
                            hookType = MoSync.Constants.MAW_CONSTANT_SOFT;
                        }
                        else
                        {
                            return;
                        }

                        //the MAW_EVENT_WEB_VIEW_HOOK_INVOKED needs a chunk of 16 bytes of memory
                        Memory eventData = new Memory(16);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        const int MAWidgetEventData_hookType = 8;
                        const int MAWidgetEventData_urlData = 12;

                        //constructing the urlData
                        Memory urlData = new Memory(str.Length + 1);
                        urlData.WriteStringAtAddress(0, str, str.Length + 1);

                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_WEB_VIEW_HOOK_INVOKED);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        eventData.WriteInt32(MAWidgetEventData_hookType, hookType);
                        eventData.WriteInt32(MAWidgetEventData_urlData, mRuntime.AddResource(
                            new Resource(urlData, MoSync.Constants.RT_BINARY)));
                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    });

                mWebBrowser.LoadCompleted += new LoadCompletedEventHandler(
                    delegate(object from, NavigationEventArgs args)
                    {
                        //Note that this event occurs when the content is completely loaded
                        //which means that this is the place to post the custom MoSync event
                        //MAW_EVENT_WEB_VIEW_CONTENT_LOADING to signal that the loading process
                        //is completed

                        //sending the MAW_EVENT_WEB_VIEW_CONTENT_LOADING with the MAW_CONSTANT_DONE parameter

                        //the MAW_EVENT_WEB_VIEW_CONTENT_LOADING needs a chunk of 12 bytes of memory
                        Memory eventData = new Memory(12);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        const int MAWidgetEventData_status = 8;
                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_WEB_VIEW_CONTENT_LOADING);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        eventData.WriteInt32(MAWidgetEventData_status, MoSync.Constants.MAW_CONSTANT_DONE);
                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    });

                mWebBrowser.Navigated += new EventHandler<NavigationEventArgs>(
                    delegate(object from, NavigationEventArgs args)
                    {
                        //Note that when this event is called it means that the current page has been
                        //navigated to which implies that the content will start loading so this is the
                        //place to post the custom MoSync event MAW_EVENT_WEB_VIEW_CONTENT_LOADING to
                        //signal that the process has started

                        //sending the MAW_EVENT_WEB_VIEW_CONTENT_LOADING with the MAW_CONSTANT_STARTED parameter

                        //the MAW_EVENT_WEB_VIEW_CONTENT_LOADING needs a chunk of 12 bytes of memory
                        Memory eventData = new Memory(12);
                        const int MAWidgetEventData_eventType = 0;
                        const int MAWidgetEventData_widgetHandle = 4;
                        const int MAWidgetEventData_status = 8;

                        eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_WEB_VIEW_CONTENT_LOADING);
                        eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle);
                        eventData.WriteInt32(MAWidgetEventData_status, MoSync.Constants.MAW_CONSTANT_STARTED);

                        mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData);
                    });
            }
开发者ID:patrickbroman,项目名称:MoSync,代码行数:96,代码来源:MoSyncWebView.cs


注:本文中的Memory.WriteStringAtAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。