void LoadStyles(object sender = null, EventArgs args = null) { if (IdeApp.Preferences.UserInterfaceSkin == Skin.Dark) { Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantDark); } else { Appearance = NSAppearance.GetAppearance(NSAppearance.NameAqua); } textField.Cell.PlaceholderAttributedString = GetStatusString(BrandingService.ApplicationName, ColorForType(MessageType.Ready)); textColor = ColorForType(messageType); ReconstructString(); }
public LaunchWindow(CoreGraphics.CGRect contentRect, NSWindowStyle aStyle, NSBackingStore bufferingType, bool deferCreation) : base(contentRect, aStyle, bufferingType, deferCreation) { Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantDark); IsOpaque = true; MovableByWindowBackground = true; ReleasedWhenClosed = false; Title = NSBundle.MainBundle.GetName(); TitlebarAppearsTransparent = true; TitleVisibility = NSWindowTitleVisibility.Hidden; Toolbar = new NSToolbar() { ShowsBaselineSeparator = false }; }
public void ToggleDarkMode() { if (UsesDarkMode) { Window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameAqua); DarkModeButton.State = NSCellStateValue.Off; UsesDarkMode = false; } else { Window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameDarkAqua); DarkModeButton.State = NSCellStateValue.On; UsesDarkMode = true; } }
public override void DidFinishLaunching(NSNotification notification) { // Insert code here to initialize your application storyboard = NSStoryboard.FromName("Main", null); controller = storyboard.InstantiateControllerWithIdentifier("PopupController") as ViewController; popover.ContentViewController = controller; popover.SetAppearance(NSAppearance.GetAppearance(NSAppearance.NameVibrantDark)); statusBar = new StatusBarController(popover, "StatusBarIcon.png"); //Registering the default settings loaded from the .plist file in the constructor NSUserDefaults.StandardUserDefaults.RegisterDefaults(defaultSettings); }
public AutoClosePopOver(IHostResourceProvider hostResources, NSAppearance effectiveAppearance) { if (hostResources == null) { throw new ArgumentNullException(nameof(hostResources)); } this.hostResources = hostResources; Behavior = NSPopoverBehavior.Semitransient; Delegate = new PopoverFocusRestoreDelegate(); CloseOnEnter = true; this.SetAppearance(this.hostResources.GetVibrantAppearance(effectiveAppearance)); }
void LoadStyles(object sender = null, EventArgs args = null) { if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark) { Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantDark); } else { Appearance = NSAppearance.GetAppearance(NSAppearance.NameAqua); } UpdateApplicationNamePlaceholderText(); textColor = ColorForType(messageType); ReconstructString(); }
static void SetupInit(IMauiContext context, InitializationOptions?maybeOptions = null) { MauiContext = context; Microsoft.Maui.Controls.Internals.Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); Application.AccentColor = Color.FromRgba(50, 79, 133, 255); #if __MOBILE__ Device.SetFlowDirection(UIApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); #else if (!IsInitialized) { // Only need to do this once // Subscribe to notifications in OS Theme changes NSDistributedNotificationCenter.GetDefaultCenter().AddObserver((NSString)"AppleInterfaceThemeChangedNotification", (n) => { var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle"); var aquaAppearance = NSAppearance.GetAppearance(interfaceStyle == "Dark" ? NSAppearance.NameDarkAqua : NSAppearance.NameAqua); NSApplication.SharedApplication.Appearance = aquaAppearance; Application.Current?.TriggerThemeChanged(new AppThemeChangedEventArgs(interfaceStyle == "Dark" ? OSAppTheme.Dark : OSAppTheme.Light)); }); } Device.SetFlowDirection(NSApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); if (IsMojaveOrNewer) { var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle"); var aquaAppearance = NSAppearance.GetAppearance(interfaceStyle == "Dark" ? NSAppearance.NameDarkAqua : NSAppearance.NameAqua); NSApplication.SharedApplication.Appearance = aquaAppearance; } #endif var platformServices = new IOSPlatformServices(); Device.PlatformServices = platformServices; if (maybeOptions?.Flags.HasFlag(InitializationFlags.SkipRenderers) != true) { RegisterCompatRenderers(context); } ExpressionSearch.Default = new iOSExpressionSearch(); IsInitialized = true; }
void DetectTheme() { NSAppearance appearance = Window.ContentView.EffectiveAppearance; string basicAppearance = appearance?.FindBestMatch(new [] { NSAppearance.NameAqua.ToString(), NSAppearance.NameDarkAqua.ToString() }); var value = NSAppearance.NameDarkAqua == basicAppearance ? ColorThemeMode.Dark : ColorThemeMode.Light;; if (value != colorThemeMode) { colorThemeMode = value; viewModel?.ChangeNotification.Post(); } }
public override void AwakeFromNib() { base.AwakeFromNib(); Window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantDark); Window.TitleVisibility = NSWindowTitleVisibility.Hidden; SetupStatusDisplayTextField(); _ = NotificationCenter.AddObserver(ToggleCollapsed.Name, notification => { NSNumber?collapsed = (NSNumber)notification.UserInfo.ObjectForKey(IsCollapsed.NSString()); NSNumber?segmentIndex = (NSNumber)notification.UserInfo.ObjectForKey(SegmentIndex.NSString()); ToggleSidebarSegmentedControl.SetSelected(!collapsed.BoolValue, segmentIndex.NIntValue); }); }
protected override void SetTheme() { switch (Theme) { case PropertyEditorTheme.Dark: CurrentAppearance = DarkAppearance; break; case PropertyEditorTheme.Light: CurrentAppearance = LightAppearance; break; case PropertyEditorTheme.None: CurrentAppearance = NSAppearance.CurrentAppearance; break; } }
public static void EditCollection(NSAppearance appearance, IHostResourceProvider hostResources, CollectionPropertyViewModel collectionVm) { var w = new CollectionEditorWindow(hostResources, collectionVm) { Appearance = appearance }; var result = (NSModalResponse)(int)NSApplication.SharedApplication.RunModalForWindow(w); if (result != NSModalResponse.OK) { collectionVm.CancelCommand.Execute(null); return; } collectionVm.CommitCommand.Execute(null); }
public NativeViewHost() { Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantLight); WantsLayer = true; Layer.BackgroundColor = NSColor.SystemOrangeColor.CGColor; var eventView = new NativeEventView(); AddSubview(eventView); eventView.TranslatesAutoresizingMaskIntoConstraints = false; eventView.LeadingAnchor.ConstraintEqualToAnchor(LeadingAnchor).Active = true; eventView.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor).Active = true; eventView.TopAnchor.ConstraintEqualToAnchor(TopAnchor).Active = true; eventView.BottomAnchor.ConstraintEqualToAnchor(BottomAnchor).Active = true; }
// Called after the application is ready to open the GUI public override void DidFinishLaunching(NSNotification notification) { // Create container for popover Container container = Container.FreshController(); // Furnish popover with content popover.ContentViewController = container; popover.Behavior = NSPopoverBehavior.Transient; popover.Delegate = new PopoverDelegate(); popover.Animates = false; popover.SetAppearance(NSAppearance.GetAppearance(NSAppearance.NameLightContent)); // Enable the tray item only after the app has launched statusItem.Button.Activated += StatusItem_Click; statusItem.Button.SendActionOn(NSEventType.OtherMouseUp); statusItem.Visible = true; Application.Current.SendStart(); }
static void SetTheme(NSWindow window) { if (IdeApp.Preferences.UserInterfaceTheme == Theme.Light) { window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameAqua); } else { window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantDark); } if (IdeApp.Preferences.UserInterfaceTheme == Theme.Light) { window.StyleMask &= ~NSWindowStyle.TexturedBackground; window.BackgroundColor = MonoDevelop.Ide.Gui.Styles.BackgroundColor.ToNSColor(); return; } if (window is NSPanel || window.ContentView.Class.Name != "GdkQuartzView") { window.BackgroundColor = MonoDevelop.Ide.Gui.Styles.BackgroundColor.ToNSColor(); if (MacSystemInformation.OsVersion <= MacSystemInformation.Sierra) { window.StyleMask |= NSWindowStyle.TexturedBackground; } } else { object[] platforms = Mono.Addins.AddinManager.GetExtensionObjects("/MonoDevelop/Core/PlatformService"); if (platforms.Length > 0) { var platformService = (MonoDevelop.Ide.Desktop.PlatformService)platforms [0]; var image = Xwt.Drawing.Image.FromResource(platformService.GetType().Assembly, "maintoolbarbg.png"); window.IsOpaque = false; window.BackgroundColor = NSColor.FromPatternImage(image.ToBitmap().ToNSImage()); } window.StyleMask |= NSWindowStyle.TexturedBackground; } if (MacSystemInformation.OsVersion >= MacSystemInformation.HighSierra && !window.IsSheet) { window.TitlebarAppearsTransparent = true; } }
partial void onClickThemePicker(NSObject sender) { if (_popoverViewController == null) { _popoverViewController = Storyboard.InstantiateControllerWithIdentifier("ThemePickerViewController") as ThemePickerViewController; } if (_popover == null) { _popover = new NSPopover(); _popover.ContentViewController = _popoverViewController; _popover.SetAppearance(NSAppearance.GetAppearance(NSAppearance.NameVibrantLight)); _popover.Animates = true; _popover.Behavior = NSPopoverBehavior.Transient; _popover.WeakDelegate = this; var button = sender as NSButton; _popover.Show(button.Frame, button, NSRectEdge.MaxXEdge); } }
// View menu partial void ToggleDarkModeClicked(NSObject sender) { NSWindow window = NSApplication.SharedApplication.MainWindow; if (window.WindowController is DocumentWindowController) { (window.WindowController as DocumentWindowController).ToggleDarkMode(); } else { if (window.EffectiveAppearance.Name == NSAppearance.NameDarkAqua) { window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameAqua); } else { window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameDarkAqua); } } }
public AppDelegate() { OperatingSystem os = Environment.OSVersion; var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Miniaturizable | NSWindowStyle.Titled; var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768); window = new NSWindow(rect, style, NSBackingStore.Buffered, false); window.Title = "MyLogo 2019"; // choose your own Title here window.TitleVisibility = NSWindowTitleVisibility.Hidden; if (os.Version.Major < 18) { window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameVibrantDark); } else { window.Appearance = NSAppearance.GetAppearance(NSAppearance.NameDarkAqua); } NSApplication.SharedApplication.ServicesProvider = this; }
public static void Init() { if (IsInitialized) { return; } IsInitialized = true; Color.SetAccent(ColorExtensions.AccentColor.ToColor()); Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); #if __MOBILE__ Device.SetIdiom(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? TargetIdiom.Tablet : TargetIdiom.Phone); Device.SetFlowDirection(UIApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); #else Device.SetIdiom(TargetIdiom.Desktop); Device.SetFlowDirection(NSApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); var mojave = new NSOperatingSystemVersion(10, 14, 0); if (NSProcessInfo.ProcessInfo.IsOperatingSystemAtLeastVersion(mojave) && typeof(NSApplication).GetProperty("Appearance") is PropertyInfo appearance && appearance != null) { var aquaAppearance = NSAppearance.GetAppearance(NSAppearance.NameAqua); appearance.SetValue(NSApplication.SharedApplication, aquaAppearance); } #endif Device.SetFlags(s_flags); Device.PlatformServices = new IOSPlatformServices(); #if __MOBILE__ Device.Info = new IOSDeviceInfo(); #else Device.Info = new Platform.macOS.MacDeviceInfo(); #endif Internals.Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportFontAttribute) }); ExpressionSearch.Default = new iOSExpressionSearch(); }
public virtual NSImage GetNamedImage(string name) { NSAppearance currentAppearance = CurrentAppearance ?? NSAppearance.CurrentAppearance; if (currentAppearance != null && currentAppearance.Name.ToLower().Contains("dark")) { bool sel = name.EndsWith("~sel"); if (sel) { name = name.Substring(0, name.Length - 4); } name += "~dark"; if (sel) { name += "~sel"; } } return(this.resourceBundle.ImageForResource(name)); }
public override IView ConvertTo(FigmaNode currentNode, ProcessedNode parent, FigmaRendererService rendererService) { var figmaInstance = (FigmaInstance)currentNode; var button = new ComboBox(); var view = (NSPopUpButton)button.NativeObject; var controlType = figmaInstance.ToControlType(); switch (controlType) { case NativeControlType.PopUpButtonSmall: case NativeControlType.PopUpButtonSmallDark: view.ControlSize = NSControlSize.Small; break; case NativeControlType.PopUpButtonStandard: case NativeControlType.PopUpButtonStandardDark: view.ControlSize = NSControlSize.Regular; break; } var label = figmaInstance.children .OfType <FigmaText>() .FirstOrDefault(s => s.name == "lbl"); if (label != null) { button.AddItem(label.characters); view.Font = label.style.ToNSFont(); } if (controlType.ToString().EndsWith("Dark", StringComparison.Ordinal)) { view.Appearance = NSAppearance.GetAppearance(NSAppearance.NameDarkAqua); } return(button); }
// If theme toggled, then notify our manager partial void OnThemeChanged(NSObject sender) { var themeControl = (NSSegmentedControl)sender; NSString appearance = NSAppearance.NameAqua; if (themeControl.SelectedSegment == 0) { if (NSProcessInfo.ProcessInfo.OperatingSystemVersion.Minor > 13) { appearance = NSAppearance.NameDarkAqua; } else { appearance = NSAppearance.NameVibrantDark; } } var realAppearance = NSAppearance.GetAppearance(appearance); ((HostResourceProvider)PropertyPanel.HostResourceProvider).CurrentAppearance = realAppearance; View.Appearance = realAppearance; }
public static void SetAppearance(NSAppearance appearance) { __Appearance = appearance; }
static void SetupInit(IMauiContext context, InitializationOptions?maybeOptions = null) { MauiContext = context; Microsoft.Maui.Controls.Internals.Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); //TODO: MAUI Accent Color? Color.SetAccent(Color.FromRgba(50, 79, 133, 255)); if (!IsInitialized) { // Only need to do this once Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); } #if __MOBILE__ Device.SetIdiom(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? TargetIdiom.Tablet : TargetIdiom.Phone); Device.SetFlowDirection(UIApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); #else if (!IsInitialized) { // Only need to do this once // Subscribe to notifications in OS Theme changes NSDistributedNotificationCenter.GetDefaultCenter().AddObserver((NSString)"AppleInterfaceThemeChangedNotification", (n) => { var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle"); var aquaAppearance = NSAppearance.GetAppearance(interfaceStyle == "Dark" ? NSAppearance.NameDarkAqua : NSAppearance.NameAqua); NSApplication.SharedApplication.Appearance = aquaAppearance; Application.Current?.TriggerThemeChanged(new AppThemeChangedEventArgs(interfaceStyle == "Dark" ? OSAppTheme.Dark : OSAppTheme.Light)); }); } Device.SetIdiom(TargetIdiom.Desktop); Device.SetFlowDirection(NSApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); if (IsMojaveOrNewer) { var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle"); var aquaAppearance = NSAppearance.GetAppearance(interfaceStyle == "Dark" ? NSAppearance.NameDarkAqua : NSAppearance.NameAqua); NSApplication.SharedApplication.Appearance = aquaAppearance; } #endif Device.SetFlags(s_flags); var platformServices = new IOSPlatformServices(); Device.PlatformServices = platformServices; // use field and not property to avoid exception in getter if (Device.info is IDisposable infoDisposable) { infoDisposable.Dispose(); Device.info = null; } #if __MOBILE__ Device.PlatformInvalidator = platformServices; Device.Info = new IOSDeviceInfo(); #else Device.Info = new Platform.macOS.MacDeviceInfo(); #endif if (maybeOptions?.Flags.HasFlag(InitializationFlags.SkipRenderers) != true) { RegisterCompatRenderers(); } ExpressionSearch.Default = new iOSExpressionSearch(); IsInitialized = true; }
void UpdateCell() { Appearance = NSAppearance.GetAppearance(IdeApp.Preferences.UserInterfaceSkin == Skin.Dark ? NSAppearance.NameVibrantDark : NSAppearance.NameAqua); NeedsDisplay = true; }
public override IView ConvertTo(FigmaNode currentNode, ProcessedNode parent, FigmaRendererService rendererService) { var figmaInstance = (FigmaInstance)currentNode; var button = new Button(); var view = (NSButton)button.NativeObject; view.Title = ""; view.BezelStyle = NSBezelStyle.Rounded; button.Size = new Size(figmaInstance.absoluteBoundingBox.Width, 30); var controlType = figmaInstance.ToControlType(); switch (controlType) { case NativeControlType.ButtonLarge: case NativeControlType.ButtonLargeDark: view.ControlSize = NSControlSize.Regular; break; case NativeControlType.ButtonStandard: case NativeControlType.ButtonStandardDark: view.ControlSize = NSControlSize.Regular; break; case NativeControlType.ButtonSmall: case NativeControlType.ButtonSmallDark: view.ControlSize = NSControlSize.Small; break; } //first figma var group = figmaInstance.children .OfType <FigmaGroup>() .FirstOrDefault(s => s.visible); if (group != null) { var label = group.children .OfType <FigmaText>() .FirstOrDefault(); if (label != null) { button.Text = label.characters; view.Font = label.style.ToNSFont(); } if (group.name == "Disabled") { button.Enabled = false; } } else { var label = figmaInstance.children .OfType <FigmaText>() .FirstOrDefault(); if (label != null) { button.Text = label.characters; view.Font = label.style.ToNSFont(); } } if (controlType.ToString().EndsWith("Dark", StringComparison.Ordinal)) { view.Appearance = NSAppearance.GetAppearance(NSAppearance.NameDarkAqua); } return(button); }
public void SetAppareance(bool isDark) { base.Appearance = NSAppearance.GetAppearance(isDark ? NSAppearance.NameVibrantDark : NSAppearance.NameVibrantLight); }
public MonoDevelopHostResourceProvider() { CurrentAppearance = NSAppearance.GetAppearance(IdeApp.Preferences.UserInterfaceTheme == Theme.Dark ? NSAppearance.NameDarkAqua : NSAppearance.NameAqua); }
public static void Init(IActivationState activationState) { if (IsInitialized) { return; } ActivationState = activationState; IsInitialized = true; Microsoft.Maui.Controls.Internals.Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); //TODO: MAUI Accent Color? Color.SetAccent(Color.FromRgba(50, 79, 133, 255)); Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); #if __MOBILE__ Device.SetIdiom(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? TargetIdiom.Tablet : TargetIdiom.Phone); Device.SetFlowDirection(UIApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); #else // Subscribe to notifications in OS Theme changes NSDistributedNotificationCenter.GetDefaultCenter().AddObserver((NSString)"AppleInterfaceThemeChangedNotification", (n) => { var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle"); var aquaAppearance = NSAppearance.GetAppearance(interfaceStyle == "Dark" ? NSAppearance.NameDarkAqua : NSAppearance.NameAqua); NSApplication.SharedApplication.Appearance = aquaAppearance; Application.Current?.TriggerThemeChanged(new AppThemeChangedEventArgs(interfaceStyle == "Dark" ? OSAppTheme.Dark : OSAppTheme.Light)); }); Device.SetIdiom(TargetIdiom.Desktop); Device.SetFlowDirection(NSApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); if (IsMojaveOrNewer) { var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle"); var aquaAppearance = NSAppearance.GetAppearance(interfaceStyle == "Dark" ? NSAppearance.NameDarkAqua : NSAppearance.NameAqua); NSApplication.SharedApplication.Appearance = aquaAppearance; } #endif Device.SetFlags(s_flags); var platformServices = new IOSPlatformServices(); Device.PlatformServices = platformServices; #if __MOBILE__ Device.PlatformInvalidator = platformServices; Device.Info = new IOSDeviceInfo(); #else Device.Info = new Platform.macOS.MacDeviceInfo(); #endif if (!IsInitializedRenderers) { IsInitializedRenderers = true; Controls.Internals.Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportFontAttribute) }); } ExpressionSearch.Default = new iOSExpressionSearch(); }