compact-framework

Generics where T is class implementing interface

人盡茶涼 提交于 2019-12-05 11:50:20
问题 I have a interface: interface IProfile { ... } ...and a class: [Serializable] class Profile : IProfile { private Profile() { ... } //private to ensure only xmlserializer creates instances } ...and a manager with method: class ProfileManager { public T Load<T>(string profileName) where T : class, IProfile { using(var stream = new .......) { var ser = new XmlSerializer(typeof(T)); return (T)ser.Deserialize(stream); } } } I expect the method to be used like this: var profile = myManager.Load

beep in WinCE , it possible ?

帅比萌擦擦* 提交于 2019-12-05 09:37:44
is it possible to make beep in WinCE ? i try and i get an error JaredPar The .net framework methods for beeing are not available in the CF version of the framework. The best way to get a beep sound is to PInvoke into the MessageBeep function. The PInvoke signature for this method is pretty straight forward [DllImport("CoreDll.dll")] public static extern void MessageBeep(int code); public static void MessageBeep() { MessageBeep(-1); // Default beep code is -1 } This blog post has an excellent more thorough example: http://blog.digitforge.com/?p=4 (on archive.org) Yes. P/Invoke PlaySound or

Create monochrome bitmap in Compact Framework

时光总嘲笑我的痴心妄想 提交于 2019-12-05 07:33:53
I need to create a Bitmap object using raw bytes representing monochrome bitmap data. On the full framework, I am doing the following: Bitmap bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed) BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat); // Write my data into bmpData.Scan0 bmp.UnlockBits(bmpData); Unfortunately, the Compact Framework doesn't have the PixelFormat.Format8bppIndexed enum value. So how can I accomplish this on the CF? The only thing I can think of is to manually create the bitmap file header

HOWTO: Call Managed C# Interface From Unmanaged C++ On WindowsCE Compact Framework

假如想象 提交于 2019-12-05 06:37:56
I have extensive unmanaged Windows CE 5 C++ code that provides a UI that I want to use in a new product by combining it with a large amount of newer business and communications logic written in managed C# on Windows CE 6 and the Compact Framework. The UI may know about the business logic, but I want the business logic ignorant of the UI such that I can later replace it with a managed version, or any other UI that I choose as a front-end. I found an article that describes how to use COM as the bridge in the Windows world, but I'm having difficulty applying it in the .NET CF under WinCE. In the

What is the best way to make a single instance application in Compact Framework?

若如初见. 提交于 2019-12-05 05:41:30
问题 I've seen all the answers for the standard framework What is the correct way to create a single instance application? Prevent multiple instances of a given app in .NET? What is the best way to make a single instance application in .net? How do I check whether another process with the same name exists using the compact framework? The 3 parameter constructor is not supported by the CF Process GetProcessByName is not supported by the CF 回答1: OpenNETCF gives you class OpenNETCF.Threading

Remove readonly in Compact Framework

允我心安 提交于 2019-12-05 03:59:30
What is the preferred way to remove the readonly attribute of a file in Compact Framework as we don't have a File::SetAttributes? You could use the OpenNetCF Smart Device Framework , which has a FileHelper class that implements the SetAttributes function. Or if you don't want to go that route, you could PInvoke the native SetFileAttributes method. This also works: FileInfo fileInfo = new FileInfo(path); FileAttributes attributes = fileInfo.Attributes; if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { // set the attributes to nonreadonly fileInfo.Attributes &=

Notification when my form is fully loaded in C# (.Net Compact Framework)?

夙愿已清 提交于 2019-12-05 03:59:17
问题 I have a form in my application and I want to do some processing when my form has been Fully loaded but I have no event or something which I can bind to when load is finished. Does anyone has any idea, how can I do this? 回答1: What exaclty mean "fully loaded" ? Do you mean, the "Load" event was successfully proceeded? You can do this: public class MyForm : Form { protected override void OnLoad( EventArgs e ) { // the base method raises the load method base.OnLoad( e ); // now are all events

Taking screenshot of a device screen using c#

▼魔方 西西 提交于 2019-12-05 01:00:30
问题 Hii... Is there any way to take screenshot of the application running on WIN CE5.0 device screen. Thanxxx in advance.... 回答1: using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; using System.Drawing; using System.Drawing.Imaging; namespace ScreenShot { public class Program { enum RasterOperation : uint { SRC_COPY = 0x00CC0020 } [DllImport("coredll.dll")] static extern int BitBlt(IntPtr hdcDest, int nXDest, int

WebRequest with POST-parameters in .NET Compact Framework

血红的双手。 提交于 2019-12-04 19:55:15
I'm trying to do an HTTP POST REQUEST on .NET Compact Framework and I can't get it working. This is what I got: public static string DoPost(string url) { // initialize from variables string responseString = string.Empty; ASCIIEncoding encoding = new ASCIIEncoding(); //// UTF8Encoding encoding = new UTF8Encoding(); HttpWebResponse response; byte[] data = encoding.GetBytes("dummy"); StreamReader reader; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); //do the processing SetRequestProperties(request, "POST"); // SETTING METHOD TO POST HERE request.GetRequestStream().Write

Knowing the state of orange button in motorola MC65

空扰寡人 提交于 2019-12-04 19:39:49
I need to be able to know what is the current state of orange button and be notified if this state has changed on Motorola device MC65. Sadly I can't use Symbol.Keyboard.KeyPad class since it is not supported on MC65 The docos state: Keyboard Supported feature - Only the following two API’s are supported on MC65. Symbol.Keyboard.KeyPad.SetKeyState. Symbol.Keyboard.KeyPad.GetKeyStateEx. Following keys are not supported in MC65. KEYSTATE_ALT, KEYSTATE_CTRL, KEYSTATE_NUMLOCK, KEYSTATE_NUMERIC_LOCK, KEYSTATE_CAPSLOCK For the MC65, Microsoft APIs cannot be used to get the Orange key states. The