forked from cheungt6/public
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
547 additions
and
10 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...mitClassGeneration/Command/CommandBase.cs → Common.Wpf/Command/CommandBase.cs
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
2 changes: 1 addition & 1 deletion
2
...ClassGeneration/Command/GenericCommand.cs → Common.Wpf/Command/GenericCommand.cs
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
</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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="TPLDataflowProcessing.App" | ||
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:TPLDataflowProcessing" | ||
StartupUri="View/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace TPLDataflowProcessing | ||
{ | ||
/// <summary> | ||
/// Interaction logic for 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace TPLDataflowProcessing.Model | ||
{ | ||
public class MockPriceFeed | ||
{ | ||
public class PriceEventArgs : EventArgs | ||
{ | ||
public PriceEventArgs(string name, decimal price) | ||
{ | ||
TimeStampUtc = DateTime.UtcNow; | ||
Price = price; | ||
Name = string.Intern(name); | ||
} | ||
public DateTime TimeStampUtc { get; } | ||
public decimal Price { get; } | ||
public string Name { get; } | ||
} | ||
|
||
public delegate void PriceEvent(MockPriceFeed sender, PriceEventArgs e); | ||
public event PriceEvent OnNextPricePublished; | ||
|
||
|
||
private decimal _lastPrice; | ||
private Random _rand = new Random(); | ||
private object _feedLock = new object(); | ||
private bool _isRunning = false; | ||
|
||
public MockPriceFeed(string feedName) | ||
{ | ||
FeedName = feedName; | ||
_lastPrice = _rand.Next(0, 100); | ||
} | ||
|
||
public string FeedName { get; } | ||
|
||
public async void StartAsync() | ||
{ | ||
lock (_feedLock) | ||
{ | ||
if (_isRunning) return; | ||
_isRunning = true; | ||
} | ||
|
||
while (_isRunning) | ||
{ | ||
_lastPrice = Math.Abs(_lastPrice + (_rand.Next(-5, 5) / 10m)); | ||
var priceObj = new PriceEventArgs(FeedName, _lastPrice); | ||
OnNextPricePublished(this, priceObj); | ||
await Task.Delay(100); | ||
} | ||
} | ||
|
||
public void Stop() | ||
{ | ||
lock (_feedLock) | ||
{ | ||
if (!_isRunning) return; | ||
_isRunning = false; | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.11.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Processors\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Common.Wpf\Common.Wpf.csproj" /> | ||
</ItemGroup> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29411.108 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TPLDataflowProcessing", "TPLDataflowProcessing.csproj", "{6F1C1BF7-46D9-4401-8C7A-E0D0CFE420C5}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.Wpf", "..\Common.Wpf\Common.Wpf.csproj", "{DAD4476B-351A-46EE-9D14-EF3902F18E75}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{6F1C1BF7-46D9-4401-8C7A-E0D0CFE420C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6F1C1BF7-46D9-4401-8C7A-E0D0CFE420C5}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6F1C1BF7-46D9-4401-8C7A-E0D0CFE420C5}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6F1C1BF7-46D9-4401-8C7A-E0D0CFE420C5}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{DAD4476B-351A-46EE-9D14-EF3902F18E75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DAD4476B-351A-46EE-9D14-EF3902F18E75}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DAD4476B-351A-46EE-9D14-EF3902F18E75}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DAD4476B-351A-46EE-9D14-EF3902F18E75}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {7625D392-52B8-4A05-86AF-68EC73AC5669} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<Window x:Class="TPLDataflowProcessing.MainWindow" | ||
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="https://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="https://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:viewmodel="clr-namespace:TPLDataflowProcessing.ViewModel" | ||
mc:Ignorable="d" | ||
Title="MainWindow" Height="450" Width="900"> | ||
<Window.DataContext> | ||
<viewmodel:MainWindowViewModel/> | ||
</Window.DataContext> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="35"/> | ||
<RowDefinition Height="*"/> | ||
<RowDefinition Height="35"/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<Label Grid.Row="0" | ||
Grid.Column="0" | ||
Content="Feed"/> | ||
<Label Grid.Row="0" | ||
Grid.Column="1" | ||
Content="10 Update Intervals"/> | ||
<Label Grid.Row="0" | ||
Grid.Column="2" | ||
Content="1 Second Intervals"/> | ||
<ListView Grid.Row="1" | ||
Grid.Column="0" | ||
ItemsSource="{Binding UpdateLog}" /> | ||
<DataGrid Grid.Row="1" | ||
Grid.Column="1" | ||
ItemsSource="{Binding AveragePrices}" AutoGenerateColumns="False"> | ||
<DataGrid.Columns> | ||
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/> | ||
<DataGridTextColumn Header="TimeStamp" Binding="{Binding TimeStampUtc}"/> | ||
<DataGridTextColumn Header="Low" Binding="{Binding Low}"/> | ||
<DataGridTextColumn Header="High" Binding="{Binding High}"/> | ||
<DataGridTextColumn Header="Avg" Binding="{Binding Price}"/> | ||
</DataGrid.Columns> | ||
</DataGrid> | ||
<DataGrid Grid.Row="1" | ||
Grid.Column="2" | ||
ItemsSource="{Binding LatestPrices}" AutoGenerateColumns="False"> | ||
<DataGrid.Columns> | ||
<DataGridTextColumn Header="Name" Binding="{Binding Name}" SortDirection="Ascending" SortMemberPath="Name"/> | ||
<DataGridTextColumn Header="TimeStamp" Binding="{Binding TimeStampUtc}"/> | ||
<DataGridTextColumn Header="Low" Binding="{Binding Low}"/> | ||
<DataGridTextColumn Header="High" Binding="{Binding High}"/> | ||
<DataGridTextColumn Header="Latest" Binding="{Binding Price}"/> | ||
</DataGrid.Columns> | ||
</DataGrid> | ||
<Button Grid.Row="2" | ||
Grid.Column="1" | ||
Command="{Binding StartFeedsCommand}">Start Feeds</Button> | ||
<Button Grid.Row="2" | ||
Grid.Column="2" | ||
Command="{Binding StopFeedsCommand}">Stop Feeds</Button> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
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 TPLDataflowProcessing | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
Oops, something went wrong.