public AvaloniaNativeMenuExporter(IAvaloniaNativeFactory factory) { _factory = factory; _menu = NativeMenu.GetMenu(Application.Current); DoLayoutReset(); }
private void DoLayoutReset(bool forceUpdate = false) { if (_resetQueued || forceUpdate) { _resetQueued = false; if (_nativeWindow is null) { var appMenu = NativeMenu.GetMenu(Application.Current); if (appMenu == null) { appMenu = CreateDefaultAppMenu(); NativeMenu.SetMenu(Application.Current, appMenu); } SetMenu(appMenu); } else { if (_menu != null) { SetMenu(_nativeWindow, _menu); } } _exported = true; } }
void DoLayoutReset() { _resetQueued = false; foreach (var i in _menuItems) { i.PropertyChanged -= OnItemPropertyChanged; if (i.Menu != null) { ((INotifyCollectionChanged)i.Menu.Items).CollectionChanged -= OnMenuItemsChanged; } } _menuItems.Clear(); if (_nativeWindow is null) { _menu = NativeMenu.GetMenu(Application.Current); if (_menu != null) { SetMenu(_menu); } } else { SetMenu(_nativeWindow, _menu?.Items); } _exported = true; }
public MainWindow() { this.InitializeComponent(); this.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() { StartupScreenIndex = 1, }); //Renderer.DrawFps = true; //Renderer.DrawDirtyRects = Renderer.DrawFps = true; _notificationArea = new WindowNotificationManager(this) { Position = NotificationPosition.TopRight, MaxItems = 3 }; DataContext = new MainWindowViewModel(_notificationArea); _recentMenu = ((NativeMenu.GetMenu(this).Items[0] as NativeMenuItem).Menu.Items[2] as NativeMenuItem).Menu; var mainMenu = this.FindControl <Menu>("MainMenu"); mainMenu.AttachedToVisualTree += MenuAttached; ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.OSXThickTitleBar; }
public override void Initialize() { AvaloniaXamlLoader.Load(this); Name = "Avalonia"; _recentMenu = (NativeMenu.GetMenu(this).Items[1] as NativeMenuItem).Menu; }
public MainWindow() { this.InitializeComponent(); //Renderer.DrawFps = true; //Renderer.DrawDirtyRects = Renderer.DrawFps = true; _notificationArea = new WindowNotificationManager(this) { Position = NotificationPosition.TopRight, MaxItems = 3 }; DataContext = new MainWindowViewModel(_notificationArea); _recentMenu = ((NativeMenu.GetMenu(this)?.Items[0] as NativeMenuItem)?.Menu?.Items[2] as NativeMenuItem)?.Menu; }
private void InitializeViewMenu() { var mainTabs = this.FindControl <TabControl>("MainTabs"); var viewMenu = (NativeMenuItem)NativeMenu.GetMenu(this).Items[1]; foreach (TabItem tabItem in mainTabs.Items) { var menuItem = new NativeMenuItem { Header = (string)tabItem.Header !, IsChecked = tabItem.IsSelected, ToggleType = NativeMenuItemToggleType.Radio, }; menuItem.Click += (s, e) => tabItem.IsSelected = true; viewMenu.Menu.Items.Add(menuItem); } }
public MainWindow() { this.InitializeComponent(); //Renderer.DrawFps = true; //Renderer.DrawDirtyRects = Renderer.DrawFps = true; _notificationArea = new WindowNotificationManager(this) { Position = NotificationPosition.TopRight, MaxItems = 3 }; DataContext = new MainWindowViewModel(_notificationArea); _recentMenu = ((NativeMenu.GetMenu(this).Items[0] as NativeMenuItem).Menu.Items[2] as NativeMenuItem).Menu; ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.OSXThickTitleBar; }
public MainWindow() { this.InitializeComponent(); this.AttachDevTools(); //Renderer.DrawFps = true; //Renderer.DrawDirtyRects = Renderer.DrawFps = true; _notificationArea = new WindowNotificationManager(this) { Position = NotificationPosition.TopRight, MaxItems = 3 }; DataContext = new MainWindowViewModel(_notificationArea); _recentMenu = ((NativeMenu.GetMenu(this).Items[0] as NativeMenuItem).Menu.Items[2] as NativeMenuItem).Menu; var mainMenu = this.FindControl <Menu>("MainMenu"); mainMenu.AttachedToVisualTree += MenuAttached; }