当前位置: 首页>>代码示例>>C#>>正文


C# Skin.ToString方法代码示例

本文整理汇总了C#中Skin.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Skin.ToString方法的具体用法?C# Skin.ToString怎么用?C# Skin.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Skin的用法示例。


在下文中一共展示了Skin.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateGtkTheme

		internal static void UpdateGtkTheme ()
		{
			if (DefaultTheme == null)
				SetupGtkTheme ();

			string current_theme = IdeApp.Preferences.UserInterfaceTheme;

			if (!Platform.IsLinux) {
				UserInterfaceSkin = IdeApp.Preferences.UserInterfaceTheme == "Dark" ? Skin.Dark : Skin.Light;
				if (current_theme != UserInterfaceSkin.ToString ()) // Only Skin names allowed on Win/Mac
					current_theme = UserInterfaceSkin.ToString ();
			}

			var use_bundled_theme = false;

			
			// Use the bundled gtkrc only if the Xamarin theme is installed
			if (File.Exists (Path.Combine (Gtk.Rc.ModuleDir, "libxamarin.so")) || File.Exists (Path.Combine (Gtk.Rc.ModuleDir, "libxamarin.dll")))
				use_bundled_theme = true;
			// on Windows we can't rely on Gtk.Rc.ModuleDir to be valid
			// and test additionally the default installation dir
			if (!use_bundled_theme && Platform.IsWindows) {
				var gtkBasePath = Environment.GetEnvironmentVariable ("GTK_BASEPATH");
				if (String.IsNullOrEmpty (gtkBasePath))
					gtkBasePath = "C:\\Program Files (x86)\\GtkSharp\\2.12\\";
				if (File.Exists (Path.Combine (gtkBasePath, "lib\\gtk-2.0\\2.10.0\\engines\\libxamarin.dll")))
				    use_bundled_theme = true;
			}
			
			if (use_bundled_theme) {
				
				if (!Directory.Exists (UserProfile.Current.ConfigDir))
					Directory.CreateDirectory (UserProfile.Current.ConfigDir);
				
				if (Platform.IsWindows) {
					// HACK: Gtk Bug: Rc.ReparseAll () and the include "[rcfile]" gtkrc statement are broken on Windows.
					//                We must provide our own XDG folder structure to switch bundled themes.
					var rc_themes = UserProfile.Current.ConfigDir.Combine ("share", "themes");
					var rc_theme_light = rc_themes.Combine ("Light", "gtk-2.0", "gtkrc");
					var rc_theme_dark = rc_themes.Combine ("Dark", "gtk-2.0", "gtkrc");
					if (!Directory.Exists (rc_theme_light.ParentDirectory))
						Directory.CreateDirectory (rc_theme_light.ParentDirectory);
					if (!Directory.Exists (rc_theme_dark.ParentDirectory))
						Directory.CreateDirectory (rc_theme_dark.ParentDirectory);

					string gtkrc = PropertyService.EntryAssemblyPath.Combine ("gtkrc");
					File.Copy (gtkrc + ".win32", rc_theme_light, true);
					File.Copy (gtkrc + ".win32-dark", rc_theme_dark, true);

					var themeDir = UserProfile.Current.ConfigDir;
					if (!themeDir.IsAbsolute)
						themeDir = themeDir.ToAbsolute (Environment.CurrentDirectory);
					Environment.SetEnvironmentVariable ("GTK_DATA_PREFIX", themeDir);

					// set the actual theme and reset the environment only after Gtk has been fully
					// initialized. See SetupGtkTheme ().
					if (Gtk.Settings.Default != null) {
						LoggingService.LogInfo ("GTK: Using Gtk theme from {0}", Path.Combine (Gtk.Rc.ThemeDir, current_theme));
						Gtk.Settings.Default.ThemeName = current_theme;
						Environment.SetEnvironmentVariable ("GTK_DATA_PREFIX", DefaultGtkDataFolder);
					}

				} else if (Platform.IsMac) {
					
					var gtkrc = "gtkrc.mac";
					if (IdeApp.Preferences.UserInterfaceSkin == Skin.Dark)
						gtkrc += "-dark";
					gtkrc = PropertyService.EntryAssemblyPath.Combine (gtkrc);

					LoggingService.LogInfo ("GTK: Using gtkrc from {0}", gtkrc);
					
					// Generate a dummy rc file and use that to include the real rc. This allows changing the rc
					// on the fly. All we have to do is rewrite the dummy rc changing the include and call ReparseAll
					var rcFile = UserProfile.Current.ConfigDir.Combine ("gtkrc");
					File.WriteAllText (rcFile, "include \"" + gtkrc + "\"");
					Environment.SetEnvironmentVariable ("GTK2_RC_FILES", rcFile);

					Gtk.Rc.ReparseAll ();
				}

			} else if (Gtk.Settings.Default != null && current_theme != Gtk.Settings.Default.ThemeName) {
				LoggingService.LogInfo ("GTK: Using Gtk theme from {0}", Path.Combine (Gtk.Rc.ThemeDir, current_theme));
				Gtk.Settings.Default.ThemeName = current_theme;
			}

			// let Gtk realize the new theme
			// Style is being updated by DefaultWorkbench.OnStyleSet ()
			// This ensures that the theme and all styles have been loaded when
			// the Styles.Changed event is raised.
			//GLib.Timeout.Add (50, delegate { UpdateStyles(); return false; });
		}
开发者ID:vvarshne,项目名称:monodevelop,代码行数:91,代码来源:IdeTheme.cs

示例2: Initialise

 /// <summary>
 /// Initialise the skin manager - BaseDictionaryUriStrings, ResourceManager and DictionaryNameExpander
 /// must be initialised before calling.
 /// </summary>
 /// <param name="skin">
 /// The initial skin to use.
 /// </param>
 public void Initialise(Skin skin)
 {
     this.dictionaries = new List<ResourceDictionary>(this.BaseDictionaryUriStrings.Count());
     this.dictionaries.AddRange(this.LoadDictionaries(skin.ToString()));
     this.resourceManager.SwitchDictionaries(null, this.dictionaries);
 }
开发者ID:modulexcite,项目名称:WPF-Composite-Application-Dynamic-Skin-Switching,代码行数:13,代码来源:SkinManagerBase.cs


注:本文中的Skin.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。