private static NotificationClass Get(string clsidStr) { RegistryKey key = Registry.CurrentUser.OpenSubKey(ClsidKey(clsidStr), false); if (key == null) { return(null); } NotificationClass result = new NotificationClass(); result.Name = key.GetValue(null) as string; object optionsValue = key.GetValue("Options"); if (optionsValue == null) { result.Options = 0; } else { result.Options = (NotificationOptions)int.Parse(optionsValue.ToString()); } result.Duration = (int)(key.GetValue("Duration") ?? 0); result.WaveFile = key.GetValue("Wave") as string; return(result); }
private static void Set(string clsidStr, NotificationClass cls) { RegistryKey key = Registry.CurrentUser.OpenSubKey(ClsidKey(clsidStr), true); if (key == null) { key = Registry.CurrentUser.CreateSubKey(ClsidKey(clsidStr)); } SetDeleteValue(key, null, cls.Name); key.SetValue("Options", (int)cls.Options); key.SetValue("Duration", cls.Duration); SetDeleteValue(key, "Wave", cls.WaveFile); }
/// <summary> /// Initialize standard WM notification options in "Sound and Notifications" system page /// </summary> /// <returns></returns> private static bool InitNotification() { bool needToSave = false; //if (Device.PlatformType == PlatformType.Standard) // return true; // Not yet supported on Smartphone NotificationClass programNotification = NotificationClass.Get(NotificationCLSID); if (programNotification == null) { programNotification = new NotificationClass(); programNotification.Options = NotificationOptions.Message | NotificationOptions.Vibrate | NotificationOptions.Sound; programNotification.WaveFile = @"\Windows\Alert-Dopple.wma"; programNotification.Duration = 10; needToSave = true; } if (String.IsNullOrEmpty(programNotification.Name)) { programNotification.Name = @"""В Контакте"" cобытия:";// This string have to be from the localize resources needToSave = true; } //programNotification.Options |= NotificationOptions.EnableRepeatSoundCheckBox; if (needToSave) { NotificationClass.Set(NotificationCLSID, programNotification); } return true; }
private static void Set(string clsidStr, NotificationClass cls) { RegistryKey key = Registry.CurrentUser.OpenSubKey(ClsidKey(clsidStr), true); if (key == null) key = Registry.CurrentUser.CreateSubKey(ClsidKey(clsidStr)); SetDeleteValue(key, null, cls.Name); key.SetValue("Options", (int)cls.Options); key.SetValue("Duration", cls.Duration); SetDeleteValue(key, "Wave", cls.WaveFile); }
private static NotificationClass Get(string clsidStr) { RegistryKey key = Registry.CurrentUser.OpenSubKey(ClsidKey(clsidStr), false); if (key == null) return null; NotificationClass result = new NotificationClass(); result.Name = key.GetValue(null) as string; object optionsValue = key.GetValue("Options"); if (optionsValue == null) result.Options = 0; else result.Options = (NotificationOptions)int.Parse(optionsValue.ToString()); result.Duration = (int)(key.GetValue("Duration") ?? 0); result.WaveFile = key.GetValue("Wave") as string; return result; }
/// <summary> /// Modify the notification class options /// </summary> /// <param name="clsid">The notification class ID</param> /// <param name="cls">Options to set</param> public static void Set(Guid clsid, NotificationClass cls) { string clsidStr = clsid.ToString("B"); Set(clsidStr, cls); }
/// <summary> /// Modify the notification class options /// </summary> /// <param name="clsid">The notification class ID</param> /// <param name="cls">Options to set</param> public static void Set(Guid clsid, NotificationClass cls) { string clsidStr = clsid.ToString("B"); Set(clsidStr, cls); }