/// <summary> /// 加载保存的信息 /// </summary> public void LoadSaveInfo() { // 加载账号信息 var saveInfo = SteamHelper.GetSaveInfo(); SteamAccoutInfoList = saveInfo.SteamAccoutInfoList.OrderBy(r => r.Order).ThenBy(r => r.Account).ToList(); // 选中第一个 if (selectedSteamAccoutInfo == null && SteamAccoutInfoList != null && SteamAccoutInfoList.Count > 0) { // 选回之前的账号 SteamAccoutInfo currentSteamAccountInfo = null; if (!string.IsNullOrEmpty(currentSteamAccount)) { currentSteamAccountInfo = SteamAccoutInfoList.First(r => r.Account == currentSteamAccount); } // 选中第一个 if (currentSteamAccountInfo == null) { currentSteamAccountInfo = SteamAccoutInfoList.FirstOrDefault(); } SelectedSteamAccoutInfo = currentSteamAccountInfo; } }
/// <summary> /// 点击新建 /// </summary> private void DoNewBtnClickCommand() { var autoLoginUser = SteamHelper.GetSteamRegistry("AutoLoginUser"); if (string.IsNullOrEmpty(autoLoginUser)) { ShowToolTip("请先登陆Steam!"); return; } // 构建账号信息 var steamAccount = new SteamAccoutInfo(); steamAccount.Account = autoLoginUser; steamAccount.Name = autoLoginUser; steamAccount.Password = ""; steamAccount.Order = "0"; // 添加账号 var saveInfo = SteamHelper.GetSaveInfo(); if (saveInfo.SteamAccoutInfoList.Any(r => r.Account == steamAccount.Account)) { ShowToolTip("添加失败!账号已存在!"); return; } saveInfo.SteamAccoutInfoList.Add(steamAccount); SteamHelper.SaveSaveInfo(saveInfo); currentSteamAccount = steamAccount.Account; ReLoad(); ShowToolTip("添加成功!"); }