private static void BindNotificationSafeHandle(Notification notification) { IntPtr ptr; NotificationError ret; if (notification.Handle != null && notification.Handle.IsInvalid == false) { notification.Handle.Dispose(); } if (notification.IsOngoing == true || notification.Progress != null) { ptr = Interop.Notification.Create(NotificationType.Ongoing); } else { ptr = Interop.Notification.Create(NotificationType.Basic); } if (ptr == IntPtr.Zero) { ret = (NotificationError)Tizen.Internals.Errors.ErrorFacts.GetLastResult(); throw NotificationErrorFactory.GetException(ret, "Unable to create IntPtr Notification"); } notification.Handle = new NotificationSafeHandle(ptr, true); }
internal static void BindObject(Notification notification) { int flag; NotificationError ret = NotificationError.None; Notification.IndicatorStyle style = (Notification.IndicatorStyle)notification.GetStyle("Indicator"); Interop.Notification.GetApplist(notification.Handle, out flag); if (string.IsNullOrEmpty(style.SubText) == false) { ret = Interop.Notification.SetText(notification.Handle, NotificationText.FirstMainText, style.SubText, null, -1); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "unable to set indicator text"); } flag |= (int)NotificationDisplayApplist.Ticker; } if (string.IsNullOrEmpty(style.IconPath) == false) { ret = Interop.Notification.SetImage(notification.Handle, NotificationImage.IconForIndicator, style.IconPath); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "unable to set indicator image"); } flag |= (int)NotificationDisplayApplist.Indicator; } Interop.Notification.SetApplist(notification.Handle, flag); }
private static void BindLedToHandle(Notification notification) { NotificationError ret = NotificationError.None; Notification.AccessorySet accessory = notification.Accessory; ret = Interop.Notification.SetLed(notification.Handle, accessory.LedOption, 0); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "unable to set led"); } ret = Interop.Notification.SetLedTimePeriod(notification.Handle, accessory.LedOnMillisecond, accessory.LedOffMillisecond); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "unable to set led period"); } if (notification.Accessory.LedOption == AccessoryOption.Custom) { Color color = accessory.LedColor; ret = Interop.Notification.SetLed(notification.Handle, AccessoryOption.Custom, color.GetArgb()); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "unable to set led color"); } } }
/// <summary> /// Searches for a posted notification which has the specified tag and has not been deleted yet. /// </summary> /// <remarks> /// Load method should be called only for notifications, which have been posted using the NotificationManager.Post method. /// If two or more notifications share the same tag, the notification posted most recently is returned. /// </remarks> /// <param name="tag">Tag used to query.</param> /// <returns>Notification Object with specified tag.</returns> /// <exception cref="ArgumentException">Throwing the same exception when argument is invalid and when the tag does not exist is misleading.</exception> /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <example> /// <code> /// Notification notification = new Notification /// { /// Title = "title", /// Content = "content", /// Icon = "absolute icon path", /// Tag = "first notification" /// }; /// NotificationManager.Post(notification); /// /// // do someting /// /// Notification loadNotification = NotificationManager.Load("first notification"); /// </code> /// </example> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 3 </since_tizen> public static Notification Load(string tag) { IntPtr ptr = IntPtr.Zero; if (string.IsNullOrEmpty(tag)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered"); } ptr = Interop.Notification.Load(tag); if (ptr == IntPtr.Zero) { NotificationError ret = (NotificationError)Tizen.Internals.Errors.ErrorFacts.GetLastResult(); Log.Error(Notification.LogTag, "unable to load Notification : " + ret.ToString()); if (ret == NotificationError.DbError) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "the tag does not exist"); } else { throw NotificationErrorFactory.GetException(ret, "unable to load Notification"); } } Notification notification = new Notification { Handle = new NotificationSafeHandle(ptr, true) }.Build(); return(notification); }
/// <summary> /// Posts a new notification. /// </summary> /// <param name="notification">Notification to post.</param> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission is denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <example> /// <code> /// Notification notification = new Notification /// { /// Title = "title", /// Content = "content", /// Icon = "absolute icon path", /// Tag = "first notification" /// }; /// /// Notification.AccessorySet accessory = new Notification.AccessorySet /// { /// SoundOption = AccessoryOption.On, /// CanVibrate = true /// }; /// notification.Accessory = accessory; /// /// // do something /// /// NotificationManager.Post(notification); /// </code> /// </example> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 3 </since_tizen> public static void Post(Notification notification) { if (notification == null) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to post method"); } notification.Make(); if (ResponseEventHandler != null && ResponseEventHandler.GetInvocationList().Length > 0) { NotificationError ret = Interop.Notification.PostWithEventCallback(notification.Handle, responseEventCallback, IntPtr.Zero); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "post notification with event callback failed"); } } else { NotificationError ret = Interop.Notification.Post(notification.Handle); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "post notification failed"); } } int priv_id, group_id; Interop.Notification.GetID(notification.Handle, out group_id, out priv_id); notification.PrivID = priv_id; }
/// <summary> /// Loads a notification template from the notification database. /// </summary> /// <param name="name">Template name.</param> /// <returns>Notification Object with inputted template name.</returns> /// <exception cref="ArgumentException">Throwing the same exception when argument is invalid and when the template does not exist is misleading.</exception> /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <example> /// <code> /// Notification notification = new Notification /// { /// Title = "title", /// Content = "content", /// Icon = "absolute icon path", /// Tag = "first notification" /// }; /// /// Notification.Accessory accessory = new Notification.Accessory /// { /// LedOption = AccessoryOption.On, /// VibrationOption = AccessoryOption.Custom, /// VibrationPath = "vibration absolute path" /// } /// notification.setAccessory(accessory); /// /// // do something /// /// NotificationManager.Post(notification); /// /// Notification.LockStyle style = new Notification.LockStyle /// { /// IconPath = "icon path", /// ThumbnailPath = "Thumbnail path" /// } /// notification.AddStyle(style); /// NotificationManager.SaveTemplate(notification, "firstTemplate"); /// Notification notificationTemplate = NotificationManager.LoadTemplate("firstTemplate"); /// </code> /// </example> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 3 </since_tizen> public static Notification LoadTemplate(string name) { IntPtr handle = IntPtr.Zero; if (string.IsNullOrEmpty(name)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to load template"); } handle = Interop.Notification.LoadTemplate(name); if (handle == IntPtr.Zero) { NotificationError ret = (NotificationError)Tizen.Internals.Errors.ErrorFacts.GetLastResult(); if (ret == NotificationError.DbError) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "the name does not exist"); } else { throw NotificationErrorFactory.GetException(ret, "unable to create Notification from template"); } } Notification notification = new Notification { Handle = new NotificationSafeHandle(handle, true) }.Build(); return(notification); }
/// <summary> /// Method to set time to hide or delete notification. /// </summary> /// <remarks> /// The time settings for hiding and deleting are only reflected on the Tizen TV. /// If you use this API on other profile, this time settings have no effect. /// </remarks> /// <param name="hideTime">The value in seconds when the notification can be hidden from the notification viewer after the notification is posted.</param> /// <param name="deleteTime">The value in seconds when the notification can be deleted from the notification list in setting application after notification is posted.</param> /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception> /// <since_tizen> 3 </since_tizen> public void SetRemoveTime(int hideTime, int deleteTime) { if (hideTime < 0 || deleteTime < 0) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument"); } hideTimeout = hideTime; deleteTimeout = deleteTime; }
public static NotificationSafeHandle MakeNotificationSafeHandle(Notification notification) { if (notification == null) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid notification object"); } notification.Make(); return(notification.Handle); }
public static Notification MakeNotification(NotificationSafeHandle handle) { if (handle == null || handle.IsInvalid == true) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "handle is invalid or null"); } Notification notification = new Notification { Handle = handle }.Build(); return(notification); }
/// <summary> /// Method to remove style you already added. /// </summary> /// <typeparam name="T">Type of notification style to be queried.</typeparam> /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception> /// <since_tizen> 3 </since_tizen> public void RemoveStyle <T>() where T : Notification.StyleBase, new() { T type = new T(); if (styleDictionary.ContainsKey(type.Key)) { styleDictionary.Remove(type.Key); } else { Log.Error(LogTag, "Sytle Can't be removed, there is no style matched input key"); throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered"); } }
/// <summary> /// Deletes a posted notification. /// </summary> /// <param name="notification">Notification to remove.</param> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission is denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <example> /// <code> /// Notification notification = new Notification /// { /// Title = "title", /// Content = "content", /// Icon = "absolute icon path", /// Tag = "first notification" /// }; /// NotificationManager.Post(notification); /// /// // do something /// /// NotificationManager.Delete(notification); /// </code> /// </example> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <pre> /// Post method should be called on the notification object. /// </pre> /// <since_tizen> 3 </since_tizen> public static void Delete(Notification notification) { if (notification == null || notification.Handle == null || notification.Handle.IsInvalid) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to post method"); } NotificationError ret = Interop.Notification.Delete(notification.Handle); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "delete notification failed"); } }
/// <summary> /// Gets notification block state. /// </summary> /// <remarks> /// The user can set the notification block state in settings. /// The block state indicates whether or not notifications can be posted. /// Additionally, only notifications to the notification panel are allowed in "Do not disturb mode". /// Sound, vibrate, and active notifications are blocked. /// </remarks> /// <returns>NotificationBlockState is a state if notification is posted.</returns> /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission is denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 3 </since_tizen> public static NotificationBlockState GetBlockState() { NotificationBlockState state; NotificationError ret; ret = Interop.Notification.GetBlockState(out state); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "GetBlockState failed"); } Log.Info(Notification.LogTag, "Current block state is " + state.ToString()); return(state); }
/// <summary> /// Gets the ButtonAction of the active notification. /// </summary> /// <param name="index">The index to get a button you already added.</param> /// <returns>The ButtonAction object, which you already added.</returns> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <since_tizen> 3 </since_tizen> public ButtonAction GetButtonAction(ButtonIndex index) { ButtonAction button = null; if (buttonDictionary.ContainsKey(index) == true) { buttonDictionary.TryGetValue(index, out button); } else { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The value is not existed."); } return(button); }
/// <summary> /// Method to get extra data you already set. /// </summary> /// <param name="key">The key of the extra data to get.</param> /// <returns>Bundle Object that include extra data</returns> /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception> /// <since_tizen> 4 </since_tizen> public Bundle GetExtraData(string key) { if (string.IsNullOrEmpty(key)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered"); } Bundle bundle; if (extraDataDictionary.TryGetValue(key, out bundle) == false) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered : " + key); } return(bundle); }
/// <summary> /// Removes all posted notifications of calling application. /// </summary> /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission is denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <example> /// <code> /// Notification firstNotification = new Notification /// { /// Title = "title", /// Content = "content", /// Icon = "absolute icon path", /// Tag = "first notification" /// }; /// NotificationManager.Post(firstNotification); /// /// Notification secondNotification = new Notification /// { /// Title = "title", /// Content = "content", /// Icon = "absolute icon path", /// Tag = "second notification" /// }; /// NotificationManager.Post(secondNotification); /// NotificationManager.DeleteAll(); /// </code> /// </example> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 3 </since_tizen> public static void DeleteAll() { NotificationError ret; ret = Interop.Notification.DeleteAll((int)NotificationType.Basic); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "delete all notifications failed of Noti type"); } ret = Interop.Notification.DeleteAll((int)NotificationType.Ongoing); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "delete all notifications failed of Ongoing type"); } }
private static void BindSoundToHandle(Notification notification) { Notification.AccessorySet accessory = notification.Accessory; if (accessory.SoundOption == AccessoryOption.Custom && string.IsNullOrEmpty(accessory.SoundPath)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "If the option is set to Custom, the path must also be set."); } NotificationError ret = Interop.Notification.SetSound(notification.Handle, accessory.SoundOption, accessory.SoundPath); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "unable to set sound"); } }
/// <summary> /// Saves a notification template to the notification database. /// </summary> /// <param name="notification">Notification to save as template.</param> /// <param name="name">Template name.</param> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission is denied.</exception> /// <exception cref="InvalidOperationException">Thrown when it can't be saved as a template.</exception> /// <example> /// <code> /// Notification notification = new Notification /// { /// Title = "title", /// Content = "content", /// Icon = "absolute icon path", /// Tag = "first notification" /// }; /// /// Notification.Accessory accessory = new Notification.Accessory /// { /// LedOption = AccessoryOption.On, /// VibrationOption = AccessoryOption.Custom, /// VibrationPath = "vibration absolute path" /// } /// notification.setAccessory(accessory); /// /// // do something /// /// NotificationManager.Post(notification); /// /// Notification.LockStyle style = new Notification.LockStyle /// { /// IconPath = "icon path", /// ThumbnailPath = "Thumbnail path" /// } /// notification.AddStyle(style); /// NotificationManager.SaveTemplate(notification, "firstTemplate"); /// </code> /// </example> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 3 </since_tizen> public static void SaveTemplate(Notification notification, string name) { if (notification == null || string.IsNullOrEmpty(name)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to save template"); } notification.Make(); NotificationError ret = Interop.Notification.SaveTemplate(notification.Handle, name); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "save as template failed"); } }
/// <summary> /// Method to remove extra you already added. /// </summary> /// <remarks> /// The type of extra data is bundle. /// </remarks> /// <param name="key">The key of the extra data to add.</param> /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception> /// <since_tizen> 4 </since_tizen> public void RemoveExtraData(string key) { if (string.IsNullOrEmpty(key)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered"); } if (extraDataDictionary.ContainsKey(key)) { extraDataDictionary.Remove(key); } else { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered"); } }
/// <summary> /// Initializes a new instance of the <see cref="ProgressType"/> class. /// You must initialize category, current, and max value of the progress. /// </summary> /// <param name="category">The category of progress that appeared on notification.</param> /// <param name="current">The current value of the progress.</param> /// <param name="max">The max value of the progress.</param> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <since_tizen> 3 </since_tizen> public ProgressType(ProgressCategory category, double current, double max) { if (IsNegativeNumber(current)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The current must be a positive integer."); } if (IsNegativeNumber(max)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The max must be a positive integer."); } Category = category; ProgressCurrent = current; ProgressMax = max; }
internal StyleBase GetStyle(string key) { if (string.IsNullOrEmpty(key)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "Key is null or empty"); } StyleBase style = null; bool ret = styleDictionary.TryGetValue(key, out style); if (ret == false) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "The Style object matched input key is not existed"); } return(style); }
/// <summary> /// Method to get style you already added. /// </summary> /// <typeparam name="T">Type of notification style to be queried.</typeparam> /// <returns> /// The Notification.Style object associated with the given style. /// </returns> /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception> /// <since_tizen> 3 </since_tizen> public T GetStyle <T>() where T : Notification.StyleBase, new() { T type = new T(); StyleBase style = null; styleDictionary.TryGetValue(type.Key, out style); if (style == null) { Log.Error(LogTag, "Invalid Style"); throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered"); } else { return(style as T); } }
/// <summary> /// Method to set extra data to add extra data. /// </summary> /// <remarks> /// The type of extra data is bundle. /// </remarks> /// <param name="key">The key of the extra data you want to add.</param> /// <param name="value">The value you want to add.</param> /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception> /// <example> /// <code> /// Notification notification = new Notification /// { /// Title = "Notification", /// Content = "Hello Tizen", /// Icon = "Icon path", /// }; /// /// Bundle bundle = new Bundle(); /// bundle.AddItem("key", "value"); /// /// notification.SetExtraData("firstKey", bundle); /// </code> /// </example> /// <since_tizen> 4 </since_tizen> public void SetExtraData(string key, Bundle value) { if (value == null || value.SafeBundleHandle.IsInvalid || string.IsNullOrEmpty(key)) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered"); } if (extraDataDictionary.ContainsKey(key) == true) { Log.Info(LogTag, "The key is existed, so extender data is replaced"); extraDataDictionary.Remove(key); extraDataDictionary.Add(key, value); } else { extraDataDictionary.Add(key, value); } }
/// <summary> /// Method for adding various styles to be applied to notification. /// </summary> /// <remarks> /// The user always see about valid notification style. If you add a style which is not supported in platform, /// this method has no effect. /// </remarks> /// <param name="style">The style to be applied to notification.</param> /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception> /// <example> /// <code> /// Notification notification = new Notification /// { /// Title = "Notification", /// Content = "Hello Tizen", /// Icon = "Icon path", /// Count = 3 /// }; /// /// Notification.LockStyle lockStyle = new Notification.LockStyle /// { /// IconPath = "Icon path", /// ThumbnailPath = "Thumbnail Path" /// }; /// /// notification.AddStyle(lockStyle); /// /// NotificationManager.Post(notification); /// </code> /// </example> /// <since_tizen> 3 </since_tizen> public void AddStyle(StyleBase style) { if (style == null) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered"); } if (styleDictionary.ContainsKey(style.Key) == true) { Log.Info(LogTag, "The Style is existed, so extender data is replaced"); styleDictionary.Remove(style.Key); styleDictionary.Add(style.Key, style); } else { styleDictionary.Add(style.Key, style); } }
/// <summary> /// Posts a new notification. /// </summary> /// <param name="notification">Notification to post.</param> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <exception cref="UnauthorizedAccessException">Thrown in case of a permission is denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <example> /// <code> /// Notification notification = new Notification /// { /// Title = "title", /// Content = "content", /// Icon = "absolute icon path", /// Tag = "first notification" /// }; /// /// Notification.AccessorySet accessory = new Notification.AccessorySet /// { /// SoundOption = AccessoryOption.On, /// CanVibrate = true /// }; /// notification.Accessory = accessory; /// /// // do something /// /// NotificationManager.Post(notification); /// </code> /// </example> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 3 </since_tizen> public static void Post(Notification notification) { if (notification == null) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid argument to post method"); } notification.Make(); NotificationError ret = Interop.Notification.Post(notification.Handle); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "post notification failed"); } int priv_id, group_id; Interop.Notification.GetID(notification.Handle, out group_id, out priv_id); notification.PrivID = priv_id; }
/// <summary> /// Method to add a button to the active notification style. /// Buttons are displayed on the notification. /// </summary> /// <remarks> /// If you add button that has same index, the button is replaced to latest adding button. /// If you don't set an index on ButtonAction, the index is set sequentially from zero. /// </remarks> /// <param name="button">A ButtonAction for appear to the notification.</param> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <example> /// <code> /// /// ButtonAction button = new ButtonAction /// { /// Index = 0, /// Text = "Yes" /// Action = new AppControl{ ApplicationId = "org.tizen.app" }; /// }; /// /// ActiveStyle active = new ActiveStyle /// { /// IsAutoRemove = true, /// BackgroundImage = "image path", /// }; /// /// active.AddButtonAction(button); /// /// </code> /// </example> /// <since_tizen> 3 </since_tizen> public void AddButtonAction(ButtonAction button) { if (button == null) { throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid ButtonAction object"); } if (button.Index == ButtonIndex.None) { button.Index = (ButtonIndex)buttonDictionary.Count; buttonDictionary.Add(button.Index, button); } else if (button.Index >= ButtonIndex.First) { if (buttonDictionary.ContainsKey(button.Index)) { buttonDictionary.Remove(button.Index); } buttonDictionary.Add(button.Index, button); } }
internal static void BindObject(Notification notification) { int flag; NotificationError ret = NotificationError.None; Notification.LockStyle style = (Notification.LockStyle)notification.GetStyle("Lock"); ret = Interop.Notification.SetImage(notification.Handle, NotificationImage.IconForLock, style.IconPath); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "unable to set lock icon"); } ret = Interop.Notification.SetImage(notification.Handle, NotificationImage.ThumbnailForLock, style.ThumbnailPath); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "unable to set lock thumbnail"); } Interop.Notification.GetApplist(notification.Handle, out flag); Interop.Notification.SetApplist(notification.Handle, flag | (int)NotificationDisplayApplist.Lock); }
internal static void BindObject(Notification notification) { int flag; int hidetime = 0; int deletetime = 0; NotificationError ret = NotificationError.None; Notification.ActiveStyle style = (Notification.ActiveStyle)notification.GetStyle("Active"); Interop.Notification.SetAutoRemove(notification.Handle, style.IsAutoRemove); style.GetRemoveTime(out hidetime, out deletetime); if (hidetime > 0) { Interop.Notification.SetHideTime(notification.Handle, hidetime); } if (deletetime > 0) { try { Interop.Notification.SetDeleteTime(notification.Handle, deletetime); } catch (TypeLoadException) { // To support in API version 3.0 style.SetRemoveTime(hidetime, 60); } } ret = Interop.Notification.SetImage(notification.Handle, NotificationImage.Background, style.BackgroundImage); if (ret != NotificationError.None) { throw NotificationErrorFactory.GetException(ret, "unable to set background Image"); } if (style.DefaultButton != ButtonIndex.None) { Interop.Notification.SetDefaultButton(notification.Handle, (int)style.DefaultButton + 1); } Interop.Notification.GetApplist(notification.Handle, out flag); Interop.Notification.SetApplist(notification.Handle, flag | (int)NotificationDisplayApplist.Active); foreach (Notification.ButtonAction button in style.GetButtonAction()) { button.Make(notification); } if (style.ReplyAction != null) { style.ReplyAction.Make(notification); } if (style.HiddenByUserAction != null) { Interop.Notification.SetExtensionAction(notification.Handle, NotificationEventType.HiddenByUser, style.HiddenByUserAction.SafeAppControlHandle); } if (style.HiddenByTimeoutAction != null) { Interop.Notification.SetExtensionAction(notification.Handle, NotificationEventType.HiddenByTimeout, style.HiddenByTimeoutAction.SafeAppControlHandle); } if (style.HiddenByExternalAction != null) { Interop.Notification.SetExtensionAction(notification.Handle, NotificationEventType.HiddenByExternal, style.HiddenByExternalAction.SafeAppControlHandle); } }