This commit is contained in:
Laurent Bugnion 2009-11-13 23:17:36 +00:00
Родитель 3176ea7515
Коммит 1782ba4f5a
42 изменённых файлов: 2717 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,25 @@
<!--App.xaml by GalaSoft Laurent Bugnion http://www.galasoft.ch -->
<!--Project: CleanShutdown | Date: 15.10.2009-->
<!--Copyright © GalaSoft Laurent Bugnion 2009 laurent@galasoft.ch-->
<!--See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt-->
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="CleanShutdown.App"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:CleanShutdown.ViewModel"
mc:Ignorable="d">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Skins/MainSkin.xaml" />
</ResourceDictionary.MergedDictionaries>
<!--Global View Model Locator-->
<vm:ViewModelLocator x:Key="Locator"
d:IsDataSource="True" />
</ResourceDictionary>
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,69 @@
// ****************************************************************************
// <copyright file="App.xaml.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>ProjectName</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Browser;
namespace CleanShutdown
{
public partial class App : Application
{
public App()
{
Startup += this.ApplicationStartup;
UnhandledException += this.ApplicationUnhandledException;
InitializeComponent();
}
private void ApplicationStartup(object sender, StartupEventArgs e)
{
RootVisual = new Page();
}
private void ApplicationUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
// If the app is running outside of the debugger then report the exception using
// the browser's exception mechanism. On IE this will display it a yellow alert
// icon in the status bar and Firefox will display a script error.
if (!Debugger.IsAttached)
{
// NOTE: This will allow the application to continue running after an exception has been thrown
// but not handled.
// For production applications this error handling should be replaced with something that will
// report the error to the website and stop the application.
e.Handled = true;
Deployment.Current.Dispatcher.BeginInvoke(() => ReportErrorToDom(e));
}
}
private static void ReportErrorToDom(ApplicationUnhandledExceptionEventArgs e)
{
try
{
var errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight 2 Application " + errorMsg
+ "\");");
}
catch (Exception)
{
}
}
}
}

Просмотреть файл

@ -0,0 +1,158 @@
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{13C5E2B0-1707-4EF1-B30A-5B964F8012F4}</ProjectGuid>
<ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CleanShutdown</RootNamespace>
<AssemblyName>CleanShutdown.SL</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>CleanShutdown.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>CleanShutdown.App</SilverlightAppEntry>
<TestPageFileName>TestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>false</ThrowErrorsInValidation>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="GalaSoft.MvvmLight, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ef0f8c0372b87f18, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\External\Silverlight\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CleanShutdown\Helpers\Settings.cs">
<Link>Helpers\Settings.cs</Link>
</Compile>
<Compile Include="..\CleanShutdown\Helpers\ShutdownAnimationService.cs">
<Link>Helpers\ShutdownAnimationService.cs</Link>
</Compile>
<Compile Include="..\CleanShutdown\Helpers\ShutdownService.cs">
<Link>Helpers\ShutdownService.cs</Link>
</Compile>
<Compile Include="..\CleanShutdown\Messaging\NotificationMessageAction.cs">
<Link>Messaging\NotificationMessageAction.cs</Link>
</Compile>
<Compile Include="..\CleanShutdown\Messaging\NotificationMessageFunc.cs">
<Link>Messaging\NotificationMessageFunc.cs</Link>
</Compile>
<Compile Include="..\CleanShutdown\Messaging\NotificationMessageWithCallback.cs">
<Link>Messaging\NotificationMessageWithCallback.cs</Link>
</Compile>
<Compile Include="..\CleanShutdown\Messaging\Notifications.cs">
<Link>Messaging\Notifications.cs</Link>
</Compile>
<Compile Include="..\CleanShutdown\ViewModel\MainViewModel.cs">
<Link>ViewModel\MainViewModel.cs</Link>
</Compile>
<Compile Include="..\CleanShutdown\ViewModel\SettingsViewModel.cs">
<Link>ViewModel\SettingsViewModel.cs</Link>
</Compile>
<Compile Include="..\CleanShutdown\ViewModel\ViewModelLocator.cs">
<Link>ViewModel\ViewModelLocator.cs</Link>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Helpers\ApplicationExtensions.cs" />
<Compile Include="Helpers\Settings.SL.cs" />
<Compile Include="Helpers\SettingsFileHandler.cs" />
<Compile Include="Page.xaml.cs">
<DependentUpon>Page.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<DependentUpon>Resources.resx</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="Page.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Skins\MainSkin.xaml">
<Generator>MSBuild:MarkupCompilePass1</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="Properties\AppManifest.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Resource Include="License.txt" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets" Condition="" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
<SilverlightProjectProperties />
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>

Просмотреть файл

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

Просмотреть файл

