Beispiel #1
0
        private void InitializeWindow()
        {
            // Start monitoring tablet mode
            this.StartMonitoringTabletMode();

            // Tray controls
            this.trayControls = this.container.Resolve <Views.TrayControls>();

            this.miniPlayerPlaylist = this.container.Resolve <Views.Playlist>(new DependencyOverride(typeof(DopamineWindow), this));
            RegionManager.SetRegionManager(this.miniPlayerPlaylist, this.regionManager);
            RegionManager.UpdateRegions();

            this.notificationService.SetApplicationWindows(this, this.miniPlayerPlaylist, this.trayControls);

            // Handler
            this.Restored += Shell_Restored;

            // Workaround to make sure the PART_MiniPlayerButton ToolTip also gets updated on a language change
            this.CloseToolTipChanged += Shell_CloseToolTipChanged;

            // This makes sure the position and size of the window is correct and avoids jumping of
            // the window to the correct position when SetPlayer() is called later while starting up
            this.SetPlayerType(SettingsClient.Get <bool>("General", "IsMiniPlayer"), (MiniPlayerType)SettingsClient.Get <int>("General", "MiniPlayerType"));

            // Make sure the window geometry respects tablet mode at startup
            this.CheckIfTabletMode();
        }
Beispiel #2
0
        private void InitializeShellWindow()
        {
            // Start monitoring tablet mode
            this.windowsIntegrationService.StartMonitoringTabletMode();

            // Tray controls
            this.trayControls = this.container.Resolve <TrayControls>();

            // Create the Mini Player playlist
            this.miniPlayerPlaylist = this.container.Resolve <MiniPlayerPlaylist>(new DependencyOverride(typeof(DopamineWindow), this));

            // NotificationService needs to know about the application windows
            this.notificationService.SetApplicationWindows(this, this.miniPlayerPlaylist, this.trayControls);

            // Settings changed
            SettingsClient.SettingChanged += (_, e) =>
            {
                if (SettingsClient.IsSettingChanged(e, "Appearance", "ShowWindowBorder"))
                {
                    this.SetWindowBorder((bool)e.SettingValue);
                }

                if (SettingsClient.IsSettingChanged(e, "Behaviour", "ShowTrayIcon"))
                {
                    this.trayIcon.Visible = (bool)e.SettingValue;
                }
            };

            // Make sure the window geometry respects tablet mode at startup
            this.CheckIfTabletMode();
        }
Beispiel #3
0
        private void InitializeWindows()
        {
            // Start monitoring tablet mode
            this.windowsIntegrationService.StartMonitoringTabletMode();

            // Tray controls
            this.trayControls = this.container.Resolve <TrayControls>();

            // Create the Mini Player playlist
            this.miniPlayerPlaylist = this.container.Resolve <Func <BorderlessWindows10Window, MiniPlayerPlaylist> >()(this);

            // NotificationService needs to know about the application windows
            this.notificationService.SetApplicationWindows(this, this.miniPlayerPlaylist, this.trayControls);

            // Settings changed
            SettingsClient.SettingChanged += (_, e) =>
            {
                if (SettingsClient.IsSettingChanged(e, "Appearance", "ShowWindowBorder"))
                {
                    this.WindowBorder.BorderThickness = new Thickness((bool)e.SettingValue ? 1 : 0);
                }

                if (SettingsClient.IsSettingChanged(e, "Behaviour", "ShowTrayIcon"))
                {
                    this.trayIcon.Visible = (bool)e.SettingValue;
                }
            };

            this.shellService.WindowStateChangeRequested += (_, e) => this.WindowState = e.WindowState;
            this.shellService.IsMovableChangeRequested   += (_, e) => this.IsMovable = e.IsMovable;
            this.shellService.ResizeModeChangeRequested  += (_, e) => this.ResizeMode = e.ResizeMode;
            this.shellService.TopmostChangeRequested     += (_, e) => this.Topmost = e.IsTopmost;

            this.shellService.GeometryChangeRequested += (_, e) => this.SetGeometry(
                e.Top, e.Left, e.Size.Width, e.Size.Height,
                Constants.DefaultShellTop,
                Constants.DefaultShellLeft);

            this.shellService.MinimumSizeChangeRequested += (_, e) =>
            {
                this.MinWidth  = e.MinimumSize.Width;
                this.MinHeight = e.MinimumSize.Height;
            };

            this.shellService.PlaylistVisibilityChangeRequested += (_, e) =>
            {
                if (e.IsPlaylistVisible)
                {
                    this.miniPlayerPlaylist.Show(e.MiniPlayerType);
                }
                else
                {
                    this.miniPlayerPlaylist.Hide();
                }
            };

            this.shellService.CheckIfTabletMode(true); // Make sure the window geometry respects tablet mode at startup
            this.SetWindowBorder();
        }
