public static AppData GetInstance() { if (actInstance == null) { if (actInstance == null) { actInstance = new AppData(); string uuid = (string)Application.UserAppDataRegistry.GetValue("sensor_uuid"); if (uuid == null || "".Equals(uuid)) { uuid = Utils.Sha1Encrypt(Utils.GetMacAddress()); Application.UserAppDataRegistry.SetValue("sensor_uuid", uuid); } actInstance.SensorUUID = uuid; string token = (string)Application.UserAppDataRegistry.GetValue("auth_token"); if (token == null || "".Equals(token)) { token = Utils.Sha1Encrypt(Utils.GetMacAddress() + "brainpage"); Application.UserAppDataRegistry.SetValue("auth_token", token); } actInstance.AuthToken = token; actInstance.FirstTimeLaunch = (Application.UserAppDataRegistry.GetValue("first_time") == null); } } return actInstance; }
private FormState(KeyRecord form) { tracker = ActivityTracker.GetInstance(); targetForm = form; appData = AppData.GetInstance(); }
private void MainForm_Load(object sender, EventArgs e) { this.Opacity = 0; FormState.SetForm(this); appData = AppData.GetInstance(); SensocolSocket.GetInstance(); FormState.GetInstance().Restore(); this.Text = Strings.connecting; this.Width = 600; this.Height = 500; int boundWidth = Screen.PrimaryScreen.Bounds.Width; int boundHeight = Screen.PrimaryScreen.Bounds.Height; int x = boundWidth - this.Width; int y = boundHeight - this.Height; this.Location = new Point(x / 2, y / 2); this.FormBorderStyle = FormBorderStyle.None; this.TopMost = true; this.WindowState = FormWindowState.Normal; btnGood.Top = this.Height - btnGood.Height * 3 / 2; btnGood.Left = this.Width / 2 - btnGood.Width / 2; webBrowser.Width = this.Width; webBrowser.Height = btnGood.Top; webBrowser.Top = 0; webBrowser.Left = 0; menuItemExit.Text = Strings.exit; menuItemSetting.Text = Strings.viewSetting; menuItemView.Text = Strings.viewChart; btnGood.Text = Strings.stopBreak; ActivityTracker.Start(); Application.ApplicationExit += new EventHandler(this.application_Exit); RegistryKey add = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); add.SetValue("Brainpage", "\"" + Application.ExecutablePath.ToString() + "\""); }