internal TimerLoop(MainWindow mainWindow) { _mw = mainWindow; switch (Convert.ToInt16(SettingsIo.ReadSettings("Freq"))) { case 0: Time = 30 * 60 * 1000; //30 mins break; case 1: Time = 60 * 60 * 1000; //1 hour break; case 2: Time = 120 * 60 * 1000; //2 hours break; case 3: Time = 240 * 60 * 1000; //4 hours break; case 4: Time = 480 * 60 * 1000; //8 hours break; case 5: Time = 720 * 60 * 1000; //12 hours break; } Tmr.AutoReset = true; Tmr.Interval = Time; Tmr.Elapsed += Elapsed; Tmr.Start(); GC.KeepAlive(Tmr); }
internal CheckBuild(MainWindow mainWindow) { _mw = mainWindow; try { _mw.LatestBuild = Convert.ToInt32( Web.DownloadString("https://commondatastorage.googleapis.com/chromium-browser-continuous/Win/LAST_CHANGE")); } catch (WebException) { var errorMessage = new StringBuilder(175); errorMessage.Append("Unable to connect to the Chromium server, possible reasons could be:"); errorMessage.Append(Environment.NewLine); errorMessage.Append(Environment.NewLine); errorMessage.Append("\u2022 No active Internet connection"); errorMessage.Append(Environment.NewLine); errorMessage.Append("\u2022 A firewall is blocking access"); errorMessage.Append(Environment.NewLine); errorMessage.Append("\u2022 The server is currently unavailable"); _mw.TrayIcon.BalloonTipTitle = "Problem accessing server"; _mw.TrayIcon.BalloonTipText = errorMessage.ToString(); _mw.TrayIcon.BalloonTipIcon = ToolTipIcon.Error; _mw.TrayIcon.ShowBalloonTip(15000); _mw.LatestBuild = 0; } }
internal UpdateBuild(MainWindow mainWindow) { _thread = new Thread(UpdateBuildMain); _mw = mainWindow; _thread.Name = ""; _thread.Start(); }
internal GetLibVersion(MainWindow mainWindow) { _mw = mainWindow; try { if (File.Exists(_mw.InstallDir + @"\chrome.dll")) { unsafe { int handle; var size = NativeMethods.GetFileVersionInfoSize(_mw.InstallDir + @"\chrome.dll", out handle); var buffer = new byte[size]; if (NativeMethods.GetFileVersionInfo(_mw.InstallDir + @"\chrome.dll", handle, size, buffer)) { } short* subBlock; uint len; if (!NativeMethods.VerQueryValue(buffer, @"\VarFileInfo\Translation", out subBlock, out len)){} var spb = @"\StringFileInfo\" + subBlock[0].ToString("X4") + subBlock[1].ToString("X4") + @"\LastChange"; var spv = @"\StringFileInfo\" + subBlock[0].ToString("X4") + subBlock[1].ToString("X4") + @"\ProductVersion"; string buildInfo; if (NativeMethods.VerQueryValue(buffer, spb, out buildInfo, out len)) { _mw.CurrentBuild = Convert.ToInt32(buildInfo); } string versionInfo; if (NativeMethods.VerQueryValue(buffer, spv, out versionInfo, out len)) { _mw.CurrentVersion = versionInfo; } } } else { _mw.CurrentVersion = String.Empty; _mw.CurrentBuild = 0; } } catch (Exception e) { MessageBox.Show(e.ToString()); } }