mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Remove speech synthesis support, improve ApplicationInstanceManager
This commit is contained in:
parent
e1e67c3c9b
commit
e038a8ace7
4 changed files with 15 additions and 34 deletions
|
@ -75,10 +75,12 @@ public void Dispose()
|
|||
{
|
||||
if (IsFirstInstance)
|
||||
{
|
||||
mutex?.ReleaseMutex();
|
||||
pipeServer?.Dispose();
|
||||
semaphore?.Close();
|
||||
mutex.ReleaseMutex();
|
||||
}
|
||||
|
||||
mutex.Dispose();
|
||||
semaphore?.Dispose();
|
||||
pipeServer?.Dispose();
|
||||
}
|
||||
|
||||
private void CreateFirstInstance(EventHandler<InstanceCallbackEventArgs> callback)
|
||||
|
@ -107,6 +109,8 @@ private void CreateMultipleInstance(string[] args)
|
|||
try
|
||||
{
|
||||
semaphore = Semaphore.OpenExisting(SemaphoreName);
|
||||
|
||||
// Wait until the server is ready to accept data
|
||||
semaphore.WaitOne();
|
||||
SendDataToServer(args);
|
||||
}
|
||||
|
@ -136,7 +140,6 @@ private void SendDataToServer(string[] args)
|
|||
|
||||
private void CreateServer(EventHandler<InstanceCallbackEventArgs> callback)
|
||||
{
|
||||
pipeServer?.Dispose();
|
||||
pipeServer = new NamedPipeServerStream(PipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
|
||||
pipeServer.BeginWaitForConnection(ConnectionCallback, callback);
|
||||
}
|
||||
|
@ -157,9 +160,14 @@ private void ConnectionCallback(IAsyncResult ar)
|
|||
}
|
||||
finally
|
||||
{
|
||||
semaphore?.Release();
|
||||
// Close the existing server
|
||||
sr.Dispose();
|
||||
|
||||
// Create a new server
|
||||
CreateServer(callback);
|
||||
|
||||
// Signal that we are ready to accept a new connection
|
||||
semaphore.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,6 @@
|
|||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Design" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Speech" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
|
|
@ -40,7 +40,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Speech.Synthesis;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -1347,11 +1346,7 @@ public static void PlayCaptureSound(TaskSettings taskSettings)
|
|||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
if (!string.IsNullOrEmpty(taskSettings.AdvancedSettings.SpeechCapture))
|
||||
{
|
||||
TextToSpeechAsync(taskSettings.AdvancedSettings.SpeechCapture);
|
||||
}
|
||||
else if (taskSettings.AdvancedSettings.UseCustomCaptureSound && !string.IsNullOrEmpty(taskSettings.AdvancedSettings.CustomCaptureSoundPath))
|
||||
if (taskSettings.AdvancedSettings.UseCustomCaptureSound && !string.IsNullOrEmpty(taskSettings.AdvancedSettings.CustomCaptureSoundPath))
|
||||
{
|
||||
Helpers.PlaySoundAsync(taskSettings.AdvancedSettings.CustomCaptureSoundPath);
|
||||
}
|
||||
|
@ -1365,11 +1360,7 @@ public static void PlayTaskCompleteSound(TaskSettings taskSettings)
|
|||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
if (!string.IsNullOrEmpty(taskSettings.AdvancedSettings.SpeechTaskCompleted))
|
||||
{
|
||||
TextToSpeechAsync(taskSettings.AdvancedSettings.SpeechTaskCompleted);
|
||||
}
|
||||
else if (taskSettings.AdvancedSettings.UseCustomTaskCompletedSound && !string.IsNullOrEmpty(taskSettings.AdvancedSettings.CustomTaskCompletedSoundPath))
|
||||
if (taskSettings.AdvancedSettings.UseCustomTaskCompletedSound && !string.IsNullOrEmpty(taskSettings.AdvancedSettings.CustomTaskCompletedSoundPath))
|
||||
{
|
||||
Helpers.PlaySoundAsync(taskSettings.AdvancedSettings.CustomTaskCompletedSoundPath);
|
||||
}
|
||||
|
@ -1393,17 +1384,6 @@ public static void PlayErrorSound(TaskSettings taskSettings)
|
|||
}
|
||||
}
|
||||
|
||||
public static void TextToSpeechAsync(string text)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
using (SpeechSynthesizer speaker = new SpeechSynthesizer())
|
||||
{
|
||||
speaker.Speak(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void OpenUploadersConfigWindow(IUploaderService uploaderService = null)
|
||||
{
|
||||
SettingManager.WaitUploadersConfig();
|
||||
|
|
|
@ -429,9 +429,6 @@ public class TaskSettingsAdvanced
|
|||
Editor(typeof(WavFileNameEditor), typeof(UITypeEditor))]
|
||||
public string CustomCaptureSoundPath { get; set; }
|
||||
|
||||
[Category("Sound"), DefaultValue(""), Description("If this text is not empty then when the screen is captured text to speech engine will say the phrase entered instead of playing the default sound.")]
|
||||
public string SpeechCapture { get; set; }
|
||||
|
||||
[Category("Sound"), DefaultValue(false), Description("Enable/disable custom task complete sound.")]
|
||||
public bool UseCustomTaskCompletedSound { get; set; }
|
||||
|
||||
|
@ -439,9 +436,6 @@ public class TaskSettingsAdvanced
|
|||
Editor(typeof(WavFileNameEditor), typeof(UITypeEditor))]
|
||||
public string CustomTaskCompletedSoundPath { get; set; }
|
||||
|
||||
[Category("Sound"), DefaultValue(""), Description("If this text is not empty then when a task is completed text to speech engine will say the phrase entered instead of playing the default sound.")]
|
||||
public string SpeechTaskCompleted { get; set; }
|
||||
|
||||
[Category("Sound"), DefaultValue(false), Description("Enable/disable custom error sound.")]
|
||||
public bool UseCustomErrorSound { get; set; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue