static int GetRelatedness(XmlLanguage keyLang, XmlLanguage userLang) { try { // Get equivalent cultures. CultureInfo keyCulture = CultureInfo.GetCultureInfoByIetfLanguageTag(keyLang.IetfLanguageTag); CultureInfo userCulture = CultureInfo.GetCultureInfoByIetfLanguageTag(userLang.IetfLanguageTag); if (!userCulture.IsNeutralCulture) { userCulture = userCulture.Parent; } // If the key is a prefix or parent of the user language it's a good match. if (IsPrefixOf(keyLang.IetfLanguageTag, userLang.IetfLanguageTag) || userCulture.Equals(keyCulture)) { return 2; } // If the key and user language share a common prefix or parent neutral culture, it's a reasonable match. if (IsPrefixOf(TrimSuffix(userLang.IetfLanguageTag), keyLang.IetfLanguageTag) || userCulture.Equals(keyCulture.Parent)) { return 1; } } catch (ArgumentException) { // Language tag with no corresponding CultureInfo. } // They're unrelated languages. return 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); }
private void OnStartup(object sender, StartupEventArgs e) { // Set the language for all FrameworkElements to the current culture // see: https://serialseb.com/blog/2007/04/03/wpf-tips-1-have-all-your-dates-times/ FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); MainWindow window = new MainWindow(); window.Show(); }
WriteXML(XmlWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } writer.WriteStartElement( XpsS0Markup.SignatureDefinition, XpsS0Markup.SignatureDefinitionNamespace ); //Spot ID, Signer Name and xml:lang are attributes of SignatureDefinition //Spot ID is required. If it is not specified, then we throw. if (SpotId != null) { writer.WriteAttributeString(XpsS0Markup.SpotId, XmlConvert.EncodeName(SpotId.ToString())); } else { throw new XpsPackagingException(SR.Get(SRID.ReachPackaging_SpotIDRequiredAttribute)); } if (RequestedSigner != null) { writer.WriteAttributeString(XpsS0Markup.RequestedSigner, RequestedSigner); } if (Culture != null) { XmlLanguage language = XmlLanguage.GetLanguage(Culture.Name); writer.WriteAttributeString(XpsS0Markup.XmlLang, language.ToString()); } //SpotLocation, Intent, Signby, and Signing Location are elements of SignatureDefinition if (SpotLocation != null) { writer.WriteStartElement(XpsS0Markup.SpotLocation); Uri pageUri = new Uri(SpotLocation.PageUri.GetComponents(UriComponents.SerializationInfoString, UriFormat.SafeUnescaped), UriKind.RelativeOrAbsolute); string pageUriAsString = pageUri.GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped); writer.WriteAttributeString(XpsS0Markup.PageUri, pageUriAsString); writer.WriteAttributeString(XpsS0Markup.StartX, SpotLocation.StartX.ToString(System.Globalization.CultureInfo.InvariantCulture)); writer.WriteAttributeString(XpsS0Markup.StartY, SpotLocation.StartY.ToString(System.Globalization.CultureInfo.InvariantCulture)); writer.WriteEndElement(); } if (Intent != null) { writer.WriteStartElement(XpsS0Markup.Intent); writer.WriteString(Intent); writer.WriteEndElement(); } if (SignBy != null) { writer.WriteStartElement(XpsS0Markup.SignBy); writer.WriteString(((DateTime)SignBy).ToUniversalTime().ToString("s", DateTimeFormatInfo.InvariantInfo) + "Z"); writer.WriteEndElement(); } if (SigningLocale != null) { writer.WriteStartElement(XpsS0Markup.SigningLocale); writer.WriteString(SigningLocale); writer.WriteEndElement(); } // //Signature Definition // writer.WriteEndElement(); _hasBeenModified = false; }
private void AppStartup(object sender, StartupEventArgs e) { var localizationCollector = new LocalizationCollector(); var moduleInit = new InitializationManager(); moduleInit.Add(new Framework.Tools.ModuleInitializer()); moduleInit.Add(new Framework.Arduino.SerialCommunication.ModuleInitializer()); moduleInit.Add(new Framework.Logic.ModuleInitializer() { MapperConfiguration = new MapperConfiguration( cfg => { cfg.AddProfile <LogicAutoMapperProfile>(); cfg.AddProfile <WpfAutoMapperProfile>(); cfg.AddProfile <GCodeGUIAutoMapperProfile>(); }) }); moduleInit.Add(new CNCLib.Logic.ModuleInitializer()); moduleInit.Add(new CNCLib.Logic.Client.ModuleInitializer()); moduleInit.Add(new CNCLib.Repository.ModuleInitializer() { OptionsAction = SqliteDatabaseTools.OptionBuilder }); moduleInit.Add(new CNCLib.Service.Logic.ModuleInitializer()); moduleInit.Add(new CNCLib.WpfClient.ModuleInitializer()); string connectString = SqliteDatabaseTools.SetEnvironment(false); GlobalDiagnosticsContext.Set("logDir", $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/CNCLib/logs"); GlobalDiagnosticsContext.Set("connectionString", connectString); LogManager.ThrowExceptions = true; var logger = LogManager.GetLogger("foo"); _logger.Info(@"Starting ..."); LogManager.ThrowExceptions = false; FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); var userContext = new CNCLibUserContext(CNCLibConst.AdminUser); AppService.ServiceCollection = new ServiceCollection(); AppService.ServiceCollection .AddTransient <ILoggerFactory, LoggerFactory>() .AddTransient(typeof(ILogger <>), typeof(Logger <>)) .AddSingleton((ICNCLibUserContext)userContext); moduleInit.Initialize(AppService.ServiceCollection, localizationCollector); AppService.BuildServiceProvider(); // Open Database here try { CNCLibContext.InitializeDatabase(AppService.ServiceProvider); } catch (Exception ex) { _logger.Error(ex); MessageBox.Show($"Cannot create/connect database in {connectString} \n\r" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); Current.Shutdown(); } var task = Task.Run(async() => await userContext.InitUserContext()); while (!task.IsCompleted) { Task.Yield(); } }
protected override void Run() { #if DEBUG Debugger.Launch(); #endif var code = int.Parse(this.Engine.FormatString("[UserLanguageID]")); CultureInfo cultureInfo; try { cultureInfo = CultureInfo.GetCultureInfo(code); } catch (CultureNotFoundException) { this.Engine.Log(LogLevel.Debug, $"Unable to get culture info for '{code}'"); cultureInfo = new CultureInfo("en-US"); } Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo; Localisation.Culture = cultureInfo; FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage(cultureInfo.IetfLanguageTag))); try { this.Engine.CloseSplashScreen(); var rebootPending = this.Engine.StringVariables["RebootPending"]; if (!string.IsNullOrEmpty(rebootPending) && rebootPending != "0") { if (this.Command.Display == Display.Full) { MessageBox.Show( string.Format(Localisation.WixBootstrapper_RestartPendingDialogBody, this.BundleName), string.Format(Localisation.WixBootstrapper_RestartPendingDialogTitle, this.BundleName), MessageBoxButton.OK, MessageBoxImage.Error); } this.Engine.Quit(3010); } this.Engine.Log(LogLevel.Verbose, "Launching Burn frontend"); BootstrapperDispatcher = Dispatcher.CurrentDispatcher; AppDomain.CurrentDomain.UnhandledException += (sender, args) => { this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {args.ExceptionObject}"); }; BootstrapperDispatcher.UnhandledException += (sender, args) => { this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {args.Exception}"); }; RootView = new WizardWindow(this); RootView.Closed += (sender, args) => BootstrapperDispatcher.InvokeShutdown(); this.Engine.Detect(); foreach (var commandLineArg in this.Command.GetCommandLineArgs()) { if (commandLineArg.StartsWith("InstallationType=", StringComparison.InvariantCultureIgnoreCase)) { var param = commandLineArg.Split(new[] { '=' }, 2); RootView.ViewModel.PackageCombinationConfiguration.InstallationType = (InstallationType)Enum.Parse(typeof(InstallationType), param[1]); } } if (this.Command.Display == Display.Passive || this.Command.Display == Display.Full) { RootView.Show(); Dispatcher.Run(); } this.Engine.Quit(RootView.ViewModel.Status); } catch (Exception e) { this.Engine.Log(LogLevel.Error, $"Critical bootstrapper exception: {e}"); throw e; } }
protected DetectivePaneViewBase() { this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag); }
/// <summary> /// Initializes a new instance of the <see cref="RegularTimePage" /> class. /// </summary> public RegularTimePage() { this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.Name); //DataContext = new AddModifyTimeViewModel(); InitializeComponent(); }
public App() { // Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE"); FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); }
private void Application_Startup(object sender, StartupEventArgs e) { // Detect the current configuration //Models.Settings.ConfigurationManager.Detect(); // Detect the current configuration Models.Settings.ConfigurationManager.Detect(); // Get assembly informations AssemblyManager.Load(); // Load application settings (profiles/Profiles/clients are loaded when needed) try { // Update integrated settings %LocalAppData%\{AssemblyName} (custom settings path) if (Settings.Default.UpgradeRequired) { Settings.Default.Upgrade(); Settings.Default.UpgradeRequired = false; } SettingsManager.Load(); // Update settings (Default --> %AppData%\NETworkManager\Settings) if (AssemblyManager.Current.Version > new Version(SettingsManager.Current.SettingsVersion)) { SettingsManager.Update(AssemblyManager.Current.Version, new Version(SettingsManager.Current.SettingsVersion)); } } catch (InvalidOperationException) { SettingsManager.InitDefault(); WpfFramework.Models.Settings.ConfigurationManager.Current.ShowSettingsResetNoteOnStartup = true; } if (SettingsManager.Current._3dPrinterMaterialTypes.Count == 0) { SettingsManager.Current._3dPrinterMaterialTypes = GlobalStaticConfiguration.defaultMaterials; } // Load localization (requires settings to be loaded first) LocalizationManager.Load(); if (SettingsManager.Current.General_OverwriteCurrencySymbol) { // Overwrite currency symbol //LocalizationManager.Culture.NumberFormat.CurrencySymbol = SettingsManager.Current.General_CurrencySymbol; } FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage( LocalizationManager.Culture.IetfLanguageTag))); WpfFramework.Resources.Localization.Strings.Culture = LocalizationManager.Culture; // Create mutex _mutex = new Mutex(true, "{" + GUID + "}"); var mutexIsAcquired = _mutex.WaitOne(TimeSpan.Zero, true); // Release mutex if (mutexIsAcquired) { _mutex.ReleaseMutex(); } if (SettingsManager.Current.Window_MultipleInstances || mutexIsAcquired) { if (SettingsManager.Current.General_BackgroundJobInterval != 0) { _dispatcherTimer = new DispatcherTimer { Interval = TimeSpan.FromMinutes(SettingsManager.Current.General_BackgroundJobInterval) }; _dispatcherTimer.Tick += DispatcherTimer_Tick; _dispatcherTimer.Start(); } StartupUri = new Uri("MainWindow.xaml", UriKind.Relative); } else { // Bring the already running application into the foreground SingleInstance.PostMessage((IntPtr)SingleInstance.HWND_BROADCAST, SingleInstance.WM_SHOWME, IntPtr.Zero, IntPtr.Zero); _singleInstanceClose = true; Shutdown(); } }
/// <summary> /// By default, we are configured to use MEF /// </summary> protected override void Configure() { try { var splashScreen = new SplashScreen(Assembly.GetAssembly(typeof(AppBootstrapper)), "daxstudio-splash.png"); splashScreen.Show(true); // Tell Caliburn Micro how to find controls in Fluent Ribbon /* * defaultElementLookup = BindingScope.GetNamedElements; * BindingScope.GetNamedElements = new Func<System.Windows.DependencyObject, IEnumerable<System.Windows.FrameworkElement>>( * k => * { * List<FrameworkElement> namedElements = new List<FrameworkElement>(); * namedElements.AddRange(defaultElementLookup(k)); * Fluent.Ribbon ribbon = LookForRibbon(k); * if (null != ribbon) * AppendRibbonNamedItem(ribbon, namedElements); * return namedElements; * } * ); */ ConventionManager.AddElementConvention <Fluent.Spinner>(Fluent.Spinner.ValueProperty, "Value", "ValueChanged"); ConventionManager.AddElementConvention <Xceed.Wpf.Toolkit.DoubleUpDown>(Xceed.Wpf.Toolkit.DoubleUpDown.ValueProperty, "Value", "ValueChanged"); ConventionManager.AddElementConvention <Xceed.Wpf.Toolkit.IntegerUpDown>(Xceed.Wpf.Toolkit.IntegerUpDown.ValueProperty, "Value", "ValueChanged"); ConventionManager.AddElementConvention <Xceed.Wpf.Toolkit.WatermarkTextBox>(Xceed.Wpf.Toolkit.WatermarkTextBox.TextProperty, "Text", "TextChanged"); // Fixes the default datetime format in the results listview // from: http://stackoverflow.com/questions/1993046/datetime-region-specific-formatting-in-wpf-listview FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); var catalog = new AggregateCatalog( AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType <ComposablePartCatalog>() ); //_container = new CompositionContainer(catalog,true); _container = new CompositionContainer(catalog); var batch = new CompositionBatch(); if (JsonSettingProvider.SettingsFileExists()) { batch.AddExportedValue <ISettingProvider>(new JsonSettingProvider()); } else { batch.AddExportedValue <ISettingProvider>(new RegistrySettingProvider()); } batch.AddExportedValue <IWindowManager>(new WindowManager()); batch.AddExportedValue <IEventAggregator>(new EventAggregator()); batch.AddExportedValue <Func <DocumentViewModel> >(() => _container.GetExportedValue <DocumentViewModel>()); batch.AddExportedValue <Func <IWindowManager, IEventAggregator, DocumentViewModel> >( (w, e) => _container.GetExportedValue <DocumentViewModel>()); batch.AddExportedValue(_container); batch.AddExportedValue(catalog); _container.Compose(batch); // Add AvalonDock binding convetions AvalonDockConventions.Install(); ConfigureKeyBindings(); // TODO - not working //VisibilityBindingConvention.Install(); LogManager.GetLog = type => new DebugLogger(type); // Add Application object to MEF catalog _container.ComposeExportedValue <Application>("System.Windows.Application", Application.Current); } catch (Exception e) { Debug.WriteLine(e); } }
public ProjectDependenciesView() { InitializeComponent(); Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag); }
public ExportDocumentWindow() { this.InitializeComponent(); this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag); this.Title = (string)Application.Current.Resources["ApplicationName"]; }
public Shell(IApplicationState applicationState, IMethodQueue methodQueue) { _applicationState = applicationState; _methodQueue = methodQueue; InitializeComponent(); LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); Application.Current.MainWindow.SizeChanged += MainWindow_SizeChanged; var selectedIndexChange = DependencyPropertyDescriptor.FromProperty(Selector.SelectedIndexProperty, typeof(TabControl)); selectedIndexChange.AddValueChanged(MainTabControl, MainTabControlSelectedIndexChanged); EventServiceFactory.EventService.GetEvent <GenericEvent <User> >().Subscribe(x => { if (x.Topic == EventTopicNames.UserLoggedIn) { UserLoggedIn(x.Value); } if (x.Topic == EventTopicNames.UserLoggedOut) { UserLoggedOut(x.Value); } }); EventServiceFactory.EventService.GetEvent <GenericEvent <UserControl> >().Subscribe( x => { if (x.Topic == EventTopicNames.DashboardClosed) { SerialPortService.ResetCache(); EventServiceFactory.EventService.PublishEvent(EventTopicNames.ResetCache, true); } }); EventServiceFactory.EventService.GetEvent <GenericEvent <EventAggregator> >().Subscribe( x => { if (x.Topic == EventTopicNames.LocalSettingsChanged) { InteractionService.Scale(MainGrid); } }); UserRegion.Visibility = Visibility.Collapsed; RightUserRegion.Visibility = Visibility.Collapsed; Height = Properties.Settings.Default.ShellHeight; Width = Properties.Settings.Default.ShellWidth; _timer = new DispatcherTimer(); _timer.Tick += TimerTick; TimeLabel.Text = "..."; #if !DEBUG WindowStyle = WindowStyle.None; WindowState = WindowState.Maximized; #endif }
public App() { UIErrorOverdoor.SetBehavior(new ErrorOverdoorBehavior()); this.Dispatcher.UnhandledException += OnDispatcherUnhandledException; IContainerWrapper ioc = new UnityContainerWrapper(); IoC.InitializeWith(ioc); Transactions.Service = IoC.Resolve <TransactionService>(); foreach (var uiAssistant in IoC.ResolveAll <IUISettingsTypeAssistant>()) { UISettings.RegisterTypeAssistant(uiAssistant); } FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs e) => { e.SetObserved(); UIErrorOverdoor.Show(e.Exception); }; }
/// <summary> /// Return the <see cref="XmlLanguage"/> to use for the associated Markup element. /// </summary> /// <returns> /// The <see cref="XmlLanguage"/> corresponding to the current /// <see cref="ICultureManager.UICulture"/> property value /// </returns> protected override object GetValue() { return(XmlLanguage.GetLanguage(_cultureManager.UICulture.IetfLanguageTag)); }
private void Application_Startup(object sender, StartupEventArgs e) { bool createdNew; _mutex = new Mutex(true, Constants.AppName, out createdNew); if (!createdNew) { ShowToFront($"{Constants.AppName} : {Environment.MachineName}"); Application.Current.Shutdown(); return; } // Set local culture for the entire app FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); // Set app's current directory string path = Helpers.ApplicationPath(); Directory.SetCurrentDirectory(Path.GetDirectoryName(path)); // Check if Mining Station registry keys exist and create such if they don't. using (RegistryKey rk = Microsoft.Win32.Registry.CurrentUser) { try { string baseKey = "SOFTWARE\\Mining Station"; if (rk.OpenSubKey(baseKey, true) == null) { rk.CreateSubKey(baseKey); } List <string> subKeys = new List <string> { "\\Switch", "\\UpdatePriceHistory" }; foreach (var subKey in subKeys) { string currentSubKey = baseKey + subKey; if (rk.OpenSubKey(currentSubKey, true) == null) { rk.CreateSubKey(currentSubKey); var sk = rk.OpenSubKey(currentSubKey, true); sk.SetValue("IsInProgress", false); sk.SetValue("Round", 0); sk.SetValue("Schedule", string.Empty); sk.SetValue("LastUpdate", string.Empty); sk.SetValue("LastSuccess", string.Empty); } } } catch (Exception ex) { MessageBox.Show("Error while accessing registry.\n" + ex.Message); } } }
public SetEpgView() { InitializeComponent(); if (CommonManager.Instance.NWMode == true) { stackPanel_epgArchivePeriod.IsEnabled = false; } else { checkBox_CacheKeepConnect.IsEnabled = false; } listBox_tab.KeyDown += ViewUtil.KeyDown_Enter(button_tab_chg); SelectableItem.Set_CheckBox_PreviewChanged(listBox_tab); var bx = new BoxExchangeEditor(null, this.listBox_tab, true, true, true); bx.targetBoxAllowDoubleClick(bx.TargetBox, (sender, e) => button_tab_chg.RaiseEvent(new RoutedEventArgs(Button.ClickEvent))); button_tab_del.Click += bx.button_Delete_Click; button_tab_del_all.Click += bx.button_DeleteAll_Click; button_tab_up.Click += bx.button_Up_Click; button_tab_down.Click += bx.button_Down_Click; button_tab_top.Click += bx.button_Top_Click; button_tab_bottom.Click += bx.button_Bottom_Click; button_RecInfoDropExceptDefault.Click += (sender, e) => textBox_RecInfoDropExcept.Text = string.Join(", ", Settings.RecInfoDropExceptDefault); var FLanguage = XmlLanguage.GetLanguage("ja-JP"); comboBox_fontTitle.ItemsSource = Fonts.SystemFontFamilies.Select(f => f.FamilyNames.ContainsKey(FLanguage) == true ? f.FamilyNames[FLanguage] : f.Source).OrderBy(s => s).ToList(); //カラー関係はまとめてバインドする var colorReference = typeof(Brushes).GetProperties().Select(p => new ColorComboItem(p.Name, (Brush)p.GetValue(null, null))).ToList(); colorReference.Add(new ColorComboItem("カスタム", this.Resources["HatchBrush"] as VisualBrush)); var setComboColor1 = new Action <string, ComboBox>((path, cmb) => { cmb.ItemsSource = colorReference; SetBindingColorCombo(cmb, path); }); var setComboColors = new Action <string, Panel>((path, pnl) => { foreach (var cmb in pnl.Children.OfType <ComboBox>()) { setComboColor1(path + "[" + (string)cmb.Tag + "]", cmb); } }); setComboColor1(CommonUtil.NameOf(() => settings.TitleColor1), comboBox_colorTitle1); setComboColor1(CommonUtil.NameOf(() => settings.TitleColor2), comboBox_colorTitle2); setComboColors(CommonUtil.NameOf(() => settings.ContentColorList), grid_EpgColors); setComboColors(CommonUtil.NameOf(() => settings.EpgResColorList), grid_EpgColorsReserve); setComboColors(CommonUtil.NameOf(() => settings.EpgEtcColors), grid_EpgTimeColors); setComboColors(CommonUtil.NameOf(() => settings.EpgEtcColors), grid_EpgEtcColors); setComboColors(CommonUtil.NameOf(() => settings.TunerServiceColors), grid_TunerFontColor); setComboColors(CommonUtil.NameOf(() => settings.TunerServiceColors), grid_TunerColors); setComboColors(CommonUtil.NameOf(() => settings.TunerServiceColors), grid_TunerEtcColors); var setButtonColors = new Action <string, Panel>((path, pnl) => { foreach (var btn in pnl.Children.OfType <Button>()) { SetBindingColorButton(btn, path + "[" + (string)btn.Tag + "]"); } }); SetBindingColorButton(button_colorTitle1, CommonUtil.NameOf(() => settings.TitleCustColor1)); SetBindingColorButton(button_colorTitle2, CommonUtil.NameOf(() => settings.TitleCustColor2)); setButtonColors(CommonUtil.NameOf(() => settings.ContentCustColorList), grid_EpgColors); setButtonColors(CommonUtil.NameOf(() => settings.EpgResCustColorList), grid_EpgColorsReserve); setButtonColors(CommonUtil.NameOf(() => settings.EpgEtcCustColors), grid_EpgTimeColors); setButtonColors(CommonUtil.NameOf(() => settings.EpgEtcCustColors), grid_EpgEtcColors); setButtonColors(CommonUtil.NameOf(() => settings.TunerServiceCustColors), grid_TunerFontColor); setButtonColors(CommonUtil.NameOf(() => settings.TunerServiceCustColors), grid_TunerColors); setButtonColors(CommonUtil.NameOf(() => settings.TunerServiceCustColors), grid_TunerEtcColors); //録画済み一覧画面 setButtonColors(CommonUtil.NameOf(() => settings.RecEndCustColors), grid_RecInfoBackColors); setComboColors(CommonUtil.NameOf(() => settings.RecEndColors), grid_RecInfoBackColors); //予約一覧・共通画面 SetBindingColorButton(btn_ListDefFontColor, CommonUtil.NameOf(() => settings.ListDefCustColor)); setButtonColors(CommonUtil.NameOf(() => settings.RecModeFontCustColors), grid_ReserveRecModeColors); setButtonColors(CommonUtil.NameOf(() => settings.ResBackCustColors), grid_ReserveBackColors); setButtonColors(CommonUtil.NameOf(() => settings.StatCustColors), grid_StatColors); setComboColor1(CommonUtil.NameOf(() => settings.ListDefColor), cmb_ListDefFontColor); setComboColors(CommonUtil.NameOf(() => settings.RecModeFontColors), grid_ReserveRecModeColors); setComboColors(CommonUtil.NameOf(() => settings.ResBackColors), grid_ReserveBackColors); setComboColors(CommonUtil.NameOf(() => settings.StatColors), grid_StatColors); button_clearSerchKeywords.ToolTip = SearchKeyView.ClearButtonTooltip; checkBox_NotNoStyle.ToolTip = string.Format("チェック時、テーマファイル「{0}」があればそれを、無ければ既定のテーマ(Aero)を適用します。", System.IO.Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().Location) + ".rd.xaml"); }
protected override void Configure() { // GitHub uses Tls 1.2 only, and it isn't enabled by default before .NET 4.6. Since we target an earlier // .NET version, we have to enable this ourselves. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; this.options = this.Container.Get <CommandLineOptionsParser>(); if (!this.options.Parse(this.Args)) { Environment.Exit(0); } var pathTransformer = this.Container.Get <IPathTransformer>(); // Have to set the log path before anything else var pathConfiguration = AppSettings.Instance.PathConfiguration; GlobalDiagnosticsContext.Set("LogFilePath", pathTransformer.MakeAbsolute(pathConfiguration.LogFilePath)); AppDomain.CurrentDomain.UnhandledException += (o, e) => OnAppDomainUnhandledException(e); var logger = LogManager.GetCurrentClassLogger(); var assembly = this.Container.Get <IAssemblyProvider>(); logger.Info("SyncTrazor version {0} ({1}) started at {2} (.NET version: {3})", assembly.FullVersion, assembly.ProcessorArchitecture, assembly.Location, DotNetVersionFinder.FindDotNetVersion()); // This needs to happen before anything which might cause the unhandled exception stuff to be shown, as that wants to know // where to find the log file. this.Container.Get <IApplicationPathsProvider>().Initialize(pathConfiguration); var client = this.Container.Get <IIpcCommsClientFactory>().TryCreateClient(); if (client != null) { try { if (this.options.StartSyncthing || this.options.StopSyncthing) { if (this.options.StartSyncthing) { client.StartSyncthing(); } else if (this.options.StopSyncthing) { client.StopSyncthing(); } if (!this.options.StartMinimized) { client.ShowMainWindow(); } Environment.Exit(0); } if (AppSettings.Instance.EnforceSingleProcessPerUser) { if (!this.options.StartMinimized) { client.ShowMainWindow(); } Environment.Exit(0); } } catch (Exception e) { logger.Error(e, $"Failed to talk to {client}: {e.Message}. Pretending that it doesn't exist..."); } } var configurationProvider = this.Container.Get <IConfigurationProvider>(); configurationProvider.Initialize(AppSettings.Instance.DefaultUserConfiguration); var configuration = this.Container.Get <IConfigurationProvider>().Load(); if (AppSettings.Instance.EnforceSingleProcessPerUser) { this.Container.Get <IIpcCommsServer>().StartServer(); } // Has to be done before the VMs are fetched from the container var languageArg = this.Args.FirstOrDefault(x => x.StartsWith("-culture=")); if (languageArg != null) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(languageArg.Substring("-culture=".Length)); } else if (!configuration.UseComputerCulture) { Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); } // WPF ignores the current culture by default - so we have to force it FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.IetfLanguageTag))); var autostartProvider = this.Container.Get <IAutostartProvider>(); #if DEBUG autostartProvider.IsEnabled = false; #endif // If it's not in portable mode, and if we had to create config (i.e. it's the first start ever), then enable autostart if (autostartProvider.CanWrite && AppSettings.Instance.EnableAutostartOnFirstStart && configurationProvider.HadToCreateConfiguration) { autostartProvider.SetAutoStart(new AutostartConfiguration() { AutoStart = true, StartMinimized = true }); } // Needs to be done before ConfigurationApplicator is run this.Container.Get <IApplicationWindowState>().Setup(this.RootViewModel); this.Container.Get <ConfigurationApplicator>().ApplyConfiguration(); this.Container.Get <MemoryUsageLogger>().Enabled = true; // Handles Restart Manager requests - sent by the installer. We need to shutdown syncthing in this case this.Application.SessionEnding += (o, e) => { LogManager.GetCurrentClassLogger().Info("Shutting down: {0}", e.ReasonSessionEnding); var manager = this.Container.Get <ISyncthingManager>(); manager.StopAndWaitAsync().Wait(2000); manager.Kill(); }; MessageBoxViewModel.ButtonLabels = new Dictionary <MessageBoxResult, string>() { { MessageBoxResult.Cancel, Resources.Generic_Dialog_Cancel }, { MessageBoxResult.No, Resources.Generic_Dialog_No }, { MessageBoxResult.OK, Resources.Generic_Dialog_OK }, { MessageBoxResult.Yes, Resources.Generic_Dialog_Yes }, }; MessageBoxViewModel.DefaultFlowDirection = Localizer.FlowDirection; RecycleBinDeleter.Logger = s => LogManager.GetLogger(typeof(RecycleBinDeleter).FullName).Error(s); }
protected override void OnStartup(StartupEventArgs e) { var cultureInfo = new CultureInfo("ru-Ru"); Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo; CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); base.OnStartup(e); }
private void LicenseTab_OnLoaded(object sender, RoutedEventArgs e) { // Display conversions from WPF bindings in current locale, i.e. Dates Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name); }
public FrmVentas() { InitializeComponent(); Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name); }
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))); } }
public ViewPreviousVisit() { this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.Name); InitializeComponent(); }
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; }
/// <summary> /// Resets the <see cref="FrameworkElement"/> language information with a <see cref="XmlLanguage"/> matching the <see cref="P:System.Threading.Thread.CurrentThread.CurrentCulture"/>. /// </summary> /// <param name="frameworkElement">The framework element.</param> public static void ResetLanguageWithCurrentCulture(this FrameworkElement frameworkElement) { frameworkElement.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name); }
private FontFamilyMap GetTargetFamilyMap( CharacterBufferRange unicodeString, CultureInfo culture, CultureInfo digitCulture, out int cchAdvance ) { DigitMap digitMap = new DigitMap(digitCulture); ushort[] familyMaps = _fontInfo.GetFamilyMapsOfLanguage(XmlLanguage.GetLanguage(culture.IetfLanguageTag)); int sizeofChar = 0; int ch = 0; // skip all the leading joinder characters. They need to be shaped with the // surrounding strong characters. cchAdvance = Classification.AdvanceWhile(unicodeString, ItemClass.JoinerClass); if (cchAdvance >= unicodeString.Length) { // It is rare that the run only contains joiner characters. // If it really happens, just map them to the initial family map. return(_fontInfo.GetFamilyMapOfChar( familyMaps, Classification.UnicodeScalar(unicodeString, out sizeofChar) )); } // // If the run starts with combining marks, we will not be able to find base characters for them // within the run. These combining marks will be mapped to their best fonts as normal characters. // ch = Classification.UnicodeScalar( new CharacterBufferRange(unicodeString, cchAdvance, unicodeString.Length - cchAdvance), out sizeofChar ); bool hasBaseChar = !Classification.IsCombining(ch); ch = digitMap[ch]; FontFamilyMap familyMap = _fontInfo.GetFamilyMapOfChar(familyMaps, ch); Invariant.Assert(familyMap != null); for (cchAdvance += sizeofChar; cchAdvance < unicodeString.Length; cchAdvance += sizeofChar) { ch = Classification.UnicodeScalar( new CharacterBufferRange(unicodeString, cchAdvance, unicodeString.Length - cchAdvance), out sizeofChar ); if (Classification.IsJoiner(ch)) { continue; // continue to advance if current char is a joiner } if (!Classification.IsCombining(ch)) { hasBaseChar = true; } else if (hasBaseChar) { continue; // continue to advance for combining mark with base char } ch = digitMap[ch]; if (_fontInfo.GetFamilyMapOfChar(familyMaps, ch) != familyMap) { break; } } return(familyMap); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var cultureKey = ConfigurationManager.AppSettings["Culture"]; var culture = CultureInfo.GetCultureInfo(cultureKey); CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = culture; FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(culture.IetfLanguageTag))); }
public void Initialize() { FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Log.App.Info("{0} {1} is starting; OS: {2}", ApplicationInfo.ProductName, ApplicationInfo.Version, Environment.OSVersion); #if (!DEBUG) DispatcherUnhandledException += AppDispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException; #endif catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(typeof(IMessageService).Assembly)); // WinApplicationFramework catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly())); // Writer.Presentation catalog.Catalogs.Add(new AssemblyCatalog(typeof(ShellViewModel).Assembly)); // Writer.Applications container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection); var batch = new CompositionBatch(); batch.AddExportedValue(container); container.Compose(batch); var settingsService = container.GetExportedValue <ISettingsService>(); settingsService.ErrorOccurred += (_, e) => Log.Default.Error(e.Error, "Error in SettingsService"); InitializeCultures(settingsService.Get <AppSettings>()); FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); moduleControllers = container.GetExportedValues <IModuleController>(); foreach (var x in moduleControllers) { x.Initialize(); } foreach (var x in moduleControllers) { x.Run(); } }
public MainWindow() { InitializeComponent(); DataContext = this; LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(LocalizationManager.Culture.IetfLanguageTag))); // Load appearance AppearanceManager.Load(); if (SettingsManager.Current.Appearance_EnableTransparency) { AllowsTransparency = true; Opacity = SettingsManager.Current.Appearance_Opacity; } // Autostart & Window start if (CommandLineManager.Current.Autostart && SettingsManager.Current.Autostart_StartMinimizedInTray || SettingsManager.Current.TrayIcon_AlwaysShowIcon) { InitNotifyIcon(); } if (CommandLineManager.Current.Autostart && SettingsManager.Current.Autostart_StartMinimizedInTray) { HideWindowToTray(); } // Set windows title if admin if (ConfigurationManager.Current.IsAdmin) { Title = string.Format("[{0}] {1}", System.Windows.Application.Current.Resources["String_Administrator"] as string, Title); } // Load application list, filter, sort LoadApplicationList(); // Load settings ApplicationView_Expand = SettingsManager.Current.ApplicationView_Expand; _isLoading = false; }