Wednesday, May 21, 2008

DoEvent in WPF

From http://shevaspace.spaces.live.com/blog/cns!FD9A0F1F8DD06954!526.entry:

Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { }));

Friday, March 16, 2007

SAPI and .NET 3.0 downloads

Pre-released Microsoft .NET Framework 3.0 Uninstall Tool
http://www.microsoft.com/downloads/details.aspx?FamilyId=AAE7FC63-D405-4E13-909F-E85AA9E66146&displaylang=en


.NET 3.0 Redistributable Package
http://www.microsoft.com/downloads/details.aspx?familyid=10CC340B-F857-4A14-83F5-25634C3BF043&displaylang=en

Microsoft® Windows® Software Development Kit for Windows Vista™ and .NET Framework 3.0 Runtime Components
http://www.microsoft.com/downloads/details.aspx?familyid=7614FE22-8A64-4DFB-AA0C-DB53035F40A0&displaylang=en

Microsoft® Visual Studio® 2005 Team Suite Service Pack 1
http://www.microsoft.com/downloads/details.aspx?familyid=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=en

Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP
http://www.microsoft.com/downloads/details.aspx?familyid=f54f5537-cc86-4bf5-ae44-f5a1e805680d&displaylang=en




The Windows Vista Developer Story: Speech
http://msdn2.microsoft.com/en-us/library/aa480207.aspx

All the Cool Developers use Speech APIs
http://blogs.msdn.com/chuckop/archive/2006/11/24/microsoft-speech-api-sdk.aspx

SAPI 5.1 SDK
http://www.microsoft.com/speech/download/old/sapi5.asp

Sapi 5.1: clarifications there of
http://blindprogramming.com/pipermail/programming_blindprogramming.com/2006-February/004794.html





Install .NET Framework 3.0 June 2006 CTP from:
http://www.microsoft.com/downloads/details.aspx?FamilyId=8D09697E-4868-4D8D-A4CF-9B82A2AE542D&displaylang=en

Install Windows SDK June for CTP of .NET Framework 3.0 Runtime Components from:
http://www.microsoft.com/downloads/details.aspx?FamilyID=9221A6AA-AC1C-4604-A326-B8CF2B12B6EB&displaylang=en

Install Microsoft Visual Studio Code Name "Orcas" CTP Development Tools for .NET Framework 3.0 from:
http://www.microsoft.com/downloads/details.aspx?FamilyId=1A994549-94CB-4F61-903D-A8C8E453EEF4&displaylang=en

Install Windows Imaging Components (WIC) from:
http://go.microsoft.com/fwlink/?LinkID=69301&clcid=0x409

Thursday, March 8, 2007

Updating UI from non-UI thread

In .NET 2.0:
void vj_engine_VowelGenerated(PatternDataCLR patternData)
{
if (this.InvokeRequired)
{
this.BeginInvoke(new VJEngineCLR_vowelGenerated(vj_engine_VowelGenerated), new object[] { patternData });
return;
}
}

In .NET 3.0:
http://www.codeproject.com/KB/cpp/SyncContextTutorial.aspx
using System.ComponentModel;
...
namespace MyNamespace
{
...
public class MyClass
{
AsyncOperation operation;
...

public MyClass()
{
operation = AsyncOperationManager.CreateOperation(null);
...
}

void nonUIThreadEvent(...)
{
operation.Post(new System.Threading.SendOrPostCallback(delegate(object state)
{
// do something
}), null);
}
}
}

How to enable code syntax highlighting in Blogger

How-to:
http://blog.the-dargans.co.uk/2007/01/syntax-highlighting-in-blogger.html

C# code formatter:
http://www.manoli.net/csharpformat/


Span class tags to use inside <pre class="csharpcode">...</pre> tags:

<span class="kwrd">kwrd</span>
<span class="rem">rem</span>
<span class="str">str</span>
<span class="class">class</span>
<span class="op">op</span>
<span class="preproc">preproc</span>
<span class="asp">asp</span>
<span class="html">html</span>
<span class="attr">attr</span>
<span class="alt">alt</span>
<span class="lnum">lnum</span>

Tuesday, February 27, 2007

WPF references

MSDN documentation
http://msdn2.microsoft.com/en-us/library/ms754130.aspx

WPF Samples in MSDN:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETFX30SDK4VS.1033/wpf_samples/html/b7781121-4c27-4814-a8d8-e6e0be247c00.htm

WPF Sample files part of Windows SDK:
C:\Program Files\Microsoft SDKs\Windows\v6.0\Samples\WPFSamples.zip

Location of WPF samples:
http://blogs.msdn.com/wpfsdk/attachment/1495353.ashx

Using Templates to Customize WPF Controls
http://msdn.microsoft.com/msdnmag/issues/07/01/Foundations/
In here, you can also find DumpControlTemplate code from Chapter 25 that allows you to dump out a control's default template property.

Custom TreeView Layout in WPF
http://www.codeproject.com/useritems/CustomTreeViewLayout.asp

Advanced Custom TreeView Layout in WPF
http://www.codeproject.com/WPF/AdvancedCustomTreeViewLyt.asp

Dependency property syntax:

