コード例 #1
0
    /// <summary>
    /// Initializes the module.
    /// </summary>
    public static void Initialize()
    {
        var serviceLocator = ServiceLocator.Default;

        // Fix for https://github.com/Catel/Catel/issues/1208
        serviceLocator.RegisterType <IEntryAssemblyResolver, EntryAssemblyResolver>();

        InitializeLogging();

        // Ensure that we are using the right culture
#pragma warning disable WPF0011 // Containing type should be used as registered owner.
        FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
                                                           new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
#pragma warning restore WPF0011 // Containing type should be used as registered owner.

        // Overide style of Catel please wait service
        serviceLocator.RegisterType <IPleaseWaitService, Orchestra.Services.PleaseWaitService>();

        serviceLocator.RegisterTypeIfNotYetRegistered <IThirdPartyNoticesService, ThirdPartyNoticesService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <ICloseApplicationService, CloseApplicationService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IRecentlyUsedItemsService, RecentlyUsedItemsService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IKeyboardMappingsService, KeyboardMappingsService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IStatusFilterService, StatusFilterService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IStatusService, StatusService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <Orchestra.Services.ISplashScreenService, Orchestra.Services.SplashScreenService>();

        serviceLocator.RegisterTypeIfNotYetRegistered <ICommandInfoService, CommandInfoService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IAppDataService, AppDataService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IEnsureStartupService, EnsureStartupService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IAccentColorService, AccentColorService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IAboutInfoService, AboutInfoService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IAboutService, AboutService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IClipboardService, ClipboardService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IThemeService, ThemeService>();
        serviceLocator.RegisterTypeIfNotYetRegistered <IViewActivationService, ViewActivationService>();

        serviceLocator.RegisterType <IMessageService, Orchestra.Services.MessageService>();

        // Hints system
        serviceLocator.RegisterType <IAdorneredTooltipsCollection, AdorneredTooltipsCollection>();
        serviceLocator.RegisterType <IAdornerLayer, HintsAdornerLayer>();
        serviceLocator.RegisterType <IAdorneredTooltipsManager, AdorneredTooltipsManager>();
        serviceLocator.RegisterType <IHintsProvider, HintsProvider>();

        serviceLocator.RegisterType <IAdornerLayer, HintsAdornerLayer>(RegistrationType.Transient);
        serviceLocator.RegisterType <IAdorneredTooltipFactory, AdorneredTooltipFactory>(RegistrationType.Transient);
        serviceLocator.RegisterType <IAdorneredTooltipsCollection, AdorneredTooltipsCollection>(RegistrationType.Transient);

        var uiVisualizerService = serviceLocator.ResolveType <IUIVisualizerService>();

        // Can be replaced by this in the future:
        //uiVisualizerService.Register<KeyboardMappingsCustomizationViewModel, KeyboardMappingsCustomizationWindow>(false);
        //uiVisualizerService.Register<KeyboardMappingsOverviewViewModel, KeyboardMappingsOverviewWindow>(false);

        if (!uiVisualizerService.IsRegistered(typeof(KeyboardMappingsCustomizationViewModel)))
        {
            uiVisualizerService.Register(typeof(KeyboardMappingsCustomizationViewModel).FullName, typeof(KeyboardMappingsCustomizationWindow));
        }

        if (!uiVisualizerService.IsRegistered(typeof(KeyboardMappingsOverviewViewModel)))
        {
            uiVisualizerService.Register(typeof(KeyboardMappingsOverviewViewModel).FullName, typeof(KeyboardMappingsOverviewWindow));
        }

        var thirdPartyNoticesService = serviceLocator.ResolveType <IThirdPartyNoticesService>();
        thirdPartyNoticesService.AddWithTryCatch(() => new ResourceBasedThirdPartyNotice("Catel", "https://www.catelproject.com", "Orchestra.Core", "Orchestra", "Resources.ThirdPartyNotices.catel.txt"));
        thirdPartyNoticesService.AddWithTryCatch(() => new ResourceBasedThirdPartyNotice("DotNetZip", string.Empty, "Orchestra.Core", "Orchestra", "Resources.ThirdPartyNotices.dotnetzip.txt"));
        thirdPartyNoticesService.AddWithTryCatch(() => new ResourceBasedThirdPartyNotice("Orchestra", "https://opensource.wildgums.com", "Orchestra.Core", "Orchestra", "Resources.ThirdPartyNotices.orchestra.txt"));
        thirdPartyNoticesService.AddWithTryCatch(() => new ResourceBasedThirdPartyNotice("Ricciolo", string.Empty, "Orchestra.Core", "Orchestra", "Resources.ThirdPartyNotices.ricciolo.txt"));

        var languageService = serviceLocator.ResolveType <ILanguageService>();
        languageService.RegisterLanguageSource(new LanguageResourceSource("Orchestra.Core", "Orchestra.Properties", "Resources"));

        DotNetPatchHelper.Initialize();
    }
