private static void AlertEvents_Saved(AlertEntity ident, SavedEventArgs args) { if (ident.Recipient != null) { NotifyOnCommit(ident.Recipient); } }
private void OnSaved(object sender, SavedEventArgs eventArgs) { if (eventArgs.Error == null) { // If saving to a file this time, or if always saving to a stream, mark that a save has happened and that the model is not dirty if (!string.IsNullOrEmpty(eventArgs.FilePath) || string.IsNullOrEmpty(this.CurrentFilePath)) { this.changedSinceLastSave = false; if (this.IsUndoRedoAvailable) { this.lastSavedUndoableKey = this.UndoManager.CurrentUndoableKey; } } this.AddStatusEvent((IMutable) new ManagedResourceString(Properties.WpfViewResources.ResourceManager, "SavedString", eventArgs.FilePath ?? string.Empty)); } else { this.AddStatusEvent((IMutable) new ManagedResourceString(Properties.WpfViewResources.ResourceManager, "SaveErrorMessageString", eventArgs.FilePath ?? string.Empty)); } this.IsSaving = false; this.OnCurrentFileChanged(); }
/// <summary> /// Write the save data buffer containing save data of a non-host multiplayer player to the save file. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> /// <remarks> /// Typically, SMAPI mods use the <see cref="IGameLoopEvents.Saving"/> event to write the data /// they want to save. Hence, we wait for that event with all its handlers to pass and write our /// save data buffer in the <see cref="IGameLoopEvents.Saved"/> event, containing all of the mod data /// requested of being saved. /// </remarks> private void OnSaved(object sender, SavedEventArgs e) { if (!Context.IsMainPlayer && this.serializedSaveData != null) { this.jsonHelper.WriteJsonFile(GetSaveDataFilePath(), this.serializedSaveData); } }
private void BlogRollItem_Saved(object sender, SavedEventArgs e) { if (e.Action == SaveAction.Insert || e.Action == SaveAction.Update || e.Action == SaveAction.Delete) { if (e.Action == SaveAction.Insert) { AddBlog((BlogRollItem)sender); } else if (e.Action == SaveAction.Delete) { blogRequest affected = null; foreach (blogRequest req in _Items) { if (req.RollItem.Equals(sender)) { affected = req; break; } } _Items.Remove(affected); } if (_Items.Count > 0) { // Re-sort _Items collection in case sorting of blogroll items was changed. _Items.Sort(delegate(blogRequest br1, blogRequest br2) { return(br1.RollItem.CompareTo(br2.RollItem)); }); } } }
protected virtual void OnSaved(SavedEventArgs e) { if (Saved != null) { Saved(this, e); } }
static void Post_Saved(object sender, SavedEventArgs e) { if (e.Action != SaveAction.Update) { BuildPostList(); } }
static void Post_Saving(object sender, SavedEventArgs e) { // Set SendNewsletterEmails to true whenever a post is changing from an unpublished // state to a published state. To check the published state of this Post before // it was changed, it's necessary to retrieve the post from the datastore since the // post in memory (via Post.GetPost()) will already have the updated values about // to be saved. Post post = (Post)sender; SetSendNewsletterEmails(post.Id, false); // default to not sending if (e.Action == SaveAction.Insert && post.IsVisibleToPublic) { SetSendNewsletterEmails(post.Id, true); } else if (e.Action == SaveAction.Update && post.IsVisibleToPublic) { Post preUpdatePost = BlogEngine.Core.Providers.BlogService.SelectPost(post.Id); if (preUpdatePost != null && !preUpdatePost.IsVisibleToPublic) { SetSendNewsletterEmails(post.Id, true); } } }
private void UpdateSavedData(object sender, SavedEventArgs args) { var savedData = Helper.Data.ReadJsonFile <SavedData>($"data/{Constants.SaveFolderName}.json") ?? new SavedData(); savedData.TotalTokens = _totalTokens; Helper.Data.WriteJsonFile($"data/{Constants.SaveFolderName}.json", savedData); }
// Private Methods (2) private static void Post_Saved(object sender, SavedEventArgs e) { Post post = sender as Post; //Nach dem speichern muss neu gezählt werden. Könnte ja änderungen gegeben haben. m_WordCountList.Remove(post.Id); }
/// <summary> /// Handles the Saved event of the Post control. /// Sends the pings in a new thread. /// <remarks> /// It opens a new thread and executes the pings from there, /// because it takes some time to complete. /// </remarks> /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param> private static void PostSaved(object sender, SavedEventArgs e) { if (!ExtensionManager.ExtensionEnabled("SendPings")) { return; } if (e.Action == SaveAction.None || e.Action == SaveAction.Delete) { return; } var item = (IPublishable)sender; if (!item.IsVisibleToPublic) { return; } var url = item.AbsoluteLink; // Need blogSettings to pass to Ping since the current blog instance won't // be detectable once in a BG thread. Guid blogId = Blog.CurrentInstance.Id; ThreadPool.QueueUserWorkItem(state => { // because HttpContext is not available within this BG thread // needed to determine the current blog instance, // set override value here. Blog.InstanceIdOverride = blogId; Ping(item, url); }); }
private static void OnAnySaved(object sender, SavedEventArgs e) { //var Info = sender as IInfo; var Info = e.Data as IInfo; if (Info == null) { return; } if (e.Action == SaveAction.Insert) { if (!Info.InfoCount.ContainsKey(Info.CityId)) { Info.InfoCount[Info.CityId] = 1; } else { Info.InfoCount[Info.CityId]++; } } if (e.Action == SaveAction.Delete) { if (!Info.InfoCount.ContainsKey(Info.CityId)) { Info.InfoCount[Info.CityId] = 0; } else { Info.InfoCount[Info.CityId]--; } } }
static void Post_Saved(object sender, SavedEventArgs e) { if (e.Action != SaveAction.Update) { BindComments(); } }
private void OnSaved(object sender, SavedEventArgs eventArgs) { if (eventArgs.Error == null) { this.Update(eventArgs.FilePath); } }
public void OnSaved(object sender, SavedEventArgs args) { if (Context.IsMainPlayer) { Bot.ConvertChestsToBots(); } }
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary> internal static void OnSaved(object sender, SavedEventArgs e) { // clear custom data after a normal save (to avoid restoring old state) if (!Config.DisableSaveAnyTime && !IsCustomSaving) { SaveManager.ClearData(); } else { IsCustomSaving = false; } if (!IsCustomSaving || !Config.DisableBackupSaveAnyTime) { if (!Config.DisableBackupOnSave) { BackupSaves(); } if (Config.ShareOptions) { StartupPreferences options = new StartupPreferences(); options.loadPreferences(false, false); options.clientOptions = Game1.options; options.savePreferences(false); } } }
private void GameLoop_Saved(object sender, SavedEventArgs e) { if (Context.IsMainPlayer) { Helper.Data.WriteJsonFile(LocationSaveFileName, PortalSprites.GetAllActiveSprites()); } }
private void OnSaved(object sender, SavedEventArgs e) { Monitor.Log("Reloading trees after save:", LogLevel.Trace); var locations = GetLocations(); EnrageTrees(locations); }
internal void OnSaveCompleted(object sender, SavedEventArgs e) { if (Config.ShowVisualUpgrades) { Helper.Content.InvalidateCache("Buildings/Greenhouse"); //invalidate the cache each night, forcing load of new sprite if applicable. } }
private void onSaved(object sender, SavedEventArgs e) { if (Game1.IsMasterGame) { Helper.Data.WriteSaveData("FrostDungeon.SaveData", saveData); } }
private void Saved(object sender, SavedEventArgs e) { Farm farm = Game1.getFarm(); int amountOfBreeders = GetBreeders(farm); int maleRabbits = _config.GenderMatters ? GetMatureMales(farm) : amountOfBreeders; List <string> outty = new List <string>(); foreach (FarmAnimal animal in farm.getAllFarmAnimals()) { if (animal.type.Value == "Rabbit" && animal.age.Value >= animal.ageWhenMature.Value + 14 && (!animal.isMale() || _config.GenderMatters)) { if (_debug) { this.Monitor.Log("Passed the check, grabbing the home info now.", LogLevel.Alert); } Building home = animal.home; int availableSpace = AvailableSpace(home); /* (home.buildingType.Value == "Coop" ? 4 : home.buildingType.Value == "Big Coop" ? 8 : 12) - * home.currentOccupants.Value;*/ double babyChance = ChanceOfBabies(maleRabbits, animal); int babyNum = NumberOfBabies(availableSpace, animal); if (!(_random.NextDouble() <= babyChance) || availableSpace <= 0 || babyNum <= 0) { continue; } for (int i = 0; i < babyNum; i++) { if (_debug) { this.Monitor.Log($"Trying to add baby number {i} now.", LogLevel.Alert); } this.AddBaby(home); if (_debug) { this.Monitor.Log($"Baby number {i} should have been added.", LogLevel.Alert); } } if (_debug) { this.Monitor.Log( $"Name: {animal.Name} \n Happiness: {animal.happiness.Value} \n AvailableSpace: {availableSpace} \n ChanceOfBaby: {babyChance}"); } outty.Add($"During the night, {animal.Name} gave birth to {babyNum} baby rabbits."); } else { if (_debug) { this.Monitor.Log("The check failed.", LogLevel.Alert); } } } if (outty.Count >= 1) { Game1.multipleDialogues(outty.ToArray()); } }
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnSaved(object sender, SavedEventArgs e) { // delete legacy mod data (migrated into save file by this point) { FileInfo legacyFile = new FileInfo(Path.Combine(Constants.CurrentSavePath, "Entoarox.Framework", "CustomItems.json")); if (legacyFile.Exists) { legacyFile.Delete(); } DirectoryInfo legacyDir = new DirectoryInfo(Path.Combine(Constants.CurrentSavePath, "Entoarox.Framework")); if (legacyDir.Exists && !legacyDir.GetFileSystemInfos().Any()) { legacyDir.Delete(); } } // read data this.Monitor.Log("Unpacking custom objects...", LogLevel.Trace); ItemEvents.FireBeforeDeserialize(); IDictionary <string, InstanceState> data = this.Helper.Data.ReadSaveData <Dictionary <string, InstanceState> >("custom-items") ?? new Dictionary <string, InstanceState>(); this.RestoreItems(data); ItemEvents.FireAfterDeserialize(); }
/// <summary> /// Called when a loaded data model is saved. /// </summary> /// <param name="sender">The sender.</param> /// <param name="eventArgs">The <see cref="EditorFoundation.Controller.SavedEventArgs"/> instance containing the event data.</param> protected virtual void OnSaved(object sender, SavedEventArgs eventArgs) { if (eventArgs.Error != null) { Utilities.HandleException(eventArgs.Error, false, Properties.WpfViewResources.SaveErrorCaptionString, Properties.WpfViewResources.SaveErrorMessageString + ": ", eventArgs.FilePath); } }
/// <summary> /// Handles the Saved event of the Publishable. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data. /// </param> private void PublishableSaved(object sender, SavedEventArgs e) { var publishable = (IPublishable)sender; if (!GetSendSendNewsletterEmails(publishable.Id)) { return; } XmlNodeList emails = null; lock (syncRoot) { LoadEmails(); emails = docs[Blog.CurrentInstance.Id].SelectNodes("emails/email"); } if (emails == null) { return; } List <MailMessage> messages = new List <MailMessage>(); foreach (XmlNode node in emails) { string address = node.InnerText.Trim(); if (!Utils.StringIsNullOrWhitespace(address) && Utils.IsEmailValid(address)) { MailMessage message = CreateEmail(publishable); message.To.Add(address); messages.Add(message); } } if (messages.Count == 0) { return; } // retrieve the blogId before entering the BG thread. Guid blogId = Blog.CurrentInstance.Id; ThreadPool.QueueUserWorkItem(state => { Thread.Sleep(3000); // because HttpContext is not available within this BG thread // needed to determine the current blog instance, // set override value here. Blog.InstanceIdOverride = blogId; foreach (MailMessage message in messages) { Utils.SendMailMessage(message); } }); }
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void onSaved(object sender, SavedEventArgs e) { if (!Game1.IsMultiplayer || Game1.IsMasterGame) { Log.info($"Saving save data..."); Helper.Data.WriteSaveData(MultiplayerSaveData.SaveKey, Data); } }
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void onSaved(object sender, SavedEventArgs e) { if (!Game1.IsMultiplayer || Game1.IsMasterGame) { Log.info($"Saving save data (\"{MultiplayerSaveData.FilePath}\")..."); File.WriteAllText(MultiplayerSaveData.FilePath, JsonConvert.SerializeObject(Data)); } }
static void Post_Saved(object sender, SavedEventArgs e) { // invalidate cache whenever a post is modified lock (_SyncRoot) { HttpRuntime.Cache.Remove(CacheKey); } }
/// <summary>Raised after the game finishes writing data to the save file (except the initial save creation).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnSaved(object sender, SavedEventArgs e) { if (!Context.IsWorldReady) { return; } _handler.AfterSave(); }
/// <summary> /// Saved event handler. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> private void OnSaved(object sender, SavedEventArgs e) { foreach (KeyValuePair <GameLocation, IList <Processor> > kv in locationProcessors) { PlaceObjects(kv.Key, kv.Value); kv.Value.Clear(); } }
/// <summary> /// Handles the Saved event of the Post control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param> private static void PostSaved(object sender, SavedEventArgs e) { if (e.Action == SaveAction.Update) { return; } ClearCache(null, new EventArgs()); }
/// <summary> /// Writes migration data then detaches the migrator. /// </summary> /// <param name="sender">Smapi thing.</param> /// <param name="e">Arguments for just-before-saving.</param> private void WriteMigrationData(object?sender, SavedEventArgs e) { if (this.migrator is not null) { this.migrator.SaveVersionInfo(); this.migrator = null; } this.Helper.Events.GameLoop.Saved -= this.WriteMigrationData; }
public void OnSaved(SavedEventArgs args) { Saved(this, args); }