// dependency property for minimum number of pies
public int MinNumPies
{
get { return (int)GetValue(MinNumPiesProperty); }
set { SetValue(MinNumPiesProperty, value); }
}
public static readonly DependencyProperty MinNumPiesProperty =
DependencyProperty.Register("MinNumPies", typeof(int), typeof(RadialPanel));

Routed events syntax:

MSDN documentation
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETFX30SDK4VS.1033/wpf_conceptual/html/1a2189ae-13b4-45b0-b12c-8de2e49c29d2.htm

// routed event
public static readonly RoutedEvent EventNameEvent = EventManager.RegisterRoutedEvent("EventName",
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyEnclosingClass));

// A .NET event wrapper (optional)
public event RoutedEventHandler EventName
{
add { AddHandler(EventNameEvent, value); }
remove { RemoveHandler(EventNameEvent, value); }
}

{
...
RaiseEvent(new RoutedEventArgs(EventNameEvent, this));
...
}

Binding syntax:

FAQ on Binding from MSDN blog:
http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx

NOTE: Can’t seem to nest bindings, e.g. {Binding Source={Binding Source={StaticResource resourceName}}}
NOTE: Target property (i.e. the left-hand side of {Binding...} must be a dependency property.
NOTE: When the source property is not a dependency property, the target property won’t be updated as the source property changes. To get them to be synchronized, the source object needs to either 1) implement the System.ComponentModel.INotifyPropertyChanged interface which has the single PropertyChanged event, or 2) implement an XXXChanged event, where XXX is the name of the property whose value changed. (first approach is recommended)

// ElementName used to refer to a XAML element defined by x:Name and source property on that object accessed through property1.property2
{Binding ElementName=elementName, Path=property1.property2}
{Binding property1.property2, ElementName=elementName}
// ElementName used to refer to a XAML element defined by x:Name
{Binding ElementName=elementName}
// Source used to refer to data source defined in ResourceDictionary and source property on that object accessed through property1.property2
{Binding Source={StaticResource resourceName}, Path=property1.property2}
// Source used to refer to data source defined in ResourceDictionary
{Binding Source={StaticResource resourceName}}

// when used within a FrameworkElement/FrameworkContentElement that have the DataContext property set to some data source, all nested Binding references implicitly assume a Source property value equal to that DataContext
<StackPanel DataContext={StaticResource resourceName}>
<Label Content={Binding Path=property}/>
<ListBox ItemsSource={Binding}/>
</StackPanel>

// when used within a DataTemplate, the DataContext is automatically set to the appropriate Source object, i.e. for ItemTemplate, it’s the current item
<ListBox>
<ListBox.ItemTemplate>
<Image Source=“{Binding Path=property}”/>
</ListBox.ItemTemplate>
</ListBox>

Binding’s RelativeSource property syntax:

RelativeSource property of Binding can be used to refer to data source relative to the target element

// source element equals target element
<Binding RelativeSource={RelativeSource Self}>
// source element equals target element’s TemplatedParent, which is essentially the target element of the template
<Binding RelativeSource={RelativeSource TemplatedParent}>
// source element equals the closest parent of a given type
<Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type desiredType}}>
// source element equals the nth closest parent of a given type
<Binding RelativeSource={RelativeSource FindAncestor, AncestorLevel=n, AncestorType={x:Type desiredType}}>
// source element equals the previous data item in a data-bound collection
<Binding RelativeSource={RelativeSource PreviousData}}>

TemplateBinding syntax:

Data source for TemplateBinding is always the target element, and the path is any of its dependency properties.
TemplateBinding can’t be used outside of a template’s VisualTree property, so can’t use in a trigger. Instead, you can use {Binding RelativeSource={RelativeSource TemplatedParent}}

<ControlTemplate TargetType=“{x:Type Button}”>
<!-- following bindings are all the same -->
<TextBlock Text=“{TemplateBinding Property=Button.Content}”/>
<TextBlock Text=“{TemplateBinding Button.Content}”/>
<TextBlock Text=“{TemplateBinding Content}”/>
</ControlTemplate>

ValueConverter syntax:

<Application.Resources>
<local:SingleConverter x:Key=“converter1”/>
<local:MultiConverter x:Key=“converter2”/>
</Application.Resources>

// single binding
<Label Background=“{Binding Source={StaticResource source}, Path=property, Converter={StaticResource converter1}, ConverterParameter=parameter}”/>

public class SingleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
...
}
}

// multibinding
<ProgressBar ...>
<ProgressBar.Value>
<MultiBinding Converter=“{StaticResource converter2}, ConverterParameter=parameter”>
<Binding ...}”/>
<Binding ...}”/>
<Binding ...}”/>
</MultiBinding>
</ProgressBar.Value>
</ProgressBar>

public class MultiConverter : IMultiConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
object value1 = values[0];
object value2 = values[1];
...
}
}

dev notes


Philip Martin Chavez, drawing using DNS and Paint
http://evoiceart.com/
Philip Martin Chavez
1261 Hopkins Street
Berkeley, CA 94702
510 524-6043
JettChair@aol.com


by 3/10, pilot start
by 3/15, visit Berkeley
by 3/25, draft finished
then video

February 28, 2007 9:24 AM
calling Philip

DESIGN NOTE:
- initially, we chose to use short discrete sound as the mode switcher out of continuous vowel mode since any other long word would cause the cursor to move.