private void InitializeComponent() { // TODO: iOS does not support dynamically loading assemblies // so we must refer to this resource DLL statically. For // now I am doing that here. But we need a better solution!! var theme = new Avalonia.Themes.Default.DefaultTheme(); theme.TryGetResource("Button", out _); AvaloniaXamlLoader.Load(this); this.FindControl <Control>("TitleBar").PointerPressed += delegate { PlatformImpl?.BeginMoveDrag(); }; SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West); SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East); SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North); SetupSide("Bottom", StandardCursorType.BottomSide, WindowEdge.South); SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest); SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast); SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest); SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast); this.FindControl <Button>("MinimizeButton").Click += delegate { this.WindowState = WindowState.Minimized; }; this.FindControl <Button>("MaximizeButton").Click += delegate { WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; }; this.FindControl <Button>("CloseButton").Click += delegate { Close(); }; }
public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { var builder = new ConfigurationBuilder() .SetBasePath(Path.Combine(AppContext.BaseDirectory)) .AddJsonFile("appsettings.json", optional: true); _configuration = builder.Build(); _commandText = new CommandText(); _executer = new Executer(); var repo = new DataRepository(_configuration, _commandText, _executer); desktop.MainWindow = new MainWindow { DataContext = new MainWindowViewModel(repo), }; var theme = new Avalonia.Themes.Default.DefaultTheme(); theme.TryGetResource("Button", out _); /*var theme1 = new Avalonia.Themes.Fluent.FluentTheme(); * theme1.TryGetResource("Button", out _);*/ } base.OnFrameworkInitializationCompleted(); }
public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { desktop.MainWindow = new MainWindow { DataContext = new MainWindowViewModel(), }; } else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime) { singleViewLifetime.MainView = new MainView { DataContext = new MainWindowViewModel(), }; } var theme = new Avalonia.Themes.Default.DefaultTheme(); theme.TryGetResource("Button", out _); var theme1 = new Avalonia.Themes.Fluent.FluentTheme(); theme1.TryGetResource("Button", out _); base.OnFrameworkInitializationCompleted(); }
private void InitializeComponent() { // TODO: iOS does not support dynamically loading assemblies // so we must refer to this resource DLL statically. For // now I am doing that here. But we need a better solution!! var theme = new Avalonia.Themes.Default.DefaultTheme(); theme.TryGetResource("Button", out _); AvaloniaXamlLoader.Load(this); }
private async void InitializeComponent() { // TODO: iOS does not support dynamically loading assemblies // so we must refer to this resource DLL statically. For // now I am doing that here. But we need a better solution!! var theme = new Avalonia.Themes.Default.DefaultTheme(); theme.TryGetResource("Button", out _); AvaloniaXamlLoader.Load(this); var file = await NesFile.FromStream(File.OpenRead("lj65.nes")).ConfigureAwait(false); _nesSystem.Cartridge.InsertNesFile(file); _nesSystem.PowerUp(); }
public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { desktop.MainWindow = new MainWindow { DataContext = new MainWindowViewModel() }; desktop.Exit += OnExit; } var theme = new Themes.Default.DefaultTheme(); theme.TryGetResource("Button", out _); base.OnFrameworkInitializationCompleted(); }
private void InitializeComponent() { // TODO: iOS does not support dynamically loading assemblies // so we must refer to this resource DLL statically. For // now I am doing that here. But we need a better solution!! // Note, theme swiching probably will not work in runtime for iOS. if (Application.Current.Styles.Contains(App.FluentDark) || Application.Current.Styles.Contains(App.FluentLight)) { var theme = new Avalonia.Themes.Fluent.Controls.FluentControls(); theme.TryGetResource("Button", out _); } else { var theme = new Avalonia.Themes.Default.DefaultTheme(); theme.TryGetResource("Button", out _); } AvaloniaXamlLoader.Load(this); }
public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { ServiceLocator.Initialize(Locator.CurrentMutable, Locator.Current); desktop.MainWindow = Locator.Current.GetService <MainWindow>(); var notificationManager = Locator.Current.GetService <INotificationManager>(); RxApp.DefaultExceptionHandler = Observer.Create <Exception>(ex => RxApp.MainThreadScheduler.Schedule(() => notificationManager.Show( new Avalonia.Controls.Notifications.Notification( "Unhandled exception occured", ex.Message, NotificationType.Error)))); var viewModel = Locator.Current.GetService <MainWindowViewModel>(); desktop.MainWindow.DataContext = viewModel; var args = Environment.GetCommandLineArgs().Skip(1).ToList(); if (args.Count > 1) { ShowCommandLineError($"Failed to parse command line arguments:\n\n{string.Join(" ", args)}", viewModel); } else if (args.Count == 1) { var fi = new FileInfo(args[0]); if (!fi.Exists) { ShowCommandLineError($"File '{fi.FullName}' does not exist.", viewModel); } else { OpenFile(fi.FullName, viewModel); } } } var theme = new Avalonia.Themes.Default.DefaultTheme(); theme.TryGetResource("Button", out _); base.OnFrameworkInitializationCompleted(); }