Git Product home page Git Product logo

bot's Introduction

BOT!

The Bag of Tricks (BOT) Started in December 2005. Kevin was working at Microsoft on v1 of Windows Presentation Foundation (WPF). He was blogging a lot of code samples and wanted to keep them all together and ensure everything kept working as features changed and evolved as WPF moved towards shipping.

The BOT grew to be an important resource for those learning and pushing the capabilities of WPF.

It now includes a set of helper libraries that are generally useful for .NET programming with an emphasis on building GUI applications targetting WPF (v4), Silverlight (v4) and Windows Phone 7.

It is actively maintained by Kevin and your friends at Pixel Lab.

NuGet

The BOT is on NuGet. Search for PixelLab.BOT.

Code Contracts

Parts of the Bag of Tricks are built using Code Contracts. You may wish to install and use these tools when you are working with BOT.

The MIT License

Copyright (c) 2010, 2011 Pixel Lab

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

bot's People

Contributors

kevmoo avatar loarabia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bot's Issues

AnimatingTilePanel Performance

I have an application with a TabControl and several TabItem.

Each TabItem has an AnimatingTilePanel. My ItemTemplate has a thumbnail image.

Even with ~100 max items per tile panel, the performance degrades and out of memory exceptions are occasionally thrown when switching tabs. Swapping out the AnimatingTilePanel for a plain old VirtualizingStackPanel shows a measureable performance increase and is error free.

Is AnimatingTilePanel just not able to handle that many items at that size? Or are there some tricks that I could be employing?

Demos does not work

After run WPF4 demo and choose whatever in menu it shows exception "Must use the rewriter when using Contract.Requies"

ReorderListBox selects items when dragging outside list

When an element is dragged outside the vertical bounds of the listbox, the item that was previously on top (or bottom) will get selected.

A workaround for this is:

        _myListBox.SelectionChanged += delegate
                {
                    if (_myListBox.SelectedIndex != -1)
                        _myListBox.SelectedIndex = -1;
                };

ReorderListBox doesn't support hybrid Winform applications

If a ReorderListBox will throw a NullReferenceException when used in a winform hybrid application. the reason is that the DragPreviewAdorner uses Application.Current, but this static property is not assigned when running in a winform application. A solution is to change the following method:

    private static void GetCurrentDPI(out double x, out double y)
    {
        Matrix m = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice;
        x = 96 / m.M11;
        y = 96 / m.M22;
    }

to

    private static void GetCurrentDPI(out double x, out double y, FrameworkElement element)
    {
        Matrix m = PresentationSource.FromVisual(element).CompositionTarget.TransformToDevice;
        x = 96 / m.M11;
        y = 96 / m.M22;
    }

and pass the current element in SetPreviewElement:

    public void SetPreviewElement(FrameworkElement element)
    {
        //...
        GetCurrentDPI(out x, out y, element);

Side note: the class NotifyWorker seems to have the same issue in the OnClientException method... haven't looked at how that could be handled. We aren't using that class.

Graph does not arrange according to available size

I'm pretty sure that on one of the old versions of the Graph control when I change the size of the window, and by that changing the available size of the Graph control, the children were re-arrange to use the available size.
The new version does not do that, it arrange the children as if it had all the space it require.

Thank you,
Ido.

Invalid .sln files

Since the great file move around, Demo_SL4.sln, Demo_WP7.sln, and Demo_WPF4.sln still have the old folder names in their project references, though Demo_All.sln properly reflects the new structure. The other solutions need to be updated to run in VS straight out of the box. I'd fix it myself and submit a pull, but at the moment I'm on a work computer without git. :(

Again as Issue 1

After run WPF4 demo and choose whatever in menu it shows exception "Must use the rewriter when using Contract.Requies"

It works only on some demos.
These does not work:
Animating Title Panel
Graphs
Org Tree
Set game
Treemap panel
Zap controler

Sample Images path

In wpf.Core.SampleImageHelper......GetDefaultPicturePaths() you might consider changing the literal path as it bombs out if you don't have your Pictures in the default location.

e.g.
change:
return new string[]{@"C:\Users\Public\Pictures\Sample Pictures",
Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)}.ToReadOnlyCollection();
to:
return new string[]{Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures) + @"\Sample Pictures",
Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)}.ToReadOnlyCollection();

Mind you anyone able to use a non-default location could probably figure this out for themselves.

ReorderListBox bugs out when ScrollViewer is active

Whenever a listbox contains more items than it can handle, by default it will display a scrollviewer.
The reordering will stop to function properly when this happens.

The first thing i notice is that because of the standard virtualisation of the ItemsPanel, Transform item breaks because the item with an index higher than the ones visible will return null at ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement. This however is easily fixed by declaratively implementing a non virtualized ItemsPanel.

Second, the position of the overlay adorner is not updated when scrolling occurs. The adorner scrolls with the content of the ListBox and thus moves up or down.

The behaviour is easily reproduced by setting a ListBox height to 120 in the demo app.

Any clues on how to fix the second issue/observation?

Regards,
avsomeren

RotateTransition bug

if TransitionPresenter content have Alignment (eg: Center), and have no background. The animation could't get the margin. The animation will cause content stretch.

Minesweeper demo throws exception on win/loss

The following on line 385 in minesweeper.cs causes an exception (something along the lines of 'attempt to throw propertychange event for a property that doesn't exist'):

    public const string StatePropertyName = "StateLeft";

It should read:

    public const string StatePropertyName = "State";

The exception occurs when you win or lose the game.

In addition, the "square_PropertyChanged" method uses a hard-coded string "State" and should reference the const above.

Add breadth first traversal to mirror the depth-first traversal in SelectRecursive

Implementation thoughts:

  1. Add a SelectRecursiveAtLevel method that only returns items at a provided depth n
  2. For the breadth first version, just call SelectrecursizeAtLevel for 0 -> N (where we stop once an empty level is found)
  3. Allows for a breadth first search where one can provide a max level paramater
  4. To keep the implementation cheap, this would require multiple iterations of the provided source collection
    • This is probably better than the potentially huge state the method would have to maintain to keep track of where the traversal is

Add 'Watch Property' extension method

public static T WatchProperty(this T source, Action handler, params string[] propertyNames) where T : INotifyPropertyChanged

  • takes 1 (or more?) property names + action to handle one property change
  • in debug, checks to make sure the object actually has a property of that name -> great baby sitter that the property exists
  • returns the source object to allow chaining...cool!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.