Example #1
0
        /// <summary>
        /// Constructs a history entry of a particular type, populating
        /// its fields with the contents of a cartridge tag, and using
        /// <code>DateTime.Now</code> as timestamp.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="cartTag"></param>
        public HistoryEntry(HistoryEntry.Type type, CartridgeTag cartTag)
        {
            EntryType = type;
            RelatedCartridgeFilename = cartTag.Cartridge.Filename;
            RelatedCartridgeGuid = cartTag.Guid;
            RelatedCartridgeName = cartTag.Title;

            BitmapSource thumb = (BitmapSource)cartTag.Thumbnail;
            RelatedCartridgeThumbnailBase64 = thumb == null ? null : Utils.ImageUtils.ToBase64String(thumb, ThumbnailWidth, ThumbnailWidth);

            Timestamp = DateTime.Now;
        }
Example #2
0
 /// <summary>
 /// Constructs a history entry of a particular type, populating
 /// its fields with the contents of a cartridge tag and a cartridge
 /// savegame, and using <code>DateTime.Now</code> as timestamp.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="cartTag"></param>
 /// <param name="savegame"></param>
 public HistoryEntry(HistoryEntry.Type type, CartridgeTag cartTag, CartridgeSavegame savegame)
     : this(type, cartTag)
 {
     RelatedSavegameHashColor = savegame.HashColor;
     RelatedSavegameName = savegame.Name;
 }
        private void RunHistoryEntryAction(HistoryEntry entry)
        {
            // Is the entry is related to saving the game?
            bool isRelatedToSavegame = entry.EntryType == HistoryEntry.Type.Saved ||
                entry.EntryType == HistoryEntry.Type.Restored;

            // Gets the cartridge tag if it still exists.
            CartridgeTag tag = entry.CartridgeTag;

            // Does the cartridge still exist?
            // NO -> Asks for clearing the history.
            if (tag == null)
            {
                // Asks for clearing the history.
                if (System.Windows.MessageBox.Show(String.Format("The cartridge {0} could not be found, perhaps because it is not installed anymore.\n\nDo you want to remove the history entries for this cartridge?", entry.RelatedCartridgeName), "Cartridge not found", MessageBoxButton.OKCancel) == System.Windows.MessageBoxResult.OK)
                {
                    // Clears the history of the entries related to this cartridge.
                    Model.History.RemoveAllOf(entry.RelatedCartridgeGuid);
                }

                // No more to do.
                return;
            }

            // Is the entry is related to saving the game?
            // YES -> Asks if the user wants to restore it.
            // NO -> Go to the cartridge info page.
            if (isRelatedToSavegame)
            {
                // Gets the savegame if it still exists.
                CartridgeSavegame savegame = entry.Savegame;

                // Does the savegame still exist?
                // NO -> Asks for removing the entry.
                // YES -> Restore it.
                if (savegame == null)
                {
                    // Asks for removing the entry.
                    if (System.Windows.MessageBox.Show(String.Format("The savegame {0} could not be found, perhaps because it is not installed anymore.\n\nDo you want to remove this history entry?", entry.RelatedSavegameName), "Savegame not found", MessageBoxButton.OKCancel) == System.Windows.MessageBoxResult.OK)
                    {
                        // Clears the history of the entries related to this cartridge.
                        Model.History.Remove(entry);
                    } 
                }
                else
                {
                    // Restores the cartridge.
                    App.Current.ViewModel.NavigationManager.NavigateToGameHome(tag.Cartridge.Filename, savegame);
                }
            }
            else
            {
                // Navigates to the cartridge info.
                // (We know the cartridge tag exists at this point.)
                ShowCartridgeInfo(tag);
            }

        }