From 9f300475816ebaa4d36935c217be10699737af24 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Sun, 17 Apr 2022 21:12:08 -0600 Subject: [PATCH] Hide console when launching Jellyfin Fix reading tray icon --- Jellyfin.Windows.Tray/Jellyfin.Windows.Tray.csproj | 3 ++- Jellyfin.Windows.Tray/TrayApplicationContext.cs | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Windows.Tray/Jellyfin.Windows.Tray.csproj b/Jellyfin.Windows.Tray/Jellyfin.Windows.Tray.csproj index bf0e285..dddda4e 100644 --- a/Jellyfin.Windows.Tray/Jellyfin.Windows.Tray.csproj +++ b/Jellyfin.Windows.Tray/Jellyfin.Windows.Tray.csproj @@ -43,7 +43,7 @@ - + @@ -54,6 +54,7 @@ Never + diff --git a/Jellyfin.Windows.Tray/TrayApplicationContext.cs b/Jellyfin.Windows.Tray/TrayApplicationContext.cs index caf869f..82a8334 100644 --- a/Jellyfin.Windows.Tray/TrayApplicationContext.cs +++ b/Jellyfin.Windows.Tray/TrayApplicationContext.cs @@ -1,14 +1,15 @@ using System; using System.ComponentModel; using System.Diagnostics; +using System.Drawing; using System.IO; using System.Linq; +using System.Reflection; using System.Security.Principal; using System.ServiceProcess; using System.Windows.Forms; using System.Xml.Linq; using System.Xml.XPath; -using Jellyfin.Windows.Tray.Properties; using Microsoft.Win32; namespace Jellyfin.Windows.Tray; @@ -18,6 +19,7 @@ namespace Jellyfin.Windows.Tray; /// public class TrayApplicationContext : ApplicationContext { + private const string TrayIconResourceName = "Jellyfin.Windows.Tray.Resources.JellyfinIcon.ico"; private readonly string _jellyfinServiceName = "JellyfinServer"; private readonly string _autostartKey = "JellyfinTray"; private string _configFile; @@ -133,7 +135,8 @@ private void CreateTrayIcon() contextMenu.Items.Add(_menuItemExit); contextMenu.Opening += new CancelEventHandler(ContextMenuOnPopup); - _trayIcon = new NotifyIcon() { Icon = Resources.JellyfinIcon, ContextMenuStrip = contextMenu, Visible = true }; + using var iconStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(TrayIconResourceName); + _trayIcon = new NotifyIcon() { Icon = new Icon(iconStream), ContextMenuStrip = contextMenu, Visible = true }; } private void LoadJellyfinConfig() @@ -244,6 +247,7 @@ private void Start(object sender, EventArgs e) Process p = new Process(); p.StartInfo.FileName = _executableFile; p.StartInfo.CreateNoWindow = true; + p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; p.StartInfo.Arguments = "--datadir \"" + _dataFolder + "\""; p.Start(); }