/// <summary>
        /// συνάρτηση για το φόρτωμα των ρυθμίσεων από την registry του υπολογιστή
        /// </summary>
        private void loadPreferences()
        {
            data = new RegUserPreferences();
            FromLanguageCombo.ItemsSource = Languages.getDisplayNameList();
            ToLanguageCombo.ItemsSource = Languages.getDisplayNameListWithoutAuto();

            translateKeyCombo.ItemsSource = Keyboard.keys;
            startstopKeyCombo.ItemsSource = Keyboard.keys;

            FromLanguageCombo.SelectedIndex = Languages.getIndexOfLanguage(data.FromLanguage);
            ToLanguageCombo.SelectedIndex = Languages.getIndexOfLanguage(data.ToLanguage);

            translateKeyCombo.Text = data.Key;
            translateKeyCTRL.IsChecked = data.CTRL;
            translateKeyALT.IsChecked = data.ALT;
            translateKeySHIFT.IsChecked = data.SHIFT;

            startstopKeyCombo.Text = data.StartstopKey;
            startstopKeyCTRL.IsChecked = data.StartstopCTRL;
            startstopKeyALT.IsChecked = data.StartstopALT;
            startstopKeySHIFT.IsChecked = data.StartstopSHIFT;
            startstopKeyEnable.IsChecked = data.StartstopENABLED;
        }
        /// <summary>
        /// συνάρτηση δημιουργίας ομιλίας σύμφωνα με επιλεγμένο κείμενο
        /// </summary>
        /// <param name="message">κείμενο να "ακουστεί"</param>
        public static string SpeakMethod(string message)
        {
            data = new RegUserPreferences();
            string uri = "http://api.microsofttranslator.com/v2/Http.svc/Speak?text="
                            + message + "&language=" + data.FromLanguageShort + "&format=audio/wav"
                            + "&options=MaxQuality";

            WebRequest webRequest = WebRequest.Create(uri);
            webRequest.Headers.Add("Authorization", headerValue);
            WebResponse response = null;
            try
            {
                response = webRequest.GetResponse();
                using (Stream stream = response.GetResponseStream())
                {
                    using (SoundPlayer player = new SoundPlayer(stream))
                    {
                        player.PlaySync();
                    }
                }
            }
            catch
            {
                return "error";
                throw;
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                    response = null;
                }
            }
            return "";
        }
        /// <summary>
        /// συνάρτηση μετάφρασης
        /// </summary>
        /// <param name="sourceText"> κείμενο προς μετάφραση</param>
        /// <returns>μεταφρασμένο κείμενο</returns>
        public static string translate(string sourceText)
        {
            data = new RegUserPreferences();
            string fromLanguage = data.FromLanguageShort;
            if (data.FromLanguageShort.Equals("auto"))
            {
                fromLanguage = detect(sourceText);
                if (fromLanguage.Equals("TranslatorException"))
                {
                    init();
                    fromLanguage = detect(sourceText);
                }
            }

            try
            {
                TranslatorService.LanguageServiceClient client = new TranslatorService.LanguageServiceClient();

                HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                httpRequestProperty.Headers.Add("Authorization", headerValue);
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
                    string translationResult;

                    translationResult = client.Translate("", sourceText, fromLanguage, data.ToLanguageShort, "text/plain", "");

                    return translationResult;
                }
            }
            catch (Exception )
            {
                //return (ex.Message);
                return "TranslatorException";
            }
        }
        /// <summary>
        /// συνάρτηση εκκίνησης της διαδικασίας μετάφρασης
        /// </summary>
        public static bool init()
        {
            data = new RegUserPreferences();
            admAuth = new AdmAuthentication("teikavtranslatorZaxVag", "c8NjSbyiJGdZRkY9Iz8vS2K8dpIgxxy94CTpe/ii1Zg=");
            try
            {
                admToken = admAuth.GetAccessToken();
                headerValue = "Bearer " + admToken.access_token;

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return false;
            }
            //GetLanguagesForSpeakMethod();
            return true;
        }