Exemple #1
0
        private void GenerateContent()
        {
            Log.DebugFormat("GenerateContent called. Language setting is '{0}' and Keyboard type is '{1}'", 
                Settings.Default.Language, Keyboard != null ? Keyboard.GetType() : null);

            var cultureInfo = Settings.Default.Language.ToCultureInfo();
            if (!Equals(cultureInfo, Properties.Resources.Culture)) 
            {
                //Updates UI and Resource Culture to reflect selected language
                Thread.CurrentThread.CurrentCulture = cultureInfo;
                Thread.CurrentThread.CurrentUICulture = cultureInfo;
                Properties.Resources.Culture = cultureInfo;
            }
            
            //Clear out point to key map and pause input service
            PointToKeyValueMap = null;
            if(InputService != null)
            {
                InputService.RequestSuspend();
            }
            
            object newContent = ErrorContent;

            if (Keyboard is ViewModelKeyboards.Alpha)
            {
                switch (Settings.Default.Language)
                {
                    case Languages.EnglishUS:
                    case Languages.EnglishUK:
                    case Languages.EnglishCanada:
                        newContent = new EnglishViews.Alpha {DataContext = Keyboard};
                        break;
                    case Languages.FrenchFrance:
                        newContent = new FrenchViews.Alpha {DataContext = Keyboard};
                        break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.ConversationAlpha)
            {
                switch (Settings.Default.Language)
                {
                    case Languages.EnglishUS:
                    case Languages.EnglishUK:
                    case Languages.EnglishCanada:
                        newContent = new EnglishViews.ConversationAlpha { DataContext = Keyboard };
                        break;
                    case Languages.FrenchFrance:
                        newContent = new FrenchViews.ConversationAlpha {DataContext = Keyboard};
                        break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.ConversationNumericAndSymbols)
            {
                newContent = new CommonViews.ConversationNumericAndSymbols { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.Currencies1)
            {
                newContent = new CommonViews.Currencies1 { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.Currencies2)
            {
                newContent = new CommonViews.Currencies2 { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics1)
            {
                switch (Settings.Default.Language)
                {
                    case Languages.EnglishUS:
                    case Languages.EnglishUK:
                    case Languages.EnglishCanada:
                        newContent = new EnglishViews.Diacritics1 { DataContext = Keyboard };
                        break;
                    case Languages.FrenchFrance:
                        newContent = new FrenchViews.Diacritics1 { DataContext = Keyboard };
                        break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics2)
            {
                switch (Settings.Default.Language)
                {
                    case Languages.EnglishUS:
                    case Languages.EnglishUK:
                    case Languages.EnglishCanada:
                        newContent = new EnglishViews.Diacritics2 { DataContext = Keyboard };
                        break;
                    case Languages.FrenchFrance:
                        newContent = new FrenchViews.Diacritics2 { DataContext = Keyboard };
                        break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics3)
            {
                switch (Settings.Default.Language)
                {
                    case Languages.EnglishUS:
                    case Languages.EnglishUK:
                    case Languages.EnglishCanada:
                        newContent = new EnglishViews.Diacritics3 { DataContext = Keyboard };
                        break;
                    case Languages.FrenchFrance:
                        newContent = new FrenchViews.Diacritics3 { DataContext = Keyboard };
                        break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Menu)
            {
                newContent = new CommonViews.Menu { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.Minimised)
            {
                newContent = new CommonViews.Minimised { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.Mouse)
            {
                newContent = new CommonViews.Mouse { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols2)
            {
                newContent = new CommonViews.NumericAndSymbols2 { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols3)
            {
                newContent = new CommonViews.NumericAndSymbols3 { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols1)
            {
                newContent = new CommonViews.NumericAndSymbols1 { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.PhysicalKeys)
            {
                newContent = new CommonViews.PhysicalKeys { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.SizeAndPosition)
            {
                newContent = new CommonViews.SizeAndPosition { DataContext = Keyboard };
            }
            else if (Keyboard is ViewModelKeyboards.YesNoQuestion)
            {
                newContent = new CommonViews.YesNoQuestion { DataContext = Keyboard };
            }

            Content = newContent;
        }
Exemple #2
0
        private void GenerateContent()
        {
            Log.DebugFormat("GenerateContent called. Language setting is '{0}' and Keyboard type is '{1}'",
                            Settings.Default.Language, Keyboard != null ? Keyboard.GetType() : null);

            var cultureInfo = Settings.Default.Language.ToCultureInfo();

            if (!Equals(cultureInfo, Properties.Resources.Culture))
            {
                //Updates UI and Resource Culture to reflect selected language
                Thread.CurrentThread.CurrentCulture   = cultureInfo;
                Thread.CurrentThread.CurrentUICulture = cultureInfo;
                Properties.Resources.Culture          = cultureInfo;
            }

            //Clear out point to key map and pause input service
            PointToKeyValueMap = null;
            if (InputService != null)
            {
                InputService.RequestSuspend();
            }

            object newContent = ErrorContent;

            if (Keyboard is ViewModelKeyboards.Alpha)
            {
                switch (Settings.Default.Language)
                {
                case Languages.EnglishUS:
                case Languages.EnglishUK:
                case Languages.EnglishCanada:
                    newContent = new EnglishViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.FrenchFrance:
                    newContent = new FrenchViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.ConversationAlpha)
            {
                switch (Settings.Default.Language)
                {
                case Languages.EnglishUS:
                case Languages.EnglishUK:
                case Languages.EnglishCanada:
                    newContent = new EnglishViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.FrenchFrance:
                    newContent = new FrenchViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.ConversationNumericAndSymbols)
            {
                newContent = new CommonViews.ConversationNumericAndSymbols {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Currencies1)
            {
                newContent = new CommonViews.Currencies1 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Currencies2)
            {
                newContent = new CommonViews.Currencies2 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics1)
            {
                switch (Settings.Default.Language)
                {
                case Languages.EnglishUS:
                case Languages.EnglishUK:
                case Languages.EnglishCanada:
                    newContent = new EnglishViews.Diacritics1 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.FrenchFrance:
                    newContent = new FrenchViews.Diacritics1 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics2)
            {
                switch (Settings.Default.Language)
                {
                case Languages.EnglishUS:
                case Languages.EnglishUK:
                case Languages.EnglishCanada:
                    newContent = new EnglishViews.Diacritics2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.FrenchFrance:
                    newContent = new FrenchViews.Diacritics2 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics3)
            {
                switch (Settings.Default.Language)
                {
                case Languages.EnglishUS:
                case Languages.EnglishUK:
                case Languages.EnglishCanada:
                    newContent = new EnglishViews.Diacritics3 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.FrenchFrance:
                    newContent = new FrenchViews.Diacritics3 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Menu)
            {
                newContent = new CommonViews.Menu {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Minimised)
            {
                newContent = new CommonViews.Minimised {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Mouse)
            {
                newContent = new CommonViews.Mouse {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols2)
            {
                newContent = new CommonViews.NumericAndSymbols2 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols3)
            {
                newContent = new CommonViews.NumericAndSymbols3 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols1)
            {
                newContent = new CommonViews.NumericAndSymbols1 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.PhysicalKeys)
            {
                newContent = new CommonViews.PhysicalKeys {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.SizeAndPosition)
            {
                newContent = new CommonViews.SizeAndPosition {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.YesNoQuestion)
            {
                newContent = new CommonViews.YesNoQuestion {
                    DataContext = Keyboard
                };
            }

            Content = newContent;
        }