| I turn on a light each night to attract insects for toads (which seems a little odd now that I think about it). The other night I went outside to look at the moon and planets, and I noticed that I had forgotten to turn on the light. On my way back to the house, there were several toads waiting in their usual spot, looking at me wondering what happened to their light. 
|
| We came across another red-eyed devil (type of katydid) over the weekend. They are more unique since they are quite large, and very aggressive. When provoked, they rear back in defensive stand and will bite if possible. The bite does not hurt too bad since they don’t inject any type of poison, but can break the skin. Here are photos of one we found before. 
|
| At first they were cute, little wild pigs sneaking up to our yard in the late evening eating spilled bird seed and food we put out for the deer. But now they are really a pain… they come up every night, tip over the bird baths, move landscaping rocks around, and root up the plants. I tried larger rocks, but they keep persisting in their quest to root up everything. I can hear them outside my window when working late, mocking me, with their squealy pig laughter while they root up another trailing purple lantana. |
| 'Twelve plus one' contains the same letters as 'eleven plus two'. I did not come up with this, but thought it was interesting. |
| The kids found a
Giant
Redheaded Centipede crawling around outside so we caught it
and put Bob (kids named it Bob right away) in a cage to observe for a
few days. It started off well, it ate 7 mealworms the first evening,
but we were surprised to discover it had escaped the next morning. Now
we have a 7" centipede crawling around somewhere.
|
|
I ran into an
error with web services when updating an application from Silverlight 2
to Silverlight 3.
Custom
tool error: Failed to generate file: Unable to find service
'DynamicTypeService'. Ensure that the application is
installed correctly.
This turned out
to be a problem with the upgrade process and not Silverlight 3. I did
the following to resolve the problem.
- Delete
the file \Program Files\Microsoft Visual Studio
9.0\Common7\IDE\Microsoft.VisualStudio.ServicesProxy.dll.
- Reinstall
Silverlight 3, which installs an updated
Microsoft.VisualStudio.ServicesProxy.dll.
- Open
the solution and update each web service.
|
|
You
can use the
RenderTargetBitmap class to generate an image from a
UI element. For
example, say you want to generate an image from the XAML
element ThePanel.
<StackPanel Name="ThePanel" Orientation="Horizontal">
<Rectangle Width="50" Height="50" Fill="Red" />
<Rectangle Width="50" Height="50" Fill="Orange" />
<Rectangle Width="50" Height="50" Fill="YellowGreen" />
</StackPanel>
You can use RenderTargetBitmap to generate an
image,
and PngBitmapEncode
to save to a PNG file.
void SaveImage(Visual visual, int width, int height, string filePath)
{
// generate the image
RenderTargetBitmap bitmap = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
bitmap.Render(visual);
// create image file
PngBitmapEncoder image = new PngBitmapEncoder();
image.Frames.Add(BitmapFrame.Create(bitmap));
using (Stream fs = File.Create(filePath))
{
image.Save(fs);
}
}
Calling
the
SaveImage method.
// full path to the image
string filePath = Path.Combine(System.Environment.CurrentDirectory, "sample.png");
// generate image from XAML element
SaveImage(this.ThePanel, 500, 500, filePath);
If you are creating the control dynamically, be sure to call Arrange
on
the control before generating the image.
// full path to the image
string filePath = Path.Combine(System.Environment.CurrentDirectory, "sample.png");
// create instance of control
Button button = new Button();
button.Content = "Nifty Button";
// layout control before generating image
button.Arrange(new Rect(0, 0, 500, 500));
// generate image from XAML element
SaveImage(button, 500, 500, filePath);
|
| It's
a good idea to make sure your Silverlight application runs correctly
when running on a system that uses a different language. This is not
localizing an application (changing the user interface), but just
making sure it executes as expected.
For example,
the following code executes correctly running as English
(United States).
// get data, could be from an XML file or some other data source
string someNumber = "1.23";
string someDate = "2/15/1564";
// convert data, everything is fine
running as English
double number = double.Parse(someNumber);
DateTime date = DateTime.Parse(someDate);
But
fails when running as Dutch (Belgium).
// get data, could be from an XML file or some other data source
string someNumber = "1.23";
string someDate = "2/15/1564";
// not good, returns 123.0
instead of 1.23 when running as Dutch
double number = double.Parse(someNumber);
// not good, throws a FormatException when running as Dutch
DateTime date = DateTime.Parse(someDate);
This
can be fixed by specifying the culture
specific format when
parsing the string.
// get data, could be from an XML file or some other data source
string someNumber = "1.23";
string someDate = "2/15/1564";
// good, returns 1.23 when running as Dutch
double number = double.Parse(someNumber, CultureInfo.InvariantCulture);
// good, returns correct date when when running as Dutch
DateTime date = DateTime.Parse(someDate, CultureInfo.InvariantCulture);
The
point is not the specific parse calls, but there is a
potential problem anytime you format or parse a string.
Help catch problems
You can use FxCop
or Visual
Studio Code Analysis to help find globalization (and other)
problems.

