Example #1
0
        /// <summary>
        /// This function queries the user for notification settings by displaying a dialog box showing options that are valid for the current hardware platform.
        /// </summary>
        /// <param name="hWnd">Handle to the parent window for the notification settings dialog box.</param>
        /// <param name="template">UserNotification structure used to populate the default settings.</param>
        /// <returns>A UserNotification structure containing the user's notification settings.</returns>
        public static UserNotification GetUserNotificationPreferences(IntPtr hWnd, UserNotification template)
        {
            template.Sound = new string('\0', 255);

            if (!CeGetUserNotificationPreferences(hWnd, template.ToByteArray()))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not get user preferences");
            }
            return(template);
        }
Example #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);
        }
Example #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);
        }
Example #4
0
        /// <summary>
        /// Edit an existing user notification.
        /// </summary>
        /// <param name="handle">Handle to the notification to overwrite.</param>
        /// <param name="application">String that specifies the name of the application that owns this notification.</param>
        /// <param name="time">The time when the notification should occur.</param>
        /// <param name="notify">Notification object that describes the events that are to occur when the notification time is reached.</param>
        /// <returns>The handle to the notification indicates success.</returns>
        public static int SetUserNotification(int handle, string application, System.DateTime time, UserNotification notify)
        {
            //call api function
            int outhandle = CeSetUserNotification(handle, application, SystemTime.FromDateTime(time).ToByteArray(), notify.ToByteArray());

            //if invalid handle throw exception
            if (outhandle == 0)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error(), "Error setting UserNotification");
            }
            return(outhandle);
        }
Example #5
0
		/// <summary>
		/// This function queries the user for notification settings by displaying a dialog box showing options that are valid for the current hardware platform.
		/// </summary>
		/// <param name="hWnd">Handle to the parent window for the notification settings dialog box.</param>
		/// <param name="template">UserNotification structure used to populate the default settings.</param>
		/// <returns>A UserNotification structure containing the user's notification settings.</returns>
		public static UserNotification GetUserNotificationPreferences(IntPtr hWnd, UserNotification template)
		{
			template.Sound = new string('\0', 255);

			if(!CeGetUserNotificationPreferences(hWnd, template.ToByteArray()))
			{
				throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not get user preferences");
			}
			return template;
		}
Example #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;
		}
Example #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;
		}
Example #8
0
		/// <summary>
		/// Edit an existing user notification.
		/// </summary>
		/// <param name="handle">Handle to the notification to overwrite.</param>
		/// <param name="application">String that specifies the name of the application that owns this notification.</param>
		/// <param name="time">The time when the notification should occur.</param>
		/// <param name="notify">Notification object that describes the events that are to occur when the notification time is reached.</param>
		/// <returns>The handle to the notification indicates success.</returns>
		public static int SetUserNotification(int handle, string application, System.DateTime time, UserNotification notify)
		{
			//call api function
			int outhandle = CeSetUserNotification(handle, application, SystemTime.FromDateTime(time).ToByteArray(), notify.ToByteArray()); 
			
			//if invalid handle throw exception
			if(outhandle==0)
			{
				throw new Win32Exception(Marshal.GetLastWin32Error(),"Error setting UserNotification");
			}
			return outhandle;
		}