static void Main(string[] args) { var version = AssemblyInformationManager.GetAssemblyVersion(@"C:\Program Files\Miner Tracker\Miner Tracker Desktop.exe"); Console.WriteLine($"Version: {version}"); Console.WriteLine("--------End------------"); //Console.WriteLine(res[0].ToString()); Console.ReadKey(); }
private void Window_ContentRendered(object sender, EventArgs e) { var currentVersion = AssemblyInformationManager.GetAssemblyVersion(DESKTOP_FILE_NAME); CurrentVersionTextBlock.Text = currentVersion; if (currentVersion.Equals("Error")) { CurrentVersionTextBlock.Foreground = new SolidColorBrush(Colors.Red); } }
public MainWindow(Dictionary <string, string> args) { InitializeComponent(); //Set Client ID string rawID = $"{Environment.MachineName}-{Environment.UserName}-Miner Tracker-Client"; CLIENT_ID = CryptTool.Encrypt(rawID); //Set SystemTray Icon systemTrayIcon = new NotifyIcon(); systemTrayIcon.Icon = new Icon(SYSTEM_TRAY_ICON); systemTrayIcon.Visible = true; systemTrayIcon.Text = ToolTipsText; this.Hide(); systemTrayIcon.DoubleClick += delegate(object callBack, EventArgs mouseEvent) { this.Show(); this.WindowState = WindowState.Normal; this.Activate(); }; systemTrayIcon.BalloonTipClosed += (sender, e) => { var thisIcon = (NotifyIcon)sender; thisIcon.Visible = false; thisIcon.Dispose(); }; System.Windows.Forms.ContextMenu contextMenu = new System.Windows.Forms.ContextMenu(); PCIDContextMenu = contextMenu.MenuItems.Add("Checking PCID..."); PCIDContextMenu.Enabled = false; GPUContextMenu = contextMenu.MenuItems.Add("GPU List"); GPUContextMenu.Enabled = false; contextMenu.MenuItems.Add("View Log", (s, e) => { try { Process.Start("notepad.exe", Path.Combine(ServiceConfig.LogPath, EventLogger.GetLogFileName())); } catch (Exception ex) { ShowErrorDialog("Unable to open log", ex.ToString()); EventLogger.WriteLog("OPEN LOG ERROR", ex.ToString()); } }); contextMenu.MenuItems.Add("Change PC ID", (s, e) => { OpenSettingContextMenu(); }); contextMenu.MenuItems.Add("Restore", (s, e) => { this.Show(); this.WindowState = WindowState.Normal; this.Activate(); }); contextMenu.MenuItems.Add("Exit", (s, e) => { System.Windows.Application.Current.Shutdown(); }); systemTrayIcon.ContextMenu = contextMenu; //Get version var currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); FooterVersionTextBlock.Text = $"Version: {currentVersion}"; var createdTime = AssemblyInformationManager.GetCreatedTime(@"C:\Program Files\Miner Tracker\Miner Tracker Desktop.exe"); AboutVersionTextBlock.Text = $"Version {currentVersion} -Released {createdTime.Month}/{createdTime.Year}"; //Get config var serviceConfigReader = new ConfigurationReader(); ServiceConfig = serviceConfigReader.GetServiceConfig(); //If can not get service config, then show error and shutdown if (!ClassUtils.CheckNull(ServiceConfig)) { EventLogger.WriteLog("CLIENT READ SERVICE CONFIG ERROR", "Null retrieved config"); ShowErrorDialog("File system error", "Unable to retrieve service configuration"); System.Windows.Application.Current.Shutdown(); } var userConfigReader = new ConfigurationReader(isService: false, userConfigPath: ServiceConfig.UserConfigPath, userConfigFile: ServiceConfig.UserConfigFileName); UserConfig = userConfigReader.GetUserConfig(); var CurrentUserConfig = UserConfig; //Service config is okay but can not retrieve the user.config if (!ClassUtils.CheckNull(UserConfig)) { ShowErrorDialog("File system error", "Unable to retrieve client configuration. Options have been set to default."); UserConfig = new UserConfiguration { ID = CurrentUserConfig == null || CurrentUserConfig.ID == 0 ? ServiceConfig.UserID : CurrentUserConfig.ID, LogPath = CurrentUserConfig == null || CurrentUserConfig.LogPath == null ? ServiceConfig.UserLogPath : CurrentUserConfig.LogPath, OpenOnStartup = CurrentUserConfig == null || CurrentUserConfig.OpenOnStartup == null ? ServiceConfig.UserOpenOnStartup : CurrentUserConfig.OpenOnStartup, CheckInterval = CurrentUserConfig == null || CurrentUserConfig.CheckInterval == null ? ServiceConfig.UserCheckInterval : CurrentUserConfig.CheckInterval, MinimizedWhenClose = CurrentUserConfig == null || CurrentUserConfig.MinimizedWhenClose == null ? ServiceConfig.UserMinimizedWhenClose : CurrentUserConfig.MinimizedWhenClose, PCID = CurrentUserConfig == null || CurrentUserConfig.PCID == null ? ServiceConfig.UserPCID : CurrentUserConfig.PCID, PreviousPCID = CurrentUserConfig == null || CurrentUserConfig.PreviousPCID == null ? ServiceConfig.UserPCID : CurrentUserConfig.PreviousPCID }; SaveUserConfig(); } // Since here, can use UserConfig SetupComputerSection(); SetupConfigSection(); SetupOptionSection(); try { CheckTimer = new System.Timers.Timer(); CheckTimer.Elapsed += new ElapsedEventHandler(OnTimer); CheckTimer.Interval = 10; CheckTimer.Start(); } catch (Exception ex) { EventLogger.WriteLog("TIMER ERROR", ex.ToString(), UserConfig.LogPath); EventLogger.WriteLog("", "Exiting....", UserConfig.LogPath); return; } if (args.TryGetValue("--minimized", out string value)) { if (value.Equals("true")) { //this.Hide(); } } }