Beispiel #4
0
        private void InitializeTrayIcon()
        {
            this.trayIcon         = new System.Windows.Forms.NotifyIcon();
            this.trayIcon.Visible = false;
            this.trayIcon.Text    = ProductInformation.ApplicationName;

            // Reflection is needed to get the full path of the executable. Because when starting the application from the start menu
            // without specifying the full path, the application fails to find the Tray icon and crashes here
            string iconFile = EnvironmentUtils.IsWindows10() ? "Tray.ico" : "Legacy tray.ico";

            string iconPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), ApplicationPaths.IconsSubDirectory, iconFile);

            this.trayIcon.Icon = new System.Drawing.Icon(iconPath, System.Windows.Forms.SystemInformation.SmallIconSize);

            this.trayIcon.MouseClick       += TrayIcon_MouseClick;
            this.trayIcon.MouseDoubleClick += (_, __) => this.ShowWindowInForeground();

            this.trayIconContextMenu = (ContextMenu)this.FindResource("TrayIconContextMenu");

            this.trayControls = this.container.Resolve <TrayControls>();
        }
Beispiel #5
0
        private void InitializeWindows()
        {
            // Start monitoring tablet mode
            this.windowsIntegrationService.StartMonitoringTabletMode();

            // Tray controls
            this.trayControls = this.container.Resolve <TrayControls>();

            // Create the Mini Player playlist
            this.miniPlayerPlaylist = this.container.Resolve <MiniPlayerPlaylist>(new DependencyOverride(typeof(DopamineWindow), this));

            // NotificationService needs to know about the application windows
            this.notificationService.SetApplicationWindows(this, this.miniPlayerPlaylist, this.trayControls);

            PART_MiniPlayerButton.ToolTip = SettingsClient.Get <bool>("General", "IsMiniPlayer") ? ResourceUtils.GetString("Language_Restore") : ResourceUtils.GetString("Language_Mini_Player");

            // Settings changed
            SettingsClient.SettingChanged += (_, e) =>
            {
                if (SettingsClient.IsSettingChanged(e, "Appearance", "ShowWindowBorder"))
                {
                    this.WindowBorder.BorderThickness = new Thickness((bool)e.SettingValue ? 1 : 0);
                }

                if (SettingsClient.IsSettingChanged(e, "Behaviour", "ShowTrayIcon"))
                {
                    this.trayIcon.Visible = (bool)e.SettingValue;
                }

                if (SettingsClient.IsSettingChanged(e, "General", "IsMiniPlayer"))
                {
                    PART_MiniPlayerButton.ToolTip = (bool)e.SettingValue ? ResourceUtils.GetString("Language_Restore") : ResourceUtils.GetString("Language_Mini_Player");
                }
            };

            this.shellService.WindowStateChanged        += (_, e) => this.WindowState = e.WindowState;
            this.shellService.IsMovableChanged          += (_, e) => this.IsMovable = e.IsMovable;
            this.shellService.ResizeModeChanged         += (_, e) => this.ResizeMode = e.ResizeMode;
            this.shellService.TopmostChanged            += (_, e) => this.Topmost = e.IsTopmost;
            this.shellService.ShowWindowControlsChanged += (_, e) => this.ShowWindowControls = e.ShowWindowControls;

            this.shellService.GeometryChanged += (_, e) => this.SetGeometry(
                e.Top, e.Left, e.Size.Width, e.Size.Height,
                Constants.DefaultShellTop,
                Constants.DefaultShellLeft);

            this.shellService.MinimumSizeChanged += (_, e) =>
            {
                this.MinWidth  = e.MinimumSize.Width;
                this.MinHeight = e.MinimumSize.Height;
            };

            this.shellService.PlaylistVisibilityChanged += (_, e) =>
            {
                if (e.IsPlaylistVisible)
                {
                    this.miniPlayerPlaylist.Show(e.MiniPlayerType);
                }
                else
                {
                    this.miniPlayerPlaylist.Hide();
                }
            };

            this.shellService.CheckIfTabletMode(true); // Make sure the window geometry respects tablet mode at startup
            this.SetWindowBorder();
        }