|
using System;
using System.IO;
using System.Windows;
using System.Windows.Markup;
using GG.GameAttackCombos.Logic;
namespace GG.GameAttackCombos.Client {
/// <summary>
/// Interaction logic for App.xaml.
/// </summary>
public partial class App : Application {
/// <summary>
/// Gets the current Application as an App type.
/// </summary>
public new static App Current {
get { return Application.Current as App; }
}
/// <summary>
/// Gets or sets the isolated storage file name of the current combo package being
/// viewed in the application.
/// </summary>
public string CurrentComboPackageFileName {
get {
string Value = null;
if (Properties.Contains("CurrentComboPackageFileName")) {
Value = Properties["CurrentComboPackageFileName"] as string;
}
return Value;
}
set {
Properties["CurrentComboPackageFileName"] = value;
}
}
/// <summary>
/// Load the skin from the specified stream and replace the application resources accordingly.
/// </summary>
/// <param name="skinStream">The Stream for the new skin resource.</param>
public void LoadSkin(Stream skinStream) {
// Create a new resource dictionary for the skin from the specified stream via an XAML reader.
ResourceDictionary NewSkin = XamlReader.Load(skinStream) as ResourceDictionary;
// Replace the last dictionary with the new skin.
Resources.MergedDictionaries.RemoveAt(Resources.MergedDictionaries.Count - 1);
Resources.MergedDictionaries.Add(NewSkin);
}
/// <summary>
/// Opens any current combo package from disk.
/// </summary>
/// <returns></returns>
public ComboPackage OpenCurrentComboPackage() {
ComboPackage Package = null;
// Get the current combo package's path from the application.
string CurrentComboPackageFileName = App.Current.CurrentComboPackageFileName;
if (!string.IsNullOrEmpty(CurrentComboPackageFileName)) {
try {
// Open a stream to the package file.
Stream PackageStream = ComboPackageHelper.OpenPackageStream(CurrentComboPackageFileName);
// Attempt to open a ComboPackage for the stream.
Package = new ComboPackage(PackageStream);
} catch {
throw new ApplicationException("There was a problem opening the combo package.");
}
}
return Package;
}
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) {
// Make sure to save any completion state on the main window.
if (MainWindow != null && MainWindow is MainWindow) {
((MainWindow)MainWindow).SaveCompletionState();
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I began programming on my Commodore 64 at around the age of 12. After migrating to DOS and then Windows, I decided to take on the Web. Several languages and platforms later, I have settled in with .NET nicely. I am currently the owner of a software consulting company and lead application developer for a learning-based technology consultation company.
The love of a finished application is usually at war with the desire to improve it as soon as it's released (they're never really finished).