Created
December 27, 2011 08:22
-
-
Save masaru-b-cl/1523030 to your computer and use it in GitHub Desktop.
MVVM BMI Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bin/ | |
obj/ | |
*.suo | |
*.user | |
TestResults/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Application x:Class="BMICalculator.App" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
StartupUri="MainWindow.xaml"> | |
<Application.Resources> | |
</Application.Resources> | |
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Configuration; | |
using System.Data; | |
using System.Linq; | |
using System.Windows; | |
namespace BMICalculator | |
{ | |
/// <summary> | |
/// App.xaml の相互作用ロジック | |
/// </summary> | |
public partial class App : Application | |
{ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
using System.Resources; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
using System.Windows; | |
// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 | |
// アセンブリに関連付けられている情報を変更するには、 | |
// これらの属性値を変更してください。 | |
[assembly: AssemblyTitle("BMICalculator")] | |
[assembly: AssemblyDescription("")] | |
[assembly: AssemblyConfiguration("")] | |
[assembly: AssemblyCompany("")] | |
[assembly: AssemblyProduct("BMICalculator")] | |
[assembly: AssemblyCopyright("Copyright © 2011")] | |
[assembly: AssemblyTrademark("")] | |
[assembly: AssemblyCulture("")] | |
// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから | |
// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、 | |
// その型の ComVisible 属性を true に設定してください。 | |
[assembly: ComVisible(false)] | |
//ローカライズ可能なアプリケーションのビルドを開始するには、 | |
//.csproj ファイルの <UICulture>CultureYouAreCodingWith</UICulture> を | |
//<PropertyGroup> 内部で設定します。たとえば、 | |
//ソース ファイルで英語を使用している場合、<UICulture> を en-US に設定します。次に、 | |
//下の NeutralResourceLanguage 属性のコメントを解除します。下の行の "en-US" を | |
//プロジェクト ファイルの UICulture 設定と一致するよう更新します。 | |
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] | |
[assembly: ThemeInfo( | |
ResourceDictionaryLocation.None, //テーマ固有のリソース ディクショナリが置かれている場所 | |
//(リソースがページ、 | |
//またはアプリケーション リソース ディクショナリに見つからない場合に使用されます) | |
ResourceDictionaryLocation.SourceAssembly //汎用リソース ディクショナリが置かれている場所 | |
//(リソースがページ、 | |
//アプリケーション、またはいずれのテーマ固有のリソース ディクショナリにも見つからない場合に使用されます) | |
)] | |
// アセンブリのバージョン情報は、以下の 4 つの値で構成されています: | |
// | |
// Major Version | |
// Minor Version | |
// Build Number | |
// Revision | |
// | |
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を | |
// 既定値にすることができます: | |
// [assembly: AssemblyVersion("1.0.*")] | |
[assembly: AssemblyVersion("1.0.0.0")] | |
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup> | |
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> | |
<ProductVersion>8.0.30703</ProductVersion> | |
<SchemaVersion>2.0</SchemaVersion> | |
<ProjectGuid>{01F89AAC-478C-4817-AA70-53B3F927E779}</ProjectGuid> | |
<OutputType>WinExe</OutputType> | |
<AppDesignerFolder>Properties</AppDesignerFolder> | |
<RootNamespace>BMICalculator</RootNamespace> | |
<AssemblyName>BMICalculator</AssemblyName> | |
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | |
<TargetFrameworkProfile>Client</TargetFrameworkProfile> | |
<FileAlignment>512</FileAlignment> | |
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | |
<WarningLevel>4</WarningLevel> | |
</PropertyGroup> | |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | |
<PlatformTarget>x86</PlatformTarget> | |
<DebugSymbols>true</DebugSymbols> | |
<DebugType>full</DebugType> | |
<Optimize>false</Optimize> | |
<OutputPath>bin\Debug\</OutputPath> | |
<DefineConstants>DEBUG;TRACE</DefineConstants> | |
<ErrorReport>prompt</ErrorReport> | |
<WarningLevel>4</WarningLevel> | |
</PropertyGroup> | |
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | |
<PlatformTarget>x86</PlatformTarget> | |
<DebugType>pdbonly</DebugType> | |
<Optimize>true</Optimize> | |
<OutputPath>bin\Release\</OutputPath> | |
<DefineConstants>TRACE</DefineConstants> | |
<ErrorReport>prompt</ErrorReport> | |
<WarningLevel>4</WarningLevel> | |
</PropertyGroup> | |
<ItemGroup> | |
<Reference Include="MvvmHelper"> | |
<HintPath>..\lib\MvvmHelper.dll</HintPath> | |
</Reference> | |
<Reference Include="System" /> | |
<Reference Include="System.Data" /> | |
<Reference Include="System.Xml" /> | |
<Reference Include="Microsoft.CSharp" /> | |
<Reference Include="System.Core" /> | |
<Reference Include="System.Xml.Linq" /> | |
<Reference Include="System.Data.DataSetExtensions" /> | |
<Reference Include="System.Xaml"> | |
<RequiredTargetFramework>4.0</RequiredTargetFramework> | |
</Reference> | |
<Reference Include="WindowsBase" /> | |
<Reference Include="PresentationCore" /> | |
<Reference Include="PresentationFramework" /> | |
</ItemGroup> | |
<ItemGroup> | |
<ApplicationDefinition Include="App.xaml"> | |
<Generator>MSBuild:Compile</Generator> | |
<SubType>Designer</SubType> | |
</ApplicationDefinition> | |
<Compile Include="BmiModel.cs" /> | |
<Compile Include="ViewModel.cs" /> | |
<Page Include="MainWindow.xaml"> | |
<Generator>MSBuild:Compile</Generator> | |
<SubType>Designer</SubType> | |
</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="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> | |
<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> | |
<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> | |
--> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| |
Microsoft Visual Studio Solution File, Format Version 11.00 | |
# Visual C# Express 2010 | |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMICalculator", "BMICalculator\BMICalculator.csproj", "{01F89AAC-478C-4817-AA70-53B3F927E779}" | |
EndProject | |
Global | |
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |
Debug|x86 = Debug|x86 | |
Release|x86 = Release|x86 | |
EndGlobalSection | |
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |
{01F89AAC-478C-4817-AA70-53B3F927E779}.Debug|x86.ActiveCfg = Debug|x86 | |
{01F89AAC-478C-4817-AA70-53B3F927E779}.Debug|x86.Build.0 = Debug|x86 | |
{01F89AAC-478C-4817-AA70-53B3F927E779}.Release|x86.ActiveCfg = Release|x86 | |
{01F89AAC-478C-4817-AA70-53B3F927E779}.Release|x86.Build.0 = Release|x86 | |
EndGlobalSection | |
GlobalSection(SolutionProperties) = preSolution | |
HideSolutionNode = FALSE | |
EndGlobalSection | |
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace BMICalculator | |
{ | |
public class BmiModel | |
{ | |
public decimal Height { get; set; } | |
public decimal Weight { get; set; } | |
public decimal CalculateBmi() | |
{ | |
return Math.Round( | |
d: Weight / (decimal)Math.Pow((double)(Height / 100m), 2d), | |
decimals: 2, | |
mode: MidpointRounding.AwayFromZero); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="BMICalculator.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="MainWindow" Height="350" Width="525"> | |
<Grid> | |
<Grid.ColumnDefinitions> | |
<ColumnDefinition Width="89*" /> | |
<ColumnDefinition Width="79*" /> | |
<ColumnDefinition Width="335*" /> | |
</Grid.ColumnDefinitions> | |
<Grid.RowDefinitions> | |
<RowDefinition Height="48*" /> | |
<RowDefinition Height="32*" /> | |
<RowDefinition Height="30*" /> | |
<RowDefinition Height="30*" /> | |
<RowDefinition Height="23*" /> | |
<RowDefinition Height="44*" /> | |
<RowDefinition Height="104*" /> | |
</Grid.RowDefinitions> | |
<Button Command="{Binding CalculateCommand}" Content="Calculate" Grid.Column="2" Grid.Row="5" Height="23" HorizontalAlignment="Left" Name="button1" VerticalAlignment="Top" Width="75" /> | |
<Label Content="BMI" Grid.Column="1" Grid.Row="6" Height="28" HorizontalAlignment="Left" Name="label1" VerticalAlignment="Top" /> | |
<Label Content="Height" Grid.Column="1" Grid.Row="1" Height="28" HorizontalAlignment="Left" Name="label2" VerticalAlignment="Top" /> | |
<Label Content="Weight" Grid.Column="1" Grid.Row="3" Height="28" HorizontalAlignment="Left" Name="label3" VerticalAlignment="Top" /> | |
<Label Grid.Column="2" Grid.Row="6" Height="28" HorizontalAlignment="Left" Name="label4" VerticalAlignment="Top" Content="{Binding Bmi}" /> | |
<TextBox Grid.Column="2" Grid.Row="1" Height="24" HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top" Width="120" Margin="0,2,0,0" Text="{Binding Height}" /> | |
<TextBox Grid.Column="2" Grid.Row="3" Height="24" HorizontalAlignment="Left" Margin="0,2,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" Text="{Binding Weight}" /> | |
</Grid> | |
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Data; | |
using System.Windows.Documents; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Windows.Media.Imaging; | |
using System.Windows.Navigation; | |
using System.Windows.Shapes; | |
namespace BMICalculator | |
{ | |
/// <summary> | |
/// MainWindow.xaml の相互作用ロジック | |
/// </summary> | |
public partial class MainWindow : Window | |
{ | |
private ViewModel vm; | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
vm = new ViewModel() { Height = 173m, Weight = 60m }; | |
this.DataContext = vm; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------ | |
// <auto-generated> | |
// このコードはツールによって生成されました。 | |
// ランタイム バージョン:4.0.30319.239 | |
// | |
// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 | |
// コードが再生成されるときに損失したりします | |
// </auto-generated> | |
//------------------------------------------------------------------------------ | |
namespace BMICalculator.Properties | |
{ | |
/// <summary> | |
/// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。 | |
/// </summary> | |
// このクラスは StronglyTypedResourceBuilder クラスによって ResGen | |
// または Visual Studio のようなツールを使用して自動生成されました。 | |
// メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に | |
// ResGen を実行し直すか、または VS プロジェクトをビルドし直します。 | |
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.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> | |
/// このクラスに使用される、キャッシュされた ResourceManager のインスタンスを返します。 | |
/// </summary> | |
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] | |
internal static global::System.Resources.ResourceManager ResourceManager | |
{ | |
get | |
{ | |
if ((resourceMan == null)) | |
{ | |
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BMICalculator.Properties.Resources", typeof(Resources).Assembly); | |
resourceMan = temp; | |
} | |
return resourceMan; | |
} | |
} | |
/// <summary> | |
/// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、 | |
/// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。 | |
/// </summary> | |
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] | |
internal static global::System.Globalization.CultureInfo Culture | |
{ | |
get | |
{ | |
return resourceCulture; | |
} | |
set | |
{ | |
resourceCulture = value; | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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.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: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" type="xsd:string" /> | |
<xsd:attribute name="type" type="xsd:string" /> | |
<xsd:attribute name="mimetype" type="xsd:string" /> | |
</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" msdata:Ordinal="1" /> | |
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |
</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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------ | |
// <auto-generated> | |
// This code was generated by a tool. | |
// Runtime Version:4.0.30319.239 | |
// | |
// Changes to this file may cause incorrect behavior and will be lost if | |
// the code is regenerated. | |
// </auto-generated> | |
//------------------------------------------------------------------------------ | |
namespace BMICalculator.Properties | |
{ | |
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] | |
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.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; | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='utf-8'?> | |
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> | |
<Profiles> | |
<Profile Name="(Default)" /> | |
</Profiles> | |
<Settings /> | |
</SettingsFile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.ComponentModel; | |
using MvvmHelper; | |
using System.Windows.Input; | |
using System.Windows; | |
namespace BMICalculator | |
{ | |
public class ViewModel : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
#region Height | |
public decimal? Height | |
{ | |
get { return _Height; } | |
set | |
{ | |
_Height = value; | |
PropertyChanged.Raise(this, HeightName); | |
} | |
} | |
private decimal? _Height; | |
internal static readonly string HeightName = PropertyName<ViewModel>.Get(_ => _.Height); | |
#endregion | |
#region Weight | |
public decimal? Weight | |
{ | |
get { return _Weight; } | |
set | |
{ | |
_Weight = value; | |
PropertyChanged.Raise(this, WeightName); | |
} | |
} | |
private decimal? _Weight; | |
internal static readonly string WeightName = PropertyName<ViewModel>.Get(_ => _.Weight); | |
#endregion | |
#region Bmi | |
public decimal? Bmi | |
{ | |
get { return _Bmi; } | |
set | |
{ | |
_Bmi = value; | |
PropertyChanged.Raise(this, BmiName); | |
} | |
} | |
private decimal? _Bmi; | |
internal static readonly string BmiName = PropertyName<ViewModel>.Get(_ => _.Bmi); | |
#endregion | |
#region CalculateCommand | |
private void CalculateCommandHandler(object parameter) | |
{ | |
Bmi = null; | |
var model = new BmiModel { Height = this.Height.Value, Weight = this.Weight.Value }; | |
Bmi = model.CalculateBmi(); | |
} | |
public ICommand CalculateCommand | |
{ | |
get | |
{ | |
if (_CalculateCommand == null) | |
_CalculateCommand = new DelegateCommand { CommandHandler = this.CalculateCommandHandler }; | |
return _CalculateCommand; | |
} | |
} | |
private ICommand _CalculateCommand; | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment