예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
		/// <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;
		}
예제 #6
0
		/// <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;
		}
예제 #7
0
		/// <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;
		}