January 12 was my last update to the bag-o-tricks. I couldn’t let two months go by without another refresh. There is a lot of stuff here I've already talked about. The code has been available via SVN for a while, but not in the convenient package.
The Goods
Binaries and Source [zip, 4.17MB]. Tested with Visual C# Express 2008.
The Details
- VS Copy-to-HTML - New!
- Blogged about it here.
- NotifyWorker - New!
- Blogged about it here.
- HueConverter - New!
- Makes it easy to create a pretty spectrum of colors for a number of items
- Animating Tile Panel
- Renamed AnimateNewItem property to AnimatesNewItem
- Made initial load not animate new items
- Polished the demo code
- CompositionTargetRenderingListener
- Added Dispose and used it where appropriate
- Added WireParentLoadedUnloaded helper method
- DemoCollection
- Added Reset command
- Moved to library assembly
- Extentions
- Added SelectResursive (see last blog post), among others
- FlipTile3D
- Moved to WrapperElement<Viewport3D>
- FolderPicker
- Moved to new SelectRecursive implementation
- WPFUtil
- Added HSB-RGB converter
- Created ‘Animate’ methods to abstract physics model. Moved FileTile3D, AnimatingTilePanel, and ZapDecorator to these.
- ZapScroller
- A lot cleaner. Removed a completely unnecessary layer of complexity.
- Added the ability to template the buttons. Thanks for the suggestion, Atul.
- WPF Set
- New in 3D! See blog post.
- General
- A bunch of renaming of namespaces. Most of the new stuff will exist under J832.Wpf
As always, the SVN location has been updated. Patches are always welcome. (I've had one taker on this. Very cool to do an apply patch. Would love to do it again.)
Enjoy and happy hacking!
21 comments:
This is great.
How much work would it be to tweak this to make it work in Silverlight?
hi,kevin ,Bag-o-Triks a good sample and application free source for learning wpf,i hvae a question than you i don't have e-mail than you i create blog in blogspot and i want writing colorizer code in a comment , i write code in my blog like http://work.j832.com/2008/02/xaml-serialization-with-wcf.html thank you alot
Hi Kevin,
Thanks for your helpful library!
I just used the Reveal component and found a small issue regarding the sizing of the content.
The code omits the horizontal and vertical alignment rules when they're set to stretch mode.
I did this minor change inside Reveal.cs and it works fine:
protected override Size ArrangeOverride(Size finalSize)
{
UIElement child = Child;
if (child != null)
{
double percent = AnimationProgress;
HorizontalRevealMode horizontalReveal = HorizontalReveal;
VerticalRevealMode verticalReveal = VerticalReveal;
double childWidth = child.DesiredSize.Width;
double childHeight = child.DesiredSize.Height;
if(HorizontalAlignment == HorizontalAlignment.Stretch && childWidth < finalSize.Width)
childWidth = finalSize.Width;
if(VerticalAlignment == VerticalAlignment.Stretch && childHeight < finalSize.Height)
childHeight = finalSize.Height;
double x = CalculateLeft(childWidth, percent, horizontalReveal);
double y = CalculateTop(childHeight, percent, verticalReveal);
child.Arrange(new Rect(x, y, childWidth, childHeight));
childWidth = child.RenderSize.Width;
childHeight = child.RenderSize.Height;
double width = CalculateWidth(childWidth, percent, horizontalReveal);
double height = CalculateHeight(childHeight, percent, verticalReveal);
return new Size(width, height);
}
return new Size();
}
Hi Kevin,
Can you explain why you chose to define WrapperElement<T> instead of simply inheriting from Decorator? They seem to be doing the same thing.
Cheers,
Yuval
Hi there,
Great stuff!!!
Regards
C# Disciple
I'm using the DatePicker, I really appreciate the work. When I set the value of DatePicker in my code, I'm no longer able to change the date through the datePicker dialog. Even when I set the readOnly property to false and the canEdit property to true, it still won't let me update the date. Is there anything that I'm missing.
endDate.Value = DateTime.Now;
endDate.CanEdit = true;
endDate.IsReadOnly = false;
Thanks!
Brandon Petersen
Hello,
I have the same problem as Brandom.
Also, could you explain in your blog how to change the string date format for other locales than English?
Thanks
I wish I could provide a solution, but it seemed to start to work without any problems. Not sure what changed for it to start to work.
Brandon
Brandon,
I've spent over an hour on this. It's because the datetime you're binding to has a Time element (perhaps DateTime.Now ?) Use DateTime.Now.Date instead. It's a bit of a bug in the calendar control in Unselect() (MonthCalendar.cs).
Additionally, I added the following to the constructor to work around the text formatting.
Language = System.Windows.Markup.XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name);
Good control, thanks.
A very nice set of controls but I can't get the date picker to appear on my form. After much fiddling I got the compiler to accept my uri to a library that only contains the month and date controls and classes (and which builds). I have added the controls to an existing xaml page exactly as per the demo app page and although it builds and runs. I can't see anything. I also haven't found any good beginners wpf control tutorials to try and work out what might or might not be wrong. Is it because the stack panel doesn't know what it is?
<StackPanel Orientation="Horizontal">
<Label>Start Date:</Label>
<ResourcingControls:DatePicker HorizontalAlignment="Center" VerticalAlignment="Top"
Width="200" Name="m_DatePicker" />
<Button ToolTip="Click here to move the schedule grid" IsEnabled="True">Move</Button>
<Rectangle Fill="Transparent" Stroke="Transparent" Width="100" />
<ComboBox SelectionChanged="RegionChanged" SelectedIndex="0" Width="200">
//ComboBoxItems
</ComboBox>
</StackPanel>
Hi the Bag is the great but I cann't find no descriptions in form of help file alaike MSDN's. So where I can find that help with descriptions of your PF controls from Bag?
Great work! Congratulations.
Hi!
great stuff!
I had a minor issue with displaying of datestrings.
I just replaced this line in DatePicker.cs in method DoFormat(DateTime):
CultureInfo cultureInfo = Language != null ? Language.GetSpecificCulture() : null;
with this one
CultureInfo cultureInfo = System.Threading.Thread.
CurrentThread.CurrentCulture;
Because we have to make sure the user sees the date in the way he wants to see (according to his culture).
Is there a specific reason you used the 'Language' property here?
Anyway, thank you again!
Thanks to Kevin Moore and Paul Spiteri.
[datePicker1.Value = DateTime.Now.Date;] is very helpful.
I'm using the DatePicker, I have some problem.
Two datepicker and Button was set in window. On button click event, first datepicker.value added 3 months.
That value was set second datepicker.
Then click first datepicker or second datepicker, second datepicker value changed today. Why cause this? Year 2008 to 2009?
Please help me.
DatePicker - Прикольный контрол. но шаг влево - шаг вправо и пиздец - не работает. А исходники - просто песня. Миллион-строк-кода-где-автор-поюзал-много-умных-слов. Имхо, автор перемудрил, ибо в итоге пытаться осознанно что-то переделать - бесполезная трата времени.
Тем не менее, автору спасибо и респект.
hi kevin
I justed wanted to announce you that i've started a project on codeplex - http://www.codeplex.com/BagOTricks
with the intention of porting several of your components to Silverlight. And to thank you for publishing this code, cause it helped me a lot.
Great work!
I use the DayContainerStyleSelector to change the style for each day (like showing weekends or company holidays background in a different color). Seems to work great except if you click previous or next the SelectStyle function is never called so styles are not updated. I am guessing if the date were changed they would not get updated either. I noticed there is a refresh for the templates, there should be an update for Styles as well.
Thanks
Hi Kevin, great demo, I like the 3D transitions, but it is using a lot of memory without releasing it (e. g. 20MB for each 3D Rotation ==> 1 GB after 50 rotations). I'm sad I can't use it in my application, hoping this will be solved in the next version...
Would be great if you have a hotfix for this!
Post a Comment