From 289df0751a06c5fb66582f06f236239eca3736d5 Mon Sep 17 00:00:00 2001
From: Xjph <archseraphim@gmail.com>
Date: Mon, 13 Sep 2021 09:48:16 -0230
Subject: [PATCH] prevent exception when testing with no voice

---
 ObservatoryCore/UI/Views/BasicUIView.axaml.cs | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/ObservatoryCore/UI/Views/BasicUIView.axaml.cs b/ObservatoryCore/UI/Views/BasicUIView.axaml.cs
index d45b4e9..c5a1301 100644
--- a/ObservatoryCore/UI/Views/BasicUIView.axaml.cs
+++ b/ObservatoryCore/UI/Views/BasicUIView.axaml.cs
@@ -23,7 +23,6 @@ namespace Observatory.UI.Views
 
         public BasicUIView()
         {
-            Initialized += OnInitialized;
             InitializeComponent();
         }
 
@@ -65,15 +64,11 @@ namespace Observatory.UI.Views
             e.Column.CanUserSort = true;
         }
 
-        private void OnInitialized(object sender, System.EventArgs e)
-        {
-            
-        }
-
         private void UITypeChange()
         {
             var uiPanel = this.Find<Panel>("UIPanel");
             dataGrid = null;
+
             switch (UIType)
             {
                 case PluginUI.UIType.None:
@@ -442,7 +437,7 @@ namespace Observatory.UI.Views
 
                 voiceTestButton.Click += (object sender, RoutedEventArgs e) =>
                 {
-                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Properties.Core.Default.VoiceSelected.Length > 0)
                     {
                         var speech = new System.Speech.Synthesis.SpeechSynthesizer()
                         {
@@ -466,7 +461,6 @@ namespace Observatory.UI.Views
                         };
 
                         speech.SpeakAsync("Speech Synthesis Test: " + harvardSentences.OrderBy(s => new Random().NextDouble()).First());
-
                     }
                 };