mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-01 08:34:11 +02:00
parent
baaa90f49d
commit
921294eeb3
@ -66,6 +66,16 @@ public bool MuteNotifications{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string NotificationSoundPath{
|
||||||
|
get{
|
||||||
|
return !string.IsNullOrEmpty(notificationSoundPath) && File.Exists(notificationSoundPath) ? notificationSoundPath : string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
set{
|
||||||
|
notificationSoundPath = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public TrayIcon.Behavior TrayBehavior{
|
public TrayIcon.Behavior TrayBehavior{
|
||||||
get{
|
get{
|
||||||
return trayBehavior;
|
return trayBehavior;
|
||||||
@ -95,6 +105,7 @@ public TrayIcon.Behavior TrayBehavior{
|
|||||||
|
|
||||||
private int fileVersion;
|
private int fileVersion;
|
||||||
private bool muteNotifications;
|
private bool muteNotifications;
|
||||||
|
private string notificationSoundPath;
|
||||||
private TrayIcon.Behavior trayBehavior;
|
private TrayIcon.Behavior trayBehavior;
|
||||||
|
|
||||||
private UserConfig(string file){
|
private UserConfig(string file){
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
using TweetDck.Plugins;
|
using TweetDck.Plugins;
|
||||||
using TweetDck.Plugins.Enums;
|
using TweetDck.Plugins.Enums;
|
||||||
using TweetDck.Plugins.Events;
|
using TweetDck.Plugins.Events;
|
||||||
|
using System.Media;
|
||||||
|
|
||||||
namespace TweetDck.Core{
|
namespace TweetDck.Core{
|
||||||
sealed partial class FormBrowser : Form{
|
sealed partial class FormBrowser : Form{
|
||||||
@ -37,6 +38,8 @@ private static UserConfig Config{
|
|||||||
|
|
||||||
private FormWindowState prevState;
|
private FormWindowState prevState;
|
||||||
|
|
||||||
|
private SoundPlayer notificationSound;
|
||||||
|
|
||||||
public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings){
|
public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
@ -67,7 +70,13 @@ public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings)
|
|||||||
|
|
||||||
Controls.Add(browser);
|
Controls.Add(browser);
|
||||||
|
|
||||||
Disposed += (sender, args) => browser.Dispose();
|
Disposed += (sender, args) => {
|
||||||
|
browser.Dispose();
|
||||||
|
|
||||||
|
if (notificationSound != null){
|
||||||
|
notificationSound.Dispose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
this.trayIcon.ClickRestore += trayIcon_ClickRestore;
|
this.trayIcon.ClickRestore += trayIcon_ClickRestore;
|
||||||
this.trayIcon.ClickClose += trayIcon_ClickClose;
|
this.trayIcon.ClickClose += trayIcon_ClickClose;
|
||||||
@ -287,12 +296,28 @@ public void OpenPlugins(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnTweetNotification(){
|
public void OnTweetNotification(){ // may be called multiple times, once for each type of notification
|
||||||
if (Config.EnableTrayHighlight && !ContainsFocus){
|
if (Config.EnableTrayHighlight && !ContainsFocus){
|
||||||
trayIcon.HasNotifications = true;
|
trayIcon.HasNotifications = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PlayNotificationSound(){
|
||||||
|
if (string.IsNullOrEmpty(Config.NotificationSoundPath)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notificationSound == null){
|
||||||
|
notificationSound = new SoundPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notificationSound.SoundLocation != Config.NotificationSoundPath){
|
||||||
|
notificationSound.SoundLocation = Config.NotificationSoundPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
notificationSound.Play();
|
||||||
|
}
|
||||||
|
|
||||||
public void OnTweetScreenshotReady(string html, int width, int height){
|
public void OnTweetScreenshotReady(string html, int width, int height){
|
||||||
FormNotification dummyWindow = CreateNotificationForm(NotificationFlags.DisableScripts | NotificationFlags.DisableContextMenu | NotificationFlags.TopMost);
|
FormNotification dummyWindow = CreateNotificationForm(NotificationFlags.DisableScripts | NotificationFlags.DisableContextMenu | NotificationFlags.TopMost);
|
||||||
|
|
||||||
|
@ -34,6 +34,12 @@ public bool MuteNotifications{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasCustomNotificationSound{
|
||||||
|
get{
|
||||||
|
return !string.IsNullOrEmpty(Program.UserConfig.NotificationSoundPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool ExpandLinksOnHover{
|
public bool ExpandLinksOnHover{
|
||||||
get{
|
get{
|
||||||
return Program.UserConfig.ExpandLinksOnHover;
|
return Program.UserConfig.ExpandLinksOnHover;
|
||||||
@ -100,7 +106,10 @@ public void OnTweetPopup(string tweetHtml, string tweetUrl, int tweetCharacters)
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void OnTweetSound(){
|
public void OnTweetSound(){
|
||||||
form.InvokeSafe(form.OnTweetNotification);
|
form.InvokeSafe(() => {
|
||||||
|
form.OnTweetNotification();
|
||||||
|
form.PlayNotificationSound();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnNotificationReady(){
|
public void OnNotificationReady(){
|
||||||
|
@ -42,6 +42,10 @@ private void SelectTab<T>(Func<T> constructor) where T : BaseTabSettings{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){
|
private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){
|
||||||
|
foreach(BaseTabSettings control in tabs.Values){
|
||||||
|
control.OnClosing();
|
||||||
|
}
|
||||||
|
|
||||||
Program.UserConfig.Save();
|
Program.UserConfig.Save();
|
||||||
|
|
||||||
foreach(BaseTabSettings control in tabs.Values){
|
foreach(BaseTabSettings control in tabs.Values){
|
||||||
|
@ -15,6 +15,8 @@ public BaseTabSettings(){
|
|||||||
Padding = new Padding(6);
|
Padding = new Padding(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnClosing(){}
|
||||||
|
|
||||||
protected static void PromptRestart(){
|
protected static void PromptRestart(){
|
||||||
if (MessageBox.Show("The application must restart for the setting to take place. Do you want to restart now?", Program.BrandName+" Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes){
|
if (MessageBox.Show("The application must restart for the setting to take place. Do you want to restart now?", Program.BrandName+" Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes){
|
||||||
Program.Restart();
|
Program.Restart();
|
||||||
|
@ -47,12 +47,17 @@ private void InitializeComponent() {
|
|||||||
this.checkLegacyLoad = new System.Windows.Forms.CheckBox();
|
this.checkLegacyLoad = new System.Windows.Forms.CheckBox();
|
||||||
this.checkNotificationTimer = new System.Windows.Forms.CheckBox();
|
this.checkNotificationTimer = new System.Windows.Forms.CheckBox();
|
||||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||||
|
this.groupCustomSound = new System.Windows.Forms.GroupBox();
|
||||||
|
this.tbCustomSound = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnBrowseSound = new System.Windows.Forms.Button();
|
||||||
|
this.btnResetSound = new System.Windows.Forms.Button();
|
||||||
this.groupNotificationLocation.SuspendLayout();
|
this.groupNotificationLocation.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
|
||||||
this.groupNotificationDuration.SuspendLayout();
|
this.groupNotificationDuration.SuspendLayout();
|
||||||
this.tableLayoutDurationButtons.SuspendLayout();
|
this.tableLayoutDurationButtons.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.trackBarDuration)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.trackBarDuration)).BeginInit();
|
||||||
this.groupUserInterface.SuspendLayout();
|
this.groupUserInterface.SuspendLayout();
|
||||||
|
this.groupCustomSound.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupNotificationLocation
|
// groupNotificationLocation
|
||||||
@ -349,10 +354,54 @@ private void InitializeComponent() {
|
|||||||
this.checkNotificationTimer.UseVisualStyleBackColor = true;
|
this.checkNotificationTimer.UseVisualStyleBackColor = true;
|
||||||
this.checkNotificationTimer.CheckedChanged += new System.EventHandler(this.checkNotificationTimer_CheckedChanged);
|
this.checkNotificationTimer.CheckedChanged += new System.EventHandler(this.checkNotificationTimer_CheckedChanged);
|
||||||
//
|
//
|
||||||
|
// groupCustomSound
|
||||||
|
//
|
||||||
|
this.groupCustomSound.Controls.Add(this.btnResetSound);
|
||||||
|
this.groupCustomSound.Controls.Add(this.btnBrowseSound);
|
||||||
|
this.groupCustomSound.Controls.Add(this.tbCustomSound);
|
||||||
|
this.groupCustomSound.Location = new System.Drawing.Point(9, 201);
|
||||||
|
this.groupCustomSound.Name = "groupCustomSound";
|
||||||
|
this.groupCustomSound.Size = new System.Drawing.Size(183, 72);
|
||||||
|
this.groupCustomSound.TabIndex = 11;
|
||||||
|
this.groupCustomSound.TabStop = false;
|
||||||
|
this.groupCustomSound.Text = "Custom Sound";
|
||||||
|
//
|
||||||
|
// tbCustomSound
|
||||||
|
//
|
||||||
|
this.tbCustomSound.Location = new System.Drawing.Point(6, 19);
|
||||||
|
this.tbCustomSound.Name = "tbCustomSound";
|
||||||
|
this.tbCustomSound.Size = new System.Drawing.Size(170, 20);
|
||||||
|
this.tbCustomSound.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// btnBrowseSound
|
||||||
|
//
|
||||||
|
this.btnBrowseSound.AutoSize = true;
|
||||||
|
this.btnBrowseSound.Location = new System.Drawing.Point(53, 43);
|
||||||
|
this.btnBrowseSound.Name = "btnBrowseSound";
|
||||||
|
this.btnBrowseSound.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||||
|
this.btnBrowseSound.Size = new System.Drawing.Size(67, 23);
|
||||||
|
this.btnBrowseSound.TabIndex = 1;
|
||||||
|
this.btnBrowseSound.Text = "Browse...";
|
||||||
|
this.btnBrowseSound.UseVisualStyleBackColor = true;
|
||||||
|
this.btnBrowseSound.Click += new System.EventHandler(this.btnBrowseSound_Click);
|
||||||
|
//
|
||||||
|
// btnResetSound
|
||||||
|
//
|
||||||
|
this.btnResetSound.AutoSize = true;
|
||||||
|
this.btnResetSound.Location = new System.Drawing.Point(126, 43);
|
||||||
|
this.btnResetSound.Name = "btnResetSound";
|
||||||
|
this.btnResetSound.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||||
|
this.btnResetSound.Size = new System.Drawing.Size(51, 23);
|
||||||
|
this.btnResetSound.TabIndex = 2;
|
||||||
|
this.btnResetSound.Text = "Reset";
|
||||||
|
this.btnResetSound.UseVisualStyleBackColor = true;
|
||||||
|
this.btnResetSound.Click += new System.EventHandler(this.btnResetSound_Click);
|
||||||
|
//
|
||||||
// TabSettingsNotifications
|
// TabSettingsNotifications
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.groupCustomSound);
|
||||||
this.Controls.Add(this.groupUserInterface);
|
this.Controls.Add(this.groupUserInterface);
|
||||||
this.Controls.Add(this.groupNotificationDuration);
|
this.Controls.Add(this.groupNotificationDuration);
|
||||||
this.Controls.Add(this.groupNotificationLocation);
|
this.Controls.Add(this.groupNotificationLocation);
|
||||||
@ -368,6 +417,8 @@ private void InitializeComponent() {
|
|||||||
((System.ComponentModel.ISupportInitialize)(this.trackBarDuration)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.trackBarDuration)).EndInit();
|
||||||
this.groupUserInterface.ResumeLayout(false);
|
this.groupUserInterface.ResumeLayout(false);
|
||||||
this.groupUserInterface.PerformLayout();
|
this.groupUserInterface.PerformLayout();
|
||||||
|
this.groupCustomSound.ResumeLayout(false);
|
||||||
|
this.groupCustomSound.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -397,5 +448,9 @@ private void InitializeComponent() {
|
|||||||
private TweetDck.Core.Controls.FlatButton btnDurationMedium;
|
private TweetDck.Core.Controls.FlatButton btnDurationMedium;
|
||||||
private TweetDck.Core.Controls.FlatButton btnDurationLong;
|
private TweetDck.Core.Controls.FlatButton btnDurationLong;
|
||||||
private TweetDck.Core.Controls.FlatButton btnDurationShort;
|
private TweetDck.Core.Controls.FlatButton btnDurationShort;
|
||||||
|
private System.Windows.Forms.GroupBox groupCustomSound;
|
||||||
|
private System.Windows.Forms.Button btnResetSound;
|
||||||
|
private System.Windows.Forms.Button btnBrowseSound;
|
||||||
|
private System.Windows.Forms.TextBox tbCustomSound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,15 @@ public TabSettingsNotifications(FormNotification notification){
|
|||||||
trackBarEdgeDistance.SetValueSafe(Config.NotificationEdgeDistance);
|
trackBarEdgeDistance.SetValueSafe(Config.NotificationEdgeDistance);
|
||||||
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value.ToString(CultureInfo.InvariantCulture)+" px";
|
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value.ToString(CultureInfo.InvariantCulture)+" px";
|
||||||
|
|
||||||
|
tbCustomSound.Text = Config.NotificationSoundPath ?? string.Empty;
|
||||||
|
|
||||||
Disposed += (sender, args) => this.notification.Dispose();
|
Disposed += (sender, args) => this.notification.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnClosing(){
|
||||||
|
Config.NotificationSoundPath = tbCustomSound.Text;
|
||||||
|
}
|
||||||
|
|
||||||
private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){
|
private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){
|
||||||
if (Parent == null){
|
if (Parent == null){
|
||||||
notification.HideNotification(false);
|
notification.HideNotification(false);
|
||||||
@ -146,5 +152,22 @@ private void trackBarEdgeDistance_ValueChanged(object sender, EventArgs e){
|
|||||||
Config.NotificationEdgeDistance = trackBarEdgeDistance.Value;
|
Config.NotificationEdgeDistance = trackBarEdgeDistance.Value;
|
||||||
notification.ShowNotificationForSettings(false);
|
notification.ShowNotificationForSettings(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnBrowseSound_Click(object sender, EventArgs e){
|
||||||
|
using(OpenFileDialog dialog = new OpenFileDialog{
|
||||||
|
AutoUpgradeEnabled = true,
|
||||||
|
DereferenceLinks = true,
|
||||||
|
Title = "Custom Notification Sound",
|
||||||
|
Filter = "Wave file (*.wav)|*.wav"
|
||||||
|
}){
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK){
|
||||||
|
tbCustomSound.Text = dialog.FileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnResetSound_Click(object sender, EventArgs e){
|
||||||
|
tbCustomSound.Text = string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,8 +117,9 @@
|
|||||||
|
|
||||||
$TD.onTweetPopup(html.html(), url, tweet.text.length); // TODO column
|
$TD.onTweetPopup(html.html(), url, tweet.text.length); // TODO column
|
||||||
}
|
}
|
||||||
else if (column.model.getHasSound()){
|
|
||||||
$TD.onTweetSound(); // TODO disable original
|
if (column.model.getHasSound()){
|
||||||
|
$TD.onTweetSound();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -255,7 +256,7 @@
|
|||||||
var soundEle = document.getElementById("update-sound");
|
var soundEle = document.getElementById("update-sound");
|
||||||
|
|
||||||
soundEle.play = prependToFunction(soundEle.play, function(){
|
soundEle.play = prependToFunction(soundEle.play, function(){
|
||||||
return $TD.muteNotifications;
|
return $TD.muteNotifications || $TD.hasCustomNotificationSound;
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user