/// <summary> /// Returns a UserNotificationTrigger object from a native pointer. /// </summary> /// <param name="pointer">Native memory pointer.</param> /// <returns>New UserNotificationTrigger object.</returns> public static UserNotificationTrigger FromPtr(IntPtr pointer) { UserNotificationTrigger trigger = new UserNotificationTrigger(); //copy the bytes Marshal.Copy(pointer, trigger.data, 0, Size); return(trigger); }
/// <summary> /// This function modifies an existing user notification. /// </summary> /// <param name="handle">Handle of the Notification to be modified</param> /// <param name="trigger">A UserNotificationTrigger that defines what event activates a notification.</param> /// <param name="notification">A UserNotification that defines how the system should respond when a notification occurs.</param> /// <returns>Handle to the notification event if successful.</returns> public static int SetUserNotification(int handle, UserNotificationTrigger trigger, UserNotification notification) { int outhandle = CeSetUserNotificationEx(handle, trigger.ToByteArray(), notification.ToByteArray()); //throw on invalid handle if (outhandle == 0) { throw new Win32Exception(Marshal.GetLastWin32Error(), "Error setting UserNotification"); } return(outhandle); }
/// <summary> /// This function creates a new user notification. /// </summary> /// <param name="trigger">A UserNotificationTrigger that defines what event activates a notification.</param> /// <param name="notification">A UserNotification that defines how the system should respond when a notification occurs.</param> /// <returns>Handle to the notification event if successful.</returns> public static int SetUserNotification(UserNotificationTrigger trigger, UserNotification notification) { byte[] notifybytes = null; if (notification != null) { notifybytes = notification.ToByteArray(); } int outhandle = CeSetUserNotificationEx(0, trigger.ToByteArray(), notifybytes); //throw on invalid handle if (outhandle == 0) { throw new Win32Exception(Marshal.GetLastWin32Error(), "Error setting UserNotification"); } return(outhandle); }
/// <summary> /// /// </summary> /// <param name="pointer"></param> /// <returns></returns> internal static UserNotificationInfoHeader FromPtr(IntPtr pointer) { UserNotificationInfoHeader nih = new UserNotificationInfoHeader(); Marshal.Copy(pointer, nih.data, 0, Size); //marshall trigger nih.trigger = UserNotificationTrigger.FromPtr((IntPtr)BitConverter.ToInt32(nih.data, 8)); //marshall notification IntPtr notifyptr = (IntPtr)BitConverter.ToInt32(nih.data, 12); //if null pointer no notification if (notifyptr != IntPtr.Zero) { //else convert to managed notificatio object nih.notify = UserNotification.FromPtr(notifyptr); } return(nih); }
/// <summary> /// Returns a UserNotificationTrigger object from a native pointer. /// </summary> /// <param name="pointer">Native memory pointer.</param> /// <returns>New UserNotificationTrigger object.</returns> public static UserNotificationTrigger FromPtr(IntPtr pointer) { UserNotificationTrigger trigger = new UserNotificationTrigger(); //copy the bytes Marshal.Copy(pointer, trigger.data, 0, Size); return trigger; }
/// <summary> /// This function modifies an existing user notification. /// </summary> /// <param name="handle">Handle of the Notification to be modified</param> /// <param name="trigger">A UserNotificationTrigger that defines what event activates a notification.</param> /// <param name="notification">A UserNotification that defines how the system should respond when a notification occurs.</param> /// <returns>Handle to the notification event if successful.</returns> public static int SetUserNotification(int handle, UserNotificationTrigger trigger, UserNotification notification) { int outhandle = CeSetUserNotificationEx(handle, trigger.ToByteArray(), notification.ToByteArray()); //throw on invalid handle if(outhandle==0) { throw new Win32Exception(Marshal.GetLastWin32Error(), "Error setting UserNotification"); } return outhandle; }
/// <summary> /// This function creates a new user notification. /// </summary> /// <param name="trigger">A UserNotificationTrigger that defines what event activates a notification.</param> /// <param name="notification">A UserNotification that defines how the system should respond when a notification occurs.</param> /// <returns>Handle to the notification event if successful.</returns> public static int SetUserNotification(UserNotificationTrigger trigger, UserNotification notification) { byte[] notifybytes = null; if(notification!=null) { notifybytes = notification.ToByteArray(); } int outhandle = CeSetUserNotificationEx(0, trigger.ToByteArray(), notifybytes); //throw on invalid handle if(outhandle==0) { throw new Win32Exception(Marshal.GetLastWin32Error(),"Error setting UserNotification"); } return outhandle; }