本文整理汇总了C#中Runtime.RegisterCleaner方法的典型用法代码示例。如果您正苦于以下问题:C# Runtime.RegisterCleaner方法的具体用法?C# Runtime.RegisterCleaner怎么用?C# Runtime.RegisterCleaner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Runtime
的用法示例。
在下文中一共展示了Runtime.RegisterCleaner方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
});
};
//.........这里部分代码省略.........
示例2: Init
public void Init(Syscalls syscalls, Core core, Runtime runtime)
{
runtime.RegisterCleaner(delegate()
{
CleanDictionary(mFileHandles);
CleanDictionary(mStoreHandles);
mFileListHandles.Clear();
});
// todo: store "stores" in a separate location from the filesystem,
// to avoid clashes.
syscalls.maOpenStore = delegate(int _name, int _flags)
{
String name = core.GetDataMemory().ReadStringAtAddress(_name);
name = ConvertPath(name);
File file = new File(name, FileAccess.ReadWrite);
if (file.IsDirectory)
{
throw new Exception("Invalid store name");
}
if (file.Exists)
file.TryOpen();
else if ((_flags & MoSync.Constants.MAS_CREATE_IF_NECESSARY) != 0)
{
file.Create();
}
else
return MoSync.Constants.STERR_NONEXISTENT;
if (file.FileStream == null)
return MoSync.Constants.STERR_GENERIC;
mStoreHandles.Add(mNextStoreHandle, file);
return mNextStoreHandle++;
};
syscalls.maWriteStore = delegate(int _store, int _data)
{
File file = mStoreHandles[_store];
IsolatedStorageFileStream fileStream = file.FileStream;
fileStream.SetLength(0);
Resource dataRes = runtime.GetResource(MoSync.Constants.RT_BINARY, _data);
Stream data = (Stream)dataRes.GetInternalObject();
data.Seek(0, SeekOrigin.Begin);
//fileStream.Write(data.GetData(), 0, data.GetData().Length);
data.CopyTo(fileStream);
return 1;
};
syscalls.maReadStore = delegate(int _store, int _placeholder)
{
File file = mStoreHandles[_store];
IsolatedStorageFileStream fileStream = file.FileStream;
//Memory mem = new Memory((int)fileStream.Length);
MemoryStream mem = new MemoryStream((int)fileStream.Length);
fileStream.Seek(0, SeekOrigin.Begin);
fileStream.Read(mem.GetBuffer(), 0, (int)fileStream.Length);
runtime.SetResource(_placeholder, new Resource(mem, MoSync.Constants.RT_BINARY));
return MoSync.Constants.RES_OK;
};
syscalls.maCloseStore = delegate(int _store, int _delete)
{
File file = mStoreHandles[_store];
file.Close();
if (_delete != 0)
file.Delete();
mStoreHandles.Remove(_store);
};
}
示例3: Init
public void Init(Syscalls syscalls, Core core, Runtime runtime)
{
PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual;
double screenWidth = System.Windows.Application.Current.Host.Content.ActualWidth;
double screenHeight = System.Windows.Application.Current.Host.Content.ActualHeight;
if ((int)screenHeight == 0)
throw new Exception("screenHeight");
PhoneApplicationPage mainPage = (PhoneApplicationPage)frame.Content;
Image mainImage = new Image();
mainPage.Width = screenWidth;
mainPage.Height = screenHeight;
mainImage.Width = screenWidth;
mainImage.Height = screenHeight;
mainPage.Content = mainImage;
// no apparent effect on memory leaks.
runtime.RegisterCleaner(delegate()
{
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mainPage.Content = null;
});
});
mBackBuffer = new WriteableBitmap(
(int)screenWidth,
(int)screenHeight);
mFrontBuffer = new WriteableBitmap(
(int)screenWidth,
(int)screenHeight);
mainImage.Source = mFrontBuffer;
mCurrentDrawTarget = mBackBuffer;
mCurrentWindowsColor = System.Windows.Media.Color.FromArgb(0xff,
(byte)(mCurrentColor >> 16),
(byte)(mCurrentColor >> 8),
(byte)(mCurrentColor));
syscalls.maSetColor = delegate(int rgb)
{
int oldColor = (int)mCurrentColor;
mCurrentColor = 0xff000000 | (uint)(rgb & 0xffffff);
mCurrentWindowsColor = System.Windows.Media.Color.FromArgb(0xff,
(byte)(mCurrentColor >> 16),
(byte)(mCurrentColor >> 8),
(byte)(mCurrentColor));
return oldColor & 0xffffff;
};
syscalls.maSetClipRect = delegate(int x, int y, int w, int h)
{
};
syscalls.maGetClipRect = delegate(int cliprect)
{
};
syscalls.maPlot = delegate(int x, int y)
{
mCurrentDrawTarget.SetPixel(x, y, (int)mCurrentColor);
};
syscalls.maUpdateScreen = delegate()
{
System.Array.Copy(mBackBuffer.Pixels, mFrontBuffer.Pixels, mFrontBuffer.PixelWidth * mFrontBuffer.PixelHeight);
InvalidateWriteableBitmapOnMainThread(mFrontBuffer);
};
syscalls.maFillRect = delegate(int x, int y, int w, int h)
{
mCurrentDrawTarget.FillRectangle(x, y, x + w, y + h, (int)mCurrentColor);
};
syscalls.maLine = delegate(int x1, int y1, int x2, int y2)
{
mCurrentDrawTarget.DrawLine(x1, y1, x2, y2, (int)mCurrentColor);
};
TextBlock textBlock = new TextBlock();
textBlock.FontSize = mCurrentFontSize;
syscalls.maDrawText = delegate(int left, int top, int str)
{
String text = core.GetDataMemory().ReadStringAtAddress(str);
if (text.Length == 0) return;
MoSync.Util.RunActionOnMainThreadSync(() =>
{
textBlock.Text = text;
textBlock.Foreground = new SolidColorBrush(mCurrentWindowsColor);
WriteableBitmap b = new WriteableBitmap(textBlock, null);
mCurrentDrawTarget.Blit(new Rect(left, top, b.PixelWidth, b.PixelHeight),
b,
new Rect(0, 0, b.PixelWidth, b.PixelHeight));
});
};
syscalls.maGetTextSize = delegate(int str)
{
//.........这里部分代码省略.........
示例4: 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);
});
//.........这里部分代码省略.........
示例5: 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);
}
//.........这里部分代码省略.........
示例6: Init
/**
* Initializing the ioctls.
*/
public void Init(Ioctls ioctls, Core core, Runtime runtime)
{
mCamera = new PhotoCamera(mCameraType);
mVideoBrush = new VideoBrush();
runtime.RegisterCleaner(delegate()
{
if (null != mCamera)
{
mCamera.Dispose();
mCamera = null;
}
});
// this should be set according to the orientation of
// the device I guess.
// we need to handle the camera orientation by hand
PhoneApplicationPage currentPage = (((PhoneApplicationFrame)Application.Current.RootVisual).Content as PhoneApplicationPage);
// we need to handle the initial page orientation
double rotation = mCamera.Orientation;
if (currentPage.Orientation == PageOrientation.LandscapeLeft)
{
rotation -= 90;
}
else if (currentPage.Orientation == PageOrientation.LandscapeRight)
{
rotation += 90;
}
mVideoBrush.RelativeTransform = new CompositeTransform()
{
CenterX = 0.5,
CenterY = 0.5,
Rotation = rotation
};
// on orientation changed, we need to rotate the video brush
currentPage.OrientationChanged += new System.EventHandler<OrientationChangedEventArgs>(
delegate(object o, OrientationChangedEventArgs args)
{
rotation = mCamera.Orientation;
if (args.Orientation == PageOrientation.LandscapeLeft)
{
rotation -= 90;
}
else if (args.Orientation == PageOrientation.LandscapeRight)
{
rotation += 90;
}
mVideoBrush.RelativeTransform = new CompositeTransform()
{
CenterX = 0.5,
CenterY = 0.5,
Rotation = rotation
};
});
/**
* Stores an output format in fmm parameter.
* @param _index int the index of the required format.
* @param _fmt int the momory address at which to write the output format dimensions.
*
* Note: the _index should be greater than 0 and smaller than the number of camera formats.
*/
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;
};
/**
* Returns the number of different output formats supported by the current device's camera.
* \< 0 if there is no camera support.
* 0 if there is camera support, but the format is unknown.
*/
ioctls.maCameraFormatNumber = delegate()
{
// if the camera is not initialized, we cannot access any of its properties
if (!isCameraInitialized)
{
// because the cammera is supported but not initialized, we return 0
return 0;
}
IEnumerable<System.Windows.Size> res = mCamera.AvailableResolutions;
if (res == null) return 0;
IEnumerator<System.Windows.Size> resolutions = res.GetEnumerator();
//.........这里部分代码省略.........
示例7: Init
public void Init(Syscalls syscalls, Core core, Runtime runtime)
{
PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual;
double screenWidth = System.Windows.Application.Current.Host.Content.ActualWidth;
double screenHeight = System.Windows.Application.Current.Host.Content.ActualHeight;
if ((int)screenHeight == 0)
throw new Exception("screenHeight");
PhoneApplicationPage mainPage = (PhoneApplicationPage)frame.Content;
mMainImage = new Image();
mainPage.Width = screenWidth;
mainPage.Height = screenHeight;
mMainImage.Width = screenWidth;
mMainImage.Height = screenHeight;
mainPage.Content = mMainImage;
mClipRect.X = 0.0;
mClipRect.Y = 0.0;
mClipRect.Width = screenWidth;
mClipRect.Height = screenHeight;
// no apparent effect on memory leaks.
runtime.RegisterCleaner(delegate()
{
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mainPage.Content = null;
});
});
mBackBuffer = new WriteableBitmap(
(int)screenWidth,
(int)screenHeight);
mFrontBuffer = new WriteableBitmap(
(int)screenWidth,
(int)screenHeight);
mMainImage.Source = mFrontBuffer;
// clear front and backbuffer.
for (int i = 0; i < mFrontBuffer.PixelWidth * mFrontBuffer.PixelHeight; i++)
{
mBackBuffer.Pixels[i] = mBackBuffer.Pixels[i] = (int)(0xff<<24);
}
mCurrentDrawTarget = mBackBuffer;
mCurrentWindowsColor = System.Windows.Media.Color.FromArgb(0xff,
(byte)(mCurrentColor >> 16),
(byte)(mCurrentColor >> 8),
(byte)(mCurrentColor));
syscalls.maSetColor = delegate(int rgb)
{
int oldColor = (int)mCurrentColor;
mCurrentColor = 0xff000000 | (uint)(rgb & 0xffffff);
mCurrentWindowsColor = System.Windows.Media.Color.FromArgb(0xff,
(byte)(mCurrentColor >> 16),
(byte)(mCurrentColor >> 8),
(byte)(mCurrentColor));
return oldColor & 0xffffff;
};
syscalls.maSetClipRect = delegate(int x, int y, int w, int h)
{
MoSync.GraphicsUtil.ClipRectangle(
x, y, w, h,
0, 0, mCurrentDrawTarget.PixelWidth, mCurrentDrawTarget.PixelHeight,
out x, out y, out w, out h);
mClipRect.X = x;
mClipRect.Y = y;
mClipRect.Width = w;
mClipRect.Height = h;
};
syscalls.maGetClipRect = delegate(int cliprect)
{
Memory mem = core.GetDataMemory();
mem.WriteInt32(cliprect + MoSync.Struct.MARect.left, (int)mClipRect.X);
mem.WriteInt32(cliprect + MoSync.Struct.MARect.top, (int)mClipRect.Y);
mem.WriteInt32(cliprect + MoSync.Struct.MARect.width, (int)mClipRect.Width);
mem.WriteInt32(cliprect + MoSync.Struct.MARect.height, (int)mClipRect.Height);
};
syscalls.maPlot = delegate(int x, int y)
{
mCurrentDrawTarget.SetPixel(x, y, (int)mCurrentColor);
};
syscalls.maUpdateScreen = delegate()
{
//System.Array.Copy(mBackBuffer.Pixels, mFrontBuffer.Pixels, mFrontBuffer.PixelWidth * mFrontBuffer.PixelHeight);
System.Buffer.BlockCopy(mBackBuffer.Pixels, 0, mFrontBuffer.Pixels, 0, mFrontBuffer.PixelWidth * mFrontBuffer.PixelHeight * 4);
InvalidateWriteableBitmapOnMainThread(mFrontBuffer);
};
syscalls.maFillRect = delegate(int x, int y, int w, int h)
{
// this function has a bug (it only fills one pixel less than the image.)
//.........这里部分代码省略.........
示例8: Init
/**
* Initializing the ioctls.
*/
public void Init(Ioctls ioctls, Core core, Runtime runtime)
{
mCamera = new PhotoCamera(mCameraType);
mVideoBrush = new VideoBrush();
runtime.RegisterCleaner(delegate()
{
if (null != mCamera)
{
mCamera.Dispose();
mCamera = null;
}
});
PhoneApplicationPage currentPage = (((PhoneApplicationFrame)Application.Current.RootVisual).Content as PhoneApplicationPage);
// set the initial camera orientation in respect to the current page orientation
SetInitialCameraOrientation(currentPage);
// handle current page orientation and adjust the camera orientation accordingly
HandleDeviceOrientation(currentPage);
/**
* Stores an output format in fmm parameter.
* @param _index int the index of the required format.
* @param _fmt int the momory address at which to write the output format dimensions.
*
* Note: the _index should be greater than 0 and smaller than the number of camera formats.
*/
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;
};
/**
* Returns the number of different output formats supported by the current device's camera.
* \< 0 if there is no camera support.
* 0 if there is camera support, but the format is unknown.
*/
ioctls.maCameraFormatNumber = delegate()
{
// if the camera is not initialized, we cannot access any of its properties
if (!isCameraInitialized)
{
// because the cammera is supported but not initialized, we return 0
return 0;
}
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++;
resolutions.MoveNext();
if (resolutions.Current == new System.Windows.Size(0, 0))
break;
}
return number;
};
/**
* Starts the viewfinder and the camera
*/
ioctls.maCameraStart = delegate()
{
InitCamera();
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mCameraPrev.StartViewFinder();
});
return 0;
};
/**
* stops the view finder and the camera.
*/
ioctls.maCameraStop = delegate()
{
MoSync.Util.RunActionOnMainThreadSync(() =>
{
mCameraPrev.StopViewFinder();
});
return 0;
//.........这里部分代码省略.........