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


C# Runtime.PostEvent方法代码示例

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


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

示例1: Init


//.........这里部分代码省略.........
                }
                catch (MoSync.Util.ReturnValueException rve)
                {
                    return rve.result;
                }
                catch (Exception)
                {
                    return MoSync.Constants.MA_AUDIO_ERR_GENERIC;
                }

                return MoSync.Constants.MA_AUDIO_ERR_OK;
            };

            ioctls.maAudioPrepare = delegate(int _audioInstance, int async)
            {
                try
                {
                    lock (mAudioInstances)
                    {

                        IAudioInstance ad = mAudioInstances[_audioInstance];
                        if (async == 0)
                        {
                            ad.Prepare(null);
                        }
                        else
                        {
                            ad.Prepare(() =>
                                {
                                    // Send initialized event.
                                    MoSync.Memory eventData = new MoSync.Memory(8);
                                    eventData.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_AUDIO_PREPARED);
                                    eventData.WriteInt32(MoSync.Struct.MAEvent.audioInstance, _audioInstance);
                                    runtime.PostEvent(new Event(eventData));
                                }
                            );
                        }
                    }
                }
                catch (MoSync.Util.ReturnValueException rve)
                {
                    return rve.result;
                }
                catch (Exception)
                {
                    return MoSync.Constants.MA_AUDIO_ERR_GENERIC;
                }

                return MoSync.Constants.MA_AUDIO_ERR_OK;

            };

            ioctls.maAudioInstanceCreate = delegate(int _audioData)
            {
                int ret = MoSync.Constants.MA_AUDIO_ERR_GENERIC;
                try
                {
                    lock (mAudioInstances)
                    {
                        IAudioData ad = mAudioData[_audioData];
                        mAudioInstances.Add(ad.CreateInstance());
                        ret = mAudioInstances.Count - 1;
                    }
                }

                catch (MoSync.Util.ReturnValueException rve)
开发者ID:ronald132,项目名称:MoSync,代码行数:67,代码来源:MoSyncAudioModule.cs

示例2: Init

        public void Init(Syscalls syscalls, Core core, Runtime runtime)
        {
            runtime.RegisterCleaner(delegate()
            {
                foreach (KeyValuePair<int, Connection> p in mConnections)
                {
                    p.Value.close();
                }
                mConnections.Clear();
            });

            mResultHandler = delegate(int handle, int connOp, int result)
            {
                Memory evt = new Memory(4 * 4);
                evt.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_CONN);
                evt.WriteInt32(MoSync.Struct.MAEvent.conn.handle, handle);
                evt.WriteInt32(MoSync.Struct.MAEvent.conn.opType, connOp);
                evt.WriteInt32(MoSync.Struct.MAEvent.conn.result, result);
                runtime.PostEvent(new Event(evt));
            };

            syscalls.maConnect = delegate(int _url)
            {
                String url = core.GetDataMemory().ReadStringAtAddress(_url);
                //Util.Log("maConnect(" + url + ")\n");
                if (url.StartsWith("btspp"))
                    return MoSync.Constants.CONNERR_UNAVAILABLE;
                Uri uri = new Uri(url);
                Connection c;
                if (uri.Scheme.Equals("socket"))
                {
                    c = new SocketConnection(uri, mNextConnHandle);
                }
                else if (uri.Scheme.Equals("http") || uri.Scheme.Equals("https"))
                {
                    c = new WebRequestConnection(uri, mNextConnHandle, MoSync.Constants.HTTP_GET);
                }
                else
                {
                    return MoSync.Constants.CONNERR_GENERIC;
                }

                c.connect(mResultHandler);
                mConnections.Add(mNextConnHandle, c);
                return mNextConnHandle++;
            };

            syscalls.maConnClose = delegate(int _conn)
            {
                Connection c = mConnections[_conn];
                c.close();
                mConnections.Remove(_conn);
            };

            syscalls.maConnGetAddr = delegate(int _conn, int _addr)
            {
                if (_conn == MoSync.Constants.HANDLE_LOCAL) // unavailable
                    return -1;
                Connection c = mConnections[_conn];
                return c.getAddr(core.GetDataMemory(), _addr);
            };

            syscalls.maConnRead = delegate(int _conn, int _dst, int _size)
            {
                Connection c = mConnections[_conn];
                c.recv(core.GetDataMemory().GetData(), _dst, _size, mResultHandler);
            };

            DataDelegate dataDelegate = delegate(int _conn, int _data,
                    CommDelegate cd)
            {
                Connection c = mConnections[_conn];
                Resource res = runtime.GetResource(MoSync.Constants.RT_BINARY, _data);
                Stream s = (Stream)res.GetInternalObject();
                runtime.SetResourceRaw(_data, Resource.Flux);
                MemoryStream mem = null;
                if (s.GetType() == typeof(MemoryStream))
                {
                    mem = (MemoryStream)s;
                }
                else
                {
                    MoSync.Util.CriticalError("Only binaries (non-ubins) are allowed for maConn(Read/Write)(To/From)Data");
                }

                cd(c, mem.GetBuffer(),
                        delegate(int handle, int connOp, int result)
                        {
                            runtime.SetResourceRaw(_data, res);
                            mResultHandler(handle, connOp, result);
                        });
            };

            syscalls.maConnReadToData = delegate(int _conn, int _data, int _offset, int _size)
            {
                dataDelegate(_conn, _data,
                        delegate(Connection c, byte[] buf, ResultHandler rh)
                        {
                            c.recv(buf, _offset, _size, rh);
                        });
//.........这里部分代码省略.........
开发者ID:ronald132,项目名称:MoSync,代码行数:101,代码来源:MoSyncCommunicationsModule.cs

示例3: Init

        public void Init(Syscalls syscalls, Core core, Runtime runtime)
        {
            runtime.RegisterCleaner(delegate()
            {
                foreach(KeyValuePair<int, Connection> p in mConnections) {
                    p.Value.close();
                }
                mConnections.Clear();
            });

            mResultHandler = delegate(int handle, int connOp, int result)
            {
                Memory evt = new Memory(4 * 4);
                evt.WriteInt32(MAEvent_type, MoSync.Constants.EVENT_TYPE_CONN);
                evt.WriteInt32(MAConnEventData_handle, handle);
                evt.WriteInt32(MAConnEventData_opType, connOp);
                evt.WriteInt32(MAConnEventData_result, result);
                runtime.PostEvent(new Event(evt));
            };

            syscalls.maConnect = delegate(int _url)
            {
                String url = core.GetDataMemory().ReadStringAtAddress(_url);
                Uri uri = new Uri(url);
                Connection c;
                if (uri.Scheme.Equals("socket"))
                {
                    c = new SocketConnection(uri, mNextConnHandle);
                }
                else if (uri.Scheme.Equals("http") || uri.Scheme.Equals("https"))
                {
                    c = new WebRequestConnection(uri, mNextConnHandle, MoSync.Constants.HTTP_GET);
                }
                else
                {
                    return MoSync.Constants.CONNERR_GENERIC;
                }

                c.connect(mResultHandler);
                mConnections.Add(mNextConnHandle, c);
                return mNextConnHandle++;
            };

            syscalls.maConnClose = delegate(int _conn)
            {
                Connection c = mConnections[_conn];
                c.close();
                mConnections.Remove(_conn);
            };

            syscalls.maConnGetAddr = delegate(int _conn, int _addr)
            {
                Connection c = mConnections[_conn];
                return c.getAddr(_addr);
            };

            syscalls.maConnRead = delegate(int _conn, int _dst, int _size)
            {
                Connection c = mConnections[_conn];
                c.recv(core.GetDataMemory().GetData(), _dst, _size, mResultHandler);
            };

            DataDelegate dataDelegate = delegate(int _conn, int _data,
                CommDelegate cd)
            {
                Connection c = mConnections[_conn];
                Resource res = runtime.GetResource(MoSync.Constants.RT_BINARY, _data);
                Memory mem = (Memory)res.GetInternalObject();
                runtime.SetResourceRaw(_data, Resource.Flux);
                cd(c, mem.GetData(),
                    delegate(int handle, int connOp, int result)
                    {
                        runtime.SetResourceRaw(_data, res);
                        mResultHandler(handle, connOp, result);
                    });
            };

            syscalls.maConnReadToData = delegate(int _conn, int _data, int _offset, int _size)
            {
                dataDelegate(_conn, _data,
                    delegate(Connection c, byte[] buf, ResultHandler rh)
                    {
                        c.recv(buf, _offset, _size, rh);
                    });
            };

            syscalls.maConnWrite = delegate(int _conn, int _src, int _size)
            {
                Connection c = mConnections[_conn];
                c.write(core.GetDataMemory().GetData(), _src, _size, mResultHandler);
            };

            syscalls.maConnWriteFromData = delegate(int _conn, int _data, int _offset, int _size)
            {
                dataDelegate(_conn, _data,
                    delegate(Connection c, byte[] buf, ResultHandler rh)
                    {
                        c.write(buf, _offset, _size, rh);
                    });
            };
//.........这里部分代码省略.........
开发者ID:asamuelsson,项目名称:MoSync,代码行数:101,代码来源:MoSyncCommunicationsModule.cs

示例4: SendSensorEventVector

 private void SendSensorEventVector(Runtime runtime, int type, Vector3 data)
 {
     Memory evt = new Memory(5 * 4);
     evt.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_SENSOR);
     evt.WriteInt32(MoSync.Struct.MAEvent.sensor.type, type);
     evt.WriteInt32(MoSync.Struct.MAEvent.sensor.values + 0, MoSync.Util.ConvertToInt(data.X));
     evt.WriteInt32(MoSync.Struct.MAEvent.sensor.values + 4, MoSync.Util.ConvertToInt(data.Y));
     evt.WriteInt32(MoSync.Struct.MAEvent.sensor.values + 8, MoSync.Util.ConvertToInt(data.Z));
     runtime.PostEvent(new Event(evt));
 }
开发者ID:nagyist,项目名称:MoSync-MoSync,代码行数:10,代码来源:MoSyncSensorsModule.cs

示例5: Init

        public void Init(Ioctls ioctls, Core core, Runtime runtime)
        {
            mNativeUI = new NativeUI.AsyncNativeUIWindowsPhone(runtime);
            //mWidgets.Add(null); // why?

            // initialize the widget thread dictionary
            mWidgetThreadDictionary = new Dictionary<int, Thread>();

            mWidgetTypeDictionary = new Dictionary<int, Type>();

            /**
             * This will add a OrientationChanged event handler to the Application.Current.RootVisual, this is application wide.
             */
            (Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).OrientationChanged += delegate(object from, Microsoft.Phone.Controls.OrientationChangedEventArgs args)
            {
                PhoneApplicationPage currentPage = (((PhoneApplicationFrame)Application.Current.RootVisual).Content as PhoneApplicationPage);

                int mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_PORTRAIT_UP;
                switch (currentPage.Orientation)
                {
                    case PageOrientation.Landscape:
                        mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_LANDSCAPE;
                        break;
                    case PageOrientation.LandscapeLeft:
                        mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_LANDSCAPE_LEFT;
                        break;
                    case PageOrientation.LandscapeRight:
                        mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_LANDSCAPE_RIGHT;
                        break;
                    case PageOrientation.Portrait:
                        mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_PORTRAIT_UP;
                        break;
                    case PageOrientation.PortraitDown:
                        mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_PORTRAIT_UPSIDE_DOWN;
                        break;
                    case PageOrientation.PortraitUp:
                        mosyncScreenOrientation = MoSync.Constants.MA_SCREEN_ORIENTATION_PORTRAIT_UP;
                        break;
                }

                // Post event handled Moblet.
                Memory eventData = new Memory(8);
                const int MAEventData_eventType = 0;
                const int MAEventData_orientation = 4;
                eventData.WriteInt32(MAEventData_eventType, MoSync.Constants.EVENT_TYPE_ORIENTATION_DID_CHANGE);
                eventData.WriteInt32(MAEventData_orientation, mosyncScreenOrientation);

                runtime.PostEvent(new Event(eventData));
            };

            ioctls.maWidgetCreate = delegate(int _widgetType)
            {
                String widgetTypeName = core.GetDataMemory().ReadStringAtAddress(_widgetType);

                Type widgetType = mNativeUI.VerifyWidget(widgetTypeName);
                if (widgetType == null)
                {
                    return MoSync.Constants.MAW_RES_INVALID_TYPE_NAME;
                }
                IWidget widget = new WidgetBaseMock();
                widget.SetRuntime(runtime);

                int widgetHandle = FindSpaceForWidget();
                if (widgetHandle == -1)
                {
                    mWidgets.Add(widget);
                    widgetHandle = mWidgets.Count - 1;
                }
                else
                {
                    mWidgets[widgetHandle] = widget;
                }
                widget.SetHandle(widgetHandle);
                StartWidgetCreationThread(widgetHandle, widgetType);

                return widgetHandle;
            };

            ioctls.maWidgetDestroy = delegate(int _widget)
            {
                if (_widget < 0 || _widget >= mWidgets.Count)
                    return MoSync.Constants.MAW_RES_INVALID_HANDLE;
                IWidget widget = mWidgets[_widget];
                if (widget != null)
                {
                    mWidgetTypeDictionary.Remove(_widget);
                    Thread widgetCreationThread = null;
                    mWidgetThreadDictionary.TryGetValue(_widget, out widgetCreationThread);
                    if (widgetCreationThread != null)
                    {
                        if (widgetCreationThread.IsAlive)
                        {
                            widgetCreationThread.Join();
                        }
                        mWidgetThreadDictionary.Remove(_widget);
                    }

                    widget.RemoveFromParent();
                    mWidgets[_widget] = null;
                }
//.........这里部分代码省略.........
开发者ID:jpsmaia,项目名称:MoSync,代码行数:101,代码来源:MoSyncNativeUIModule.cs

示例6: Init


//.........这里部分代码省略.........

                        if (mCompass != null && !mCompassEnabled)
                        {
                            mCompass.Stop();
                            mCompass = null;
                        }

                        mMagneticFieldEnabled = false;
                        break;
                    case MoSync.Constants.SENSOR_TYPE_COMPASS:
                        if (!mCompassEnabled)
                            return MoSync.Constants.SENSOR_ERROR_NOT_ENABLED;

                        if (mCompass != null && !mMagneticFieldEnabled)
                        {
                            mCompass.Stop();
                            mCompass = null;
                        }
                        mCompassEnabled = false;
                        break;
                    case MoSync.Constants.SENSOR_TYPE_ORIENTATION:
                        if (mMotion != null)
                        {
                            mMotion.Stop();
                            mMotion = null;
                        }
                        else
                        {
                            return MoSync.Constants.SENSOR_ERROR_NOT_ENABLED;
                        }
                        break;
                }
                return MoSync.Constants.SENSOR_ERROR_NONE;
            };

            ioctls.maLocationStart = delegate()
            {
                if (mGeoWatcher == null)
                {
                    mGeoWatcher = new GeoCoordinateWatcher();
                    //mGeoWatcher.MovementThreshold = 20;

                    mGeoWatcher.StatusChanged += delegate(object sender,
                        GeoPositionStatusChangedEventArgs args)
                    {
                        int maState;
                        switch (args.Status)
                        {
                            case GeoPositionStatus.Disabled:
                                maState = MoSync.Constants.MA_LPS_OUT_OF_SERVICE;
                                break;
                            case GeoPositionStatus.NoData:
                            case GeoPositionStatus.Initializing:
                                maState = MoSync.Constants.MA_LPS_TEMPORARILY_UNAVAILABLE;
                                break;
                            case GeoPositionStatus.Ready:
                                maState = MoSync.Constants.MA_LPS_AVAILABLE;
                                break;
                            default:
                                throw new Exception("invalid GeoPositionStatus");
                        }
                        Memory evt = new Memory(2 * 4);
                        evt.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_LOCATION_PROVIDER);
                        evt.WriteInt32(MoSync.Struct.MAEvent.state, maState);
                        runtime.PostEvent(new Event(evt));
                    };

                    mGeoWatcher.PositionChanged += delegate(object sender,
                        GeoPositionChangedEventArgs<GeoCoordinate> args)
                    {
                        int maValidity = args.Position.Location.IsUnknown ?
                            MoSync.Constants.MA_LOC_INVALID : MoSync.Constants.MA_LOC_QUALIFIED;
                        Memory evt = new Memory(4 + 4 * 8 + 4);
                        GeoCoordinate l = args.Position.Location;
                        evt.WriteInt32(MoSync.Struct.MALocation.state, maValidity);
                        evt.WriteDouble(MoSync.Struct.MALocation.lat, l.Latitude);
                        evt.WriteDouble(MoSync.Struct.MALocation.lon, l.Longitude);
                        evt.WriteDouble(MoSync.Struct.MALocation.horzAcc, l.HorizontalAccuracy);
                        evt.WriteDouble(MoSync.Struct.MALocation.vertAcc, l.VerticalAccuracy);
                        evt.WriteFloat(MoSync.Struct.MALocation.alt, (float)l.Altitude);
                        runtime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_LOCATION, evt);
                    };

                    mGeoWatcher.Start();
                }

                return 0;
            };

            ioctls.maLocationStop = delegate()
            {
                if (mGeoWatcher != null)
                {
                    mGeoWatcher.Stop();
                    mGeoWatcher = null;
                }

                return 0;
            };
        }
开发者ID:nagyist,项目名称:MoSync-MoSync,代码行数:101,代码来源:MoSyncSensorsModule.cs

示例7: OnAlertMessageBoxClosed

        /*
        private void OnAlertMessageBoxClosed(IAsyncResult ar)
        {
            int? buttonIndex = Guide.EndShowMessageBox(ar);

            Memory eventData = new Memory(8);
            eventData.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_ALERT);
            eventData.WriteInt32(MoSync.Struct.MAEvent.alertButtonIndex, (int)(buttonIndex + 1));

            mRuntime.PostEvent(new Event(eventData));
        }
        */
        public void Init(Ioctls ioctls, Core core, Runtime runtime)
        {
            mRuntime = runtime;
            mCore = core;
            /**
             * Register system properties
             */
            SystemPropertyManager.SystemPropertyProvider myDelegateForDeviceInfo = new SystemPropertyManager.SystemPropertyProvider(getDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.imei",              myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.imsi",              myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.iso-639-1",         myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.iso-639-2",         myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device",            myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.name",       myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.UUID",       myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.OS",         myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.OS.version", myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.network.type",      myDelegateForDeviceInfo);

            ioctls.maWriteLog = delegate(int src, int size)
            {
                byte[] bytes = new byte[size];
                core.GetDataMemory().ReadBytes(bytes, src, size);
                MoSync.Util.Log(bytes);
                return 0;
            };

            ioctls.maMessageBox = delegate(int _caption, int _message)
            {
                String message = core.GetDataMemory().ReadStringAtAddress(_message);
                String caption = core.GetDataMemory().ReadStringAtAddress(_caption);
                MoSync.Util.ShowMessage(message, false, caption);
                return 0;
            };

            ioctls.maTextBox = delegate(int _title, int _inText, int _outText, int _maxSize, int _constraints)
            {
                bool passwordMode = false;
                if ((_constraints & MoSync.Constants.MA_TB_FLAG_PASSWORD) != 0)
                    passwordMode = true;

                if ((_constraints & MoSync.Constants.MA_TB_TYPE_MASK) != MoSync.Constants.MA_TB_TYPE_ANY)
                    return MoSync.Constants.MA_TB_RES_TYPE_UNAVAILABLE;

                try
                {
                    Guide.BeginShowKeyboardInput(Microsoft.Xna.Framework.PlayerIndex.One,
                        core.GetDataMemory().ReadWStringAtAddress(_title), "",
                        core.GetDataMemory().ReadWStringAtAddress(_inText),
                        delegate(IAsyncResult result)
                        {
                            string text = Guide.EndShowKeyboardInput(result);

                            Memory eventData = new Memory(12);
                            eventData.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_TEXTBOX);
                            int res = MoSync.Constants.MA_TB_RES_OK;
                            int len = 0;
                            if (text == null)
                            {
                                res = MoSync.Constants.MA_TB_RES_CANCEL;
                            }
                            else
                            {
                                len = text.Length;
                            }

                            eventData.WriteInt32(MoSync.Struct.MAEvent.textboxResult, res);
                            eventData.WriteInt32(MoSync.Struct.MAEvent.textboxLength, len);
                            core.GetDataMemory().WriteWStringAtAddress(_outText, text, _maxSize);
                            mRuntime.PostEvent(new Event(eventData));
                        },
                        null
                        , passwordMode);
                }
                catch (Exception)
                {
                    return -1;
                }

                return 0;
            };

            /**
             * @author: Ciprian Filipas
             * @brief: The maAlert ioctl implementation.
             * @note: On WP7 only 2 buttons are available, OK and CANCEL. Also if the buttons get null values from
             *        MoSync WP7 platform will automatically add the OK button. Regarding these facts the _b2 button will
             *        be ignored in the current implementation.
//.........这里部分代码省略.........
开发者ID:nagyist,项目名称:MoSync-MoSync,代码行数:101,代码来源:MoSyncMiscModule.cs

示例8: Init


//.........这里部分代码省略.........
                            else if (currentPage.Orientation == PageOrientation.LandscapeRight)
                            {
                                rotateAngle = 180;
                            }
                            // if the current page is in a LandscapeLeft orientation, the orientation angle will be 0
                            data = RotateImage(args.ImageStream, rotateAngle);
                        }
                        catch
                        {
                            // the orientation angle was not a multiple of 90 - we keep the original image
                            data = args.ImageStream;
                        }

                        MemoryStream dataMem = new MemoryStream((int)data.Length);
                        MoSync.Util.CopySeekableStreams(data, 0, dataMem, 0, (int)data.Length);

                        Memory eventData = new Memory(20);

                        const int MAEventData_eventType = 0;
                        const int MAEventData_snapshotImageDataHandle = 4;
                        const int MAEventData_snapshotFormatIndex = 8;
                        const int MAEventData_snapshotImageDataRepresentation = 12;
                        const int MAEventData_snapshotReturnCode = 16;

                        eventData.WriteInt32(MAEventData_eventType, MoSync.Constants.EVENT_TYPE_CAMERA_SNAPSHOT);

                        // Create new place holder.
                        eventData.WriteInt32(MAEventData_snapshotImageDataHandle, runtime.AddResource(
                            new Resource(dataMem, MoSync.Constants.RT_BINARY, true)));
                        eventData.WriteInt32(MAEventData_snapshotFormatIndex, _formatIndex);
                        eventData.WriteInt32(MAEventData_snapshotImageDataRepresentation, MoSync.Constants.MA_IMAGE_REPRESENTATION_RAW);
                        eventData.WriteInt32(MAEventData_snapshotReturnCode, MoSync.Constants.MA_CAMERA_RES_OK);

                        runtime.PostEvent(new Event(eventData));
                    });
                };

                mCamera.CaptureImageAvailable += mCameraSnapshotDelegate;
                mCamera.CaptureImage();
                return MoSync.Constants.MA_CAMERA_RES_OK;
            };

            /**
             * Sets the property represented by the string situated at the
             * _property address with the value situated at the _value address.
             * @param _property int the property name address
             * @param _value int the value address
             *
             * Note: the fallowing properties are not available on windows phone
             *      MA_CAMERA_FOCUS_MODE, MA_CAMERA_IMAGE_FORMAT, MA_CAMERA_ZOOM,
             *      MA_CAMERA_MAX_ZOOM.
             */
            ioctls.maCameraSetProperty = delegate(int _property, int _value)
            {
                // if the camera is not initialized, we cannot access any of its properties
                if (!isCameraInitialized)
                {
                    return MoSync.Constants.MA_CAMERA_RES_PROPERTY_NOTSUPPORTED;
                }

                String property = core.GetDataMemory().ReadStringAtAddress(_property);
                String value = core.GetDataMemory().ReadStringAtAddress(_value);

                if (property.Equals(MoSync.Constants.MA_CAMERA_FLASH_MODE))
                {
                    if (value.Equals(MoSync.Constants.MA_CAMERA_FLASH_ON))
开发者ID:milesm,项目名称:MoSync,代码行数:67,代码来源:MoSyncCameraModule.cs

示例9: OnAlertMessageBoxClosed

        /*
        private void OnAlertMessageBoxClosed(IAsyncResult ar)
        {
            int? buttonIndex = Guide.EndShowMessageBox(ar);

            Memory eventData = new Memory(8);
            eventData.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_ALERT);
            eventData.WriteInt32(MoSync.Struct.MAEvent.alertButtonIndex, (int)(buttonIndex + 1));

            mRuntime.PostEvent(new Event(eventData));
        }
        */
        public void Init(Ioctls ioctls, Core core, Runtime runtime)
        {
            mRuntime = runtime;

            /**
             * Register system properties
             */
            SystemPropertyManager.SystemPropertyProvider myDelegateForDeviceInfo = new SystemPropertyManager.SystemPropertyProvider(getDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.imei",              myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.imsi",              myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.iso-639-1",         myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.iso-639-2",         myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device",            myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.name",       myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.UUID",       myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.OS",         myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.OS.version", myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.network.type",      myDelegateForDeviceInfo);

            ioctls.maWriteLog = delegate(int src, int size)
            {
                byte[] bytes = new byte[size];
                core.GetDataMemory().ReadBytes(bytes, src, size);
                MoSync.Util.Log(bytes);
                return 0;
            };

            ioctls.maMessageBox = delegate(int _caption, int _message)
            {
                String message = core.GetDataMemory().ReadStringAtAddress(_message);
                String caption = core.GetDataMemory().ReadStringAtAddress(_caption);
                MoSync.Util.ShowMessage(message, false, caption);
                return 0;
            };

            ioctls.maTextBox = delegate(int _title, int _inText, int _outText, int _maxSize, int _constraints)
            {
                bool passwordMode = false;
                if ((_constraints & MoSync.Constants.MA_TB_FLAG_PASSWORD) != 0)
                    passwordMode = true;

                if ((_constraints & MoSync.Constants.MA_TB_TYPE_MASK) != MoSync.Constants.MA_TB_TYPE_ANY)
                    return MoSync.Constants.MA_TB_RES_TYPE_UNAVAILABLE;

                try
                {
                    Guide.BeginShowKeyboardInput(Microsoft.Xna.Framework.PlayerIndex.One,
                        core.GetDataMemory().ReadWStringAtAddress(_title), "",
                        core.GetDataMemory().ReadWStringAtAddress(_inText),
                        delegate(IAsyncResult result)
                        {
                            string text = Guide.EndShowKeyboardInput(result);

                            Memory eventData = new Memory(12);
                            eventData.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_TEXTBOX);
                            int res = MoSync.Constants.MA_TB_RES_OK;
                            int len = 0;
                            if (text == null)
                            {
                                res = MoSync.Constants.MA_TB_RES_CANCEL;
                            }
                            else
                            {
                                len = text.Length;
                            }

                            eventData.WriteInt32(MoSync.Struct.MAEvent.textboxResult, res);
                            eventData.WriteInt32(MoSync.Struct.MAEvent.textboxLength, len);
                            core.GetDataMemory().WriteWStringAtAddress(_outText, text, _maxSize);
                            mRuntime.PostEvent(new Event(eventData));
                        },
                        null
                        , passwordMode);
                }
                catch (Exception)
                {
                    return -1;
                }

                return 0;
            };

            /*
            ioctls.maAlert = delegate(int _title, int _message, int _b1, int _b2, int _b3)
            {
                String title = core.GetDataMemory().ReadStringAtAddress(_title);
                String message = core.GetDataMemory().ReadStringAtAddress(_message);
                List<string> buttons = new List<string>();
//.........这里部分代码省略.........
开发者ID:vedran-,项目名称:MoSync,代码行数:101,代码来源:MoSyncMiscModule.cs

示例10: OnAlertMessageBoxClosed

        /*
        private void OnAlertMessageBoxClosed(IAsyncResult ar)
        {
            int? buttonIndex = Guide.EndShowMessageBox(ar);

            Memory eventData = new Memory(8);
            eventData.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_ALERT);
            eventData.WriteInt32(MoSync.Struct.MAEvent.alertButtonIndex, (int)(buttonIndex + 1));

            mRuntime.PostEvent(new Event(eventData));
        }
        */
        public void Init(Ioctls ioctls, Core core, Runtime runtime)
        {
            mRuntime = runtime;

            // add system property providers
            SystemPropertyManager.mSystemPropertyProviders.Clear();

            /**
             * Register system properties
             */
            SystemPropertyManager.SystemPropertyProvider myDelegateForDeviceInfo = new SystemPropertyManager.SystemPropertyProvider(getDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.imei",              myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.imsi",              myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.iso-639-1",         myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.iso-639-2",         myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device",            myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.name",       myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.UUID",       myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.OS",         myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.device.OS.version", myDelegateForDeviceInfo);
            SystemPropertyManager.RegisterSystemPropertyProvider("mosync.network.type",      myDelegateForDeviceInfo);

            ioctls.maWriteLog = delegate(int src, int size)
            {
                byte[] bytes = new byte[size];
                core.GetDataMemory().ReadBytes(bytes, src, size);
                MoSync.Util.Log(bytes);
                return 0;
            };

            ioctls.maMessageBox = delegate(int _caption, int _message)
            {
                String message = core.GetDataMemory().ReadStringAtAddress(_message);
                String caption = core.GetDataMemory().ReadStringAtAddress(_caption);
                MoSync.Util.ShowMessage(message, false, caption);
                return 0;
            };

            ioctls.maTextBox = delegate(int _title, int _inText, int _outText, int _maxSize, int _constraints)
            {
                bool passwordMode = false;
                if ((_constraints & MoSync.Constants.MA_TB_FLAG_PASSWORD) != 0)
                    passwordMode = true;

                if ((_constraints & MoSync.Constants.MA_TB_TYPE_MASK) != MoSync.Constants.MA_TB_TYPE_ANY)
                    return MoSync.Constants.MA_TB_RES_TYPE_UNAVAILABLE;

                try
                {
                    Guide.BeginShowKeyboardInput(Microsoft.Xna.Framework.PlayerIndex.One,
                        core.GetDataMemory().ReadWStringAtAddress(_title), "",
                        core.GetDataMemory().ReadWStringAtAddress(_inText),
                        delegate(IAsyncResult result)
                        {
                            string text = Guide.EndShowKeyboardInput(result);

                            Memory eventData = new Memory(12);
                            eventData.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_TEXTBOX);
                            int res = MoSync.Constants.MA_TB_RES_OK;
                            int len = 0;
                            if (text == null)
                            {
                                res = MoSync.Constants.MA_TB_RES_CANCEL;
                            }
                            else
                            {
                                len = text.Length;
                            }

                            eventData.WriteInt32(MoSync.Struct.MAEvent.textboxResult, res);
                            eventData.WriteInt32(MoSync.Struct.MAEvent.textboxLength, len);
                            core.GetDataMemory().WriteWStringAtAddress(_outText, text, _maxSize);
                            mRuntime.PostEvent(new Event(eventData));
                        },
                        null
                        , passwordMode);
                }
                catch (Exception)
                {
                    return -1;
                }

                return 0;
            };

            /*
            ioctls.maAlert = delegate(int _title, int _message, int _b1, int _b2, int _b3)
            {
//.........这里部分代码省略.........
开发者ID:andych008,项目名称:MoSync,代码行数:101,代码来源:MoSyncMiscModule.cs


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