public TranslationRequest(string inSentence, TranslationEngineName translationEngineName, string fromLang, string toLang)
 {
     InSentence            = inSentence;
     TranslationEngineName = translationEngineName;
     FromLang = fromLang;
     ToLang   = toLang;
 }
Example #2
0
 public TranslationEngine(TranslationEngineName translationEngineName, List <TranslatorLanguague> translatorLanguagues, double quality)
 {
     this.EngineName     = translationEngineName;
     _SupportedLanguages = new ReadOnlyCollection <TranslatorLanguague>(translatorLanguagues);
     Quality             = quality;
 }
Example #3
0
        private void CreateBinderCouples(PropertyBinder binder)
        {
            binder.AddPropertyCouple(new PropertyCouple <string, string>("Name", "Name"));
            binder.AddPropertyCouple(new PropertyCouple <double, double>("ChatFontSize", "ChatFontSize"));
            binder.AddPropertyCouple(new PropertyCouple <double, double>("LineBreakHeight", "LineBreakHeight"));
            binder.AddPropertyCouple(new PropertyCouple <int, int>("SpacingCount", "SpacingCount"));

            binder.AddPropertyCouple(new PropertyCouple <System.Windows.Media.FontFamily, System.Windows.Media.FontFamily>("ChatFont", "ChatFont"));

            binder.AddPropertyCouple(new PropertyCouple <bool, bool>("IsAlwaysOnTop", "IsAlwaysOnTop"));
            binder.AddPropertyCouple(new PropertyCouple <bool, bool>("IsClickThrough", "IsClickThrough"));
            binder.AddPropertyCouple(new PropertyCouple <bool, bool>("IsAutoHide", "IsAutoHide"));

            binder.AddPropertyCouple(new PropertyCouple <TimeSpan, TimeSpan>("AutoHideTimeout", "AutoHideTimeout"));

            //binder.AddPropertyCouple(new PropertyCouple<bool, bool>("IsHiddenByUser", "IsHiddenByUser"));

            binder.AddPropertyCouple(new PropertyCouple <System.Windows.Media.Color, System.Windows.Media.Color>("BackGroundColor", "BackGroundColor"));

            binder.AddPropertyCouple(new PropertyCouple <bool, bool>("ShowTimestamps", "ShowTimestamps"));

            binder.AddPropertyCouple(new PropertyCouple <System.Drawing.RectangleD, System.Drawing.RectangleD>("ChatWindowRectangle", "ChatWindowRectangle"));

            binder.AddPropertyCouple(new PropertyCouple <TranslationEngineName, System.Windows.Data.CollectionView>("TranslationEngineName", "TranslationEngines",
                                                                                                                    (ref TranslationEngineName x, ref System.Windows.Data.CollectionView y) =>
            {
                var engine     = x;
                var collection = y;

                UiWindow.Window.UIThread(() =>
                {
                    TranslationEngine result = null;

                    foreach (TranslationEngine elem in collection.SourceCollection)
                    {
                        if (elem.EngineName == engine)
                        {
                            result = elem;
                            break;
                        }
                    }

                    if (result != null)
                    {
                        if (!collection.CurrentItem.Equals(result))
                        {
                            collection.MoveCurrentTo(result);
                        }
                    }
                });
            },
                                                                                                                    (ref System.Windows.Data.CollectionView y, ref TranslationEngineName x) =>
            {
                var collection = y;
                TranslationEngineName selectedEngine = TranslationEngineName.GoogleTranslate;

                UiWindow.Window.UIThread(() =>
                {
                    selectedEngine = ((TranslationEngine)collection.CurrentItem).EngineName;
                });
                x = selectedEngine;
            }));


            binder.AddPropertyCouple(new PropertyCouple <TranslatorLanguague, System.Windows.Data.CollectionView>("FromLanguague", "TranslateFromLanguagues",
                                                                                                                  (ref TranslatorLanguague x, ref System.Windows.Data.CollectionView y) =>
            {
                var languague  = x;
                var collection = y;

                UiWindow.Window.UIThread(() =>
                {
                    TranslatorLanguague result = null;

                    foreach (TranslatorLanguague elem in collection.SourceCollection)
                    {
                        if (elem.SystemName == languague.SystemName)
                        {
                            result = elem;
                            break;
                        }
                    }

                    if (result != null)
                    {
                        if (!collection.CurrentItem.Equals(result))
                        {
                            collection.MoveCurrentTo(result);
                        }
                    }
                });
            },
                                                                                                                  (ref System.Windows.Data.CollectionView y, ref TranslatorLanguague x) =>
            {
                var collection           = y;
                TranslatorLanguague lang = new TranslatorLanguague();

                UiWindow.Window.UIThread(() =>
                {
                    lang = new TranslatorLanguague((TranslatorLanguague)collection.CurrentItem);
                });

                x = lang;
            }));

            binder.AddPropertyCouple(new PropertyCouple <TranslatorLanguague, System.Windows.Data.CollectionView>("ToLanguague", "TranslateToLanguagues",
                                                                                                                  (ref TranslatorLanguague x, ref System.Windows.Data.CollectionView y) =>
            {
                var languague  = x;
                var collection = y;

                UiWindow.Window.UIThread(() =>
                {
                    TranslatorLanguague result = null;

                    foreach (TranslatorLanguague elem in collection.SourceCollection)
                    {
                        if (elem.SystemName == languague.SystemName)
                        {
                            result = elem;
                            break;
                        }
                    }

                    if (result != null)
                    {
                        if (!collection.CurrentItem.Equals(result))
                        {
                            collection.MoveCurrentTo(result);
                        }
                    }
                });
            },
                                                                                                                  (ref System.Windows.Data.CollectionView y, ref TranslatorLanguague x) =>
            {
                var collection           = y;
                TranslatorLanguague lang = new TranslatorLanguague();


                UiWindow.Window.UIThread(() =>
                {
                    lang = new TranslatorLanguague((TranslatorLanguague)collection.CurrentItem);
                });
                x = lang;
            }));

            binder.AddPropertyCouple(new PropertyCouple <WinUtils.HotKeyCombination, WinUtils.HotKeyCombination>("ShowHideChatKeys", "ShowHideChatKeys"));
            binder.AddPropertyCouple(new PropertyCouple <WinUtils.HotKeyCombination, WinUtils.HotKeyCombination>("ClickThoughtChatKeys", "ClickThoughtChatKeys"));
            binder.AddPropertyCouple(new PropertyCouple <WinUtils.HotKeyCombination, WinUtils.HotKeyCombination>("ClearChatKeys", "ClearChatKeys"));

            binder.AddPropertyCouple(new PropertyCouple <List <ChatCodeViewModel>, BindingList <ChatCodeViewModel> >("ChatCodes", "ChatCodes",
                                                                                                                     (ref List <ChatCodeViewModel> x, ref BindingList <ChatCodeViewModel> y) =>
            {
                var list        = x;
                var bindinglist = y;

                UiWindow.Window.UIThread(() =>
                {
                    foreach (var code in list)
                    {
                        var fCode = bindinglist.FirstOrDefault(p => p.Equals(code));
                        if (fCode != null)
                        {
                            fCode.Color     = code.Color;
                            fCode.IsChecked = code.IsChecked;
                        }
                    }
                });
            },
                                                                                                                     (ref BindingList <ChatCodeViewModel> y, ref List <ChatCodeViewModel> x) =>
            {
                var list        = x;
                var bindinglist = y;

                UiWindow.Window.UIThread(() =>
                {
                    foreach (var code in bindinglist)
                    {
                        var fCode = list.FirstOrDefault(p => p.Equals(code));
                        if (fCode != null)
                        {
                            fCode.Color     = code.Color;
                            fCode.IsChecked = code.IsChecked;
                        }
                    }
                });
            }));
        }