コード例 #2
0
        private static void InitializeCultures()
        {
            if (!string.IsNullOrEmpty(Settings.Default.Culture))
            {
                LocalizeDictionary.Instance.Culture
                      = Thread.CurrentThread.CurrentCulture
                      = new CultureInfo(Settings.Default.Culture);
            }

            if (!string.IsNullOrEmpty(Settings.Default.UICulture))
            {
                LocalizeDictionary.Instance.Culture
                      = Thread.CurrentThread.CurrentUICulture
                      = new CultureInfo(Settings.Default.UICulture);
            }

            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name)));
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: weishig/Project-19004
        private void ApplicationStartup(object sender, StartupEventArgs e)
        {
            DoHandleUnexpectedExceptions = true;
            try
            {
                //#if DEBUG
                //#else
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
                //#endif

                FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

                CommonUserSettings.InitializeCommonSettings(ELLO.Properties.Settings.Default);
                // setup the JumpList features before testing for single application as otherwise the JumpList can be reset
                JumpList jumpList = JumpList.GetJumpList(Current);

                JumpTask jt = new JumpTask
                {
                    Title            = "Edit application settings",
                    ApplicationPath  = SettingPath(ApplicationName + ".Config", App.ApplicationName),
                    IconResourcePath = @"c:\windows\notepad.exe",
                    Description      = "Edit the application configuration file to customise settings",
                    CustomCategory   = "Customise"
                };
                jumpList.JumpItems.Add(jt);

                jt = new JumpTask
                {
                    Arguments        = LogPath(ApplicationName + ".Log"),
                    Title            = "Open MotionControlManager log",
                    ApplicationPath  = @"c:\windows\notepad.exe",
                    IconResourcePath = @"c:\windows\notepad.exe",
                    Description      = "Open the diagnostics log",
                    CustomCategory   = "Logging"
                };
                jumpList.JumpItems.Add(jt);

                jumpList.Apply();

                // Create the View Model for the Main Window
                _mainWindowViewModel = new MainWindowViewModel(e.Args);

                // Set it as the DataContext for Binding and Commanding
                _mainWindow = new MainWindow(_mainWindowViewModel);

                _mainWindow.Show();
                Thread.Sleep(500);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Caught exception: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
            FrameworkContentElement.LanguageProperty.OverrideMetadata(typeof(Run), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            new Bootstrapper().Run();
        }
コード例 #5
0
        public static void SetCurrent(string name, bool init)
        {
            Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = string.Equals(name, DEFAULT, StringComparison.Ordinal) ? Default : new CultureInfo(name);

            if (init)
            {
                FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name)));
            }
        }
コード例 #6
0
        BeginPersistObjectData(SerializableObjectContext serializableObjectContext, out ReachTreeWalker treeWalker)
        {
            if (serializableObjectContext == null)
            {
                throw new ArgumentNullException("serializableObjectContext");
            }

            _xpsOMSerializationManager.RegisterPageStart();


            if (serializableObjectContext.IsComplexValue)
            {
                PrintTicket printTicket = _xpsOMSerializationManager.FixedPagePrintTicket;

                if (printTicket != null)
                {
                    PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
                    serializer.SerializeObject(printTicket);
                    _xpsOMSerializationManager.FixedPagePrintTicket = null;
                }
            }

            FixedPage fixedPage = serializableObjectContext.TargetObject as FixedPage;

            treeWalker = new ReachTreeWalker(this);
            treeWalker.SerializeLinksInFixedPage((FixedPage)serializableObjectContext.TargetObject);

            String xmlnsForType = SerializationManager.GetXmlNSForType(serializableObjectContext.TargetObject.GetType());

            if (xmlnsForType == null)
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);
            }
            else
            {
                XmlWriter.WriteStartElement(serializableObjectContext.Name);

                XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType);
                XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema);

                XmlLanguage language = fixedPage.Language;
                if (language == null)
                {
                    //If the language property is null, assign the language to the default
                    language = XmlLanguage.GetLanguage(XpsS0Markup.XmlLangValue);
                }

                SerializationManager.Language = language;

                XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, language.ToString());
            }

            Size fixedPageSize = new Size(fixedPage.Width, fixedPage.Height);

            _xpsOMSerializationManager.FixedPageSize = fixedPageSize;

            //
            // Before we serialize any properties on the FixedPage, we need to
            // serialize the FixedPage as a Visual
            //
            Visual fixedPageAsVisual = serializableObjectContext.TargetObject as Visual;

            bool needEndVisual = false;

            if (fixedPageAsVisual != null)
            {
                needEndVisual = SerializePageAsVisual(fixedPageAsVisual);
            }

            return(needEndVisual);
        }
