Click here to Skip to main content
Licence BSD
First Posted 24 Jun 2010
Views 16,381
Downloads 5,385
Bookmarked 31 times

PSAM WPF Control Library

By | 24 Jun 2010 | Article
PSAM Control Library ported over to WPF

Introduction

PSAM WPF Control Library is a WPF version of PSAM Control Library containing the IncipitViewer control for drawing musical notes which can be read from MusicXml file or added programmatically. PSAM WPF Control Library requires PSAM Control Library to run because it uses some of PSAM Control Library's classes. PSAM WPF Control Library is written in C# and XAML under Microsoft Visual Studio Express.

Using the Code

IncipitViewerWPF control requires special font to draw notes and other musical symbols. You can create your own font or use the included font Polihymnia which is based on Ben Laenen's Euterpe font and distributed under Sil Open Font Licence. Of course, you have to install the font in your fonts directory to display notes properly.

You can load a MusicXml file or add notes programmatically the same way as it is done in PSAM Control Library. Read the article about PSAM Control Library for details.

The control looks like that:

example1.png

Because it's a WPF control, you can apply fancy effects like these:

example2.png

example3.png

Printing is even simpler than in PSAM Control Library. You just have to write the following code:

PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
     dialog.PrintVisual(viewer, "Test");
} 

where viewer is a IncipitViewerWPF control. Sample printout:

example4.png

Points of Interest

Porting PSAM Control Library to WPF was quite simple. I made some changes to PSAM Control Library, namely I added a new interface IIncipitViewer which represents IncipitViewer's methods and properties and then I implemented this interface in IncipitViewerWPF class. I also moved ParseXml method from IncipitViewer to a new class called XmlParser so I didn't have to rewrite this method in IncipitViewerWPF class. To draw notes and musical symbols, I use an overridden OnRender method and a DrawingContext object.

License

This article, along with any associated source code and files, is licensed under The BSD License

About the Author

Ajcek84



Poland Poland

Member

I graduated from Adam Mickiewicz University in Poznań where I completed a MA degree in computer science (MA thesis: Analysis of Sound of Viola da Gamba and Human Voice and an Attempt of Comparison of Their Timbres Using Various Techniques of Digital Signal Analysis) and a bachelor degree in musicology (BA thesis: Continuity and Transitions in European Music Theory Illustrated by the Example of 3rd part of Zarlino's Institutioni Harmoniche and Bernhard's Tractatus Compositionis Augmentatus). I also graduated from a solo singing class in Fryderyk Chopin Musical School in Poznań. I'm a self-taught composer and a member of informal international group Vox Saeculorum, gathering composers, which common goal is to revive the old (mainly baroque) styles and composing traditions in contemporary written music. I'm the annual participant of International Summer School of Early Music in Lidzbark Warmiński.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
SuggestionRefactoring & Silverlight porting PinmemberKvanttt22:09 26 Jun '11  
GeneralRe: Refactoring & Silverlight porting PinmemberAjcek8422:24 26 Jun '11  
GeneralRe: Refactoring & Silverlight porting PinmemberKvanttt22:45 26 Jun '11  
GeneralRe: Refactoring & Silverlight porting PinmemberAjcek842:54 24 Jul '11  
GeneralRe: Refactoring & Silverlight porting Pinmembermcraig1554:28 5 Aug '11  
NewsRe: Refactoring & Silverlight porting PinmemberKvanttt2:01 14 Aug '11  
GeneralRe: Refactoring & Silverlight porting Pinmembermcraig1555:20 3 Oct '11  
GeneralVery good work! Question about multiple staves Pinmembermcraig1557:48 20 May '11  
GeneralRe: Very good work! Question about multiple staves PinmemberAjcek840:17 21 May '11  
GeneralRe: Very good work! Question about multiple staves Pinmembermcraig1551:41 21 May '11  
GeneralExcellent! Vote of 5, and two questions: PinmemberGuenter Prossliner3:22 29 Mar '11  
GeneralRe: Excellent! Vote of 5, and two questions: PinmemberAjcek844:06 29 Mar '11  
GeneralRe: Excellent! Vote of 5, and two questions: PinmemberGuenter Prossliner0:06 30 Mar '11  
GeneralRe: Excellent! Vote of 5, and two questions: PinmemberAjcek840:13 31 Mar '11  
GeneralRe: Excellent! Vote of 5, and two questions: PinmemberGuenter Prossliner22:45 31 Mar '11  
GeneralRe: Excellent! Vote of 5, and two questions: PinmemberAjcek840:53 1 Apr '11  
GeneralRe: Excellent! Vote of 5, and two questions: Pinmemberdavidorn19:10 25 Jul '11  
GeneralMy vote of 5 PinmemberKenJohnson20:48 9 Jul '10  
GeneralNice! PinmemberJammer22:16 4 Jul '10  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 25 Jun 2010
Article Copyright 2010 by Ajcek84
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid