本文整理汇总了C#中Runtime.GetModule方法的典型用法代码示例。如果您正苦于以下问题:C# Runtime.GetModule方法的具体用法?C# Runtime.GetModule怎么用?C# Runtime.GetModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Runtime
的用法示例。
在下文中一共展示了Runtime.GetModule方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init(Ioctls ioctls, Core core, Runtime runtime)
{
/**
* Shows a dialog widget.
* \param _dialogHandle The handle of the dialog that will be shown.
*
* \returns Any of the following result codes:
* - #MAW_RES_OK if the child could be removed from the parent.
* - #MAW_RES_INVALID_HANDLE if the handle was invalid.
* - #MAW_RES_ERROR otherwise.
*/
ioctls.maWidgetModalDialogShow = delegate(int _dialogHandle)
{
if (!isHandleValid(runtime, _dialogHandle))
{
return MoSync.Constants.MAW_RES_INVALID_HANDLE;
}
MoSync.Util.RunActionOnMainThreadSync(() =>
{
ModalDialog modalDialog = ((ModalDialog)runtime.GetModule<NativeUIModule>().GetWidget(_dialogHandle));
if (modalDialog.Visible.Equals("false"))
{
// show the dialog
modalDialog.ShowDialog(true);
// set the dialog visibility
modalDialog.Visible = "true";
}
});
return MoSync.Constants.MAW_RES_OK;
};
/**
* Hides/Dismisses a currently displayed dialog.
* \param _dialogHandle The handle of the dialog that will be hidden.
*
* \returns Any of the following result codes:
* - #MAW_RES_OK if the child could be removed from the parent.
* - #MAW_RES_INVALID_HANDLE if the handle was invalid.
* - #MAW_RES_ERROR otherwise.
*/
ioctls.maWidgetModalDialogHide = delegate(int _dialogHandle)
{
if (!isHandleValid(runtime, _dialogHandle))
{
return MoSync.Constants.MAW_RES_INVALID_HANDLE;
}
MoSync.Util.RunActionOnMainThreadSync(() =>
{
ModalDialog modalDialog = ((ModalDialog)runtime.GetModule<NativeUIModule>().GetWidget(_dialogHandle));
if (modalDialog.Visible.Equals("true"))
{
// hide the dialog
modalDialog.ShowDialog(false);
// set the dialog visibility
modalDialog.Visible = "false";
}
});
return MoSync.Constants.MAW_RES_OK;
};
}
示例2: Init
public void Init(Ioctls ioctls, Core core, Runtime runtime)
{
mCamera = new PhotoCamera(CameraType.Primary);
mVideoBrush = new VideoBrush();
mVideoBrush.SetSource(mCamera);
mVideoBrush.Stretch = Stretch.Uniform;
runtime.RegisterCleaner(delegate()
{
mCamera.Dispose();
mCamera = null;
});
// this should be set according to the orientation of
// the device I guess.
mVideoBrush.RelativeTransform = new CompositeTransform()
{
CenterX = 0.5,
CenterY = 0.5,
Rotation = 90
};
ioctls.maCameraFormat = delegate(int _index, int _fmt)
{
System.Windows.Size dim;
if (GetCameraFormat(_index, out dim) == false)
return MoSync.Constants.MA_CAMERA_RES_FAILED;
core.GetDataMemory().WriteInt32(_fmt + MoSync.Struct.MA_CAMERA_FORMAT.width,
(int)dim.Width);
core.GetDataMemory().WriteInt32(_fmt + MoSync.Struct.MA_CAMERA_FORMAT.height,
(int)dim.Height);
return MoSync.Constants.MA_CAMERA_RES_OK;
};
ioctls.maCameraFormatNumber = delegate()
{
IEnumerable<System.Windows.Size> res = mCamera.AvailableResolutions;
if (res == null) return 0;
IEnumerator<System.Windows.Size> resolutions = res.GetEnumerator();
resolutions.MoveNext();
int number = 0;
while (resolutions.Current != null)
{
number++;
}
return number;
};
ioctls.maCameraStart = delegate()
{
return 0;
};
ioctls.maCameraStop = delegate()
{
return 0;
};
ioctls.maCameraSetPreview = delegate(int _widgetHandle)
{
// something like
// videoBrush = ((CameraViewFinder)runtime.GetModule<MoSyncNativeUIModule>.GetWidget(_widgetHandle)).GetBrush();
// videoBrush.SetSource(mCamera)
IWidget w = runtime.GetModule<NativeUIModule>().GetWidget(_widgetHandle);
if (w.GetType() != typeof(MoSync.NativeUI.CameraPreview))
{
return MoSync.Constants.MA_CAMERA_RES_FAILED;
}
NativeUI.CameraPreview prev = (NativeUI.CameraPreview)w;
System.Windows.Controls.Canvas canvas = prev.GetViewFinderCanvas();
MoSync.Util.RunActionOnMainThreadSync(() =>
{
canvas.Background = mVideoBrush;
});
return 0;
};
ioctls.maCameraSelect = delegate(int _cameraNumber)
{
CameraType cameraType = CameraType.Primary;
if(_cameraNumber == MoSync.Constants.MA_CAMERA_CONST_BACK_CAMERA)
{
cameraType = CameraType.Primary;
}
else if(_cameraNumber == MoSync.Constants.MA_CAMERA_CONST_FRONT_CAMERA)
{
cameraType = CameraType.FrontFacing;
}
if(mCamera==null || mCamera.CameraType != cameraType)
{
mCamera = new PhotoCamera(cameraType);
if(mVideoBrush == null)
mVideoBrush = new VideoBrush();
mVideoBrush.SetSource(mCamera);
}
//.........这里部分代码省略.........
示例3: isHandleValid
/*
* Checks if a handle is a valid handler (a valid handle shouldn't be negative).
* @param runtime The current runtime
* @param handle The handle to be checked
*/
private bool isHandleValid(Runtime runtime, int handle)
{
if (runtime.GetModule<NativeUIModule>().GetWidget(handle).GetHandle() < 0)
{
return false;
}
return true;
}
示例4: Init
public void Init(Ioctls ioctls, Core core, Runtime runtime)
{
ioctls.maFontSetCurrent = delegate(int _font)
{
FontModule.FontInfo finfo = runtime.GetModule<FontModule>().GetFont(_font);
MoSync.Util.RunActionOnMainThreadSync(() =>
{
textBlock.FontFamily = finfo.family;
textBlock.FontStyle = finfo.style;
textBlock.FontWeight = finfo.weight;
});
return 0;
};
ioctls.maFrameBufferInit = delegate(int frameBufferPointer)
{
Syscalls syscalls = runtime.GetSyscalls();
mOldUpdateScreenImplementation = syscalls.maUpdateScreen;
syscalls.maUpdateScreen = delegate()
{
Memory mem = core.GetDataMemory();
int[] dst = mFrontBuffer.Pixels;
//mFrontBuffer.FromByteArray(mem.GetData(), frameBufferPointer, dst.Length * 4);
System.Buffer.BlockCopy(mem.GetData(), frameBufferPointer, dst, 0, dst.Length * 4);
const int opaque = (int)(0xff<<24);
for (int i = 0; i < dst.Length; i++)
{
dst[i] |= opaque;
}
InvalidateWriteableBitmapBackBufferOnMainThread(mFrontBuffer);
WriteableBitmap temp = mFrontBuffer;
mFrontBuffer = mBackBuffer;
mBackBuffer = temp;
};
return 1;
};
ioctls.maFrameBufferClose = delegate()
{
Syscalls syscalls = runtime.GetSyscalls();
syscalls.maUpdateScreen = mOldUpdateScreenImplementation;
return 1;
};
ioctls.maFrameBufferGetInfo = delegate(int info)
{
Memory mem = core.GetDataMemory();
mem.WriteInt32(info + MoSync.Struct.MAFrameBufferInfo.sizeInBytes, mBackBuffer.PixelWidth * mBackBuffer.PixelHeight * 4);
mem.WriteInt32(info + MoSync.Struct.MAFrameBufferInfo.bytesPerPixel, 4);
mem.WriteInt32(info + MoSync.Struct.MAFrameBufferInfo.bitsPerPixel, 32);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.redMask, 0x00ff0000);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.redBits, 8);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.redShift, 16);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.greenMask, 0x0000ff00);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.greenBits, 8);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.greenShift, 8);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.blueMask, 0x000000ff);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.blueBits, 8);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.blueShift, 0);
mem.WriteInt32(info + MoSync.Struct.MAFrameBufferInfo.width, mBackBuffer.PixelWidth);
mem.WriteInt32(info + MoSync.Struct.MAFrameBufferInfo.height, mBackBuffer.PixelHeight);
mem.WriteInt32(info + MoSync.Struct.MAFrameBufferInfo.pitch, mBackBuffer.PixelWidth * 4);
mem.WriteUInt32(info + MoSync.Struct.MAFrameBufferInfo.supportsGfxSyscalls, 0);
return 1;
};
}
示例5: Init
//.........这里部分代码省略.........
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mCameraPrev.StartViewFinder();
});
return 0;
};
/**
* stops the view finder and the camera.
*/
ioctls.maCameraStop = delegate()
{
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mCameraPrev.StopViewFinder();
});
return 0;
};
/**
* Adds a previewWidget to the camera controller in devices that support native UI.
*/
ioctls.maCameraSetPreview = delegate(int _widgetHandle)
{
// if the camera is not initialized, we need to initialize it before
// setting the preview
if (!isCameraInitialized)
{
initCamera();
}
IWidget w = runtime.GetModule<NativeUIModule>().GetWidget(_widgetHandle);
if (w.GetType() != typeof(MoSync.NativeUI.CameraPreview))
{
return MoSync.Constants.MA_CAMERA_RES_FAILED;
}
mCameraPrev = (NativeUI.CameraPreview)w;
mCameraPrev.SetViewFinderContent(mVideoBrush);
return MoSync.Constants.MA_CAMERA_RES_OK;
};
/**
* Returns the number of available Camera on the device.
*/
ioctls.maCameraNumber = delegate()
{
if (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing) && PhotoCamera.IsCameraTypeSupported(CameraType.Primary))
return 2;
else if (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing) || PhotoCamera.IsCameraTypeSupported(CameraType.Primary))
return 1;
return 0;
};
/**
* Captures an image and stores it as a new data object in the
* supplied placeholder.
* @param _formatIndex int the required format.
* @param _placeHolder int the placeholder used for storing the image.
*/
ioctls.maCameraSnapshot = delegate(int _formatIndex, int _placeHolder)
{
AutoResetEvent are = new AutoResetEvent(false);
示例6: Init
public void Init(Ioctls ioctls, Core core, Runtime runtime)
{
/**
* @brief Creates a new banner.
* @param bannerSize One of the MA_ADS_SIZE_ constants. Only for Android and WP7.1 platforms.
* @param publisherID Only for Android and WP 7.1 platforms.
* This param is ignored on iOS platform.
*
* @note A banner is a widget type object.
* For more info see Widget API.
*
* @returns
* - #MA_ADS_RES_UNSUPPORTED if ads are not supported on current system.
* - #MA_ADS_RES_ERROR if a error occurred while creating the banner widget.
* - a handle to a new banner widget(the handle value is >= 0).
*/
ioctls.maAdsBannerCreate = delegate(int _bannerSize, int _publisherID)
{
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mAd = new NativeUI.Ad();
// If the banner size is a known windows phone 7 size, we set it.
// The default value is 480*80 (XX-Large banner).
switch (_bannerSize)
{
case MoSync.Constants.MA_ADS_SIZE_WP7_XLARGE:
mAd.Width = 300;
mAd.Height = 50;
break;
case MoSync.Constants.MA_ADS_SIZE_WP7_XXLARGE:
mAd.Width = 480;
mAd.Height = 80;
break;
default:
mAd.Width = 480;
mAd.Height = 80;
break;
}
// the publisherID for windows phone contains two components separated by '|'.
// The first one represents the application ID and the second one the ad unit ID.
// The publisher ID structure(ex): f532778c-7db5-4a8b-a292-a45a684ed890
// The ad unit ID structure(ex): 81103
String publisherID = core.GetDataMemory().ReadStringAtAddress(_publisherID);
string[] values = publisherID.Split('|');
// only if both values are present we set the properties
if (2 == values.Length)
{
mAd.ApplicationID = values[0];
mAd.AdUnitID = values[1];
}
}
);
int handle = runtime.GetModule<NativeUIModule>().AddWidget(mAd);
// if the handles is smaller than 0, the widget was not added to the layout
if (handle < 0)
{
return MoSync.Constants.MA_ADS_RES_ERROR;
}
mAd.SetHandle(handle);
mAd.SetRuntime(runtime);
return handle;
};
/**
* @brief Destroy a banner.
*
* @param bannerHandle Handle to a banner.
*
* @returns One of the next constants:
* - #MA_ADS_RES_OK if no error occurred.
* - #MA_ADS_RES_INVALID_BANNER_HANDLE if the banner handle is invalid.
*/
ioctls.maAdsBannerDestroy = delegate(int _bannerHandler)
{
if (!isHandleValid(runtime, _bannerHandler))
{
return MoSync.Constants.MA_ADS_RES_INVALID_BANNER_HANDLE;
}
mAd = null;
return MoSync.Constants.MA_ADS_RES_OK;
};
/**
* @brief Add a banner to a layout widget.
*
* @param bannerHandle Handle to a banner.
* @param layoutHandle Handle to a layout.
*
* @returns One of the next constants:
* - #MA_ADS_RES_OK if no error occurred.
* - #MA_ADS_RES_INVALID_BANNER_HANDLE if the banner handle is invalid.
* - #MA_ADS_RES_INVALID_LAYOUT_HANDLE if the layout handle is invalid.
*/
ioctls.maAdsAddBannerToLayout = delegate(int _bannerHandle, int _layoutHandle)
//.........这里部分代码省略.........
示例7: Init
//.........这里部分代码省略.........
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mCameraPrev.StartViewFinder();
});
return 0;
};
/**
* stops the view finder and the camera.
*/
ioctls.maCameraStop = delegate()
{
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mCameraPrev.StopViewFinder();
});
return 0;
};
/**
* Adds a previewWidget to the camera controller in devices that support native UI.
*/
ioctls.maCameraSetPreview = delegate(int _widgetHandle)
{
// if the camera is not initialized, we need to initialize it before
// setting the preview
if (!isCameraInitialized)
{
InitCamera();
}
IWidget w = runtime.GetModule<NativeUIModule>().GetWidget(_widgetHandle);
if (w.GetType() != typeof(MoSync.NativeUI.CameraPreview))
{
return MoSync.Constants.MA_CAMERA_RES_FAILED;
}
mCameraPrev = (NativeUI.CameraPreview)w;
mCameraPrev.SetViewFinderContent(mVideoBrush);
return MoSync.Constants.MA_CAMERA_RES_OK;
};
/**
* Returns the number of available Camera on the device.
*/
ioctls.maCameraNumber = delegate()
{
if (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing) && PhotoCamera.IsCameraTypeSupported(CameraType.Primary))
return 2;
else if (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing) || PhotoCamera.IsCameraTypeSupported(CameraType.Primary))
return 1;
return 0;
};
/**
* Captures an image and stores it as a new data object in the
* supplied placeholder.
* @param _formatIndex int the required format.
* @param _placeHolder int the placeholder used for storing the image.
*/
ioctls.maCameraSnapshot = delegate(int _formatIndex, int _placeHolder)
{
AutoResetEvent are = new AutoResetEvent(false);