コード例 #7
0
ファイル: App.xaml.cs プロジェクト: VB6Hobbyst7/CNCLib
        private void AppStartup(object sender, StartupEventArgs e)
        {
            string connectString = SqlServerDatabaseTools.ConnectString;

            GlobalDiagnosticsContext.Set("logDir", $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/CNCLib.Sql/logs");
            GlobalDiagnosticsContext.Set("connectionString", connectString);

            try
            {
#if DEBUG
                LogManager.ThrowExceptions = true;
#endif
                NLog.Logger logger = LogManager.GetLogger("foo");

                _logger.Info(@"Starting ...");
#if DEBUG
                LogManager.ThrowExceptions = false;
#endif
            }
            catch (SqlException)
            {
                // ignore Sql Exception
            }

            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            var userContext = new CNCLibUserContext("global");

            AppService.ServiceCollection = new ServiceCollection();
            AppService.ServiceCollection
            .AddFrameWorkTools()
            .AddTransient <ILoggerFactory, LoggerFactory>()
            .AddTransient(typeof(ILogger <>), typeof(Logger <>))
            .AddRepository(SqlServerDatabaseTools.OptionBuilder)
            .AddLogic()
            .AddLogicClient()
            .AddSerialCommunication()
            .AddServiceAsLogic()
            .AddCNCLibWpf()
            .AddMapper(
                new MapperConfiguration(
                    cfg =>
            {
                cfg.AddProfile <LogicAutoMapperProfile>();
                cfg.AddProfile <WpfAutoMapperProfile>();
                cfg.AddProfile <GCodeGUIAutoMapperProfile>();
            }))
            .AddSingleton((ICNCLibUserContext)userContext);

            AppService.BuildServiceProvider();

            // Open Database here

            try
            {
                CNCLibContext.InitializeDatabase2();
            }
            catch (Exception ex)
            {
                _logger.Error(ex);

                MessageBox.Show("Cannot connect to database" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Current.Shutdown();
            }

            var task = Task.Run(async() => await userContext.InitUserContext());
            while (!task.IsCompleted)
            {
                Task.Yield();
            }
        }
コード例 #8
0
 private void SetLang()
 {
     if (ui_lang == "PL")
     {
         this.Title                 = "Panel rodzica";
         btn_raport.Content         = "Generuj raport";
         lbl_history.Content        = "Historia operacji";
         lbl_newpay.Content         = "Nowa operacja";
         lbl_name.Content           = "Nazwa operacji";
         lbl_price.Content          = "Kwota";
         lbl_category.Content       = "Kategoria";
         chkbx_childPay.Content     = "Przelew do potomka";
         btn_addTransaction.Content = "Zatwierdź";
         rbtn_payin.Content         = "Przychód";
         rbtn_payout.Content        = "Wydatek";
         lbl_expensesinfo.Content   = "Wydatki:";
         lbl_revenuesinfo.Content   = "Przychody";
         lbl_saldoinfo.Content      = "Saldo";
         cal_calendar.Language      = XmlLanguage.GetLanguage("pl-PL");
     }
     else if (ui_lang == "GB")
     {
         this.Title                 = "Parent panel";
         btn_raport.Content         = "Generate report";
         lbl_history.Content        = "Operation history";
         lbl_newpay.Content         = "New operation";
         lbl_name.Content           = "Operation name";
         lbl_price.Content          = "Amount";
         lbl_category.Content       = "Category";
         btn_addTransaction.Content = "Submit";
         lbl_expensesinfo.Content   = "Expenses:";
         lbl_revenuesinfo.Content   = "Revenues:";
         lbl_saldoinfo.Content      = "Balance:";
         chkbx_childPay.Content     = "Transfer to the child";
         rbtn_payin.Content         = "Income";
         rbtn_payout.Content        = "Expenditure";
         cal_calendar.Language      = XmlLanguage.GetLanguage("en-US");
     }
     else if (ui_lang == "DE")
     {
         this.Title                 = "Parent panel";
         btn_raport.Content         = "Einen Bericht erstellen";
         lbl_history.Content        = "Betriebsverlauf";
         lbl_newpay.Content         = "Neuer Betrieb";
         lbl_name.Content           = "Der Name der Operation";
         lbl_price.Content          = "Betrag";
         lbl_category.Content       = "Kategorie";
         btn_addTransaction.Content = "Einreichen";
         lbl_expensesinfo.Content   = "Kosten:";
         lbl_revenuesinfo.Content   = "Einnahmen:";
         lbl_saldoinfo.Content      = "Balance:";
         chkbx_childPay.Content     = "Übertragung auf das Kind";
         rbtn_payin.Content         = "Einkommen";
         rbtn_payout.Content        = "Ausgabe";
         cal_calendar.Language      = XmlLanguage.GetLanguage("de-DE");
     }
     else
     {
         lbl_history.Content        = "Operation history";
         lbl_newpay.Content         = "New operation";
         lbl_name.Content           = "Operation name";
         lbl_price.Content          = "Amount";
         lbl_category.Content       = "Category";
         btn_addTransaction.Content = "Submit";
         lbl_expensesinfo.Content   = "Expenses:";
         lbl_revenuesinfo.Content   = "Revenues:";
         lbl_saldoinfo.Content      = "Balance:";
         chkbx_childPay.Content     = "Transfer to the child";
         rbtn_payin.Content         = "Income";
         rbtn_payout.Content        = "Expenditure";
         cal_calendar.Language      = XmlLanguage.GetLanguage("en-US");
     }
 }
コード例 #9
0
        /// <summary>
        /// Compute a shaped glyph run object from specified glyph-based info
        /// </summary>
        internal sealed override GlyphRun ComputeShapedGlyphRun(
            Point origin,
            char[]                   characterString,
            ushort[]                 clusterMap,
            ushort[]                 glyphIndices,
            IList <double> glyphAdvances,
            IList <Point> glyphOffsets,
            bool rightToLeft,
            bool sideways
            )
        {
            Invariant.Assert(_shapeTypeface != null);
            Invariant.Assert(glyphIndices != null);
            // Device fonts are only used through the LS non-glyphed code path. Only when a DigitCulture is set
            // will a potential device font be ignored and come through shaping.
            Invariant.Assert(_shapeTypeface.DeviceFont == null || _textItem.DigitCulture != null);

            bool[] caretStops = null;

            if (clusterMap != null &&
                (HasExtendedCharacter || NeedsCaretInfo)
                )
            {
                caretStops = new bool[clusterMap.Length + 1];

                // caret stops at cluster boundaries, the first and the last entries are always set
                caretStops[0] = true;
                caretStops[clusterMap.Length] = true;

                ushort lastGlyph = clusterMap[0];

                for (int i = 1; i < clusterMap.Length; i++)
                {
                    ushort glyph = clusterMap[i];

                    if (glyph != lastGlyph)
                    {
                        caretStops[i] = true;
                        lastGlyph     = glyph;
                    }
                }
            }

            return(GlyphRun.TryCreate(
                       _shapeTypeface.GlyphTypeface,
                       (rightToLeft ? 1 : 0),
                       sideways,
                       _emSize,
                       (float)_properties.PixelsPerDip,
                       glyphIndices,
                       origin,
                       glyphAdvances,
                       glyphOffsets,
                       characterString,
                       null,
                       clusterMap,
                       caretStops,
                       XmlLanguage.GetLanguage(CultureMapper.GetSpecificCulture(_properties.CultureInfo).IetfLanguageTag),
                       _textFormattingMode
                       ));
        }
コード例 #10
0
 public object Convert([CanBeNull] object value, [CanBeNull] Type targetType, [CanBeNull] object parameter, [CanBeNull] CultureInfo culture)
 {
     return(value is CultureInfo source?XmlLanguage.GetLanguage(source.IetfLanguageTag) : null);
 }
コード例 #11
0
 public App()
 {
     // Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");
     FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
 }
コード例 #12
0
ファイル: LanguageService.cs プロジェクト: nemesv/ASTRA.EMSG
        public void ReloadLocalization()
        {
            var localizationHandler         = ClientContainerLocator.Container.Resolve <ILocalizationHandler>();
            var clientConfigurationProvider = ClientContainerLocator.Container.Resolve <IClientConfigurationProvider>();
            var pacakgeService = ClientContainerLocator.Container.Resolve <IPackageService>();


            string loc = clientConfigurationProvider.LocalizationResourceFileName;

            var    serverPackage = Path.Combine(clientConfigurationProvider.PackageFolderPath, FileNameConstants.ServerPackageDescriptorFileName);
            string language      = "de";

            if (File.Exists(serverPackage))
            {
                var serverPackageDescriptor = pacakgeService.GetSeverpackageDescriptor(serverPackage);

                string newLanguage = serverPackageDescriptor.CurrentCulture.Substring(0, 2);
                string lng         = newLanguage.ToLower();

                if (new[] { "de", "it", "fr" }.Contains(lng))
                {
                    loc      = string.Format("{0}.{1}.resx", FileNameConstants.MobileLocalizationFileNameWithoutExtension, lng);
                    language = lng;
                }
            }

            string localizationResourceFileName = Path.Combine(clientConfigurationProvider.PackageFolderPath,
                                                               clientConfigurationProvider.LocalizationResourceDirectoryPath,
                                                               loc);

            if (!File.Exists(localizationResourceFileName))
            {
                localizationResourceFileName = clientConfigurationProvider.LocalizationResourceFilePath;
            }

            if (File.Exists(localizationResourceFileName))
            {
                LocalizationLocator.SetMobileLocalization(localizationHandler.ReadResourceFile(localizationResourceFileName));
            }
            else
            {
                Loggers.TechLogger.Warn(string.Format("Localization Resource file not found! ({0})", localizationResourceFileName));
            }

            CultureInfo currentCulture = CultureInfo.CreateSpecificCulture("de-CH");

            if (language != "de")
            {
                var newCulture = CultureInfo.CreateSpecificCulture(language + "-CH");
                newCulture.NumberFormat = currentCulture.NumberFormat;
                currentCulture          = newCulture;
            }
            currentCulture.NumberFormat.NumberDecimalSeparator = ".";
            currentCulture.NumberFormat.NumberGroupSeparator   = "'";
            Thread.CurrentThread.CurrentCulture   = currentCulture;
            Thread.CurrentThread.CurrentUICulture = currentCulture;

            if (!isLoaded)
            {
                isLoaded = true;
                FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
            }
            ((ResourceWrapper)Application.Current.Resources["Resx"]).Refresh();
        }
コード例 #13
0
 public EditTerritoryCard()
 {
     this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.Name);
     InitializeComponent();
 }
コード例 #14
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            //Changed by Vipul Thakkar ....
            IProvideValueTarget target = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;

            if (null != target && null != target.TargetObject)
            {
                if (target.TargetObject.GetType().FullName == "System.Windows.SharedDp")
                {
                    return(this);
                }
            }
            //....

            //const string undifnedLanguage = "*****";

            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            foreach (var item in _collection)
            {
                dictionary.Add(item.IetfLanguageTag.Substring(0, 2).ToLower(), item.Text);
            }

            DependencyObject   targetObject;
            DependencyProperty targetProperty;

            if (!TryGetTargetItems(serviceProvider, out targetObject, out targetProperty))
            {
                return(null);
            }

            //Default Text settings according to Default language
            XmlLanguage xmlLanguage = null;

            xmlLanguage = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
            //if (targetObject is FrameworkElement)
            //    xmlLanguage = (targetObject as FrameworkElement).Language;
            //string lan = System.Globalization.CultureInfo.CurrentUICulture.Name.ToString();
            //if ((targetObject as FrameworkElement).Language.IetfLanguageTag != lan.ToLower())
            //{
            // Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo(lan.ToString());
            // }
            //#if SILVERLIGHT

            //#else
            //else if (targetObject is FrameworkContentElement)
            //    xmlLanguage = (targetObject as FrameworkContentElement).Language;
            //#endif
            if (xmlLanguage == null)
            {
                return(null);
            }

            // <--------------- modified by antony
            string defaultValue;

            dictionary.TryGetValue("en", out defaultValue);

            string value;

            if (!dictionary.TryGetValue(
                    xmlLanguage.IetfLanguageTag.Substring(0, 2), out value))
            {
                return(defaultValue);
            }
            // ---->

            PropertyChangeNotifier languageChangeNotifier = new PropertyChangeNotifier(targetObject, "Language");

            targetObject.SetValue(Behavior.LanguageNotifierProperty, languageChangeNotifier);
            languageChangeNotifier.ValueChanged += ((sender1, e1) =>
            {
                PropertyChangeNotifier propNotifier = sender1 as PropertyChangeNotifier;
                XmlLanguage _xmlLanguage = null;
                if (propNotifier.PropertySource is FrameworkElement)
                {
                    _xmlLanguage = (propNotifier.PropertySource as FrameworkElement).Language;
                }
#if SILVERLIGHT
#else
                else if (propNotifier.PropertySource is FrameworkContentElement)
                {
                    _xmlLanguage = (propNotifier.PropertySource as FrameworkContentElement).Language;
                }
#endif
                if (_xmlLanguage != null && !string.IsNullOrEmpty(_xmlLanguage.IetfLanguageTag))
                {
                    string _value;
                    if (dictionary.TryGetValue(_xmlLanguage.IetfLanguageTag.Substring(0, 2), out _value))
                    {
                        propNotifier.PropertySource.SetValue(targetProperty, _value);
                    }
                    else
                    {
                        propNotifier.PropertySource.SetValue(targetProperty, value);
                    }
                }
            });
            targetObject = null;

            return(value);
        }
