Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rhildred/csharpprojectsolutions1
examples from introductory C# class 2014
https://github.com/rhildred/csharpprojectsolutions1
Last synced: 12 days ago
JSON representation
examples from introductory C# class 2014
- Host: GitHub
- URL: https://github.com/rhildred/csharpprojectsolutions1
- Owner: rhildred
- Created: 2014-02-14T17:32:02.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-09T15:27:05.000Z (over 10 years ago)
- Last Synced: 2024-04-14T14:03:05.360Z (9 months ago)
- Language: C#
- Size: 1.35 MB
- Stars: 1
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
CSharpProjectSolutions1
======================examples from introductory C# class 2014
Adding Machine
--------------Simple XAML WPF app, taken from [Rob Miles' C# Yellow book](http://www.robmiles.com/c-yellow-book/).
Dispatcher Timer
----------------Thought I would break down the main idea of sprite animation into timer and added on WriteableBitmap code.
Sprite Animation
----------------Turns out that there are no simple examples of Sprite Animation using WPF/XAML. I wrote one that I think is pretty straightforward.
XAML
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Properties="clr-namespace:SpriteAnimation.Properties" x:Class="SpriteAnimation.MainWindow"
Title="MainWindow" Height="400" Width="555">
CSnamespace SpriteAnimation
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
WriteableBitmap writeableBitmap = null;
BitmapImage bi = null;
public MainWindow()
{
InitializeComponent();
// DispatcherTimer setup
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(enterFrame);
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 50);
dispatcherTimer.Start();
writeableBitmap = new WriteableBitmap(
(int)ImageControl.Width,
(int)ImageControl.Height,
96,
96,
PixelFormats.Pbgra32,
null);
ImageControl.Source = writeableBitmap;
bi = new BitmapImage(new Uri("pack://application:,,,/filmstrip.png"));
}
int nY = 0;
private void enterFrame(object sender, EventArgs e)
{
// Calculate stride of source
int nRowBytes = bi.PixelWidth * (bi.Format.BitsPerPixel / 8);
// Create data array to hold source pixel data
byte[] data = new byte[nRowBytes * 300];
// Copy source image pixels to the data array
bi.CopyPixels(new Int32Rect(0, nY*300, bi.PixelWidth, 300), data, nRowBytes, 0);
writeableBitmap.WritePixels(
new Int32Rect(0, 0, bi.PixelWidth, 300),
data, nRowBytes, 0);
if (++nY == 100) nY = 0;
}
}
}TDD Application
---------------Simple TDD application using nUnit. The main example is TaxTest.cs and CanadianTax.cs.