Testing
You can use Regional and Language Options
under control panel to help test.

- Run Regional and Language Options
from control panel.
- Select the Formats tab.
- Select a language such as Dutch
(Belgium) under current format.
- Press Apply.
- Run your application and test.
|
| Silverlight
does not have as much support to handle events from unreferenced child
controls as WPF. For example, say you have the following control
hierarchy and
Page needs to handle events from the Child Controls.

This
is easy in WPF since you can use commands,
or
UIElement.AddHandler.
For example:
public MainWindow()
{
InitializeComponent();
// subscribe to events
raised by any child, Child Control is a Button in this example
this.AddHandler(Button.ClickEvent, new RoutedEventHandler(ChildClicked));
}
private void ChildClicked(object sender, RoutedEventArgs e)
{
// called when event is raised by any child
}
Or
you can declare the event handler in XAML.
<Window x:Class="WpfEvents.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WpfEvents"
Title="WPF Events" Height="200" Width="200"
Button.Click="ChildClicked">
Back
to Silverlight, it
does not support commands or UIElement.AddHandler. There are several
options:
Hookup each event handler
You can specify the event handler for each child control but that is
the whole point... we want to handle events
even though we don't have a reference to the individual child controls.
//
hooking up events requires a reference to each control
this.ChildControl1.Click += new RoutedEventHandler(ChildControl1_Click);
this.ChildControl2.Click += new RoutedEventHandler(ChildControl2_Click);
this.ChildControl3.Click += new RoutedEventHandler(ChildControl3_Click);
this.ChildControl4.Click += new RoutedEventHandler(ChildControl4_Click);
Bubble
up
the events
You can write code that bubbles up the events (re-raises the events).
This usually becomes undesirable, especially when you have controls
nested at several levels.
Use global Events class
One option is to create a global Events class.