コード例 #15
0
 public static void SetGlobalLanguage()
 {
     FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
                                                        new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name)));
 }
コード例 #16
0
ファイル: App.xaml.cs プロジェクト: mrgplusm/EscInstaller
        private App()
        {
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
                                                               new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            SaveBackupFileInit();
            //#if !DEBUG
            //          if (IsSingleInstance())
            //        {
            OpenRegKey();



            return;

            //      }
            MessageBox.Show("The installer/monitor software is already running", "Allready open",
                            MessageBoxButton.OK, MessageBoxImage.Error);
            Current.Shutdown();
            //#endif

            //DispatcherHelper.Initialize();
        }
コード例 #17
0
 private void LicenseTab_OnLoaded(object sender, RoutedEventArgs e)
 {
     // Display conversions from WPF bindings in current locale, i.e. Dates
     this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);
 }
コード例 #18
0
 public MainPage()
 {
     InitializeComponent();
     Language = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.Name);
     Loaded  += (s, e) => { FlowDirection = FlowDirection.LeftToRight; };
 }
コード例 #19
0
 public NewDocumentWindow()
 {
     this.InitializeComponent();
     this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag);
     this.Title    = (string)Application.Current.Resources["ApplicationName"];
 }
コード例 #20
0
ファイル: App.xaml.cs プロジェクト: ironcev-forks/TomsToolbox
        public App()
        {
            // Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            _compositionContainer = new CompositionContainer(_compositionCatalog, true);
            _exportProvider       = new ExportProviderAdapter(_compositionContainer);
            _compositionContainer.ComposeExportedValue(_exportProvider);
        }