@ -0,0 +1,29 @@
// ****************************************************************************
// <copyright file="ApplicationExtensions.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Windows;
using System.Windows.Browser;
using System;
namespace CleanShutdown.Helpers
{
public static class ApplicationExtensions
{
public static void Shutdown(this Application app)
{
HtmlPage.Window.Navigate(new Uri("http://www.galasoft.ch", UriKind.Absolute));
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// ****************************************************************************
// <copyright file="Settings.SL.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.IO;
using System.Windows.Media;
namespace CleanShutdown.Helpers
{
public partial class Settings
{
private const string ApplicationBackgroundBrushKey = "ApplicationBackgroundBrush";
private const char Separator = ';';
public static Settings Deserialize(Stream fromStream)
{
var settings = new Settings();
using (var reader = new StreamReader(fromStream))
{
string line;
while ((line = reader.ReadLine()) != null)
{
switch (line)
{
case ApplicationBackgroundBrushKey:
settings.ApplicationBackgroundBrush = GetSolidColorBrush(reader.ReadLine());
break;
}
}
}
return settings;
}
public static void Serialize(Settings settings, Stream toStream)
{
// We only handle SolidColorBrush here
var brush = (SolidColorBrush) settings.ApplicationBackgroundBrush;
using (var writer = new StreamWriter(toStream))
{
writer.WriteLine(ApplicationBackgroundBrushKey);
writer.Write(brush.Color.R);
writer.Write(Separator);
writer.Write(brush.Color.G);
writer.Write(Separator);
writer.Write(brush.Color.B);
}
}
private static Brush GetSolidColorBrush(string line)
{
var bytes = line.Split(new[]
{
Separator
});
var color = Color.FromArgb(
255,
byte.Parse(bytes[0]),
byte.Parse(bytes[1]),
byte.Parse(bytes[2]));
return new SolidColorBrush(color);
}
}
}

Просмотреть файл

@ -0,0 +1,50 @@
// ****************************************************************************
// <copyright file="SettingsFileHandler.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.IO;
using System.IO.IsolatedStorage;
namespace CleanShutdown.Helpers
{
public class SettingsFileHandler
{
public Settings LoadSettings()
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (store.FileExists(Settings.SettingsFileName))
{
using (var stream = store.OpenFile(Settings.SettingsFileName, FileMode.Open))
{
return Settings.Deserialize(stream);
}
}
}
return Settings.GetDefaultSettings();
}
public void SaveSettings(Settings settings)
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var stream = store.OpenFile(Settings.SettingsFileName, FileMode.Create))
{
Settings.Serialize(settings, stream);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
Copyright (c) 2009 Laurent Bugnion (GalaSoft), laurent@galasoft.ch
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Просмотреть файл

@ -0,0 +1,102 @@
<!--Page.xaml by GalaSoft Laurent Bugnion http://www.galasoft.ch -->
<!--Project: CleanShutdown | Date: 15.10.2009-->
<!--Copyright © GalaSoft Laurent Bugnion 2009 laurent@galasoft.ch-->
<!--See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt-->
<UserControl x:Class="CleanShutdown.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight"
mc:Ignorable="d"
Height="400"
Width="400"
DataContext="{Binding Main, Source={StaticResource Locator}}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Skins/MainSkin.xaml" />
</ResourceDictionary.MergedDictionaries>
<Storyboard x:Key="ShutdownStoryboard">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="1440"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="0.1"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="0.1"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="0"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ResourceDictionary>
</UserControl.Resources>
<Grid x:Name="LayoutRoot"
RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Grid.RenderTransform>
<Ellipse Fill="{Binding BackgroundBrush}" />
<Button Content="X"
Style="{StaticResource CloseButtonStyle}"
cmd:ButtonBaseExtensions.Command="{Binding ShutdownCommand}"
ToolTipService.ToolTip="Click to shutdown" />
<Grid DataContext="{Binding Settings, Source={StaticResource Locator}}"
x:Name="SettingsRoot"
Style="{StaticResource SettingsGridStyle}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.33*" />
<ColumnDefinition Width="0.33*" />
<ColumnDefinition Width="0.33*" />
</Grid.ColumnDefinitions>
<Slider Orientation="Vertical"
Style="{StaticResource SliderStyle}"
Value="{Binding Red, Mode=TwoWay}"
ToolTipService.ToolTip="Red" />
<Slider Orientation="Vertical"
Grid.Column="1"
Style="{StaticResource SliderStyle}"
Value="{Binding Green, Mode=TwoWay}"
ToolTipService.ToolTip="Green" />
<Slider Orientation="Vertical"
Grid.Column="2"
Style="{StaticResource SliderStyle}"
Value="{Binding Blue, Mode=TwoWay}"
ToolTipService.ToolTip="Blue" />
</Grid>
</Grid>
</UserControl>

Просмотреть файл

@ -0,0 +1,32 @@
// ****************************************************************************
// <copyright file="Page.xaml.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Windows.Controls;
using CleanShutdown.Helpers;
namespace CleanShutdown
{
public partial class Page : UserControl
{
private ShutdownAnimationService _animationService;
public Page()
{
_animationService = new ShutdownAnimationService(this);
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>

Просмотреть файл

@ -0,0 +1,32 @@
// ****************************************************************************
// <copyright file="AssemblyInfo.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("CleanShutdown.SL")]
[assembly: AssemblyDescription("Sample application demonstrating how to cleanly shut down a Silverlight application using a Messenger.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GalaSoft Laurent Bugnion")]
[assembly: AssemblyProduct("CleanShutdown.SL")]
[assembly: AssemblyCopyright("Copyright © 2009 GalaSoft Laurent Bugnion")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("a0a54828-3abd-482f-a7ef-2f416a2a4ebb")]
[assembly: AssemblyVersion("1.0.0.*")]

144
Samples/CleanShutdown/CleanShutdown.SL/Properties/Resources.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,144 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CleanShutdown.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CleanShutdown.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Click me.
/// </summary>
internal static string ButtonContent {
get {
return ResourceManager.GetString("ButtonContent", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Test dialog.
/// </summary>
internal static string MessageBoxCaption {
get {
return ResourceManager.GetString("MessageBoxCaption", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Please confirm.
/// </summary>
internal static string MessageBoxText {
get {
return ResourceManager.GetString("MessageBoxText", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Item #{0}, design.
/// </summary>
internal static string TextItemDesign {
get {
return ResourceManager.GetString("TextItemDesign", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Item #{0}.
/// </summary>
internal static string TextItemRuntime {
get {
return ResourceManager.GetString("TextItemRuntime", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ViewModel item #{0}, design.
/// </summary>
internal static string TextItemViewModelDesign {
get {
return ResourceManager.GetString("TextItemViewModelDesign", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to ViewModel item #{0}.
/// </summary>
internal static string TextItemViewModelRuntime {
get {
return ResourceManager.GetString("TextItemViewModelRuntime", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Change this in the MainViewModel class.
/// </summary>
internal static string TextMainViewModel {
get {
return ResourceManager.GetString("TextMainViewModel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to MVVM Light Project Template.
/// </summary>
internal static string WindowTitle {
get {
return ResourceManager.GetString("WindowTitle", resourceCulture);
}
}
}
}

Просмотреть файл

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ButtonContent" xml:space="preserve">
<value>Click me</value>
<comment>Click me</comment>
</data>
<data name="MessageBoxCaption" xml:space="preserve">
<value>Test dialog</value>
<comment>Test dialog</comment>
</data>
<data name="MessageBoxText" xml:space="preserve">
<value>Please confirm</value>
<comment>Please confirm</comment>
</data>
<data name="TextItemDesign" xml:space="preserve">
<value>Item #{0}, design</value>
<comment>Item #{0}, design</comment>
</data>
<data name="TextItemRuntime" xml:space="preserve">
<value>Item #{0}</value>
<comment>Item #{0}</comment>
</data>
<data name="TextItemViewModelDesign" xml:space="preserve">
<value>ViewModel item #{0}, design</value>
<comment>ViewModel item #{0}, design</comment>
</data>
<data name="TextItemViewModelRuntime" xml:space="preserve">
<value>ViewModel item #{0}</value>
<comment>ViewModel item #{0}</comment>
</data>
<data name="TextMainViewModel" xml:space="preserve">
<value>Change this in the MainViewModel class</value>
<comment>Change this in the MainViewModel class</comment>
</data>
<data name="WindowTitle" xml:space="preserve">
<value>MVVM Light Project Template</value>
<comment>MVVM Light Project Template</comment>
</data>
</root>

Просмотреть файл

@ -0,0 +1,156 @@
<!--MainSkin.xaml by GalaSoft Laurent Bugnion http://www.galasoft.ch -->
<!--Project: CleanShutdown | Date: 15.10.2009-->
<!--Copyright © GalaSoft Laurent Bugnion 2009 laurent@galasoft.ch-->
<!--See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Storyboard x:Key="ShutdownStoryboard">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="1440"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="0.1"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="0.1"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="0"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Style x:Key="SettingsGridStyle"
TargetType="Grid">
<Setter Property="Background"
Value="#99FFFFFF" />
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="Width"
Value="82" />
<Setter Property="Margin"
Value="50,95,0,93" />
</Style>
<ControlTemplate x:Key="CloseButtonTemplate"
TargetType="Button">
<Grid x:Name="Root"
Opacity="0.6"
RenderTransformOrigin="0.5,0.5"
Background="#00000000">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Grid.RenderTransform>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="Normal"
GeneratedDuration="00:00:00.3000000"
To="MouseOver" />
<VisualTransition From="MouseOver"
GeneratedDuration="00:00:00.3000000"
To="Normal" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="Root"
Storyboard.TargetProperty="(UIElement.Opacity)">
<LinearDoubleKeyFrame KeyTime="00:00:00"
Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="Root"
Storyboard.TargetProperty="(UIElement.Opacity)">
<LinearDoubleKeyFrame KeyTime="00:00:00"
Value="1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="Root"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<LinearDoubleKeyFrame KeyTime="00:00:00"
Value="0.9" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="Root"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<LinearDoubleKeyFrame KeyTime="00:00:00"
Value="0.9" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
<Style x:Key="CloseButtonStyle"
TargetType="Button">
<Setter Property="Template"
Value="{StaticResource CloseButtonTemplate}" />
<Setter Property="FontSize"
Value="150" />
<Setter Property="FontWeight"
Value="Bold" />
<Setter Property="Cursor"
Value="Hand" />
<Setter Property="FontStyle"
Value="Italic" />
<Setter Property="HorizontalAlignment"
Value="Center" />
<Setter Property="VerticalAlignment"
Value="Center" />
</Style>
<Style x:Key="SliderStyle"
TargetType="Slider">
<Setter Property="Margin"
Value="0,10" />
<Setter Property="Maximum"
Value="255" />
<Setter Property="SmallChange"
Value="1" />
<Setter Property="LargeChange"
Value="5" />
<Setter Property="HorizontalAlignment"
Value="Center" />
</Style>
</ResourceDictionary>

Просмотреть файл

@ -0,0 +1,38 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanShutdown", "CleanShutdown\CleanShutdown.csproj", "{50332306-5DD8-45A0-A64D-3BDC4BCB57B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanShutdown.SL", "CleanShutdown.SL\CleanShutdown.SL.csproj", "{13C5E2B0-1707-4EF1-B30A-5B964F8012F4}"
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 3
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs08.codeplex.com/
SccLocalPath0 = .
SccProjectUniqueName1 = CleanShutdown.SL\\CleanShutdown.SL.csproj
SccProjectName1 = CleanShutdown.SL
SccLocalPath1 = CleanShutdown.SL
SccProjectUniqueName2 = CleanShutdown\\CleanShutdown.csproj
SccProjectName2 = CleanShutdown
SccLocalPath2 = CleanShutdown
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{50332306-5DD8-45A0-A64D-3BDC4BCB57B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50332306-5DD8-45A0-A64D-3BDC4BCB57B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50332306-5DD8-45A0-A64D-3BDC4BCB57B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50332306-5DD8-45A0-A64D-3BDC4BCB57B7}.Release|Any CPU.Build.0 = Release|Any CPU
{13C5E2B0-1707-4EF1-B30A-5B964F8012F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13C5E2B0-1707-4EF1-B30A-5B964F8012F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13C5E2B0-1707-4EF1-B30A-5B964F8012F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13C5E2B0-1707-4EF1-B30A-5B964F8012F4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
}

Просмотреть файл

@ -0,0 +1,23 @@
<!--App.xaml by GalaSoft Laurent Bugnion http://www.galasoft.ch -->
<!--Project: CleanShutdown | Date: 15.10.2009-->
<!--Copyright © GalaSoft Laurent Bugnion 2009 laurent@galasoft.ch-->
<!--See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt-->
<Application x:Class="CleanShutdown.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:CleanShutdown.ViewModel"
StartupUri="MainWindow.xaml"
mc:Ignorable="d">
<Application.Resources>
<ResourceDictionary>
<!--Global View Model Locator-->
<vm:ViewModelLocator x:Key="Locator"
d:IsDataSource="True" />
</ResourceDictionary>
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,26 @@
// ****************************************************************************
// <copyright file="App.xaml.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Windows;
namespace CleanShutdown
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

Просмотреть файл

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{50332306-5DD8-45A0-A64D-3BDC4BCB57B7}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CleanShutdown</RootNamespace>
<AssemblyName>CleanShutdown</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
<ExpressionBlendVersion>3.0.1927.0</ExpressionBlendVersion>
<ApplicationIcon>GalaSoft.ico</ApplicationIcon>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="GalaSoft.MvvmLight, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3e875cdb3903c512, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\External\WPF\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\External\WPF\WPFToolkit.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Skins\MainSkin.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Helpers\ShutdownAnimationService.cs" />
<Compile Include="Helpers\ShutdownService.cs" />
<Compile Include="Messaging\NotificationMessageAction.cs" />
<Compile Include="Messaging\NotificationMessageWithCallback.cs" />
<Compile Include="Messaging\Notifications.cs" />
<Compile Include="Helpers\Settings.cs" />
<Compile Include="Helpers\SettingsFileHandler.cs" />
<Compile Include="Messaging\NotificationMessageFunc.cs" />
<Compile Include="ViewModel\SettingsViewModel.cs" />
<Compile Include="ViewModel\ViewModelLocator.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="ViewModel\MainViewModel.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Resource Include="License.txt" />
</ItemGroup>
<ItemGroup>
<Resource Include="GalaSoft.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Expression\Blend\3.0\WPF\Microsoft.Expression.Blend.WPF.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

Двоичные данные
Samples/CleanShutdown/CleanShutdown/GalaSoft.ico Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.2 KiB

Просмотреть файл

@ -0,0 +1,40 @@
// ****************************************************************************
// <copyright file="Settings.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Windows.Media;
namespace CleanShutdown.Helpers
{
public partial class Settings
{
public const string SettingsFileName = "Settings.xaml";
public Brush ApplicationBackgroundBrush
{
get;
set;
}
internal static Settings GetDefaultSettings()
{
var settings = new Settings
{
ApplicationBackgroundBrush = new SolidColorBrush(Colors.Purple)
};
return settings;
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
// ****************************************************************************
// <copyright file="SettingsFileHandler.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.IO;
using System.Windows.Markup;
namespace CleanShutdown.Helpers
{
public class SettingsFileHandler
{
public const string ApplicationFolderName = "CleanShutdownDemo";
private FileInfo _settingsFile;
public Settings LoadSettings()
{
InitializeSettingsFile();
try
{
using (var fileStream = File.Open(_settingsFile.FullName, FileMode.Open))
{
var settings = XamlReader.Load(fileStream) as Settings;
return settings;
}
}
catch (DirectoryNotFoundException)
{
return Settings.GetDefaultSettings();
}
catch (FileNotFoundException)
{
return Settings.GetDefaultSettings();
}
catch (XamlParseException)
{
return Settings.GetDefaultSettings();
}
}
public void SaveSettings(Settings settings)
{
InitializeSettingsFile();
if (!_settingsFile.Directory.Exists)
{
_settingsFile.Directory.Create();
}
using (var stream = File.Open(_settingsFile.FullName, FileMode.Create))
{
XamlWriter.Save(settings, stream);
}
}
private void InitializeSettingsFile()
{
if (_settingsFile == null)
{
// In a real application, we would use Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
var applicationDataPath = Path.GetTempPath();
var settingsFolderPath = Path.Combine(applicationDataPath, ApplicationFolderName);
_settingsFile = new FileInfo(Path.Combine(settingsFolderPath, Settings.SettingsFileName));
}
}
}
}

Просмотреть файл

@ -0,0 +1,64 @@
// ****************************************************************************
// <copyright file="ShutdownAnimationService.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System;
using System.Windows;
using System.Windows.Media.Animation;
using CleanShutdown.Messaging;
using GalaSoft.MvvmLight.Messaging;
namespace CleanShutdown.Helpers
{
public class ShutdownAnimationService
{
private bool _shutdownAnimationHasRun;
public ShutdownAnimationService(FrameworkElement element)
{
Messenger.Default.Register<NotificationMessageAction<bool>>(
this,
message =>
{
if (message.Command == Notifications.ConfirmShutdown)
{
if (!_shutdownAnimationHasRun)
{
var sbd =
element.Resources["ShutdownStoryboard"] as Storyboard;
if (sbd != null)
{
message.Execute(true);
// true == abort shutdown
sbd.Completed += ShutdownStoryboardCompleted;
sbd.Begin();
}
}
// If the animation ran already, no need to reply
// to the message, allow shutdown.
}
});
}
private void ShutdownStoryboardCompleted(object sender, EventArgs e)
{
_shutdownAnimationHasRun = true;
// Now that our pre-shutdown task is done, we can request shutdown again.
ShutdownService.RequestShutdown();
}
}
}

Просмотреть файл

@ -0,0 +1,41 @@
// ****************************************************************************
// <copyright file="ShutdownService.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Windows;
using CleanShutdown.Messaging;
using GalaSoft.MvvmLight.Messaging;
namespace CleanShutdown.Helpers
{
public static class ShutdownService
{
public static void RequestShutdown()
{
var shouldAbortShutdown = false;
Messenger.Default.Send(new NotificationMessageAction<bool>(
Notifications.ConfirmShutdown,
shouldAbort => shouldAbortShutdown |= shouldAbort));
if (!shouldAbortShutdown)
{
// This time it is for real
Messenger.Default.Send(new CommandMessage(Notifications.NotifyShutdown));
Application.Current.Shutdown();
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
Copyright (c) 2009 Laurent Bugnion (GalaSoft), laurent@galasoft.ch
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Просмотреть файл

@ -0,0 +1,107 @@
<!--MainWindow.xaml by GalaSoft Laurent Bugnion http://www.galasoft.ch -->
<!--Project: CleanShutdown | Date: 15.10.2009-->
<!--Copyright © GalaSoft Laurent Bugnion 2009 laurent@galasoft.ch-->
<!--See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt-->
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="CleanShutdown.MainWindow"
Height="400"
Width="400"
Top="300"
Left="300"
Title="Graceful Shutdown Demo"
Background="{x:Null}"
AllowsTransparency="True"
WindowStyle="None"
Icon="GalaSoft.ico"
DataContext="{Binding Main, Source={StaticResource Locator}}">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Skins/MainSkin.xaml" />
</ResourceDictionary.MergedDictionaries>
<Storyboard x:Key="ShutdownStoryboard">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="1440"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="0.1"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="0.1"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="LayoutRoot"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:02"
Value="0"
KeySpline="0.48,0,1,1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ResourceDictionary>
</Window.Resources>
<Grid x:Name="LayoutRoot"
RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Grid.RenderTransform>
<Ellipse Fill="{Binding BackgroundBrush}" />
<Button Content="X"
Style="{StaticResource CloseButtonStyle}"
Command="{Binding ShutdownCommand}"
ToolTipService.ToolTip="Click to shutdown" />
<Grid DataContext="{Binding Settings, Source={StaticResource Locator}}"
x:Name="SettingsRoot"
Style="{StaticResource SettingsGridStyle}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.33*" />
<ColumnDefinition Width="0.33*" />
<ColumnDefinition Width="0.33*" />
</Grid.ColumnDefinitions>
<Slider Orientation="Vertical"
Style="{StaticResource SliderStyle}"
Value="{Binding Red, Mode=TwoWay}"
ToolTipService.ToolTip="Red" />
<Slider Orientation="Vertical"
Grid.Column="1"
Style="{StaticResource SliderStyle}"
Value="{Binding Green, Mode=TwoWay}"
ToolTipService.ToolTip="Green" />
<Slider Orientation="Vertical"
Grid.Column="2"
Style="{StaticResource SliderStyle}"
Value="{Binding Blue, Mode=TwoWay}"
ToolTipService.ToolTip="Blue" />
</Grid>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,36 @@
// ****************************************************************************
// <copyright file="MainWindow.xaml.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Windows;
using CleanShutdown.Helpers;
namespace CleanShutdown
{
/// <summary>
/// This application's main window.
/// </summary>
public partial class MainWindow : Window
{
private ShutdownAnimationService _animationService;
public MainWindow()
{
_animationService = new ShutdownAnimationService(this);
InitializeComponent();
MouseDown += (s, e) => DragMove();
}
}
}

Просмотреть файл

@ -0,0 +1,84 @@
// ****************************************************************************
// <copyright file="NotificationMessageAction.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System;
namespace CleanShutdown.Messaging
{
public class NotificationMessageAction : NotificationMessageWithCallback
{
public NotificationMessageAction(string notification, Action callback)
: base(notification, callback)
{
}
public void Execute()
{
base.Execute();
}
}
public class NotificationMessageAction<T> : NotificationMessageWithCallback
{
public NotificationMessageAction(string notification, Action<T> callback)
: base(notification, callback)
{
}
public void Execute(T p1)
{
base.Execute(p1);
}
}
public class NotificationMessageAction<T1, T2> : NotificationMessageWithCallback
{
public NotificationMessageAction(string notification, Action<T1, T2> callback)
: base(notification, callback)
{
}
public void Execute(T1 p1, T2 p2)
{
base.Execute(p1, p2);
}
}
public class NotificationMessageAction<T1, T2, T3> : NotificationMessageWithCallback
{
public NotificationMessageAction(string notification, Action<T1, T2, T3> callback)
: base(notification, callback)
{
}
public void Execute(T1 p1, T2 p2, T3 p3)
{
base.Execute(p1, p2, p3);
}
}
public class NotificationMessageAction<T1, T2, T3, T4> : NotificationMessageWithCallback
{
public NotificationMessageAction(string notification, Action<T1, T2, T3, T4> callback)
: base(notification, callback)
{
}
public void Execute(T1 p1, T2 p2, T3 p3, T4 p4)
{
base.Execute(p1, p2, p3, p4);
}
}
}

Просмотреть файл

@ -0,0 +1,84 @@
// ****************************************************************************
// <copyright file="NotificationMessageFunc.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System;
namespace CleanShutdown.Messaging
{
public class NotificationMessageFunc<TResult> : NotificationMessageWithCallback
{
public NotificationMessageFunc(string notification, Func<TResult> callback)
: base(notification, callback)
{
}
public TResult Execute()
{
return (TResult) base.Execute();
}
}
public class NotificationMessageFunc<T, TResult> : NotificationMessageWithCallback
{
public NotificationMessageFunc(string notification, Func<TResult> callback)
: base(notification, callback)
{
}
public TResult Execute(T p1)
{
return (TResult) base.Execute(p1);
}
}
public class NotificationMessageFunc<T1, T2, TResult> : NotificationMessageWithCallback
{
public NotificationMessageFunc(string notification, Func<T1, T2, TResult> callback)
: base(notification, callback)
{
}
public TResult Execute(T1 p1, T2 p2)
{
return (TResult) base.Execute(p1, p2);
}
}
public class NotificationMessageFunc<T1, T2, T3, TResult> : NotificationMessageWithCallback
{
public NotificationMessageFunc(string notification, Func<T1, T2, T3> callback)
: base(notification, callback)
{
}
public TResult Execute(T1 p1, T2 p2, T3 p3)
{
return (TResult) base.Execute(p1, p2, p3);
}
}
public class NotificationMessageFunc<T1, T2, T3, T4, TResult> : NotificationMessageWithCallback
{
public NotificationMessageFunc(string notification, Func<T1, T2, T3, T4, TResult> callback)
: base(notification, callback)
{
}
public TResult Execute(T1 p1, T2 p2, T3 p3, T4 p4)
{
return (TResult) base.Execute(p1, p2, p3, p4);
}
}
}

Просмотреть файл

@ -0,0 +1,41 @@
// ****************************************************************************
// <copyright file="NotificationMessageWithCallback.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System;
using GalaSoft.MvvmLight.Messaging;
namespace CleanShutdown.Messaging
{
public class NotificationMessageWithCallback : CommandMessage
{
private readonly Delegate _callback;
public NotificationMessageWithCallback(string notification, Delegate callback)
: base(notification)
{
_callback = callback;
}
public virtual object Execute(params object[] arguments)
{
if (_callback != null)
{
return _callback.DynamicInvoke(arguments);
}
return null;
}
}
}

Просмотреть файл

@ -0,0 +1,26 @@
// ****************************************************************************
// <copyright file="Notifications.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System;
namespace CleanShutdown.Messaging
{
public static class Notifications
{
public static readonly string ConfirmShutdown = Guid.NewGuid().ToString();
public static readonly string NotifyShutdown = Guid.NewGuid().ToString();
}
}

Просмотреть файл

@ -0,0 +1,41 @@
// ****************************************************************************
// <copyright file="AssemblyInfo.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System;
using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;
using System.Windows;
[assembly: AssemblyTitle("CleanShutdown")]
[assembly: AssemblyDescription("Sample application demonstrating how to cleanly shut down a WPF application using a Messenger.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GalaSoft Laurent Bugnion")]
[assembly: AssemblyProduct("CleanShutdown")]
[assembly: AssemblyCopyright("Copyright © 2009 GalaSoft Laurent Bugnion")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: CLSCompliant(true)]
[assembly: NeutralResourcesLanguage("en-US",
UltimateResourceFallbackLocation.MainAssembly)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.0.0.*")]

63
Samples/CleanShutdown/CleanShutdown/Properties/Resources.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CleanShutdown.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CleanShutdown.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

Просмотреть файл

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

30
Samples/CleanShutdown/CleanShutdown/Properties/Settings.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4918
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CleanShutdown.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Просмотреть файл

@ -0,0 +1,125 @@
<!--MainSkin.xaml by GalaSoft Laurent Bugnion http://www.galasoft.ch -->
<!--Project: CleanShutdown | Date: 15.10.2009-->
<!--Copyright © GalaSoft Laurent Bugnion 2009 laurent@galasoft.ch-->
<!--See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="SettingsGridStyle"
TargetType="Grid">
<Setter Property="Background"
Value="#99FFFFFF" />
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="Width"
Value="82" />
<Setter Property="Margin"
Value="50,95,0,93" />
</Style>
<ControlTemplate x:Key="CloseButtonTemplate"
TargetType="Button">
<Grid x:Name="Root"
Opacity="0.6"
RenderTransformOrigin="0.5,0.5"
Background="#00000000">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Grid.RenderTransform>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="Normal"
GeneratedDuration="00:00:00.3000000"
To="MouseOver" />
<VisualTransition From="MouseOver"
GeneratedDuration="00:00:00.3000000"
To="Normal" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="Root"
Storyboard.TargetProperty="(UIElement.Opacity)">
<LinearDoubleKeyFrame KeyTime="00:00:00"
Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="Root"
Storyboard.TargetProperty="(UIElement.Opacity)">
<LinearDoubleKeyFrame KeyTime="00:00:00"
Value="1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="Root"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<LinearDoubleKeyFrame KeyTime="00:00:00"
Value="0.9" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="Root"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<LinearDoubleKeyFrame KeyTime="00:00:00"
Value="0.9" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
<Style x:Key="CloseButtonStyle"
TargetType="Button">
<Setter Property="Template"
Value="{StaticResource CloseButtonTemplate}" />
<Setter Property="FontSize"
Value="150" />
<Setter Property="FontWeight"
Value="Bold" />
<Setter Property="Cursor"
Value="Hand" />
<Setter Property="FontStyle"
Value="Italic" />
<Setter Property="HorizontalAlignment"
Value="Center" />
<Setter Property="VerticalAlignment"
Value="Center" />
</Style>
<Style x:Key="SliderStyle"
TargetType="Slider">
<Setter Property="Margin"
Value="0,10" />
<Setter Property="Maximum"
Value="255" />
<Setter Property="SmallChange"
Value="1" />
<Setter Property="LargeChange"
Value="5" />
<Setter Property="HorizontalAlignment"
Value="Center" />
</Style>
</ResourceDictionary>

Просмотреть файл

@ -0,0 +1,80 @@
// ****************************************************************************
// <copyright file="MainViewModel.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Windows.Media;
using CleanShutdown.Helpers;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
namespace CleanShutdown.ViewModel
{
public class MainViewModel : ViewModelBase
{
/// <summary>
/// The <see cref="BackgroundBrush" /> property's name.
/// </summary>
public const string BackgroundBrushPropertyName = "BackgroundBrush";
private Brush _background;
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public MainViewModel()
{
if (IsInDesignMode)
{
BackgroundBrush = new SolidColorBrush(Colors.Orange);
}
else
{
Messenger.Default.Register<Brush>(this, true, m => BackgroundBrush = m);
ShutdownCommand = new RelayCommand(ShutdownService.RequestShutdown);
}
}
/// <summary>
/// Gets the BackgroundBrush property.
/// Changes to that property's value raise the PropertyChanged event.
/// This property's value is broadcasted by the Messenger's default instance when it changes.
/// </summary>
public Brush BackgroundBrush
{
get
{
return _background;
}
private set
{
if (_background == value)
{
return;
}
_background = value;
RaisePropertyChanged(BackgroundBrushPropertyName);
}
}
public RelayCommand ShutdownCommand
{
get;
private set;
}
}
}

Просмотреть файл

@ -0,0 +1,195 @@
// ****************************************************************************
// <copyright file="SettingsViewModel.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Windows.Media;
using CleanShutdown.Helpers;
using CleanShutdown.Messaging;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
namespace CleanShutdown.ViewModel
{
public class SettingsViewModel : ViewModelBase
{
/// <summary>
/// The <see cref="Blue" /> property's name.
/// </summary>
public const string BluePropertyName = "Blue";
/// <summary>
/// The <see cref="Green" /> property's name.
/// </summary>
public const string GreenPropertyName = "Green";
/// <summary>
/// The <see cref="Red" /> property's name.
/// </summary>
public const string RedPropertyName = "Red";
private readonly bool _isLoading;
private readonly SettingsFileHandler _settingsFile;
private byte _blue;
private byte _green;
private byte _red;
public SettingsViewModel()
{
if (!IsInDesignMode)
{
Messenger.Default.Register<CommandMessage>(
this,
m =>
{
if (m.Command
== Notifications.NotifyShutdown)
{
SaveSettings();
}
});
_settingsFile = new SettingsFileHandler();
var savedSettings = _settingsFile.LoadSettings();
Messenger.Default.Send<Brush, MainViewModel>(
savedSettings.ApplicationBackgroundBrush);
_isLoading = true;
var solidBrush
= savedSettings.ApplicationBackgroundBrush as SolidColorBrush;
if (solidBrush != null)
{
Red = solidBrush.Color.R;
Green = solidBrush.Color.G;
Blue = solidBrush.Color.B;
}
_isLoading = false;
}
}
/// <summary>
/// Gets the Blue property.
/// Changes to that property's value raise the PropertyChanged event.
/// </summary>
public byte Blue
{
get
{
return _blue;
}
set
{
if (_blue == value)
{
return;
}
_blue = value;
// Update bindings, no broadcast
RaisePropertyChanged(BluePropertyName);
SendBrushUpdate();
}
}
/// <summary>
/// Gets the Green property.
/// Changes to that property's value raise the PropertyChanged event.
/// </summary>
public byte Green
{
get
{
return _green;
}
set
{
if (_green == value)
{
return;
}
_green = value;
// Update bindings, no broadcast
RaisePropertyChanged(GreenPropertyName);
SendBrushUpdate();
}
}
/// <summary>
/// Gets the Red property.
/// Changes to that property's value raise the PropertyChanged event.
/// </summary>
public byte Red
{
get
{
return _red;
}
set
{
if (_red == value)
{
return;
}
_red = value;
// Update bindings, no broadcast
RaisePropertyChanged(RedPropertyName);
SendBrushUpdate();
}
}
protected virtual void SaveSettings()
{
var settings = new Settings
{
ApplicationBackgroundBrush = GetCurrentBrush()
};
_settingsFile.SaveSettings(settings);
}
private Brush GetCurrentBrush()
{
return new SolidColorBrush(
Color.FromArgb(255, Red, Green, Blue));
}
private void SendBrushUpdate()
{
if (_isLoading)
{
return;
}
Messenger.Default.Send<Brush, MainViewModel>(
GetCurrentBrush());
}
}
}

Просмотреть файл

@ -0,0 +1,132 @@
// ****************************************************************************
// <copyright file="ViewModelLocator.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>15.10.2009</date>
// <project>CleanShutdown</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using System.Diagnostics.CodeAnalysis;
namespace CleanShutdown.ViewModel
{
public class ViewModelLocator
{
private static MainViewModel _main;
private static SettingsViewModel _settings;
/// <summary>
/// Initializes a new instance of the ViewModelLocator class.
/// </summary>
public ViewModelLocator()
{
CreateMain();
}
/// <summary>
/// Gets the Main property.
/// </summary>
public static MainViewModel MainStatic
{
get
{
if (_main == null)
{
CreateMain();
}
return _main;
}
}
/// <summary>
/// Gets the Settings property.
/// </summary>
public static SettingsViewModel SettingsStatic
{
get
{
if (_settings == null)
{
CreateSettings();
}
return _settings;
}
}
/// <summary>
/// Gets the Main property.
/// </summary>
[SuppressMessage("Microsoft.Performance",
"CA1822:MarkMembersAsStatic",
Justification = "This non-static member is needed for data binding purposes.")]
public MainViewModel Main
{
get
{
return MainStatic;
}
}
/// <summary>
/// Gets the Settings property.
/// </summary>
[SuppressMessage("Microsoft.Performance",
"CA1822:MarkMembersAsStatic",
Justification = "This non-static member is needed for data binding purposes.")]
public SettingsViewModel Settings
{
get
{
return SettingsStatic;
}
}
/// <summary>
/// Provides a deterministic way to delete the Main property.
/// </summary>
public static void ClearMain()
{
_main = null;
}
/// <summary>
/// Provides a deterministic way to delete the Settings property.
/// </summary>
public static void ClearSettings()
{
_settings = null;
}
/// <summary>
/// Provides a deterministic way to create the Main property.
/// </summary>
public static void CreateMain()
{
if (_main == null)
{
_main = new MainViewModel();
}
}
/// <summary>
/// Provides a deterministic way to create the Settings property.
/// </summary>
public static void CreateSettings()
{
if (_settings == null)
{
_settings = new SettingsViewModel();
}
}
}
}