diff options
Diffstat (limited to 'Rx/NET/Samples/HOL/CS/Excercise5')
16 files changed, 604 insertions, 0 deletions
diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Start/Excercise5.csproj b/Rx/NET/Samples/HOL/CS/Excercise5/Start/Excercise5.csproj new file mode 100644 index 0000000..d71044c --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Start/Excercise5.csproj @@ -0,0 +1,60 @@ +<?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>{612EB94E-B9D8-4FC7-8400-E914C324729A}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Excercise5</RootNamespace> + <AssemblyName>Excercise5</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkProfile>Client</TargetFrameworkProfile> + <FileAlignment>512</FileAlignment> + </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="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Reactive, Version=1.0.10425.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </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>
\ No newline at end of file diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Start/Excercise5.sln b/Rx/NET/Samples/HOL/CS/Excercise5/Start/Excercise5.sln new file mode 100644 index 0000000..ebf0eb1 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Start/Excercise5.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excercise5", "Excercise5.csproj", "{E33DD010-6514-4C5E-89B5-C2BE05F71139}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Debug|x86.ActiveCfg = Debug|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Debug|x86.Build.0 = Debug|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Release|x86.ActiveCfg = Release|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Start/Program.cs b/Rx/NET/Samples/HOL/CS/Excercise5/Start/Program.cs new file mode 100644 index 0000000..2b8bc30 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Start/Program.cs @@ -0,0 +1,29 @@ +using System; +using System.Reactive.Linq; +using System.Windows.Forms; +using System.Reactive.Disposables; + +namespace Excercise5 +{ + class Program + { + static void Main() + { + var txt = new TextBox(); + + var frm = new Form() + { + Controls = { txt } + }; + + var input = from evt in Observable.FromEventPattern(txt, "TextChanged") + select ((TextBox)evt.Sender).Text; + + using (input.Subscribe(inp => Console.WriteLine("User wrote: " + inp))) + { + Application.Run(frm); + } + + } + } +} diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Start/Properties/AssemblyInfo.cs b/Rx/NET/Samples/HOL/CS/Excercise5/Start/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e64088c --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Start/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Excercise5")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Excercise5")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5ebd40c6-5262-421f-83f4-2978bf532d01")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Excercise5.csproj b/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Excercise5.csproj new file mode 100644 index 0000000..500a8f3 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Excercise5.csproj @@ -0,0 +1,60 @@ +<?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>{3F646D48-FE9B-4372-9145-C849E55C85A0}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Excercise5</RootNamespace> + <AssemblyName>Excercise5</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkProfile>Client</TargetFrameworkProfile> + <FileAlignment>512</FileAlignment> + </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="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Reactive, Version=1.0.10425.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </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>
\ No newline at end of file diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Excercise5.sln b/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Excercise5.sln new file mode 100644 index 0000000..ebf0eb1 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Excercise5.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excercise5", "Excercise5.csproj", "{E33DD010-6514-4C5E-89B5-C2BE05F71139}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Debug|x86.ActiveCfg = Debug|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Debug|x86.Build.0 = Debug|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Release|x86.ActiveCfg = Release|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Program.cs b/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Program.cs new file mode 100644 index 0000000..5d06ae5 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Program.cs @@ -0,0 +1,31 @@ +using System; +using System.Reactive.Linq; +using System.Windows.Forms; +using System.Reactive.Disposables; + +namespace Excercise5 +{ + class Program + { + static void Main() + { + var txt = new TextBox(); + + var frm = new Form() + { + Controls = { txt } + }; + + var input = (from evt in Observable.FromEventPattern(txt, "TextChanged") + select ((TextBox)evt.Sender).Text) + .Do(inp => Console.WriteLine("Before DistinctUntilChanged: " + inp)) + .DistinctUntilChanged(); + + using (input.Subscribe(inp => Console.WriteLine("User wrote: " + inp))) + { + Application.Run(frm); + } + + } + } +} diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Properties/AssemblyInfo.cs b/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e64088c --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step03/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Excercise5")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Excercise5")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5ebd40c6-5262-421f-83f4-2978bf532d01")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Excercise5.csproj b/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Excercise5.csproj new file mode 100644 index 0000000..c644e80 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Excercise5.csproj @@ -0,0 +1,61 @@ +<?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>{FDFB3A63-D70A-4DC6-92F1-D8C3EAF2F0E5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Excercise5</RootNamespace> + <AssemblyName>Excercise5</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkProfile>Client</TargetFrameworkProfile> + <FileAlignment>512</FileAlignment> + </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="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Reactive, Version=1.0.10425.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> + <Reference Include="System.Reactive.Windows.Forms, Version=1.0.10425.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </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>
\ No newline at end of file diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Excercise5.sln b/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Excercise5.sln new file mode 100644 index 0000000..ebf0eb1 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Excercise5.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excercise5", "Excercise5.csproj", "{E33DD010-6514-4C5E-89B5-C2BE05F71139}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Debug|x86.ActiveCfg = Debug|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Debug|x86.Build.0 = Debug|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Release|x86.ActiveCfg = Release|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Program.cs b/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Program.cs new file mode 100644 index 0000000..2e6b692 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Program.cs @@ -0,0 +1,37 @@ +using System; +using System.Reactive; +using System.Reactive.Linq; +using System.Windows.Forms; + +namespace Excercise5 +{ + class Program + { + static void Main() + { + var txt = new TextBox(); + + var frm = new Form() + { + Controls = { txt } + }; + + var input = (from evt in Observable.FromEventPattern(txt, "TextChanged") + select ((TextBox)evt.Sender).Text) + .Timestamp() + .Do(inp => Console.WriteLine("I: " + inp.Timestamp.Millisecond + " - " + inp.Value)) + .Select(x => x.Value) + .Throttle(TimeSpan.FromSeconds(1)) + .Timestamp() + .Do(inp => Console.WriteLine("T: " + inp.Timestamp.Millisecond + " - " + inp.Value)) + .Select(x => x.Value) + .DistinctUntilChanged(); + + using (input.Subscribe(inp => Console.WriteLine("User wrote: " + inp))) + { + Application.Run(frm); + } + + } + } +} diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Properties/AssemblyInfo.cs b/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e64088c --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step04/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Excercise5")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Excercise5")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5ebd40c6-5262-421f-83f4-2978bf532d01")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Excercise5.csproj b/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Excercise5.csproj new file mode 100644 index 0000000..8f5c634 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Excercise5.csproj @@ -0,0 +1,61 @@ +<?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>{EFB0FA3C-0F6E-435B-8627-90B8EE83AD8D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Excercise5</RootNamespace> + <AssemblyName>Excercise5</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkProfile>Client</TargetFrameworkProfile> + <FileAlignment>512</FileAlignment> + </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="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Reactive, Version=1.0.10425.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> + <Reference Include="System.Reactive.Windows.Forms, Version=1.0.10425.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </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>
\ No newline at end of file diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Excercise5.sln b/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Excercise5.sln new file mode 100644 index 0000000..ebf0eb1 --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Excercise5.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excercise5", "Excercise5.csproj", "{E33DD010-6514-4C5E-89B5-C2BE05F71139}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Debug|x86.ActiveCfg = Debug|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Debug|x86.Build.0 = Debug|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Release|x86.ActiveCfg = Release|x86 + {E33DD010-6514-4C5E-89B5-C2BE05F71139}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Program.cs b/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Program.cs new file mode 100644 index 0000000..f931cee --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Program.cs @@ -0,0 +1,41 @@ +using System; +using System.Reactive; +using System.Reactive.Linq; +using System.Windows.Forms; + +namespace Excercise5 +{ + class Program + { + static void Main() + { + var txt = new TextBox(); + + var frm = new Form() + { + Controls = { txt } + }; + + var input = (from evt in Observable.FromEventPattern(txt, "TextChanged") + select ((TextBox)evt.Sender).Text) + .LogTimestampedValues(x => Console.WriteLine("I: " + x.Timestamp.Millisecond + " - " + x.Value)) + .Throttle(TimeSpan.FromSeconds(1)) + .LogTimestampedValues(x => Console.WriteLine("T: " + x.Timestamp.Millisecond + " - " + x.Value)) + .DistinctUntilChanged(); + + using (input.Subscribe(inp => Console.WriteLine("User wrote: " + inp))) + { + Application.Run(frm); + } + + } + } + + public static class MyExtensions + { + public static IObservable<T> LogTimestampedValues<T>(this IObservable<T> source, Action<Timestamped<T>> onNext) + { + return source.Timestamp().Do(onNext).Select(x => x.Value); + } + } +} diff --git a/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Properties/AssemblyInfo.cs b/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e64088c --- /dev/null +++ b/Rx/NET/Samples/HOL/CS/Excercise5/Step05/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Excercise5")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Excercise5")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5ebd40c6-5262-421f-83f4-2978bf532d01")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] |