コード例 #21
0
        public WpfRobot2RouesInterface(GameMode gamemode)
        {
            gameMode = gamemode;
            InitializeComponent();

            //Among other settings, this code may be used
            CultureInfo ci = CultureInfo.CurrentUICulture;

            try
            {
                //Override the default culture with something from app settings
                ci = new CultureInfo("Fr");
            }
            catch { }
            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;

            //Here is the important part for databinding default converters
            FrameworkElement.LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(
                    XmlLanguage.GetLanguage(ci.IetfLanguageTag)));

            //Among other code
            if (CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator != ".")
            {
                //Handler attach - will not be done if not needed
                PreviewKeyDown += new KeyEventHandler(MainWindow_PreviewKeyDown);
            }

            var currentDir    = Directory.GetCurrentDirectory();
            var racineProjets = Directory.GetParent(currentDir);
            var imagePath     = racineProjets.Parent.Parent.FullName.ToString() + "\\Images\\";

            if (gameMode == GameMode.Eurobot)
            {
                worldMapDisplayStrategy.Init(gameMode, LocalWorldMapDisplayType.StrategyMap);
                worldMapDisplayStrategy.SetFieldImageBackGround(imagePath + "Eurobot2020.png");
                worldMapDisplayWaypoint.Init(gameMode, LocalWorldMapDisplayType.WayPointMap);
                worldMapDisplayWaypoint.SetFieldImageBackGround(imagePath + "Eurobot2020.png");
            }
            else if (gameMode == GameMode.RoboCup)
            {
                //worldMapDisplayStrategy.Init(gameMode, LocalWorldMapDisplayType.StrategyMap, imagePath + "RoboCup.png");
                //worldMapDisplayWaypoint.Init(gameMode, LocalWorldMapDisplayType.WayPointMap, imagePath + "RoboCup.png");
            }

            worldMapDisplayStrategy.InitTeamMate((int)TeamId.Team1 + (int)RobotId.Robot1, GameMode.Eurobot, "Wally");
            worldMapDisplayWaypoint.InitTeamMate((int)TeamId.Team1 + (int)RobotId.Robot1, GameMode.Eurobot, "Wally");

            worldMapDisplayStrategy.OnCtrlClickOnHeatMapEvent += WorldMapDisplay_OnCtrlClickOnHeatMapEvent;
            worldMapDisplayWaypoint.OnCtrlClickOnHeatMapEvent += WorldMapDisplay_OnCtrlClickOnHeatMapEvent;


            //foreach (string s in SerialPort.GetPortNames())
            //{
            //    Console.WriteLine("   {0}", s);
            //}

            timerAffichage.Interval = new TimeSpan(0, 0, 0, 0, 50);
            timerAffichage.Tick    += TimerAffichage_Tick;
            timerAffichage.Start();

            //oscilloX.SetTitle("Consigne / Vitesse Linéaire");
            oscilloX.AddOrUpdateLine(0, 100, "Vitesse X Consigne");
            oscilloX.AddOrUpdateLine(1, 500, "Vitesse X");
            //oscilloX.AddOrUpdateLine(2, 100, "Accel X");
            oscilloX.ChangeLineColor("Vitesse X", Colors.Red);
            oscilloX.ChangeLineColor("Vitesse X Consigne", Colors.Blue);

            //oscilloTheta.SetTitle("Consigne / Vitesse Angulaire");
            oscilloTheta.AddOrUpdateLine(0, 100, "Vitesse Theta Consigne");
            oscilloTheta.AddOrUpdateLine(1, 500, "Vitesse Theta");
            //oscilloTheta.AddOrUpdateLine(2, 100, "Gyr Z");
            oscilloTheta.ChangeLineColor(1, Colors.Red);
            oscilloTheta.ChangeLineColor(0, Colors.Blue);

            //oscilloLidar.SetTitle("Lidar");
            oscilloLidar.AddOrUpdateLine(0, 20000, "Lidar RSSI", false);
            oscilloLidar.AddOrUpdateLine(1, 20000, "Lidar Distance");
            //oscilloLidar.AddOrUpdateLine(2, 20000, "Balise Points");
            oscilloLidar.ChangeLineColor(0, Colors.SeaGreen);
            oscilloLidar.ChangeLineColor(1, Colors.IndianRed);
            oscilloLidar.ChangeLineColor(2, Colors.LightGoldenrodYellow);

            asservPositionDisplay.SetTitle("Asservissement Position");
            asserv2WheelsSpeedDisplay.SetTitle("Asservissement Vitesse");
        }
コード例 #22
0
ファイル: App.xaml.cs プロジェクト: jorik041/AppsTracker
        public App(ReadOnlyCollection <string> args)
        {
            ProfileOptimization.SetProfileRoot(Assembly.GetEntryAssembly().Location);
            ProfileOptimization.StartProfile("AppsTrackerProfile");

            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            InitializeComponent();

            this.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement)
                                                               , new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline)
                                                               , new PropertyMetadata()
            {
                DefaultValue = 40
            });

            var context = new DispatcherSynchronizationContext(Application.Current.Dispatcher);

            SynchronizationContext.SetSynchronizationContext(context);

            container = GetCompositionContainer();
            ServiceLocation.ServiceLocator.Instance.Initialize(container);

            bool autostart = args.Where(a => a.ToUpper().Contains(Constants.CMD_ARGS_AUTOSTART)).Count() > 0;

            applicationController = container.GetExportedValue <ApplicationController>();
            applicationController.Initialize(autostart);

            this.SessionEnding += (s, e) => ShutdownApp();
        }
コード例 #23
0
 protected DetectiveWindowBase()
 {
     this.Language            = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag);
     this.DataContextChanged += this.DetectiveWindowBase_DataContextChanged;
 }
コード例 #24
0
 public MainWindow()
 {
     InitializeComponent();
     LoadDataFromCSV(@"..\..\Data.csv");
     FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name)));
     this.Closing += MainWindow_Closing;
 }
コード例 #25
0
ファイル: MainWindow.xaml.cs プロジェクト: Hawk777/iecc8
 public MainWindow(MainViewModel vm)
 {
     DataContext = vm;
     Language    = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name);
     InitializeComponent();
 }
コード例 #26
0
 protected override object GetValue()
 {
     return(XmlLanguage.GetLanguage(CultureManager.UICulture.IetfLanguageTag));
 }
コード例 #27
0
ファイル: App.xaml.cs プロジェクト: sm-g/payments
 public App()
 {
     // set wpf culture
     FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
                                                            XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
 }
コード例 #28
0
ファイル: GlyphText.cs プロジェクト: NkunaNathan/Version3-1
        public GlyphText(string text, Typeface typeface, double typesize, float pixelsPerDip)
        {
            if (!GlyphUtils.SymbolTypeface.TryGetGlyphTypeface(out _glyphTypeface))
            {
                Debugger.Break();
                throw new InvalidOperationException($"No glyph typeface found for the Windows Typeface '{typeface.FaceNames[XmlLanguage.GetLanguage("en-GB")]}'");
            }
            Text            = text;
            CurrentTypeface = typeface;
            TypeSize        = typesize;
            PixelsPerDip    = pixelsPerDip;

            TextMetrics = null;
        }
コード例 #29
0
ファイル: App.xaml.cs プロジェクト: jbautistam/BauPlugStudio
 public App()
 {
     //? Wpf tiene un error al formatear las fechas. No recoge la cultura actual si no que siempre lo pone en formato inglés.
     //? Para evitarlo se utiliza la siguiente línea (que tiene que estar antes de empezar a abrir ventanas)
     //? http://www.nbdtech.com/Blog/archive/2009/02/22/wpf-data-binding-cheat-sheet-update-the-internationalization-fix.aspx
     FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
                                                        new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
     // Inicializa los manejadores de eventos para las excepciones no controladas
     // En principio sólo haría falta el primero, el resto son para excepciones de otros hilos
     DispatcherUnhandledException += (sender, evntArgs) =>
     {
         TreatException(evntArgs.Exception);
         evntArgs.Handled = true;
     };
     AppDomain.CurrentDomain.UnhandledException += (sender, evntArgs) => TreatException(evntArgs.ExceptionObject as Exception);
     TaskScheduler.UnobservedTaskException      += (sender, args) => TreatException(args.Exception);
 }
コード例 #30
0
 public void Initialize()
 {
     FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
                                                            XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
 }