public void With_Unregistered_Id_Throws() { var mockResourceDictionary = new Mock <ICollection <ResourceDictionary> >(); ThemeManager manager = new ThemeManager(mockResourceDictionary.Object); manager.ApplyTheme(Guid.NewGuid()); }
protected override void ExecuteCmdlet() { var url = CurrentWeb.EnsureProperty(w => w.Url); var tenantUrl = UrlUtilities.GetTenantAdministrationUrl(ClientContext.Url); using (var tenantContext = ClientContext.Clone(tenantUrl)) { var tenant = new Tenant(tenantContext); var webUrl = url; if (!string.IsNullOrEmpty(WebUrl)) { try { var uri = new Uri(WebUrl); webUrl = WebUrl; } catch { ThrowTerminatingError(new ErrorRecord(new System.Exception("Invalid URL"), "INVALIDURL", ErrorCategory.InvalidArgument, WebUrl)); } } if (Enum.TryParse(Theme.Name, out SharePointTheme sharePointTheme)) { ThemeManager.ApplyTheme(CurrentWeb, sharePointTheme); } else { tenant.SetWebTheme(Theme.Name, webUrl); tenantContext.ExecuteQueryRetry(); } } }
public void Activate() { string resourceDefault = global::System.IO.Path.Combine("res", "resSampleThemeResourceDefault.xaml"); string resourceDark = global::System.IO.Path.Combine("res", "SampleThemeResourceDark.xaml"); Theme sampleTheme = new Theme(global::System.IO.Path.Combine("res", "SampleTheme.xaml"), resourceDefault); ThemeManager.ApplyTheme(sampleTheme); View root = new View(); root.WidthSpecification = LayoutParamPolicies.MatchParent; root.HeightSpecification = LayoutParamPolicies.MatchParent; Window.Instance.GetDefaultLayer().Add(root); Button button = new Button(); button.ThemeChangeSensitive = true; button.Size = new Size2D(200, 200); button.Clicked += (object sender, ClickedEventArgs e) => { if (sampleTheme.Resource == resourceDefault) { sampleTheme.Resource = resourceDark; ThemeManager.ApplyTheme(sampleTheme); } else { sampleTheme.Resource = resourceDefault; ThemeManager.ApplyTheme(sampleTheme); } }; root.Add(button); }
public UserWindow() { InitializeComponent(); this.Loaded += UserWindow_Loaded; ThemeManager.ApplyTheme(App.Current, "BubbleCreme"); min_button = new Button(); close_button = new Button(); FatherWindow.TitleBarInit(min_button, close_button); this.TitleBar.Children.Add(min_button); this.TitleBar.Children.Add(close_button); min_button.Margin = new Thickness(0, 0, -5, 0); close_button.Click += close_button_Click; min_button.Click += min_button_Click; FatherWindow.buttonWrap(this.addFriendBtn, null); FatherWindow.buttonWrap(this.delFriendBtn, null); FatherWindow.buttonWrap(this.addFroupBtn, null); FatherWindow.buttonWrap(this.MsgListBtn, null); FatherWindow.buttonWrap(this.SetBtn, null); FatherWindow.buttonWrap(this.UserInfoSet, null); this.Closing += UserWindow_Closing; getUserinfo = new System.Windows.Forms.Timer(); getUserinfo.Interval = 3000; getUserinfo.Tick += getUserinfo_Tick; getUserinfo.Start(); }
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation) { #if !ONPREMISES using (var scope = new PnPMonitoredScope(this.Name)) { var context = web.Context as ClientContext; var parsedName = parser.ParseString(template.Theme.Name); if (Enum.TryParse <SharePointTheme>(parsedName, out SharePointTheme builtInTheme)) { ThemeManager.ApplyTheme(web, builtInTheme); } else { web.EnsureProperty(w => w.Url); if (!string.IsNullOrEmpty(template.Theme.Palette)) { var parsedPalette = parser.ParseString(template.Theme.Palette); ThemeManager.ApplyTheme(web, parsedPalette, template.Theme.Name ?? parsedPalette); } } } #endif return(parser); }
public static void ApplyTheme(ThemeSettings themeSettings) { _currentThemeSettings = themeSettings; if (themeSettings.IsGlassEnabled) { ((RibbonWindow)Application.Current.MainWindow).IsGlassEnabled = themeSettings.IsGlassEnabled; } ThemeName theme = ThemeName.Generic; Enum.TryParse <ThemeName>(themeSettings.ThemeName, out theme); if (themeSettings.TintColor.HasValue) { TintedThemeCatalog catalog = new TintedThemeCatalog("Custom", theme.ToString()); theme = ThemeName.Custom; catalog.TintGroups.AddRange(TintGroupSets.Default, themeSettings.TintColor.Value); catalog.TintGroups.AddRange(TintGroupSets.ApplicationMenu, themeSettings.TintColor.Value); ThemeManager.RegisterThemeCatalog("Custom", catalog); if (ThemeManager.CurrentTheme == ThemeName.Custom.ToString()) { ThemeManager.ApplyTheme(); return; } } ThemeManager.CurrentTheme = theme.ToString(); }
private void VmTheme_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "SelectedAccentColor" || e.PropertyName == "SelectedThemeMode") { tm.ApplyTheme(SelectedAccentColor, SelectedThemeMode); SelectedAccentColor = (Color)Application.Current.Resources["AccentColor"]; } }
internal static void CheckAndApplyTheme(ContentControl control) { OperatingSystemVersion os = OperatingSystemVersion.Current; if (os.OSVersion == OSVersion.Win7) { ThemeManager.ApplyTheme(control, "BureauBlue"); } }
private void themes_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { string theme = e.AddedItems[0].ToString(); ThemeManager.ApplyTheme(theme); Properties.Settings.Default.WPFControlThemeName = theme; } }
private void InitAppData() { if (App.ip == "") //非命令行启动时,ip将为""(空串) { App.ip = "172.16.49.192"; //此处手动设置ip } //App.ip = "111.195.198.161"; //此处手动设置ip ThemeManager.ApplyTheme(App.Current, "BubbleCreme"); ServerAPI.InitServerAPI(); }
/// <summary> /// Applyies user defined themes. /// </summary> /// <param name="e"></param> protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); ApplySecurity(); if (Usuario != null) { ThemeManager.ApplyTheme(this, Usuario.Theme); } }
private void OnClicked(object target, ClickedEventArgs args) { clickCount++; if ((clickCount) % 2 == 0) { ThemeManager.ApplyTheme(themeBlack); } else { ThemeManager.ApplyTheme(themeGreen); } }
public void Returns_Correct_CurrentTheme_After_Apply() { var mockResourceDictionary = new Mock <ICollection <ResourceDictionary> >(); ThemeManager manager = new ThemeManager(mockResourceDictionary.Object); ThemeDescriptor descriptor = new ThemeDescriptor(Guid.NewGuid(), "Theme name", new ResourceDictionary()); manager.RegisterTheme(descriptor); manager.ApplyTheme(descriptor.Id); Assert.AreEqual(manager.CurrentTheme.Id, descriptor.Id); }
private void AppStartup(object sender, StartupEventArgs e) { IOHelper.CreateDirectoryIfNotExist(AppDataPath); if (File.Exists(DataPath)) { SerializationHelper.Current.Load(DataPath); } Installer.Install(); Instances.Get <MainView>().Show(); ThemeManager.ApplyTheme(this, Theme.Light, (SolidColorBrush)Application.Current.FindBrush("AccentColor"), (SolidColorBrush)Application.Current.FindBrush("FontColor")); }
public void ThemeManagerApplyTheme() { tlog.Debug(tag, $"ThemeManagerApplyTheme START"); Theme a1 = new Theme(); ThemeManager.ApplyTheme(a1); a1.Id = null; ThemeManager.ApplyTheme(a1); tlog.Debug(tag, $"ThemeManagerApplyTheme END (OK)"); Assert.Pass("ThemeManagerApplyTheme"); }
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); LoadExtensions(); ThemeManager.ApplyTheme(this); // This is necessary because Safari and Chrome browsers don't display the Menu control correctly. if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1) { Page.ClientTarget = "uplevel"; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { this.WindowState = System.Windows.WindowState.Normal; //Set WPF Skin ThemeManager.ApplyTheme(Application.Current, ThemeType.Royale); mMainWindow = this; //Navigate to the Incident Entry Page: PolicePadWorkspace lp = new PolicePadWorkspace(); MainFrame.Navigate(lp); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // create a new window instance based on the screen size window = new UIWindow(UIScreen.MainScreen.Bounds); ThemeManager.ApplyTheme(); var tabs = new UITabBarController(); UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque; var firstdvc = BuildDialogViewController(); firstdvc.NavigationItem.RightBarButtonItems = new [] { new UIBarButtonItem(UIBarButtonSystemItem.Add, delegate {}), new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate {}) }; var tabControllers = new UINavigationController[] { new UINavigationController(firstdvc) { TabBarItem = new UITabBarItem("First", Theme.Resources.TempIcon, 1) }, new UINavigationController(BuildDialogViewController(style: UITableViewStyle.Plain)) { TabBarItem = new UITabBarItem("Second", Theme.Resources.TempIcon, 1) }, new UINavigationController(BuildControlsDialogViewController()) { TabBarItem = new UITabBarItem("Controls", Theme.Resources.TempIcon, 1) }, new UINavigationController(BuildDialogViewController(style: UITableViewStyle.Plain)) { TabBarItem = new UITabBarItem("Second", Theme.Resources.TempIcon, 1) } }; tabs.SetViewControllers(tabControllers, false); // If you have defined a root view controller, set it here: window.RootViewController = tabs; // make the window visible window.MakeKeyAndVisible(); return(true); }
public override TokenParser ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation) { #if !ONPREMISES using (var scope = new PnPMonitoredScope(this.Name)) { var context = web.Context as ClientContext; var parsedName = parser.ParseString(template.Theme.Name); if (!string.IsNullOrEmpty(parsedName)) { web.EnsureProperty(w => w.Url); if (Enum.TryParse <SharePointTheme>(parsedName, out SharePointTheme builtInTheme)) { ThemeManager.ApplyTheme(web, builtInTheme); } else if (!string.IsNullOrEmpty(template.Theme.Palette)) { var parsedPalette = parser.ParseString(template.Theme.Palette); ThemeManager.ApplyTheme(web, parsedPalette, template.Theme.Name ?? parsedPalette); } else { //The account used for authenticating needs to be tenant administrator. try { using (var tenantContext = web.Context.Clone(web.GetTenantAdministrationUrl())) { var tenant = new Tenant(tenantContext); var theme = tenant.GetTenantTheme(parsedName); tenantContext.Load(theme); tenant.SetWebTheme(parsedName, web.Url); tenantContext.ExecuteQueryRetry(); } } catch (Exception ex) { scope.LogWarning($"Custom theme could not be applied to site: {ex.Message}"); throw; } } } } #endif return(parser); }
private void Window_Loaded(object sender, RoutedEventArgs e) { //Start app minimized. this.WindowState = System.Windows.WindowState.Maximized; //Set WPF Skin ThemeManager.ApplyTheme(Application.Current, ThemeType.Royale); mMainWindow = this; SetWindowIcon(); //Navigate to the login page: LoginPage lp = new LoginPage(); MainFrame.Navigate(lp); }
public void Removes_All_Other_Items_From_Underlying_Resource_Dictionary() { var mockResourceDictionary = new Mock <ICollection <ResourceDictionary> >(); mockResourceDictionary.Setup(c => c.Clear()); mockResourceDictionary.Setup(c => c.Add(It.IsAny <ResourceDictionary>())); ThemeManager manager = new ThemeManager(mockResourceDictionary.Object); var resourceDic = new ResourceDictionary(); ThemeDescriptor descriptor = new ThemeDescriptor(Guid.NewGuid(), "Theme name", resourceDic); manager.RegisterTheme(descriptor); manager.ApplyTheme(descriptor.Id); mockResourceDictionary.Verify(c => c.Clear(), Times.Once); }
public void OnClicked(object target, ClickedEventArgs args) { clickCount = (clickCount + 1) % 3; if (clickCount == 0) { ThemeManager.ApplyTheme(theme1); } else if (clickCount == 1) { ThemeManager.ApplyTheme(theme2); } else { ThemeManager.ApplyTheme(theme3); } }
private void SliderTheme_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { Slider s = (Slider)sender; ThemeManager tm; string userTheme; switch (e.NewValue) { case double d when(e.NewValue >= 0 && e.NewValue <= 1): { s.Value = 1.0; userTheme = "Light"; s.ToolTip = userTheme; this.lblTheme.Content = $"Choose a theme! {userTheme}"; this.isLight = 1; tm = new ThemeManager(ThemeManager.Theme.Light); break; } case double d when(e.NewValue > 1 && e.NewValue <= 2): { s.Value = 2.0; userTheme = "Dark"; s.ToolTip = userTheme; this.lblTheme.Content = $"Choose a theme! { userTheme}"; this.isLight = 0; tm = new ThemeManager(ThemeManager.Theme.Dark); break; } default: { tm = new ThemeManager(ThemeManager.Theme.Light); break; } } tm.ApplyTheme(this); }
private void PopupButtonClickedEvent(object sender, Popup.ButtonClickEventArgs e) { if (e.ButtonIndex == 1) { (sender as Popup)?.Dismiss(); } else { clickCount = (clickCount + 1) % 2; if (clickCount == 0) { ThemeManager.ApplyTheme(theme1); } else if (clickCount == 1) { ThemeManager.ApplyTheme(theme2); } } }
public void ThemeManagerApplyTheme() { tlog.Debug(tag, $"ThemeManagerApplyTheme START"); var testingTarget = new Theme(path); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Theme>(testingTarget, "should be an instance of testing target class!"); try { ThemeManager.ApplyTheme(testingTarget); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } tlog.Debug(tag, $"ThemeManagerApplyTheme END (OK)"); }
private void Image_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ThemeCollection curCollection = ((Image)sender).Tag as ThemeCollection; if (curCollection != null) { switch (curCollection.ItemThemeType) { case ThemeType.SystemEmbedded: MPL.Utility.ApplyDefaultTheme(App.Current, curCollection.ThemeName, curCollection.ThemeFile); break; case ThemeType.Toolkit: ThemeManager.ApplyTheme(curCollection.ThemeName); break; case ThemeType.Default: MPL.Utility.ApplyTheme(App.Current, curCollection.ThemeFile); break; } } }
public void OnKeyEvent(object sender, Window.KeyEventArgs e) { if (e.Key.State == Key.StateType.Down) { if (e.Key.KeyPressedName == "1") { clickCount++; if ((clickCount) % 2 == 0) { ThemeManager.ApplyTheme(themeBlack); } else { ThemeManager.ApplyTheme(themeGreen); } } else if (e.Key.KeyPressedName == "XF86Back") { Exit(); } } }
private void OK_button_Click(object sender, RoutedEventArgs e) { if (themes.Text != "") { ThemeManager.ApplyTheme(App.Current, themes.Text.ToString()); } if (Sourcepath.Text != "") { System.Drawing.Image image = null; image = System.Drawing.Image.FromFile(Sourcepath.Text); var bitmap = new System.Drawing.Bitmap(image); var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions() ); bitmap.Dispose(); var brush = new ImageBrush(bitmapSource); App.mainWindow.Background = brush; } }
protected override void OnCreate() { base.OnCreate(); var root = NUIApplication.GetDefaultWindow(); root.BackgroundColor = Color.White; // Load and apply theme from xaml file. var resDir = Tizen.Applications.Application.Current.DirectoryInfo.Resource; ThemeManager.ApplyTheme(new Theme(resDir + "Theme/CustomTheme.xaml")); root.Add(new TextLabel() { StyleName = "TextA", Text = "TextA", Position = new Position(10, 10) }); root.Add(new TextLabel() { StyleName = "TextB", Text = "TextB", Position = new Position(10, 80) }); root.Add(new TextLabel() { StyleName = "TextC", Text = "TextC", Position = new Position(10, 170) }); root.KeyEvent += OnKeyEvent; }
/// <summary> /// Registers the shell event listener. /// </summary> /// <remarks> /// This event listener is registered by itself and first to wait for the shell to be ready /// for other event listeners to be registered. /// </remarks> private void RegisterShellEventListener() { ShellEventListener = new ShellEventListener(this, ShellService); ShellEventListener.EnvironmentColorChanged += () => ThemeManager.ApplyTheme(); ShellEventListener.ShellAvailable += RegisterNonShellEventListeners; }