public void DeleteProfile(ApplicationProfile profile) { if (profile != null && !String.IsNullOrWhiteSpace(profile.ProfileFilepath)) { if (Profile.Equals(profile)) { SwitchToProfile(Profiles[Math.Max(Profiles.IndexOf(profile) - 1, 0)]); } if (Profiles.Contains(profile)) { Profiles.Remove(profile); } if (File.Exists(profile.ProfileFilepath)) { try { File.Delete(profile.ProfileFilepath); } catch (Exception exc) { Global.logger.LogLine($"Could not delete profile with path \"{profile.ProfileFilepath}\"", Logging_Level.Error); Global.logger.LogLine($"Exception: {exc}", Logging_Level.Error, false); } } SaveProfiles(); } }
public async Task <bool> DisconnectNetworkAsync() { Debug.WriteLine("Disconnect start!"); return(await WorkAsync( x => _worker.DisconnectNetworkAsync(x, _workingTimeoutDuration), x => Profiles.Contains(x) && !x.IsConnected)); }
/// <summary> /// Datas the delete. /// </summary> protected override void DataDelete() { BlogService.DeleteProfile(this); if (Profiles.Contains(this)) { Profiles.Remove(this); } }
public void RemoveProfile(string profileName) { if (Profiles.Contains(profileName)) { Profiles.Remove(profileName); SaveProfiles(); } }
public async Task <bool> DeleteProfileAsync() { Debug.WriteLine("Delete start!"); return(await WorkAsync( x => _worker.DeleteProfileAsync(x), x => !Profiles.Contains(x))); }
private void OnSaveProfile() { if (Session.Character.Map == null) { return; } var profile = new Profile { MapId = Session.Character.Map.Id, BuffSkills = Bot.UsedBuffSkills.Select(x => x.Id).ToList(), DamageSkills = Bot.UsedDamageSkills.Select(x => x.Id).ToList(), HealItems = Bot.UsedHealItems.Select(x => new HealItem { ItemId = x.Item.Id, HpPercentage = x.HpPercentage, MpPercentage = x.MpPercentage, UseForHp = x.UseForHp, UseForMp = x.UseForMp }).ToList(), Monsters = Bot.WhitelistedMonsters.Select(x => x.ModelId).ToList(), Path = Bot.Path.ToList(), PickUpGolds = Bot.PickUpGolds, UseAmuletOfReturn = Bot.UseAmuletOfReturn, PickUpSoundFlowers = Bot.PickUpSoundFlowers, UseAncelloanBlessing = Bot.UseAncelloanBlessing, UseAttackPotion = Bot.UseAttackPotion, UseDefencePotion = Bot.UseDefencePotion, UseEnergyPotion = Bot.UseEnergyPotion, UseExperiencePotion = Bot.UseExperiencePotion, UseFairyBoost = Bot.UseFairyBoost, UseMateBlessing = Bot.UseMateBlessing, UsePetFood = Bot.UsePetFood, UseSoulstoneBlessing = Bot.UseSoulstoneBlessing }; string name = $"{Session.Character.Name} ({Session.Character.Map.Name})"; if (SelectedProfile != null) { if (name != SelectedProfile) { int id = 0; while (Profiles.Contains(name)) { name += $" - {++id}"; } Profiles.Add(name); } } profileManager.SaveProfile(name, profile); }
public void AddProfile(string profileName) { if (!Profiles.Contains(profileName)) { if (Profiles.Count == 0) { Settings.Default.CurrentProfile = profileName; } Profiles.Add(profileName); SaveProfiles(); } }
public static NetPortableProfile GetProfile(string profileName) { if (String.IsNullOrEmpty(profileName)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "profileName"); } if (Profiles.Contains(profileName)) { return(Profiles[profileName]); } return(null); }
internal UDirectory GetDefaultAssetFolder() { if (Profiles.Contains(PlatformType.Shared)) { var sharedProfile = Profiles[PlatformType.Shared]; var folder = sharedProfile.AssetFolders.FirstOrDefault(); if (folder != null && folder.Path != null) { return(folder.Path); } } return("Assets/" + PackageProfile.SharedName); }
private void UpdateTotals(ref GameStats lastGame) { lastGame.Profiles.Last().UpdateRangeVariables(); foreach (var item in lastGame.Profiles) { if (!Profiles.Contains(item)) { Profiles.Add(item); } else { Profiles[Profiles.IndexOf(item)].MergeStats(item); } } }
public void SaveCurrentProfile() { if (!AllowIpHistory.Contains(AllowIp)) { AllowIpHistory.Add(AllowIp); SetValue(string.Join("|", AllowIpHistory), $"AllowIpHistory"); } StoredValues[nameof(CurrentProfile)] = CurrentProfile; if (!Profiles.Contains(CurrentProfile)) { Profiles.Add(CurrentProfile); StoredValues[nameof(Profiles)] = string.Join("|", Profiles); } SetValue(ProtocolPort, $"ProtocolPort.{CurrentProfile}"); SetValue(NatAccess, $"NatAccess.{CurrentProfile}"); }
public void DeleteProfile(ApplicationProfile profile) { if (Disposed) { return; } if (Profiles.Count == 1) { return; } if (profile != null && !String.IsNullOrWhiteSpace(profile.ProfileFilepath)) { int profileIndex = Profiles.IndexOf(profile); if (Profiles.Contains(profile)) { Profiles.Remove(profile); } if (Profile.Equals(profile)) { SwitchToProfile(Profiles[Math.Min(profileIndex, Profiles.Count - 1)]); } if (File.Exists(profile.ProfileFilepath)) { try { File.Delete(profile.ProfileFilepath); } catch (Exception exc) { Global.logger.Error($"Could not delete profile with path \"{profile.ProfileFilepath}\""); Global.logger.Error($"Exception: {exc}"); } } SaveProfiles(); } }
private void UpdateSourceFolders() { // If there are not assets, we don't need to update or create an asset folder if (Assets.Count == 0) { return; } // Make sure there is a shared profile at least PackageProfile sharedProfile; if (!Profiles.Contains(PlatformType.Shared)) { sharedProfile = PackageProfile.NewShared(); Profiles.Add(sharedProfile); } else { sharedProfile = Profiles[PlatformType.Shared]; } // Use by default the first asset folders if not defined on the asset item var defaultFolder = sharedProfile.AssetFolders.Count > 0 ? sharedProfile.AssetFolders.First().Path : UDirectory.This; var assetFolders = new HashSet <UDirectory>(GetDistinctAssetFolderPaths()); foreach (var asset in Assets) { if (asset.SourceFolder == null) { asset.SourceFolder = defaultFolder.IsAbsolute ? defaultFolder.MakeRelative(RootDirectory) : defaultFolder; asset.IsDirty = true; } var assetFolderAbsolute = UPath.Combine(RootDirectory, asset.SourceFolder); if (!assetFolders.Contains(assetFolderAbsolute)) { assetFolders.Add(assetFolderAbsolute); sharedProfile.AssetFolders.Add(new AssetFolder(assetFolderAbsolute)); IsDirty = true; } } }
public static NetPortableProfile GetProfile(string profileName) { if (String.IsNullOrEmpty(profileName)) { throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "profileName"); } // Original behavior fully preserved, as we first try the original behavior. // NOTE: this could be a single TryGetValue if this collection was kept as a dictionary... if (Profiles.Contains(profileName)) { return(Profiles[profileName]); } // If we didn't get a profile by the simple profile name, try now with // the custom profile string (i.e. "net40-client") NetPortableProfile result = null; _portableProfilesByCustomProfileString.TryGetValue(profileName, out result); return(result); }
private void DeleteProfile([NotNull] object obj) { Assert.ArgumentNotNull(obj, "obj"); var profileView = obj as ProfileViewModel; if (profileView == null) { return; } if (profileView.NameProfile == "Default") { return; } if (Profiles.Contains(profileView)) { Profiles.Remove(profileView); ProfileHolder.Instance.DeleteProfile(profileView.NameProfile); } UpdateAddProfileCommandCanExecute(); }
public async Task <bool> MoveDownProfileAsync() { Debug.WriteLine("MoveDown start!"); var targetProfile = Profiles.FirstOrDefault(x => x.IsTarget); if (targetProfile == null) { return(false); } var oldPosition = targetProfile.Position; var newPosition = oldPosition + 1; if (newPosition > targetProfile.PositionCount - 1) { return(false); } return(await WorkAsync( x => _worker.SetProfilePositionAsync(x, newPosition), x => Profiles.Contains(x) && (x.Position > oldPosition), targetProfile)); }
private void OnLoadProfile() { if (string.IsNullOrEmpty(SelectedProfile)) { return; } if (!Profiles.Contains(SelectedProfile)) { return; } Profile profile = profileManager.LoadProfile(SelectedProfile); if (profile == null) { return; } if (profile.MapId == Session.Character.Map.Id) { Bot.Path.Clear(); Bot.Path.AddRange(profile.Path); using (var graphics = Graphics.FromImage(Session.Character.Map.Preview)) { var previous = new Position(0, 0); for (int i = 0; i < Bot.Path.Count; i++) { Position position = Bot.Path[i]; if (i != 0) { graphics.DrawLine(Pen, previous.X, previous.Y, position.X, position.Y); } graphics.FillRectangle(Brushes.DarkRed, position.X, position.Y, 1, 1); previous = position; } } Bot.MapPreview = Session.Character.Map.Preview.ToBitmapSource(); } IEnumerable <Monster> monsters = Bot.Monsters.Where(x => profile.Monsters.Any(s => s == x.ModelId)); Bot.WhitelistedMonsters.Clear(); Bot.WhitelistedMonsters.AddRange(monsters); IEnumerable <Skill> buffs = Bot.BuffSkills.Where(x => profile.BuffSkills.Any(s => s == x.Id)); IEnumerable <Skill> skills = Bot.DamageSkills.Where(x => profile.DamageSkills.Any(s => s == x.Id)); Bot.UsedDamageSkills.Clear(); Bot.UsedBuffSkills.Clear(); Bot.UsedDamageSkills.AddRange(skills); Bot.UsedBuffSkills.AddRange(buffs); IEnumerable <ItemConfiguration> healItems = Bot.HealItems.Where(x => profile.HealItems.Any(s => s.ItemId == x.Item.Id)); foreach (ItemConfiguration configuration in healItems) { HealItem saved = profile.HealItems.First(x => x.ItemId == configuration.Item.Id); configuration.UseForHp = saved.UseForHp; configuration.UseForMp = saved.UseForMp; configuration.HpPercentage = saved.HpPercentage; configuration.MpPercentage = saved.MpPercentage; } Bot.UsedHealItems.Clear(); Bot.UsedHealItems.AddRange(healItems); Bot.PickUpGolds = profile.PickUpGolds; Bot.UseAmuletOfReturn = profile.UseAmuletOfReturn; Bot.PickUpSoundFlowers = profile.PickUpSoundFlowers; Bot.UseAncelloanBlessing = profile.UseAncelloanBlessing; Bot.UseAttackPotion = profile.UseAttackPotion; Bot.UseDefencePotion = profile.UseDefencePotion; Bot.UseEnergyPotion = profile.UseEnergyPotion; Bot.UseExperiencePotion = profile.UseExperiencePotion; Bot.UseFairyBoost = profile.UseFairyBoost; Bot.UseMateBlessing = profile.UseMateBlessing; Bot.UsePetFood = profile.UsePetFood; Bot.UseSoulstoneBlessing = profile.UseSoulstoneBlessing; }
public bool HasProfile(int profileid) { return(Profiles.Any() && Profiles.Contains(profileid.ToString())); }