- There
is only one instance of the Events class in the application.
- It
contains a list of global events and helper methods to raise the events.
- Any
object can subscribe to events.
- Any
object can raise events.
- That
means the main page can handle events from any child control, children
can handle events from the main page, and siblings can handle events
from each other.
- A
reference to the control is not required to handle events.
Example
Events class.
public static class Events
{
// example global event that can be handled
by any object in the application
public static event EventHandler ChildControlClicked;
public static void RaiseChildControlClicked(object sender, EventArgs args)
{
if (ChildControlClicked != null)
{
ChildControlClicked(sender,args);
}
}
}
Example
of raising an event.
// raise global event
Events.RaiseChildControlClicked(this, EventArgs.Empty);
Example
of handling an event.
public Page()
{
InitializeComponent();
// subscribe to global event
Events.ChildControlClicked += new System.EventHandler(Events_ChildControlClicked);
}
private void Events_ChildControlClicked(object sender, System.EventArgs e)
{
// called when the event is raised, it could be raised by
// any object in the
application, this object does not need
// a reference to the object that raised
the event
}
|
View in Web Browser /personal/ralph/Blog/_layouts/VisioWebAccess/VisioWebAccess.aspx?listguid={ListId}&itemid={ItemId}&DefaultItemOpen=1 0x0 0x1 FileType vdw 255 Compliance Details javascript:commonShowModalDialog('{SiteUrl}/_layouts/itemexpiration.aspx?ID={ItemId}&List={ListId}', 'center:1;dialogHeight:500px;dialogWidth:500px;resizable:yes;status:no;location:no;menubar:no;help:no', function GotoPageAfterClose(pageid){if(pageid == 'hold') {STSNavigate(unescape(decodeURI('{SiteUrl}'))+'/_layouts/hold.aspx?ID={ItemId}&List={ListId}'); return false;} if(pageid == 'audit') {STSNavigate(unescape(decodeURI('{SiteUrl}'))+'/_layouts/Reporting.aspx?Category=Auditing&backtype=item&ID={ItemId}&List={ListId}'); return false;} if(pageid == 'config') {STSNavigate(unescape(decodeURI('{SiteUrl}'))+'/_layouts/expirationconfig.aspx?ID={ItemId}&List={ListId}'); return false;}}, null); return false; 0x0 0x1 ContentType 0x01 898 Edit in Browser /_layouts/images/icxddoc.gif /personal/ralph/Blog/_layouts/formserver.aspx?XsnLocation={ItemUrl}&OpenIn=Browser&Source={Source} 0x0 0x1 FileType xsn 255 Edit in Browser /_layouts/images/icxddoc.gif /personal/ralph/Blog/_layouts/formserver.aspx?XmlLocation={ItemUrl}&OpenIn=Browser&Source={Source} 0x0 0x1 ProgId InfoPath.Document 255 Edit in Browser /_layouts/images/icxddoc.gif /personal/ralph/Blog/_layouts/formserver.aspx?XmlLocation={ItemUrl}&OpenIn=Browser&Source={Source} 0x0 0x1 ProgId InfoPath.Document.2 255 Edit in Browser /_layouts/images/icxddoc.gif /personal/ralph/Blog/_layouts/formserver.aspx?XmlLocation={ItemUrl}&OpenIn=Browser&Source={Source} 0x0 0x1 ProgId InfoPath.Document.3 255 Edit in Browser /_layouts/images/icxddoc.gif /personal/ralph/Blog/_layouts/formserver.aspx?XmlLocation={ItemUrl}&OpenIn=Browser&Source={Source} 0x0 0x1 ProgId InfoPath.Document.4 255 View in Browser /personal/ralph/Blog/_layouts/xlviewer.aspx?id={ItemUrl}&DefaultItemOpen=1 0x0 0x1 FileType xlsx 255 View in Browser /personal/ralph/Blog/_layouts/xlviewer.aspx?id={ItemUrl}&DefaultItemOpen=1 0x0 0x1 FileType xlsm 255 View in Browser /personal/ralph/Blog/_layouts/xlviewer.aspx?id={ItemUrl}&DefaultItemOpen=1 0x0 0x1 FileType xlsb 255 View in Browser /personal/ralph/Blog/_layouts/xlviewer.aspx?id={ItemUrl}&DefaultItemOpen=1 0x0 0x1 FileType ods 255 Document Set Version History javascript:SP.UI.ModalDialog.ShowPopupDialog('{SiteUrl}/_layouts/DocSetVersions.aspx?List={ListId}&ID={ItemId}') 0x0 0x0 ContentType 0x0120D520 330 Send To other location javascript:GoToPage('{SiteUrl}/_layouts/docsetsend.aspx?List={ListId}&ID={ItemId}') 0x0 0x0 ContentType 0x0120D520 350 |
|
|
|
|