/// <summary> /// Initializes a new instance of the <see cref="MainWindow" /> class. /// </summary> public MainWindow() { InitializeComponent(); // TODO: Build usefull window controls into CEF, get rid of default windows controls. ////this.AllowsTransparency = true; ////this.WindowStyle = WindowStyle.None; ////this.BorderThickness = new Thickness(0); _musicPlayer = new MusicPlayerGate(this.Browser, this); this.Browser.JavascriptObjectRepository.Register("MusicPlayer", _musicPlayer, isAsync: true); this.Browser.JavascriptObjectRepository.ObjectBoundInJavascript += (sender, e) => { Logger.LogInfo($"C# object was registered in javascript variable: {e.ObjectName}"); }; this.Browser.DisplayHandler = new DisplayHandler(this, _dispatcher); this.KeyDown += MainWindow_KeyDown; this.Browser.Loaded += (sender, e) => { string[] args = Environment.GetCommandLineArgs(); if (args?.Length > 1) { FileAttributes attr = File.GetAttributes(args[1]); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { _musicPlayer.LoadFolder(args[1]); } else { _musicPlayer.OpenFiles(args.Skip(1).Take(args.Length - 1).ToArray()); } } }; }
/// <summary> /// Dispose of the music player UI. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Cef.Shutdown(); _musicPlayer.Dispose(); _musicPlayer = null; }