public void OnClick(View v)
        {
            switch (v.Id)
            {
            case Resource.Id.btnTranslate:
                if (string.IsNullOrEmpty(etFrom.Text))
                {
                    return;
                }
                TranslateTask translateTask = new TranslateTask(this);
                translateTask.Execute(new TranslateParams()
                {
                    TextToTranslate = etFrom.Text, IsRuToEng = isRuToEng
                });
                break;

            case Resource.Id.btnSwapLngs:
                isRuToEng = !isRuToEng;
                InitTexts();
                break;

            case Resource.Id.btnAddToFav:
                if (isTextChanged)
                {
                    Toast.MakeText(this, Resource.String.need_to_translate, ToastLength.Long).Show();
                }
                else
                {
                    realm.Write(() => {
                        Translation translation;
                        if (isRuToEng)
                        {
                            translation = realm.All <Translation>().Where(t => t.RuText.Equals(etFrom.Text.ToLower().Trim())).FirstOrDefault();
                        }
                        else
                        {
                            translation = realm.All <Translation>().Where(t => t.EngText.Equals(etFrom.Text.ToLower().Trim())).FirstOrDefault();
                        }
                        if (translation != null)
                        {
                            translation.IsInFavorits = true;
                            Toast.MakeText(this, Resource.String.traslation_added, ToastLength.Long).Show();
                        }
                        realm.Refresh();
                    });
                }
                break;

            case Resource.Id.btnShowFavs:
                Intent intent = new Intent(this, typeof(FavoritsList));
                StartActivity(intent);
                break;
            }
        }
示例#2
0
        private static ConversionResult CreateFileType(string file, bool doTtx, string tmPath)
        {
            var t = new TranslateTask();

            t.Documents.Clear();
            t.Documents.Add(file);
            t.OpenTranslationMemory($"{tmPath.Replace(".tmw", string.Empty)}.mdf", Environment.UserName,
                                    tmaTmAccessMode.tmaTmAccessExclusive, null, 0);
            t.Settings.LogFileName = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                @"SDL\OpenExchange\TTXIT\Log\conversion.log");

            if (!Directory.Exists(Path.GetDirectoryName(t.Settings.LogFileName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(t.Settings.LogFileName));
            }
            using (var sw = new StreamWriter(t.Settings.LogFileName, true))
            {
                sw.Write(" ");
            }

            t.Settings.SegmentUnknownSentences = true;
            t.Settings.SaveDocAsTtx            = doTtx;

            var backdoor = (IRunStatus)t;
            int p1, p2, p3, p4;

            backdoor.GetParameters(out p1, out p2, out p3, out p4);
            GenerateResponse(ref p1, ref p2, ref p3, ref p4);
            backdoor.SetParameters(p1, p2, p3, p4);


            t.Execute();



            t.CloseTranslationMemory();

            return(new ConversionResult(file));
        }
示例#3
0
        private static ConversionResult CreateFileType(string file, bool doTtx, string tmPath)
        {
            var t = new TranslateTask();
            t.Documents.Clear();
            t.Documents.Add(file);
            t.OpenTranslationMemory($"{tmPath.Replace(".tmw", string.Empty)}.mdf", Environment.UserName,
                                    tmaTmAccessMode.tmaTmAccessExclusive, null, 0);
            t.Settings.LogFileName = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                @"SDL\OpenExchange\TTXIT\Log\conversion.log");

            if (!Directory.Exists(Path.GetDirectoryName(t.Settings.LogFileName)))
                Directory.CreateDirectory(Path.GetDirectoryName(t.Settings.LogFileName));
            using (var sw = new StreamWriter(t.Settings.LogFileName, true))
            {
                sw.Write(" ");
            }

            t.Settings.SegmentUnknownSentences = true;
            t.Settings.SaveDocAsTtx = doTtx;

            var backdoor = (IRunStatus) t;
            int p1, p2, p3, p4;
            backdoor.GetParameters(out p1, out p2, out p3, out p4);
            GenerateResponse(ref p1, ref p2, ref p3, ref p4);
            backdoor.SetParameters(p1, p2, p3, p4);


                t.Execute();

            
           
            t.CloseTranslationMemory();
            
            return new ConversionResult(file);
        }