Posted by steveluo on August 23, 2009
Posted in Uncategorized | Leave a Comment »
Posted by steveluo on August 19, 2009
I posted the question and get an answer
Hi I get the followwing direcories by calling GetDirectories()
c:\app\20090331\
c:\app\20090430\
c:\app\20090531\
c:\app\20090630\
c:\app\20090731\
c:\app\20090831\
I want to the directories between 20090531 and 20090731, How can I do it by Linq?
the answer is
var query = directories .Where(x => { return (String.Compare(x, @”c:\app\20090531″) > 0 && String.Compare(x, @”c:\app\20090731″) < 0) ;});
Posted in Uncategorized | Leave a Comment »
Posted by steveluo on July 19, 2009
Generally we need get an initial dataset from Database by Sql and then use linq to filter it again to serve different purposes. the article show how to create a tableView based on linq:
EnumerableRowCollection query
= from customer in dtCustomer.AsEnumerable()
where customer.Field(“State”) == “NJ”
select customer;
DataView njview = query.AsDataView();
the chapter Chapter 14 in LinQ in Action gives us the details. and Other
examples on the web and Linq to DataTable example1
Points to understand Linq: (from Joseph Rattz’s book)
1) linq, a query, returnes set of objects is called a sequence. Most linq sequences are of type IEnumerable<T>
2) a lambda expression in C# with format:
a) (param1, param2, …paramN) => expr
b) (param1, param2, …paramN) => { statement1; statement2; … statementN; return(lambda_expression_return_type); }
e.g: x => x.Length > 0 could be read as “input x returns x.Length > 0.”
Linq Wiki
get data from Excel by linq
Posted in Uncategorized | Leave a Comment »
Posted by steveluo on April 11, 2009
Posted in Uncategorized | Leave a Comment »
Posted by steveluo on April 10, 2009
Posted in Uncategorized | Leave a Comment »
Posted by steveluo on March 15, 2009
Dependency Property (Notes from WPF unleashed p45-57)
dependency properties add value on top of plain .NET properties:
. Change notification — Whenever the value of a dependency property changes, WPF can automatically
trigger a number of actions depending on the property’s metadata, see trigger
. Property value inheritance — flowing of property values down the element tree.
. Support for multiple providers — a five-step process (see p57)
| want the text in each Button from the About dialog in to turn blue when the mouse pointer hovers over it. |
| normal way |
with WPF trigger |
<Button MouseEnter=”Button_MouseEnter” MouseLeave=”Button_MouseLeave”
MinWidth=”75” Margin=”10”>Help</Button>
<Button MouseEnter=”Button_MouseEnter” MouseLeave=”Button_MouseLeave”
MinWidth=”75” Margin=”10”>OK</Button>
…
void Button_MouseEnter(object sender, MouseEventArgs e)
{
Button b = sender as Button;
if (b != null)
b.Foreground = Brushes.Blue;
}
// Restore the foreground to black when the mouse exits the button
void Button_MouseLeave(object sender, MouseEventArgs e)
{
Button b = sender as Button;
if (b != null)
b.Foreground = Brushes.Black;
} |
<Trigger Property=”IsMouseOver” Value=”True”>
<Setter Property=”Foreground” Value=”Blue”/>
</Trigger> |
For example, the data binding system in WPF is rooted in the FrameworkElement.DataContext dependency property. The value of that property is inherited by all descendant elements. For more see Josh’s blog
Business objects – without dependency properties (see the details )
For a business object being bound, there are certain requirements for automatic change notification. There are three approaches you can take:
- Implement dependency properties in your business object.
- Raise an event named
<Property Name>Changed. This event must match the property name, and the class must raise the event.
- Implement the
INotifyPropertyChanged in the System.ComponentModel namespace. This interface defines a PropertyChanged event. The business object must fire this event every time any property value changes.
Posted in Uncategorized | Leave a Comment »
Posted by steveluo on March 14, 2009
I ran into speech demo Programming Speech in WPF – Speech Synthesis which is based on Speech Application Programming Interface or SAPI SDK 5.3 and found sound quality is not good because Xp default voice engine is
Mircrosoft Sam (you can find what voice engines have been installed on the computer by following Control Panel->Speech->Speech Properties->Text To Speech tab->Voice selection drop down window)
Try to download Microsoft Anna for my XP.
from
SpeechSynthesizer ttsSynth = new SpeechSynthesizer();
ttsSynth.SelectVoice(“Microsoft Anna”);
//ttsSynth.Volume = //ttsSynth.Rate
ttsSynth.Speak(“Greetings, my name is ” + ttsSynth.Voice.Name);
Posted in Uncategorized | Leave a Comment »
Posted by steveluo on March 13, 2009
Posted in WPF | Leave a Comment »
Posted by steveluo on March 8, 2009
Event
An event is a message sent by an object to signal the occurrence of an action (such as mouse click, or some program logic).
event sender: The object that raises the event
event receiver: The object that captures the event and responds to it
A delegate is thus equivalent to a type-safe function pointer or a callback
Posted in Uncategorized | Leave a Comment »