├── sl4
├── SL4.Demo
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── AppManifest.xml
│ │ └── OutOfBrowserSettings.xml
│ ├── Assets
│ │ └── sprite.png
│ ├── packages.config
│ ├── App.xaml
│ ├── WelcomePage.xaml.cs
│ ├── SpriteButtonPage.xaml.cs
│ ├── EditableTextBlockPage.xaml.cs
│ ├── SpinningProgressControlPage.xaml.cs
│ ├── PanZoomPage.xaml.cs
│ ├── ScrollBehaviorPage.xaml.cs
│ ├── SpinningProgressControlPage.xaml
│ ├── DoubleClickBehaviorPage.xaml.cs
│ ├── ModalControlPage.xaml
│ ├── DemoHost.xaml
│ ├── WelcomePage.xaml
│ ├── DoubleClickBehaviorPage.xaml
│ ├── EditableTextBlockPage.xaml
│ ├── PanZoomPage.xaml
│ ├── FlipControlPage.xaml
│ ├── FlipControlPage.xaml.cs
│ ├── DemoHost.xaml.cs
│ ├── SpriteButtonPage.xaml
│ ├── App.xaml.cs
│ ├── ModalControlPage.xaml.cs
│ └── ScrollBehaviorPage.xaml
├── SL4
│ ├── Images
│ │ ├── cross.png
│ │ ├── pencil.png
│ │ └── tick.png
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── packages.config
│ ├── LoadState.cs
│ ├── AsyncValueLoadException.cs
│ ├── GridLineControl.xaml
│ ├── SpinningProgressControl.xaml
│ ├── CollapseOnDisableBehavior.cs
│ ├── SLExtentions.cs
│ ├── ResourceHelpers.cs
│ ├── DiscreteSlider.cs
│ ├── StretchDirection.cs
│ ├── AsBigAsYouWantPanel.cs
│ ├── Helpers_Phone.cs
│ └── IAsyncValue.cs
├── Common
│ ├── packages.config
│ ├── KeyBinding.cs
│ └── CommandKeyMapper.cs
└── Test
│ ├── App.xaml
│ ├── Properties
│ ├── AppManifest.xml
│ ├── OutOfBrowserSettings.xml
│ └── AssemblyInfo.cs
│ ├── App.xaml.cs
│ ├── Helpers
│ ├── TestChangeable.cs
│ └── AssertPlus.cs
│ ├── ContractTests.cs
│ ├── EnumConverterTest.cs
│ ├── SortHelperTests.cs
│ └── PropertyWatcherTest.cs
├── net40-client
├── Common
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ICommandProxy.cs
│ ├── IDynamicValue.cs
│ ├── DeadCommand.cs
│ ├── BrushHelper.cs
│ ├── DebugTrace.cs
│ ├── SimpleValueConverter.cs
│ ├── Line.cs
│ ├── HueConverter.cs
│ ├── PixelLab.Common.csproj
│ └── DependencyPropHelper.cs
├── Core
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── System
│ │ ├── INotifyDataErrorInfo.cs
│ │ └── DataErrorsChangedEventArgs.cs
│ ├── InstanceFactory.cs
│ ├── ReaderWriterLockHelper.cs
│ ├── StreamHelpers.cs
│ ├── FuncEnumerable.cs
│ ├── CompositionHelpers.cs
│ ├── DBUtil.cs
│ ├── Contract.cs
│ ├── CastList.cs
│ ├── SortedObservableEnumerable.cs
│ ├── Changeable.cs
│ ├── ActionOnDispose.cs
│ ├── TypedDictionaryExtensions.cs
│ ├── FilteredObservableEnumerable.cs
│ ├── WrappedLock.cs
│ ├── DataErrorHelper.cs
│ └── PixelLab.Core.csproj
├── Bot.Demo
│ ├── icon.ico
│ ├── logo.png
│ ├── KevinButton
│ │ ├── up.jpg
│ │ ├── down.jpg
│ │ ├── left.jpg
│ │ ├── middle.jpg
│ │ ├── normal.jpg
│ │ ├── pressed.jpg
│ │ ├── right.jpg
│ │ ├── upleft.jpg
│ │ ├── upright.jpg
│ │ ├── disabled.jpg
│ │ ├── downleft.jpg
│ │ └── downright.jpg
│ ├── FolderPicker
│ │ ├── drive.png
│ │ ├── ChildSelection.cs
│ │ └── LocalDrives.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TransitionPresenter
│ │ └── star.png
│ ├── packages.config
│ ├── ShowElementPage.xaml
│ ├── TreeMapPanelPage.xaml
│ ├── Interactive3DPage.xaml
│ ├── Core
│ │ ├── IsStringEmptyConverter.cs
│ │ ├── DemoMetadataAttribute.cs
│ │ ├── DemoMetadataProperties.cs
│ │ ├── DemoMetadata.cs
│ │ └── XamlComponent.cs
│ ├── App.xaml.cs
│ ├── ZapPage.xaml.cs
│ ├── FlipTile3D
│ │ └── FlipTile3DPage.xaml
│ ├── MainPage.xaml.cs
│ ├── TreeMapPanelPage.xaml.cs
│ ├── NumericUpDownPage.xaml
│ ├── VisualTreeViewer
│ │ ├── VisualTreeViewerPage.xaml.cs
│ │ ├── VisualTreeViewerPage.xaml
│ │ └── VisualTreeItem.cs
│ ├── VSCopyToHtmlPage.xaml
│ ├── ReorderListboxPage.xaml.cs
│ ├── Hex
│ │ └── HexHelper.cs
│ ├── ShowElementPage.xaml.cs
│ ├── ListPagerPage.xaml.cs
│ ├── MineSweeper
│ │ └── MineSweeperPage.xaml.cs
│ ├── ColorPicker
│ │ └── Code.cs
│ ├── TreeViewHelperClasses
│ │ ├── DataTree.cs
│ │ └── TreeViewHelperPage.xaml
│ ├── ReorderListboxPage.xaml
│ ├── OrgTree
│ │ └── OrgTreePage.xaml.cs
│ ├── AnimatingTilePanelPage.xaml.cs
│ ├── IntroductionPage.xaml
│ ├── InfoTextBoxPage.xaml
│ ├── MainPage.xaml
│ ├── TreeViewDoubleClickPage.xaml
│ ├── BlockBarPage.xaml
│ ├── TreeViewDoubleClickPage.xaml.cs
│ └── Set
│ │ └── SetPage.xaml.cs
└── Bot
│ ├── packages.config
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── TemplateBorder.cs
│ ├── Transitions
│ ├── TransitionSelector.cs
│ ├── FadeTransition.cs
│ ├── TwoWayTransitionSelector.cs
│ └── Transition.cs
│ ├── RevealModeVertical.cs
│ ├── OrgTree.cs
│ ├── RevealModeHorizontal.cs
│ ├── ColorBrushConverter.cs
│ ├── themes
│ ├── generic.xaml
│ ├── TemplateBorder.generic.xaml
│ └── NumericUpDown.generic.xaml
│ ├── ButtonBase3D.cs
│ ├── WrapperElement.cs
│ ├── TreeMap3DUserControl.xaml.cs
│ ├── BlockBarRect.cs
│ ├── BlockBarCircle.cs
│ ├── InfoTextBox.cs
│ └── OrgTreeItem.cs
├── CommonAssemblyInfo.cs
├── lib
├── Microsoft.Xaml.Tools.dll
└── Microsoft.Xaml.Tools.pdb
├── packages
├── Prism.4.1.0.0
│ ├── Prism.4.1.0.0.nupkg
│ └── lib
│ │ ├── SL4
│ │ ├── Microsoft.Practices.Prism.dll
│ │ ├── System.Windows.Interactivity.dll
│ │ ├── Microsoft.Expression.Interactions.dll
│ │ └── Microsoft.Practices.Prism.Interactivity.dll
│ │ ├── SL5
│ │ ├── Microsoft.Practices.Prism.dll
│ │ ├── System.Windows.Interactivity.dll
│ │ ├── Microsoft.Expression.Interactions.dll
│ │ └── Microsoft.Practices.Prism.Interactivity.dll
│ │ └── NET40
│ │ ├── Microsoft.Practices.Prism.dll
│ │ ├── System.Windows.Interactivity.dll
│ │ ├── Microsoft.Expression.Interactions.dll
│ │ └── Microsoft.Practices.Prism.Interactivity.dll
├── CommonServiceLocator.1.0
│ ├── CommonServiceLocator.1.0.nupkg
│ └── lib
│ │ ├── SL30
│ │ └── Microsoft.Practices.ServiceLocation.dll
│ │ └── NET35
│ │ ├── Microsoft.Practices.ServiceLocation.dll
│ │ └── Microsoft.Practices.ServiceLocation.pdb
└── repositories.config
├── .gitignore
├── XamlAssemblyInfo.cs
├── sl5
├── SL5
│ └── packages.config
└── Common
│ └── packages.config
├── targets
├── SL4.targets
├── SL5.targets
├── NET4.targets
├── SL_shared.targets
├── Contracts.targets
└── BuildShared.targets
├── PixelLab.Core.nuspec
├── PixelLab.BOT.nuspec
├── PixelLab.Common.nuspec
└── README.md
/sl4/SL4.Demo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/net40-client/Common/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/net40-client/Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/CommonAssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/CommonAssemblyInfo.cs
--------------------------------------------------------------------------------
/sl4/SL4/Images/cross.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/sl4/SL4/Images/cross.png
--------------------------------------------------------------------------------
/sl4/SL4/Images/pencil.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/sl4/SL4/Images/pencil.png
--------------------------------------------------------------------------------
/sl4/SL4/Images/tick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/sl4/SL4/Images/tick.png
--------------------------------------------------------------------------------
/lib/Microsoft.Xaml.Tools.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/lib/Microsoft.Xaml.Tools.dll
--------------------------------------------------------------------------------
/lib/Microsoft.Xaml.Tools.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/lib/Microsoft.Xaml.Tools.pdb
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/icon.ico
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/logo.png
--------------------------------------------------------------------------------
/sl4/SL4.Demo/Assets/sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/sl4/SL4.Demo/Assets/sprite.png
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/up.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/up.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/down.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/down.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/left.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/left.jpg
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/Prism.4.1.0.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/Prism.4.1.0.0.nupkg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/FolderPicker/drive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/FolderPicker/drive.png
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/middle.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/middle.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/normal.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/normal.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/pressed.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/pressed.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/right.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/right.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/upleft.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/upleft.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/upright.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/upright.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/disabled.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/disabled.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/downleft.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/downleft.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/KevinButton/downright.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/KevinButton/downright.jpg
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/Properties/AssemblyInfo.cs
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/TransitionPresenter/star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/net40-client/Bot.Demo/TransitionPresenter/star.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | _build
2 | obj
3 | *.user
4 | *.suo
5 | .DS_Store
6 | *.userprefs
7 | *.vs10x
8 | StyleCop.Cache
9 | Thumbs.db
10 | *.sln.docstates
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/FolderPicker/ChildSelection.cs:
--------------------------------------------------------------------------------
1 | namespace PixelLab.Wpf.Demo.FolderPicker
2 | {
3 | public enum ChildSelection { All, Some, None }
4 | }
--------------------------------------------------------------------------------
/XamlAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Markup;
2 |
3 | [assembly: XmlnsDefinition("http://schemas.thinkpixellab.com/2011/xaml/presentation", "PixelLab.Common")]
4 |
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/SL4/Microsoft.Practices.Prism.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/SL4/Microsoft.Practices.Prism.dll
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/SL5/Microsoft.Practices.Prism.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/SL5/Microsoft.Practices.Prism.dll
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/NET40/Microsoft.Practices.Prism.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/NET40/Microsoft.Practices.Prism.dll
--------------------------------------------------------------------------------
/sl4/SL4/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Markup;
2 |
3 | [assembly: XmlnsDefinition("http://schemas.thinkpixellab.com/2011/xaml/presentation", "PixelLab.SL")]
4 |
--------------------------------------------------------------------------------
/packages/CommonServiceLocator.1.0/CommonServiceLocator.1.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/CommonServiceLocator.1.0/CommonServiceLocator.1.0.nupkg
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/NET40/System.Windows.Interactivity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/NET40/System.Windows.Interactivity.dll
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/SL4/System.Windows.Interactivity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/SL4/System.Windows.Interactivity.dll
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/SL5/System.Windows.Interactivity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/SL5/System.Windows.Interactivity.dll
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/NET40/Microsoft.Expression.Interactions.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/NET40/Microsoft.Expression.Interactions.dll
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/SL4/Microsoft.Expression.Interactions.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/SL4/Microsoft.Expression.Interactions.dll
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/SL5/Microsoft.Expression.Interactions.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/SL5/Microsoft.Expression.Interactions.dll
--------------------------------------------------------------------------------
/sl4/SL4/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sl5/SL5/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/SL4/Microsoft.Practices.Prism.Interactivity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/SL4/Microsoft.Practices.Prism.Interactivity.dll
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/SL5/Microsoft.Practices.Prism.Interactivity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/SL5/Microsoft.Practices.Prism.Interactivity.dll
--------------------------------------------------------------------------------
/sl4/Common/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sl4/SL4/LoadState.cs:
--------------------------------------------------------------------------------
1 | namespace PixelLab.SL
2 | {
3 | public enum LoadState
4 | {
5 | Unloaded,
6 | Loading,
7 | Loaded,
8 | Error
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/sl5/Common/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/net40-client/Bot/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/packages/Prism.4.1.0.0/lib/NET40/Microsoft.Practices.Prism.Interactivity.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/Prism.4.1.0.0/lib/NET40/Microsoft.Practices.Prism.Interactivity.dll
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sl4/Test/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/packages/CommonServiceLocator.1.0/lib/SL30/Microsoft.Practices.ServiceLocation.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/CommonServiceLocator.1.0/lib/SL30/Microsoft.Practices.ServiceLocation.dll
--------------------------------------------------------------------------------
/packages/CommonServiceLocator.1.0/lib/NET35/Microsoft.Practices.ServiceLocation.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/CommonServiceLocator.1.0/lib/NET35/Microsoft.Practices.ServiceLocation.dll
--------------------------------------------------------------------------------
/packages/CommonServiceLocator.1.0/lib/NET35/Microsoft.Practices.ServiceLocation.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkpixellab/bot/HEAD/packages/CommonServiceLocator.1.0/lib/NET35/Microsoft.Practices.ServiceLocation.pdb
--------------------------------------------------------------------------------
/net40-client/Common/ICommandProxy.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace PixelLab.Common
4 | {
5 | public interface ICommandProxy
6 | {
7 | object GetCommandOwner(DependencyObject source);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/net40-client/Common/IDynamicValue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace PixelLab.Common
4 | {
5 | public interface IDynamicValue
6 | {
7 | T Value { get; }
8 | event EventHandler ValueChanged;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/sl4/Test/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/App.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/net40-client/Bot/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Markup;
3 |
4 | [assembly: ThemeInfo(ResourceDictionaryLocation.SourceAssembly, ResourceDictionaryLocation.SourceAssembly)]
5 | [assembly: XmlnsDefinition("http://schemas.thinkpixellab.com/2011/xaml/presentation", "PixelLab.Wpf")]
6 |
--------------------------------------------------------------------------------
/sl4/SL4/AsyncValueLoadException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace PixelLab.SL
4 | {
5 | public class AsyncValueLoadException : Exception
6 | {
7 | public AsyncValueLoadException(Exception innerException) : base("An exception was thrown while loading an async value.", innerException) { }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/targets/SL4.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | v4.0
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/targets/SL5.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | v5.0
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/WelcomePage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 | using PixelLab.Demo.Core;
3 |
4 | namespace PixelLab.SL.Demo
5 | {
6 | [DemoMetadata("Welcome")]
7 | public partial class WelcomePage : UserControl
8 | {
9 | public WelcomePage()
10 | {
11 | InitializeComponent();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/ShowElementPage.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/TreeMapPanelPage.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/SpriteButtonPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 | using PixelLab.Demo.Core;
3 |
4 | namespace PixelLab.SL.Demo
5 | {
6 | [DemoMetadata("Sprite Button")]
7 | public partial class SpriteButtonPage : UserControl
8 | {
9 | public SpriteButtonPage()
10 | {
11 | InitializeComponent();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/Interactive3DPage.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/EditableTextBlockPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 | using PixelLab.Demo.Core;
3 |
4 | namespace PixelLab.SL.Demo
5 | {
6 | [DemoMetadata("EditableTextBlock")]
7 | public partial class EditableTextBlockPage : UserControl
8 | {
9 | public EditableTextBlockPage()
10 | {
11 | InitializeComponent();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/net40-client/Bot/TemplateBorder.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 |
4 | namespace PixelLab.Wpf
5 | {
6 | public class TemplateBorder : Border
7 | {
8 | static TemplateBorder()
9 | {
10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(TemplateBorder), new FrameworkPropertyMetadata(typeof(TemplateBorder)));
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/targets/NET4.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | v4.0
7 | Client
8 |
9 |
10 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/SpinningProgressControlPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 | using PixelLab.Demo.Core;
3 |
4 | namespace PixelLab.SL.Demo
5 | {
6 | [DemoMetadata("SpinningProgressControl")]
7 | public partial class SpinningProgressControlPage : UserControl
8 | {
9 | public SpinningProgressControlPage()
10 | {
11 | InitializeComponent();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/net40-client/Core/System/INotifyDataErrorInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace System.ComponentModel
4 | {
5 | public interface INotifyDataErrorInfo
6 | {
7 | // Events
8 | event EventHandler ErrorsChanged;
9 |
10 | // Methods
11 | IEnumerable GetErrors(string propertyName);
12 |
13 | // Properties
14 | bool HasErrors { get; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/net40-client/Core/System/DataErrorsChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace System.ComponentModel
2 | {
3 | public sealed class DataErrorsChangedEventArgs : EventArgs
4 | {
5 | // Methods
6 | public DataErrorsChangedEventArgs(string propertyName)
7 | {
8 | this.PropertyName = propertyName;
9 | }
10 |
11 | // Properties
12 | public string PropertyName { get; private set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/Core/IsStringEmptyConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using PixelLab.Common;
3 |
4 | namespace PixelLab.Wpf.Demo.Core
5 | {
6 | public class IsStringEmptyConverter : SimpleValueConverter
7 | {
8 | protected override Visibility ConvertBase(string input)
9 | {
10 | return input.IsNullOrWhiteSpace() ? Visibility.Collapsed : Visibility.Visible;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/Properties/OutOfBrowserSettings.xml:
--------------------------------------------------------------------------------
1 |
2 | Bag of Tricks - Silverlight
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/sl4/SL4/GridLineControl.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sl4/Test/Properties/OutOfBrowserSettings.xml:
--------------------------------------------------------------------------------
1 |
2 | Test.Silverlight Application on your desktop; at home, at work or on the go.
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/net40-client/Bot/Transitions/TransitionSelector.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace PixelLab.Wpf.Transitions
4 | {
5 | // Allows different transitions to run based on the old and new contents
6 | // Override the SelectTransition method to return the transition to apply
7 | public class TransitionSelector : DependencyObject
8 | {
9 | public virtual Transition SelectTransition(object oldContent, object newContent)
10 | {
11 | return null;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/PanZoomPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using PixelLab.Demo.Core;
4 |
5 | namespace PixelLab.SL.Demo
6 | {
7 | [DemoMetadata("PanZoom")]
8 | public partial class PanZoomPage : UserControl
9 | {
10 | public PanZoomPage()
11 | {
12 | InitializeComponent();
13 | }
14 |
15 | private void AsBigAsYouWantPanel_SizeChanged(object sender, SizeChangedEventArgs e)
16 | {
17 | PanZoom.CenterContent();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/sl4/SL4/SpinningProgressControl.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/packages/repositories.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/ScrollBehaviorPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Windows.Controls;
3 | using PixelLab.Common;
4 | using PixelLab.Demo.Core;
5 |
6 | namespace PixelLab.SL.Demo
7 | {
8 | [DemoMetadata("ScrollBehavior", "A behavior to attach to a ScrollViewer to expose scroll direction commands.")]
9 | public partial class ScrollBehaviorPage : UserControl
10 | {
11 | public ScrollBehaviorPage()
12 | {
13 | InitializeComponent();
14 |
15 | _demoListBox.ItemsSource = Enumerable.Range(1, 10).Select(i => "Item {0}".DoFormat(i)).ToList();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/sl4/Test/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Windows;
3 | using Microsoft.Silverlight.Testing;
4 |
5 | namespace PixelLab.Test
6 | {
7 | public partial class App : Application
8 | {
9 | public App()
10 | {
11 | this.Startup += this.Application_Startup;
12 | this.UnhandledException += (sender, args) => Debugger.Break();
13 |
14 | InitializeComponent();
15 | }
16 |
17 | private void Application_Startup(object sender, StartupEventArgs e)
18 | {
19 | RootVisual = UnitTestSystem.CreateTestPage();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/sl4/SL4.Demo/SpinningProgressControlPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/targets/SL_shared.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $(DefineConstants);SILVERLIGHT
6 | Silverlight
7 | $(TargetFrameworkVersion)
8 | true
9 | true
10 | true
11 | true
12 | Library
13 |
14 |
15 |
--------------------------------------------------------------------------------
/net40-client/Bot/RevealModeVertical.cs:
--------------------------------------------------------------------------------
1 | namespace PixelLab.Wpf
2 | {
3 | public enum VerticalRevealMode
4 | {
5 | ///
6 | /// No vertical reveal animation.
7 | ///
8 | None,
9 |
10 | ///
11 | /// Reveal from top to bottom.
12 | ///
13 | FromTopToBottom,
14 |
15 | ///
16 | /// Reveal from bottom to top.
17 | ///
18 | FromBottomToTop,
19 |
20 | ///
21 | /// Reveal from the center to the bounding edge.
22 | ///
23 | FromCenterToEdge,
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 | using System.Linq;
3 | using System.Windows;
4 | using System.Windows.Media;
5 | using PixelLab.Common;
6 |
7 | namespace PixelLab.Wpf.Demo
8 | {
9 | public partial class App : Application
10 | {
11 | public App()
12 | {
13 | InitializeComponent();
14 | }
15 |
16 | public static readonly ReadOnlyCollection DemoColors =
17 | "#E2602D,#1E94C0,#B7596B,#FF9C00,#93C6B9,#70634D,#FDCE4E,#759C00"
18 | .Split(',')
19 | .Select(cs => (Color)ColorConverter.ConvertFromString(cs))
20 | .ToReadOnlyCollection();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/net40-client/Bot/OrgTree.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 |
4 | namespace PixelLab.Wpf
5 | {
6 | public class OrgTree : ItemsControl
7 | {
8 | static OrgTree()
9 | {
10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(OrgTree), new FrameworkPropertyMetadata(typeof(OrgTree)));
11 | }
12 |
13 | protected override DependencyObject GetContainerForItemOverride()
14 | {
15 | return new OrgTreeItem();
16 | }
17 |
18 | protected override bool IsItemItsOwnContainerOverride(object item)
19 | {
20 | return item is OrgTreeItem;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/DoubleClickBehaviorPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using Microsoft.Practices.Prism.Commands;
4 | using PixelLab.Demo.Core;
5 |
6 | namespace PixelLab.SL.Demo
7 | {
8 | [DemoMetadata("DoubleClickBehavior")]
9 | public partial class DoubleClickBehaviorPage : UserControl
10 | {
11 | public DoubleClickBehaviorPage()
12 | {
13 | DataContext = new DelegateCommand((param) =>
14 | {
15 | MessageBox.Show(param, "The double click command has been fired.", MessageBoxButton.OK);
16 | });
17 |
18 | InitializeComponent();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/net40-client/Bot/RevealModeHorizontal.cs:
--------------------------------------------------------------------------------
1 | namespace PixelLab.Wpf
2 | {
3 | public enum HorizontalRevealMode
4 | {
5 | ///
6 | /// No horizontal reveal animation.
7 | ///
8 | None,
9 |
10 | ///
11 | /// Reveal from the left to the right.
12 | ///
13 | FromLeftToRight,
14 |
15 | ///
16 | /// Reveal from the right to the left.
17 | ///
18 | FromRightToLeft,
19 |
20 | ///
21 | /// Reveal from the center to the bounding edge.
22 | ///
23 | FromCenterToEdge,
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sl4/Test/Helpers/TestChangeable.cs:
--------------------------------------------------------------------------------
1 | using PixelLab.Common;
2 |
3 | namespace PixelLab.Test.Helpers
4 | {
5 | internal class TestChangeable : Changeable
6 | {
7 | private int _foo, _bar, _baz;
8 |
9 | public int Foo
10 | {
11 | get { return _foo; }
12 | set { UpdateProperty("Foo", ref _foo, value); }
13 | }
14 |
15 | public int Bar
16 | {
17 | get { return _bar; }
18 | set { UpdateProperty("Foo", ref _bar, value); }
19 | }
20 |
21 | public int Baz
22 | {
23 | get { return _baz; }
24 | set { UpdateProperty("Baz", ref _baz, value); }
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/ZapPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 | using PixelLab.Common;
3 | using PixelLab.Demo.Core;
4 |
5 | namespace PixelLab.Wpf.Demo
6 | {
7 | [DemoMetadata("Zap Scroller", "An example of the union between custom elements, custom animation, and data binding.")]
8 | public partial class ZapPage : Page
9 | {
10 | public ZapPage()
11 | {
12 | InitializeComponent();
13 |
14 | m_tabItemColors.DataContext = m_strings;
15 | }
16 |
17 | private readonly DemoCollection m_strings =
18 | DemoCollection.Create(new string[] { "red", "orange", "yellow", "green", "blue", "violet" }, 6, 0, 12);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/ModalControlPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/net40-client/Common/DeadCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace PixelLab.Common
5 | {
6 | public class DeadCommand : ICommand
7 | {
8 | private DeadCommand() { }
9 |
10 | public bool CanExecute(object parameter)
11 | {
12 | return false;
13 | }
14 |
15 | public void Execute(object parameter)
16 | {
17 | throw new NotSupportedException("This is a dead command. It never works.");
18 | }
19 |
20 | public static readonly ICommand Instance = new DeadCommand();
21 |
22 | event EventHandler ICommand.CanExecuteChanged
23 | {
24 | add { }
25 | remove { }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/DemoHost.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/FlipTile3D/FlipTile3DPage.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/net40-client/Core/InstanceFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace PixelLab.Common
4 | {
5 | public static class InstanceFactory
6 | {
7 | ///
8 | /// A generic convenience method to create the provided type.
9 | ///
10 | public static T CreateInstance(params object[] args)
11 | {
12 | return (T)typeof(T).CreateInstance(args);
13 | }
14 |
15 | ///
16 | /// A convenience extension method for Type that calls Activator.CreateInstance
17 | ///
18 | /// A new instance of the provided object.
19 | public static object CreateInstance(this Type type, params object[] args)
20 | {
21 | return Activator.CreateInstance(type, args);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/net40-client/Core/ReaderWriterLockHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.Contracts;
3 | using System.Threading;
4 |
5 | namespace PixelLab.Common
6 | {
7 | public static class ReaderWriterLockHelper
8 | {
9 | public static IDisposable BeginReadLock(this ReaderWriterLockSlim slimLock)
10 | {
11 | Contract.Requires(slimLock != null);
12 | slimLock.EnterReadLock();
13 | return new ActionOnDispose(slimLock.ExitReadLock);
14 | }
15 |
16 | public static IDisposable BeginWriteLock(this ReaderWriterLockSlim slimLock)
17 | {
18 | Contract.Requires(slimLock != null);
19 | slimLock.EnterWriteLock();
20 | return new ActionOnDispose(slimLock.ExitWriteLock);
21 | }
22 | } //*** class LockHelper
23 | } //*** namespace PixelLab.Common
24 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Windows.Controls;
3 | using PixelLab.Demo.Core;
4 |
5 | namespace PixelLab.Wpf.Demo
6 | {
7 | public partial class MainPage : Page
8 | {
9 | public MainPage()
10 | {
11 | InitializeComponent();
12 |
13 | m_sampleList.ItemsSource = DemoMetadata.GetDemos(typeof(MainPage).Assembly, "Introduction");
14 |
15 | m_contentFrame.Navigating += (sender, e) =>
16 | {
17 | if (e.Uri != null)
18 | {
19 | var uri = e.Uri.ToString();
20 | if (uri.StartsWith("http://"))
21 | {
22 | Process.Start(uri);
23 | e.Cancel = true;
24 | }
25 | }
26 | };
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/net40-client/Bot/ColorBrushConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Data;
2 | using System.Windows.Media;
3 | using PixelLab.Common;
4 |
5 | namespace PixelLab.Wpf
6 | {
7 | [ValueConversion(typeof(Color), typeof(SolidColorBrush))]
8 | public class ColorBrushConverter : SimpleValueConverter
9 | {
10 | protected override SolidColorBrush ConvertBase(Color input)
11 | {
12 | return new SolidColorBrush(input);
13 | }
14 |
15 | public static ColorBrushConverter Instance
16 | {
17 | get
18 | {
19 | if (s_instance == null)
20 | {
21 | s_instance = new ColorBrushConverter();
22 | }
23 | return s_instance;
24 | }
25 | }
26 |
27 | private static ColorBrushConverter s_instance;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/net40-client/Core/StreamHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace PixelLab.Common
4 | {
5 | public static class StreamHelpers
6 | {
7 | public static string ReadAllAsString(this Stream stream)
8 | {
9 | using (var sr = new StreamReader(stream))
10 | {
11 | return sr.ReadToEnd();
12 | }
13 | }
14 |
15 | public static byte[] ReadAllAsBytes(this Stream stream)
16 | {
17 | byte[] buffer = new byte[16 * 1024];
18 | using (MemoryStream ms = new MemoryStream())
19 | {
20 | int read;
21 | while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
22 | {
23 | ms.Write(buffer, 0, read);
24 | }
25 | return ms.ToArray();
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/net40-client/Bot/themes/generic.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/WelcomePage.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/net40-client/Bot/themes/TemplateBorder.generic.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sl4/Test/ContractTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using PixelLab.Contracts;
4 | using PixelLab.Test.Helpers;
5 |
6 | namespace PixelLab.Test.SL
7 | {
8 | [TestClass]
9 | public class ContractTests
10 | {
11 | [TestMethod]
12 | public void TestRequireFalse()
13 | {
14 | AssertPlus.ExceptionThrown(() => Contract.Requires(false));
15 | var ex = AssertPlus.ExceptionThrown(() => Contract.Requires(false, "foo"));
16 | Assert.AreEqual(ex.Message, "foo");
17 |
18 | AssertPlus.ExceptionThrown(() => Contract.Requires(false));
19 | var ax = AssertPlus.ExceptionThrown(() => Contract.Requires(false, "bar"));
20 | Assert.AreEqual(ax.Message, "bar");
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/sl4/SL4/CollapseOnDisableBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Interactivity;
4 |
5 | namespace PixelLab.SL
6 | {
7 | public class CollapseOnDisableBehavior : Behavior
8 | {
9 | protected override void OnAttached()
10 | {
11 | base.OnAttached();
12 | this.AssociatedObject.IsEnabledChanged += AssociatedObject_IsEnabledChanged;
13 | }
14 |
15 | protected override void OnDetaching()
16 | {
17 | AssociatedObject.IsEnabledChanged -= AssociatedObject_IsEnabledChanged;
18 | base.OnDetaching();
19 | }
20 |
21 | private void AssociatedObject_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
22 | {
23 | AssociatedObject.Visibility = AssociatedObject.IsEnabled ? Visibility.Visible : Visibility.Collapsed;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/targets/Contracts.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1
5 | True
6 | False
7 | True
8 | True
9 | Full
10 | DoNotBuild
11 |
12 |
13 | True
14 | Build
15 |
16 |
17 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/TreeMapPanelPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 | using System.Windows.Shapes;
6 | using PixelLab.Common;
7 | using PixelLab.Demo.Core;
8 |
9 | namespace PixelLab.Wpf.Demo
10 | {
11 | [DemoMetadata("TreeMapPanel", "Another example of a custom panel.")]
12 | public partial class TreeMapPanelPage : Page
13 | {
14 | public TreeMapPanelPage()
15 | {
16 | InitializeComponent();
17 |
18 | m_colors
19 | .Select(b => new Rectangle() { Fill = b, Margin = new Thickness(2) })
20 | .ForEach(r =>
21 | {
22 | TreeMapPanel.SetArea(r, Util.Rnd.NextDouble());
23 | m_treeMap.Children.Add(r);
24 | });
25 | }
26 |
27 | private readonly DemoCollection m_colors = DemoCollection.Create(
28 | App.DemoColors.Select(c => c.ToCachedBrush()).ToArray(), 20, 0, 40);
29 | }
30 | }
--------------------------------------------------------------------------------
/net40-client/Core/FuncEnumerable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | #if CONTRACTS_FULL
4 | using System.Diagnostics.Contracts;
5 | #else
6 | using PixelLab.Contracts;
7 | #endif
8 |
9 | namespace PixelLab.Common
10 | {
11 | public class FuncEnumerable : IEnumerable
12 | {
13 | public FuncEnumerable(Func> func)
14 | {
15 | Contract.Requires(func != null);
16 | m_enumeratorFunc = func;
17 | }
18 |
19 | public IEnumerator GetEnumerator()
20 | {
21 | return m_enumeratorFunc();
22 | }
23 |
24 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
25 | {
26 | return GetEnumerator();
27 | }
28 |
29 | private readonly Func> m_enumeratorFunc;
30 |
31 | public static FuncEnumerable Get(Func> func)
32 | {
33 | return new FuncEnumerable(func);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/net40-client/Common/BrushHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Windows.Media;
3 |
4 | namespace PixelLab.Common
5 | {
6 | public static class BrushHelper
7 | {
8 | public static SolidColorBrush ToBrush(this Color color)
9 | {
10 | return new SolidColorBrush(color);
11 | }
12 |
13 | public static SolidColorBrush ToCachedBrush(this Color color)
14 | {
15 | if (s_brushes == null)
16 | {
17 | s_brushes = new Dictionary();
18 | }
19 | return s_brushes.EnsureItem(color, () => color.ToBrush());
20 | }
21 |
22 | public static int CacheSize { get { return s_brushes == null ? 0 : s_brushes.Count; } }
23 |
24 | public static void ClearCache()
25 | {
26 | if (s_brushes != null)
27 | {
28 | s_brushes = null;
29 | }
30 | }
31 |
32 | private static Dictionary s_brushes;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/net40-client/Common/DebugTrace.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | #if CONTRACTS_FULL
4 | using System.Diagnostics.Contracts;
5 | #else
6 | using PixelLab.Contracts;
7 | #endif
8 |
9 | namespace PixelLab.Common
10 | {
11 | public static class DebugTrace
12 | {
13 | public static void WriteLine(string message)
14 | {
15 | message = message ?? string.Empty;
16 |
17 | if (Debugger.IsLogging())
18 | {
19 | Debugger.Log(0, null, message + Environment.NewLine);
20 | }
21 | }
22 |
23 | public static void WriteLine(object value)
24 | {
25 | var message = value == null ? string.Empty : value.ToString();
26 | WriteLine(message);
27 | }
28 |
29 | public static void WriteLine(string format, params object[] args)
30 | {
31 | Contract.Requires(format != null);
32 | Contract.Requires(args != null);
33 | WriteLine(format.DoFormat(args));
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sl4/SL4/SLExtentions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Windows;
6 | #if CONTRACTS_FULL
7 | using System.Diagnostics.Contracts;
8 | #else
9 | using PixelLab.Contracts;
10 | #endif
11 |
12 | namespace PixelLab.SL
13 | {
14 | public static class SilverLightExtentions
15 | {
16 | public static IEnumerable GetLoadedAssemblies(this Deployment deployment)
17 | {
18 | Contract.Requires(deployment != null);
19 | return from part in deployment.Parts
20 | let stream = Application.GetResourceStream(new Uri(part.Source, UriKind.Relative))
21 | select new AssemblyPart().Load(stream.Stream);
22 | }
23 |
24 | public static Point GetLocationFromRootVisual(this UIElement element)
25 | {
26 | Contract.Requires(element != null);
27 | return element.TransformToVisual(Application.Current.RootVisual).Transform(new Point());
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sl4/Test/Helpers/AssertPlus.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | #if CONTRACTS_FULL
4 | using System.Diagnostics.Contracts;
5 | #else
6 | using PixelLab.Contracts;
7 | #endif
8 |
9 | namespace PixelLab.Test.Helpers
10 | {
11 | // Question: Kevin - 2011-05-22: why throw AssertFailedException instead of Assert.Fail?
12 | public static class AssertPlus
13 | {
14 | public static TException ExceptionThrown(Action testAction) where TException : Exception
15 | {
16 | Contract.Requires(testAction != null);
17 | try
18 | {
19 | testAction();
20 | throw new AssertFailedException("No exception was thrown");
21 | }
22 | catch (TException ex)
23 | {
24 | return ex;
25 | }
26 | catch (Exception ex)
27 | {
28 | throw new AssertFailedException("The wrong exception was thrown", ex);
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/Core/DemoMetadataAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.Composition;
3 | using System.Windows;
4 |
5 | namespace PixelLab.Demo.Core
6 | {
7 | [MetadataAttribute]
8 | [AttributeUsage(AttributeTargets.Class)]
9 | [PartCreationPolicy(CreationPolicy.NonShared)]
10 | public class DemoMetadataAttribute : ExportAttribute, IDemoMetadata
11 | {
12 | public DemoMetadataAttribute(string name) : this(name, string.Empty) { }
13 | public DemoMetadataAttribute(string name, string description)
14 | : base(DemoContractName, typeof(FrameworkElement))
15 | {
16 | Name = name;
17 | Description = description;
18 | }
19 |
20 | public string Name { get; private set; }
21 | public string Description { get; private set; }
22 |
23 | public const string DemoContractName = "PixelLab.SL.Demo";
24 | }
25 |
26 | public interface IDemoMetadata
27 | {
28 | string Name { get; }
29 | string Description { get; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/net40-client/Bot/ButtonBase3D.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls.Primitives;
3 | using System.Windows.Input;
4 |
5 | namespace PixelLab.Wpf
6 | {
7 | public class ButtonBase3D : UIElement3D
8 | {
9 | public static readonly RoutedEvent ClickEvent = ButtonBase.ClickEvent.AddOwner(typeof(ButtonBase3D));
10 |
11 | protected virtual void OnClick()
12 | {
13 | RoutedEventArgs e = new RoutedEventArgs(ClickEvent, this);
14 | base.RaiseEvent(e);
15 | }
16 |
17 | public event RoutedEventHandler Click
18 | {
19 | add
20 | {
21 | base.AddHandler(ClickEvent, value);
22 | }
23 | remove
24 | {
25 | base.RemoveHandler(ClickEvent, value);
26 | }
27 | }
28 |
29 | protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
30 | {
31 | e.Handled = true;
32 | OnClick();
33 | base.OnMouseLeftButtonDown(e);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/NumericUpDownPage.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/sl4/SL4/ResourceHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Windows;
3 | using PixelLab.Common;
4 | #if CONTRACTS_FULL
5 | using System.Diagnostics.Contracts;
6 | #else
7 | using PixelLab.Contracts;
8 | #endif
9 |
10 | namespace PixelLab.SL
11 | {
12 | public static class ResourceHelpers
13 | {
14 | public static bool TryFindResource(this FrameworkElement element, object resourceKey, out T value)
15 | {
16 | while (element != null)
17 | {
18 | if (element.Resources.TryGetResource(resourceKey, out value))
19 | {
20 | return true;
21 | }
22 | element = element.Parent as FrameworkElement;
23 | }
24 |
25 | return Application.Current.Resources.TryGetResource(resourceKey, out value);
26 | }
27 |
28 | public static bool TryGetResource(this ResourceDictionary dictionary, object key, out T value)
29 | {
30 | Contract.Requires(dictionary != null);
31 | return dictionary.TryGetTypedValue(key, out value);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sl4/SL4/DiscreteSlider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Controls;
3 |
4 | namespace PixelLab.SL
5 | {
6 | public class DiscreteSlider : Slider
7 | {
8 | protected override void OnValueChanged(double oldValue, double newValue)
9 | {
10 | if (!m_busy)
11 | {
12 | m_busy = true;
13 |
14 | if (SmallChange != 0)
15 | {
16 | double newDiscreteValue = (int)(Math.Round(newValue / SmallChange)) * SmallChange;
17 |
18 | if (newDiscreteValue != m_discreteValue)
19 | {
20 | Value = newDiscreteValue;
21 | base.OnValueChanged(m_discreteValue, newDiscreteValue);
22 | m_discreteValue = newDiscreteValue;
23 | }
24 | }
25 | else
26 | {
27 | base.OnValueChanged(oldValue, newValue);
28 | }
29 |
30 | m_busy = false;
31 | }
32 | }
33 |
34 | bool m_busy;
35 | double m_discreteValue;
36 | }
37 | }
--------------------------------------------------------------------------------
/sl4/SL4.Demo/DoubleClickBehaviorPage.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/VisualTreeViewer/VisualTreeViewerPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Controls;
3 | using PixelLab.Demo.Core;
4 |
5 | namespace PixelLab.Wpf.Demo
6 | {
7 | [DemoMetadata("Visual Tree Viewer", "This may seem a bit silly, but it's such a great demo and amazingly useful every once-in-a-while. So I have a ListBox with a bunch of random stuff in it. What does the visual tree look like? What are the actual WPF elements that are getting created? Well, WPF has VisualTreeWalker which will let you get the children of any Visual. You could write some debug spew to walk the tree out to the Console. Or, you could create a helper class VisualTreeItem, point it at the root element you care about when you click a button, and bind to it with a TreeView. Yeah, a bit silly. :-)")]
8 | public partial class VisualTreeViewerPage : Page
9 | {
10 | public VisualTreeViewerPage()
11 | {
12 | InitializeComponent();
13 | }
14 |
15 | private void load_click(object sender, EventArgs args)
16 | {
17 | VisualTreeItem vti = new VisualTreeItem(listBox);
18 |
19 | treeView.ItemsSource = vti.Children;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/sl4/SL4/StretchDirection.cs:
--------------------------------------------------------------------------------
1 | // (c) Copyright Microsoft Corporation.
2 | // This source is subject to the Microsoft Public License (Ms-PL).
3 | // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
4 | // All other rights reserved.
5 |
6 | namespace System.Windows.Controls
7 | {
8 | ///
9 | /// Describes the direction that content is scaled.
10 | ///
11 | /// Stable
12 | public enum StretchDirection
13 | {
14 | ///
15 | /// The content scales upward only when it is smaller than the parent.
16 | /// If the content is larger, no scaling downward is performed.
17 | ///
18 | UpOnly = 0,
19 |
20 | ///
21 | /// The content scales downward only when it is larger than the parent.
22 | /// If the content is smaller, no scaling upward is performed.
23 | ///
24 | DownOnly = 1,
25 |
26 | ///
27 | /// The content stretches to fit the parent according to the
28 | /// property.
29 | ///
30 | Both = 2
31 | }
32 | }
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/VSCopyToHtmlPage.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
22 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/ReorderListboxPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 | using System.Linq;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 | using PixelLab.Common;
6 | using PixelLab.Demo.Core;
7 |
8 | namespace PixelLab.Wpf.Demo
9 | {
10 | [DemoMetadata("Reorder Listbox")]
11 | public partial class ReorderListBoxPage : Page
12 | {
13 | private readonly ObservableCollection _brushes;
14 |
15 | public ReorderListBoxPage()
16 | {
17 | DataContext = _brushes = new ObservableCollection(App.DemoColors.Select(c => c.ToCachedBrush()));
18 |
19 | InitializeComponent();
20 | }
21 |
22 | private void listbox_Reorder(object sender, ReorderEventArgs args)
23 | {
24 | var reorderListBox = (ReorderListBox)args.OriginalSource;
25 |
26 | var draggingBrush = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ItemContainer);
27 | var toBrush = (SolidColorBrush)reorderListBox.ItemContainerGenerator.ItemFromContainer(args.ToContainer);
28 |
29 | _brushes.Move(_brushes.IndexOf(draggingBrush), _brushes.IndexOf(toBrush));
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/EditableTextBlockPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/Hex/HexHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using PixelLab.Common;
4 | #if CONTRACTS_FULL
5 | using System.Diagnostics.Contracts;
6 | #else
7 | using PixelLab.Contracts;
8 | #endif
9 |
10 | namespace PixelLab.Wpf.Demo.Hex
11 | {
12 | static class HexHelper
13 | {
14 | public static readonly double HeightOverWidth = Math.Sqrt(3) / 2;
15 |
16 | public static Point GetTopLeft(int count, double itemHeight, PointInt location)
17 | {
18 | Contract.Requires(count >= 1, "count");
19 | Contract.Requires(itemHeight > 0 && itemHeight.IsValid(), "itemHeight");
20 |
21 | double itemWidth = itemHeight / HeightOverWidth;
22 |
23 | //determine the location of 0,0
24 | Point point = new Point(0, itemHeight * .5 * (count - 1));
25 |
26 | //determine the start point for the row
27 | point.X += (itemWidth * 3 / 4) * location.Row;
28 | point.Y += (itemHeight / 2) * location.Row;
29 |
30 | //calculate the offset for the column
31 | point.X += (itemWidth * 3 / 4) * location.Column;
32 | point.Y -= (itemHeight / 2) * location.Column;
33 |
34 | return point;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/ShowElementPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Controls;
5 | using System.Windows.Media.Imaging;
6 | using System.Windows.Threading;
7 | using PixelLab.Demo.Core;
8 | using PixelLab.Wpf.Demo.Core;
9 |
10 | namespace PixelLab.Wpf.Demo
11 | {
12 | [DemoMetadata("Show Element", "A simple element used to 'show' a series of UIElements.")]
13 | public partial class ShowElementPage : Page
14 | {
15 | public ShowElementPage()
16 | {
17 | InitializeComponent();
18 |
19 | IList images = SampleImageHelper.GetBitmapImages(10).ToArray();
20 | int currentIndex = 0;
21 |
22 | var addElementAction = new Action(() =>
23 | {
24 | currentIndex %= images.Count;
25 | m_showElement.AddItem(new Image() { Source = images[currentIndex++] });
26 | });
27 |
28 | DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(4) };
29 | timer.Tick += (sender, args) => addElementAction();
30 |
31 | Unloaded += (sender, args) =>
32 | {
33 | timer.Stop();
34 | };
35 |
36 | addElementAction();
37 | timer.Start();
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/sl4/Common/KeyBinding.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Windows.Input;
4 |
5 | namespace PixelLab.Common
6 | {
7 | public class KeyBinding : IEquatable
8 | {
9 | public KeyBinding(Key key, ModifierKeys modifierKeys)
10 | {
11 | Key = key;
12 | ModifierKeys = modifierKeys;
13 | }
14 | public Key Key { get; private set; }
15 | public ModifierKeys ModifierKeys { get; private set; }
16 |
17 | public bool Equals(KeyBinding other)
18 | {
19 | return other != null && other.Key == Key && other.ModifierKeys == ModifierKeys;
20 | }
21 |
22 | public override bool Equals(object obj)
23 | {
24 | return Equals(obj as KeyBinding);
25 | }
26 |
27 | public override int GetHashCode()
28 | {
29 | return Util.GetHashCode(Key, ModifierKeys);
30 | }
31 |
32 | public override string ToString()
33 | {
34 | var output = Key.ToString();
35 | (new[] { ModifierKeys.Control, ModifierKeys.Shift, ModifierKeys.Alt, ModifierKeys.Apple, ModifierKeys.Windows })
36 | .Reverse()
37 | .Where(mk => ModifierKeys.HasFlag(mk))
38 | .ForEach(mk => output = "{0}+{1}".DoFormat(mk, output));
39 | return output;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/PanZoomPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/targets/BuildShared.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 10.0.20506
5 | 2.0
6 | Debug
7 | AnyCPU
8 | 4
9 | prompt
10 | TRACE
11 | _build
12 | $(RootOutputPath)\obj
13 | Properties
14 |
15 |
16 | true
17 | full
18 | false
19 | $(RootOutputPath)\bin\Debug
20 | $(DefineConstants);DEBUG
21 |
22 |
23 | pdbonly
24 | true
25 | $(RootOutputPath)\bin\Release
26 | $(OutputPath)\$(AssemblyName).XML
27 |
28 |
29 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/ListPagerPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Windows.Controls;
4 | using PixelLab.Common;
5 | using PixelLab.Demo.Core;
6 |
7 | namespace PixelLab.Wpf.Demo
8 | {
9 | [DemoMetadata("List Pager", "This is another example of how a 'smart' data layer can minimize the number and complexity of custom elements you need to create.")]
10 |
11 | public partial class ListPagerPage : Page
12 | {
13 | public ListPagerPage()
14 | {
15 | InitializeComponent();
16 |
17 | setItems(100);
18 | }
19 |
20 | private void Click(object sender, EventArgs args)
21 | {
22 | setItems();
23 | }
24 |
25 | private void setItems()
26 | {
27 | setItems(Util.Rnd.Next(5, 15) * 3);
28 | }
29 |
30 | private void setItems(int number)
31 | {
32 | IList values = GetStrings(number);
33 |
34 | ListPager lp = (ListPager)this.FindResource("listPager");
35 |
36 | lp.ItemsSource = values;
37 | }
38 |
39 | private static string[] GetStrings(int count)
40 | {
41 | string[] strings = new string[count];
42 |
43 | for (int i = 0; i < count; i++)
44 | {
45 | strings[i] = "Item " + (i + 1).ToString();
46 | }
47 | return strings;
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/sl4/SL4.Demo/FlipControlPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/MineSweeper/MineSweeperPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Controls;
3 | using System.Windows.Media;
4 | using PixelLab.Common;
5 | using PixelLab.Demo.Core;
6 |
7 | namespace PixelLab.Wpf.Demo.MineSweeper
8 | {
9 | [DemoMetadata("Mine Sweeper", "An oldy, but a goody. Done in WPF. Custom templates are used a lot here.")]
10 | public partial class MineSweeperPage : Page
11 | {
12 | public MineSweeperPage()
13 | {
14 | InitializeComponent();
15 | }
16 | }
17 |
18 | public class GameStateBrushConverter : SimpleValueConverter
19 | {
20 | protected override Brush ConvertBase(WinState input)
21 | {
22 | switch (input)
23 | {
24 | case WinState.Unknown:
25 | return makeBrush(Colors.Navy);
26 | case WinState.Lost:
27 | return makeBrush(Colors.Maroon);
28 | case WinState.Won:
29 | return makeBrush(Colors.DarkGreen);
30 | default:
31 | throw new NotSupportedException();
32 | }
33 | }
34 |
35 | private static GradientBrush makeBrush(Color color)
36 | {
37 | return new LinearGradientBrush(new GradientStopCollection()
38 | {
39 | new GradientStop(Colors.White,0),
40 | new GradientStop(color, 1)
41 | }, 45);
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/sl4/Test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright © 2011
2 |
3 | using System.Reflection;
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("Test.Silverlight")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("Test.Silverlight")]
15 | [assembly: AssemblyCopyright("Copyright © 2011")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | // The following GUID is for the ID of the typelib if this project is exposed to COM
25 | [assembly: Guid("38d786e6-e9c3-49b8-8dba-21b0eb88cbc0")]
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Revision and Build Numbers
35 | // by using the '*' as shown below:
36 | [assembly: AssemblyVersion("1.0.0.0")]
37 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/net40-client/Bot/WrapperElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Windows;
4 | using System.Windows.Media;
5 | #if CONTRACTS_FULL
6 | using System.Diagnostics.Contracts;
7 | #else
8 | using PixelLab.Contracts;
9 | #endif
10 |
11 | namespace PixelLab.Wpf
12 | {
13 | public abstract class WrapperElement : FrameworkElement
14 | where TElement : UIElement
15 | {
16 | protected WrapperElement(TElement element)
17 | {
18 | Contract.Requires(element != null);
19 |
20 | m_element = element;
21 |
22 | AddVisualChild(m_element);
23 | }
24 |
25 | protected override Size MeasureOverride(Size availableSize)
26 | {
27 | m_element.Measure(availableSize);
28 | return m_element.DesiredSize;
29 | }
30 |
31 | protected override Size ArrangeOverride(Size finalSize)
32 | {
33 | m_element.Arrange(new Rect(finalSize));
34 | return m_element.RenderSize;
35 | }
36 |
37 | protected override int VisualChildrenCount
38 | {
39 | get
40 | {
41 | return 1;
42 | }
43 | }
44 |
45 | protected override Visual GetVisualChild(int index)
46 | {
47 | Debug.Assert(index == 0);
48 | return m_element;
49 | }
50 |
51 | protected TElement WrappedElement { get { return m_element; } }
52 |
53 | private readonly TElement m_element;
54 | }
55 | }
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/ColorPicker/Code.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 | using System.Windows.Media;
6 |
7 | namespace PixelLab.Wpf.Demo
8 | {
9 | public class ColorGradientConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
12 | {
13 | string param = parameter as string;
14 | Color color = (Color)value;
15 | if (param != null)
16 | {
17 | switch (param)
18 | {
19 | case "Red":
20 | return new LinearGradientBrush(Color.FromRgb(0, color.G, color.B), Color.FromRgb(255, color.G, color.B), 0);
21 | case "Green":
22 | return new LinearGradientBrush(Color.FromRgb(color.R, 0, color.B), Color.FromRgb(color.R, 255, color.B), 0);
23 | case "Blue":
24 | return new LinearGradientBrush(Color.FromRgb(color.R, color.G, 0), Color.FromRgb(color.R, color.G, 255), 0);
25 | default:
26 | throw new ArgumentException("not valid value", "parameter");
27 | }
28 | }
29 | throw new ArgumentException("parameter not a string");
30 | }
31 |
32 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
33 | {
34 | return DependencyProperty.UnsetValue;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/net40-client/Bot/TreeMap3DUserControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Windows.Controls;
3 |
4 | namespace PixelLab.Wpf
5 | {
6 | public partial class TreeMap3DUserControl : UserControl
7 | {
8 | public TreeMap3DUserControl()
9 | {
10 | InitializeComponent();
11 |
12 | _treeMap3D.SelectionChanged += delegate(object sender, SelectionChangedEventArgs e)
13 | {
14 | object selectedData = (e.AddedItems.Count == 0) ? null : e.AddedItems[0];
15 |
16 | if (selectedData != null)
17 | {
18 | _dataDisplay.DataContext = e.AddedItems[0];
19 | }
20 |
21 | if (_lastSelected == null)
22 | {
23 | _transition3D.IsExpanded = true;
24 | }
25 | else if (selectedData == null)
26 | {
27 | _transition3D.IsExpanded = false;
28 | }
29 |
30 | _lastSelected = selectedData;
31 | };
32 | }
33 |
34 | ///
35 | /// This is a weak ItemsSource. It does not support binding or
36 | /// INotifyCollectionChanged.
37 | ///
38 | public IList ItemsSource
39 | {
40 | get
41 | {
42 | return _treeMap3D.ItemsSource;
43 | }
44 | set
45 | {
46 | _treeMap3D.ItemsSource = value;
47 | }
48 | }
49 |
50 | private object _lastSelected = null;
51 | }
52 | }
--------------------------------------------------------------------------------
/sl4/SL4/AsBigAsYouWantPanel.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using PixelLab.Common;
4 |
5 | namespace PixelLab.SL
6 | {
7 | public class AsBigAsYouWantPanel : Panel
8 | {
9 | protected override Size MeasureOverride(Size availableSize)
10 | {
11 | double widest = 0, tallest = 0;
12 |
13 | foreach (UIElement element in this.Children)
14 | {
15 | element.Measure(GeoHelper.SizeInfinite);
16 |
17 | double dw = element.DesiredSize.Width;
18 | dw = dw.IsValid() ? dw : 0;
19 |
20 | double dh = element.DesiredSize.Height;
21 | dh = dh.IsValid() ? dh : 0;
22 |
23 | if (dw > widest) widest = dw;
24 | if (dh > tallest) tallest = dh;
25 | }
26 |
27 | return new Size(widest, tallest);
28 | }
29 |
30 | protected override Size ArrangeOverride(Size finalSize)
31 | {
32 | double widest = 0, tallest = 0;
33 |
34 | foreach (var element in this.Children)
35 | {
36 | double dw = element.DesiredSize.Width;
37 | dw = dw.IsValid() ? dw : 0;
38 |
39 | double dh = element.DesiredSize.Height;
40 | dh = dh.IsValid() ? dh : 0;
41 |
42 | element.Arrange(new Rect(0, 0, dw, dh));
43 |
44 | if (dw > widest) widest = dw;
45 | if (dh > tallest) tallest = dh;
46 | }
47 |
48 | return new Size(widest, tallest);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/FlipControlPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Media;
4 | using PixelLab.Common;
5 | using PixelLab.Demo.Core;
6 |
7 | namespace PixelLab.SL.Demo
8 | {
9 | [DemoMetadata("Flip Control")]
10 | public partial class FlipControlPage : UserControl
11 | {
12 | public FlipControlPage()
13 | {
14 | InitializeComponent();
15 |
16 | var pageSize = new Size(200, 400);
17 |
18 | m_flip.SetChild(m_contentButton = new Button() { Background = Colors.Blue.ToCachedBrush(), FontSize = 120 });
19 | m_flip.Size = pageSize;
20 | m_flip.FlipStarting += (sender, args) =>
21 | {
22 | var oldValue = args.OldValue as int?;
23 | var newValue = args.NewValue as int?;
24 |
25 | if (oldValue != null && newValue != null && oldValue.Value != newValue.Value)
26 | {
27 | args.FlipDirection = (newValue.Value > oldValue.Value) ? FlipDirection.Next : FlipDirection.Previous;
28 | }
29 | };
30 |
31 | m_contentButton.WatchDataContextChanged((oldValue, newValue) =>
32 | {
33 | m_contentButton.Content = newValue;
34 | });
35 |
36 | m_next.Click += (sender, args) => DataContext = ++value;
37 | m_previos.Click += (sender, args) => DataContext = --value;
38 |
39 | DataContext = value;
40 | }
41 |
42 | private int value = 0;
43 | private readonly ContentControl m_contentButton;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/TreeViewHelperClasses/DataTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Diagnostics;
5 | using PixelLab.Common;
6 |
7 | namespace PixelLab.Wpf.Demo
8 | {
9 | public class DataTree
10 | {
11 | public DataTree(Guid guid, IList children)
12 | {
13 | m_guid = guid;
14 | m_children = new ReadOnlyCollection(children);
15 | }
16 |
17 | public Guid Guid { get { return m_guid; } }
18 | public IList Children { get { return m_children; } }
19 |
20 | public override string ToString()
21 | {
22 | return m_guid.ToString();
23 | }
24 |
25 | public static DataTree GetRandomDataTree(int maxDepth, int maxWidth)
26 | {
27 | Debug.Assert(maxDepth >= 0);
28 | Debug.Assert(maxWidth >= 0);
29 |
30 | int depth = Util.Rnd.Next(maxDepth);
31 | int width = Util.Rnd.Next(maxWidth);
32 |
33 | List children = new List();
34 | if (depth > 0)
35 | {
36 | for (int i = 0; i < width; i++)
37 | {
38 | children.Add(GetRandomDataTree(maxDepth - 1, maxWidth));
39 | }
40 | }
41 |
42 | return new DataTree(Guid.NewGuid(), children);
43 | }
44 |
45 | #region Implementation
46 |
47 | private readonly Guid m_guid;
48 | private readonly ReadOnlyCollection m_children;
49 |
50 | #endregion
51 | }
52 | }
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/ReorderListboxPage.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/OrgTree/OrgTreePage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 | using PixelLab.Demo.Core;
3 |
4 | namespace PixelLab.Wpf.Demo.OrgTree
5 | {
6 | [DemoMetadata("Org Tree", "A play off treeview, but stacked like an org chart. Right-click on nodes to add or remove children.")]
7 | public partial class OrgTreePage : Page
8 | {
9 | public OrgTreePage()
10 | {
11 | InitializeComponent();
12 | _tree.ItemsSource = OrgViewItem.GetViewArray(GetDemoData());
13 | }
14 |
15 | private static OrgItem[] GetDemoData()
16 | {
17 | return new OrgItem[]{
18 | new Company("Acme", new OrgItem[]{
19 | new Department("Sales", new OrgItem[]{
20 | new Employee("Bill Jones", null),
21 | new Employee("Bob Jones", null),
22 | new Employee("Beth Jones", null)
23 | }),
24 | new Department("Service", new OrgItem[]{
25 | new Employee("Bill Smith", null),
26 | new Employee("Bob Smith", null),
27 | new Employee("Beth Smith", null)
28 | }),
29 | new Department("Marketing", new OrgItem[]{
30 | new Employee("Bill Adams", null),
31 | new Employee("Bob Adams", null),
32 | new Employee("Beth Adams", null)
33 | }),
34 | new Department("Engineering", new OrgItem[]{
35 | new Employee("Bill Obama", null),
36 | new Employee("Bob Obama", null),
37 | new Employee("Beth Obama", null)
38 | })
39 | })
40 | };
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/net40-client/Bot/Transitions/FadeTransition.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Media.Animation;
4 |
5 | namespace PixelLab.Wpf.Transitions
6 | {
7 | // Simple transition that fades out the old content
8 | public class FadeTransition : Transition
9 | {
10 | static FadeTransition()
11 | {
12 | IsNewContentTopmostProperty.OverrideMetadata(typeof(FadeTransition), new FrameworkPropertyMetadata(false));
13 | }
14 |
15 | public Duration Duration
16 | {
17 | get { return (Duration)GetValue(DurationProperty); }
18 | set { SetValue(DurationProperty, value); }
19 | }
20 |
21 | public static readonly DependencyProperty DurationProperty =
22 | DependencyProperty.Register("Duration", typeof(Duration), typeof(FadeTransition), new UIPropertyMetadata(Duration.Automatic));
23 |
24 | protected internal override void BeginTransition(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
25 | {
26 | DoubleAnimation da = new DoubleAnimation(0, Duration);
27 | da.Completed += delegate
28 | {
29 | EndTransition(transitionElement, oldContent, newContent);
30 | };
31 | oldContent.BeginAnimation(UIElement.OpacityProperty, da);
32 | }
33 |
34 | protected override void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
35 | {
36 | oldContent.BeginAnimation(UIElement.OpacityProperty, null);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/FolderPicker/LocalDrives.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Collections.ObjectModel;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Security;
6 | using PixelLab.Common;
7 |
8 | namespace PixelLab.Wpf.Demo.FolderPicker
9 | {
10 | public class LocalDrives : Changeable
11 | {
12 | public LocalDrives()
13 | {
14 | var drives = Enumerable.Empty();
15 |
16 | try
17 | {
18 | drives = from d in DriveInfo.GetDrives()
19 | where d.DriveType == DriveType.Fixed && d.IsReady
20 | select new SelectableDirectory(d);
21 | }
22 | catch (SecurityException) { } // This will fail in an XBap
23 |
24 | m_drives = drives.ToReadOnlyCollection();
25 |
26 | foreach (var sd in m_drives)
27 | {
28 | sd.AddWatcher(SelectableDirectory.c_selectedDirectoriesPropertyName, () => OnPropertyChanged(SelectableDirectory.c_selectedDirectoriesPropertyName));
29 | }
30 | }
31 |
32 | public IList Drives
33 | {
34 | get
35 | {
36 | return m_drives;
37 | }
38 | }
39 | public IEnumerable SelectedDirectories
40 | {
41 | get
42 | {
43 | return SelectableDirectory.GetSelectedDirectories(m_drives);
44 | }
45 | }
46 |
47 | #region Implementation
48 |
49 | private readonly ReadOnlyCollection m_drives;
50 |
51 | #endregion
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/AnimatingTilePanelPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Media;
6 | using PixelLab.Common;
7 | using PixelLab.Demo.Core;
8 |
9 | namespace PixelLab.Wpf.Demo
10 | {
11 | [DemoMetadata("Animating Tile Panel", "This is a demonstration of two concepts: custom Panel creation and use of the Composition.Render event to do animations.")]
12 | public partial class AnimatingTilePanelPage : Page
13 | {
14 | public AnimatingTilePanelPage()
15 | {
16 | InitializeComponent();
17 |
18 | this.LayoutUpdated += delegate(object sender, EventArgs e)
19 | {
20 | if (Panel == null)
21 | {
22 | Panel = m_itemsControl.FirstVisualDescendentOfType();
23 | }
24 | };
25 |
26 | m_itemsControl.ItemsSource = m_colors;
27 | m_stackPanelCommands.DataContext = m_colors;
28 | }
29 |
30 | public static readonly DependencyProperty PanelProperty =
31 | DependencyProperty.Register("Panel", typeof(AnimatingTilePanel), typeof(AnimatingTilePanelPage));
32 |
33 | public AnimatingTilePanel Panel
34 | {
35 | get
36 | {
37 | return (AnimatingTilePanel)GetValue(PanelProperty);
38 | }
39 | set
40 | {
41 | SetValue(PanelProperty, value);
42 | }
43 | }
44 |
45 | private readonly DemoCollection m_colors = DemoCollection.Create(
46 | App.DemoColors.Select(c => c.ToCachedBrush()).ToArray(), 48, 0, 96);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/DemoHost.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.Composition;
3 | using System.Linq;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using PixelLab.Common;
7 | using PixelLab.Demo.Core;
8 |
9 | namespace PixelLab.SL.Demo
10 | {
11 | public partial class DemoHost : UserControl
12 | {
13 | public DemoHost()
14 | {
15 | InitializeComponent();
16 |
17 | Catalog = new List>();
18 | CompositionInitializer.SatisfyImports(this);
19 |
20 | var items = Catalog.OrderBy(v => v.Metadata.Name).ToList();
21 | var welcome = items.FirstOrDefault(m => m.Metadata.Name.Equals("welcome", System.StringComparison.InvariantCultureIgnoreCase));
22 | if (welcome != null)
23 | {
24 | items.Remove(welcome);
25 | items.Insert(0, welcome);
26 | }
27 | Catalog = items.ToReadOnlyCollection();
28 |
29 | m_items.ItemsSource = Catalog;
30 |
31 | m_items.SelectionChanged += (sender, args) =>
32 | {
33 | var item = m_items.SelectedItem as ExportFactory;
34 | if (item != null)
35 | {
36 | using (var export = item.CreateExport())
37 | {
38 | m_container.Child = export.Value;
39 | }
40 | }
41 | };
42 |
43 | m_items.SelectedIndex = 0;
44 | }
45 |
46 | [ImportMany(DemoMetadataAttribute.DemoContractName)]
47 | public IList> Catalog { get; private set; }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/net40-client/Core/CompositionHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.Composition.Hosting;
3 | using System.ComponentModel.Composition.Primitives;
4 | using System.Linq;
5 |
6 | namespace PixelLab.Common
7 | {
8 | public class FunctionExportDefinition : ExportDefinition
9 | {
10 | private FunctionExportDefinition(ExportDefinition definition, ComposablePartDefinition partDefinition)
11 | : base(definition.ContractName, definition.Metadata)
12 | {
13 | m_exportDefinition = definition;
14 | m_partDefinition = partDefinition;
15 | }
16 |
17 | public static IEnumerable> GetExports(ComposablePartCatalog catalog)
18 | {
19 | return
20 | from part in catalog.Parts
21 | from definition in part.ExportDefinitions
22 | where definition.Metadata.ContainsKey(CompositionConstants.ExportTypeIdentityMetadataName)
23 | where typeof(T).FullName == definition.Metadata[CompositionConstants.ExportTypeIdentityMetadataName] as string
24 | select new FunctionExportDefinition(definition, part);
25 | }
26 |
27 | public T GetValue()
28 | {
29 | return (T)m_partDefinition.CreatePart().GetExportedValue(m_exportDefinition);
30 | }
31 |
32 | private readonly ExportDefinition m_exportDefinition;
33 | private readonly ComposablePartDefinition m_partDefinition;
34 | }
35 |
36 | public static class CompositionHelpers
37 | {
38 | public static IEnumerable> GetExports(this ComposablePartCatalog catalog)
39 | {
40 | return FunctionExportDefinition.GetExports(catalog);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/PixelLab.Core.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 6.0.1
5 | Kevin Moore,Robby Ingebretsen,Derek Lakin
6 | Pixel Lab - http://thinkpixellab.com
7 | http://creativecommons.org/licenses/MIT/
8 | https://github.com/thinkpixellab/bot
9 | http://www.nuget.org/Media/Default/Packages/PixelLab.BOT/1.0.1/logo.png
10 | PixelLab.Core
11 | PixelLab.Core
12 | false
13 | A collection of helpers and controls for .NET, WPF and Silverlight.
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/VisualTreeViewer/VisualTreeViewerPage.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Radom UI 1
21 |
22 | cool beans 3
23 | cool beans 4
24 | cool beans 5
25 |
26 | cool
27 | beans
28 | 6
29 |
30 | cool beans 7
31 | cool beans 8
32 | cool beans 9
33 | cool beans 0
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/net40-client/Bot/themes/NumericUpDown.generic.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/TreeViewHelperClasses/TreeViewHelperPage.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/net40-client/Core/DBUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlClient;
3 | #if CONTRACTS_FULL
4 | using System.Diagnostics.Contracts;
5 | #else
6 | using PixelLab.Contracts;
7 | #endif
8 |
9 | namespace PixelLab.Common
10 | {
11 | ///
12 | /// Utility classes for dealing with databases.
13 | ///
14 | public static class DBUtil
15 | {
16 | ///
17 | /// Creates a SQL command from a command format string and
18 | /// parameters to avoid SQL injection attacks.
19 | ///
20 | ///
21 | /// SQL command string with format substitution points for
22 | /// parameters.
23 | ///
24 | /// Parameters to substitute into the SQL command string.
25 | /// using parameters.
26 | public static SqlCommand CreateSqlCommandWithParameters(
27 | string commandFormatString,
28 | params object[] parameters)
29 | {
30 | Contract.Requires(commandFormatString != null);
31 | Contract.Requires(parameters != null);
32 |
33 | SqlCommand command = new SqlCommand();
34 |
35 | string[] paramLabels = new string[parameters.Length];
36 | for (int paramIndex = 0; paramIndex < parameters.Length; paramIndex++)
37 | {
38 | paramLabels[paramIndex] = "@{0}".DoFormat(paramIndex);
39 | command.Parameters.AddWithValue(paramLabels[paramIndex], parameters[paramIndex]);
40 | }
41 |
42 | command.CommandText = commandFormatString.DoFormat(paramLabels);
43 | return command;
44 | } //*** createSqlCommandWithParameters
45 | } //*** class SqlUtil
46 | } //*** PixelLab.Common
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/IntroductionPage.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 | Welcome to the Bag of Tricks.
12 | This is a collection of samples and controls that show the power and flexibility of WPF.
13 | For updates, check out
14 | bot.codeplex.com .
15 |
16 | Thanks to Ben for
17 | Reveal , Neil for
18 | TransitionPresenter , and Kurt for the
19 | Interactive 3D code .
20 |
21 | Have fun!
22 |
23 | Kevin and Robby
24 |
25 | Partners
26 |
27 | Pixel Lab
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/PixelLab.BOT.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 6.0.1
5 | Kevin Moore,Robby Ingebretsen,Derek Lakin
6 | Pixel Lab - http://thinkpixellab.com
7 | http://creativecommons.org/licenses/MIT/
8 | https://github.com/thinkpixellab/bot
9 | http://www.nuget.org/Media/Default/Packages/PixelLab.BOT/1.0.1/logo.png
10 |
11 |
12 |
13 |
14 | PixelLab.BOT
15 | PixelLab.BOT
16 | false
17 | A collection of helpers and controls for .NET, WPF and Silverlight.
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/sl4/Common/CommandKeyMapper.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | #if CONTRACTS_FULL
4 | using System.Diagnostics.Contracts;
5 | #else
6 | using PixelLab.Contracts;
7 | #endif
8 | using System.Windows.Input;
9 |
10 | namespace PixelLab.Common
11 | {
12 | public class CommandKeyMapper
13 | {
14 | public void AddKeyBinding(ICommand command, Key key, ModifierKeys modifierKeys = ModifierKeys.None)
15 | {
16 | AddKeyBinding(command, null, key, modifierKeys);
17 | }
18 |
19 | public void AddKeyBinding(ICommand command, object param, Key key, ModifierKeys modifierKeys = ModifierKeys.None)
20 | {
21 | Contract.Requires(command != null);
22 |
23 | var binding = new KeyBinding(key, modifierKeys);
24 | m_keyBindings.Add(binding, new CommandParamPair(command, param));
25 | }
26 |
27 | public bool TryExecuteKeyboardCommand(Key key, ModifierKeys modifierKeys)
28 | {
29 | CommandParamPair commandPair;
30 | if (m_keyBindings.TryGetValue(new KeyBinding(key, modifierKeys), out commandPair))
31 | {
32 | if (commandPair.Command.CanExecute(commandPair.Param))
33 | {
34 | commandPair.Command.Execute(commandPair.Param);
35 | return true;
36 | }
37 | }
38 |
39 | return false;
40 | }
41 |
42 | private readonly Dictionary m_keyBindings = new Dictionary();
43 |
44 | private class CommandParamPair
45 | {
46 | public CommandParamPair(ICommand command, object param)
47 | {
48 | Command = command;
49 | Param = param;
50 | }
51 |
52 | public ICommand Command { get; private set; }
53 | public object Param { get; private set; }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/SpriteButtonPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/sl4/Test/EnumConverterTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using Microsoft.Silverlight.Testing;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using PixelLab.Common;
6 |
7 | namespace PixelLab.Test
8 | {
9 | [TestClass]
10 | public class EnumConverterTest : SilverlightTest
11 | {
12 | private readonly EnumConverter _converter = new EnumConverter();
13 |
14 | [TestMethod]
15 | public void TestEnumConverter()
16 | {
17 | var flipBool = "true->false,true";
18 |
19 | Test(flipBool, false, true);
20 | Test(flipBool, true, false);
21 | Test(flipBool, false, "true");
22 | Test(flipBool, true, "false");
23 | Test(flipBool, false, "TRUE");
24 | Test(flipBool, true, "FalsE");
25 |
26 | // string comparisons are case-insensitive
27 | Test(flipBool, "false", true);
28 | Test(flipBool, "true", false);
29 | Test(flipBool, "false", "true");
30 | Test(flipBool, "true", "false");
31 | Test(flipBool, "false", "TRUE");
32 | Test(flipBool, "true", "FalsE");
33 |
34 |
35 | var objectNullToBoolTest = "null->False,True";
36 | Test(objectNullToBoolTest, false, null);
37 | Test(objectNullToBoolTest, true, this);
38 | Test(objectNullToBoolTest, true, new Nullable(4));
39 |
40 | var objectNullToEnumTest = "null->Saturday,Sunday";
41 | Test(objectNullToEnumTest, DayOfWeek.Saturday, null);
42 | Test(objectNullToEnumTest, DayOfWeek.Sunday, this);
43 | Test(objectNullToEnumTest, DayOfWeek.Sunday, new Nullable(5));
44 | }
45 |
46 | private void Test(string param, T targetValue, object input)
47 | {
48 | Assert.AreEqual(targetValue, _converter.Convert(input, typeof(T), param, CultureInfo.InvariantCulture));
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/net40-client/Bot/BlockBarRect.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Media;
3 | #if CONTRACTS_FULL
4 | using System.Diagnostics.Contracts;
5 | #else
6 | using PixelLab.Contracts;
7 | #endif
8 |
9 | namespace PixelLab.Wpf
10 | {
11 | public class BlockBarRect : BlockBarBase
12 | {
13 | protected override void OnRender(DrawingContext drawingContext)
14 | {
15 | Rect rect;
16 | int blockCount = BlockCount;
17 | Size renderSize = this.RenderSize;
18 | double blockMargin = this.BlockMargin;
19 | double value = Value;
20 | for (int i = 0; i < blockCount; i++)
21 | {
22 | rect = GetRect(renderSize, blockCount, blockMargin, i, BorderBen.Thickness);
23 |
24 | if (!rect.IsEmpty)
25 | {
26 | int threshold = GetThreshold(value, blockCount);
27 | drawingContext.DrawRectangle((i < threshold) ? Foreground : Background, BorderBen, rect);
28 | }
29 | }
30 | }
31 |
32 | private static Rect GetRect(Size targetSize, int blockCount, double blockMargin, int blockNumber, double penThickness)
33 | {
34 | Contract.Requires(!targetSize.IsEmpty, "targetSize");
35 | Contract.Requires(blockCount > 0, "blockCount");
36 | Contract.Requires(blockCount > blockNumber, "blockNumber");
37 |
38 | double width = (targetSize.Width - (blockCount - 1) * blockMargin - penThickness) / blockCount;
39 | double left = penThickness / 2 + (width + blockMargin) * blockNumber;
40 | double height = targetSize.Height - penThickness;
41 |
42 | if (width > 0 && height > 0)
43 | {
44 | return new Rect(left, penThickness / 2, width, height);
45 | }
46 | else
47 | {
48 | return Rect.Empty;
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/net40-client/Bot/Transitions/TwoWayTransitionSelector.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace PixelLab.Wpf.Transitions
4 | {
5 | public enum TransitionDirection
6 | {
7 | Forward,
8 | Backward,
9 | }
10 |
11 | //Choose between a forward and backward transition based on the Direction property
12 | public class TwoWayTransitionSelector : TransitionSelector
13 | {
14 | public TwoWayTransitionSelector() { }
15 |
16 | public Transition Forward
17 | {
18 | get { return (Transition)GetValue(ForwardProperty); }
19 | set { SetValue(ForwardProperty, value); }
20 | }
21 |
22 | public static readonly DependencyProperty ForwardProperty =
23 | DependencyProperty.Register("Forward", typeof(Transition), typeof(TwoWayTransitionSelector), new UIPropertyMetadata(null));
24 |
25 | public Transition Backward
26 | {
27 | get { return (Transition)GetValue(BackwardProperty); }
28 | set { SetValue(BackwardProperty, value); }
29 | }
30 |
31 | public static readonly DependencyProperty BackwardProperty =
32 | DependencyProperty.Register("Backward", typeof(Transition), typeof(TwoWayTransitionSelector), new UIPropertyMetadata(null));
33 |
34 | public TransitionDirection Direction
35 | {
36 | get { return (TransitionDirection)GetValue(DirectionProperty); }
37 | set { SetValue(DirectionProperty, value); }
38 | }
39 |
40 | public static readonly DependencyProperty DirectionProperty =
41 | DependencyProperty.Register("Direction", typeof(TransitionDirection), typeof(TwoWayTransitionSelector), new UIPropertyMetadata(TransitionDirection.Forward));
42 |
43 | public override Transition SelectTransition(object oldContent, object newContent)
44 | {
45 | return Direction == TransitionDirection.Forward ? Forward : Backward;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/net40-client/Bot/BlockBarCircle.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Media;
3 |
4 | namespace PixelLab.Wpf
5 | {
6 | public class BlockBarCircle : BlockBarBase
7 | {
8 | protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
9 | {
10 | double penThickness = BorderBen.Thickness;
11 | Size effectiveRenderSize = new Size(this.RenderSize.Width - penThickness, this.RenderSize.Height - penThickness);
12 |
13 | //two possible scenarios
14 | //1) we are driven by width
15 | //2) we are driven by height
16 | //let's run both to see which works
17 |
18 | double circleDiameter;
19 | circleDiameter = (effectiveRenderSize.Width - (BlockCount - 1) * BlockMargin) / BlockCount;
20 | if (circleDiameter > effectiveRenderSize.Height)
21 | {
22 | circleDiameter = effectiveRenderSize.Height;
23 | }
24 |
25 | double startLeft = penThickness / 2 + effectiveRenderSize.Width - (this.BlockCount * circleDiameter + (this.BlockCount - 1) * BlockMargin);
26 | double startTop = penThickness / 2 + (effectiveRenderSize.Height - circleDiameter) / 2;
27 |
28 | double circleRadius = circleDiameter / 2;
29 | Point center = new Point();
30 |
31 | int threshHold = BlockBarBase.GetThreshold(this.Value, this.BlockCount);
32 |
33 | Brush brushToUse;
34 | for (int i = 0; i < this.BlockCount; i++)
35 | {
36 | brushToUse = ((this.BlockCount - (i + 1)) < threshHold) ? Foreground : Background;
37 |
38 | center.X = startLeft + circleRadius;
39 | center.Y = startTop + circleRadius;
40 | drawingContext.DrawEllipse(brushToUse, BorderBen, center, circleRadius, circleRadius);
41 | startLeft += circleDiameter + BlockMargin;
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/net40-client/Bot/InfoTextBox.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 |
4 | namespace PixelLab.Wpf
5 | {
6 | public class InfoTextBox : TextBox
7 | {
8 | static InfoTextBox()
9 | {
10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(InfoTextBox), new FrameworkPropertyMetadata(typeof(InfoTextBox)));
11 |
12 | TextProperty.OverrideMetadata(
13 | typeof(InfoTextBox),
14 | new FrameworkPropertyMetadata(new PropertyChangedCallback(TextPropertyChanged)));
15 | }
16 |
17 | public static readonly DependencyProperty TextBoxInfoProperty = DependencyProperty.Register(
18 | "TextBoxInfo",
19 | typeof(string),
20 | typeof(InfoTextBox),
21 | new PropertyMetadata(string.Empty));
22 |
23 | public string TextBoxInfo
24 | {
25 | get { return (string)GetValue(TextBoxInfoProperty); }
26 | set { SetValue(TextBoxInfoProperty, value); }
27 | }
28 |
29 | private static readonly DependencyPropertyKey HasTextPropertyKey = DependencyProperty.RegisterReadOnly(
30 | "HasText",
31 | typeof(bool),
32 | typeof(InfoTextBox),
33 | new FrameworkPropertyMetadata(false));
34 |
35 | public static readonly DependencyProperty HasTextProperty = HasTextPropertyKey.DependencyProperty;
36 |
37 | public bool HasText
38 | {
39 | get
40 | {
41 | return (bool)GetValue(HasTextProperty);
42 | }
43 | }
44 |
45 | static void TextPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
46 | {
47 | InfoTextBox itb = (InfoTextBox)sender;
48 |
49 | bool actuallyHasText = itb.Text.Length > 0;
50 | if (actuallyHasText != itb.HasText)
51 | {
52 | itb.SetValue(HasTextPropertyKey, actuallyHasText);
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/net40-client/Common/SimpleValueConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 | using System.Windows;
5 | #if CONTRACTS_FULL
6 | using System.Diagnostics.Contracts;
7 | #else
8 | using PixelLab.Contracts;
9 | #endif
10 |
11 | namespace PixelLab.Common
12 | {
13 | public abstract class SimpleValueConverter : IValueConverter
14 | {
15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 | {
17 | if (value is TSource)
18 | {
19 | try
20 | {
21 | return ConvertBase((TSource)value);
22 | }
23 | catch (NotSupportedException) { }
24 | }
25 | return DependencyProperty.UnsetValue;
26 | }
27 |
28 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
29 | {
30 | if (value is TTarget)
31 | {
32 | try
33 | {
34 | return ConvertBackBase((TTarget)value);
35 | }
36 | catch (NotSupportedException) { }
37 | }
38 | return DependencyProperty.UnsetValue;
39 | }
40 |
41 | protected abstract TTarget ConvertBase(TSource input);
42 |
43 | protected virtual TSource ConvertBackBase(TTarget input)
44 | {
45 | throw new NotSupportedException();
46 | }
47 | }
48 |
49 | public class FuncValueConverter : SimpleValueConverter
50 | {
51 | public FuncValueConverter(Func func)
52 | {
53 | Contract.Requires(func != null);
54 | m_func = func;
55 | }
56 | protected override TTarget ConvertBase(TSource input)
57 | {
58 | return m_func(input);
59 | }
60 |
61 | private readonly Func m_func;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/InfoTextBoxPage.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
26 |
27 |
29 |
30 |
31 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/PixelLab.Common.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 6.0.1
5 | Kevin Moore,Robby Ingebretsen,Derek Lakin
6 | Pixel Lab - http://thinkpixellab.com
7 | http://creativecommons.org/licenses/MIT/
8 | https://github.com/thinkpixellab/bot
9 | http://www.nuget.org/Media/Default/Packages/PixelLab.BOT/1.0.1/logo.png
10 |
11 |
12 |
13 |
14 | PixelLab.Common
15 | PixelLab.Common
16 | false
17 | A collection of helpers and controls for .NET, WPF and Silverlight.
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Diagnostics;
4 |
5 | namespace PixelLab.SL.Demo
6 | {
7 | public partial class App : Application
8 | {
9 | public App()
10 | {
11 | this.Startup += (sender, args) => { this.RootVisual = new DemoHost(); };
12 | this.UnhandledException += this.Application_UnhandledException;
13 |
14 | InitializeComponent();
15 | }
16 |
17 | private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
18 | {
19 | Debugger.Break();
20 | // If the app is running outside of the debugger then report the exception using
21 | // the browser's exception mechanism. On IE this will display it a yellow alert
22 | // icon in the status bar and Firefox will display a script error.
23 | if (!System.Diagnostics.Debugger.IsAttached)
24 | {
25 | // NOTE: This will allow the application to continue running after an exception has been thrown
26 | // but not handled.
27 | // For production applications this error handling should be replaced with something that will
28 | // report the error to the website and stop the application.
29 | e.Handled = true;
30 | Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
31 | }
32 | }
33 |
34 | private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
35 | {
36 | try
37 | {
38 | string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
39 | errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
40 |
41 | System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
42 | }
43 | catch (Exception)
44 | {
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sl4/Test/SortHelperTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Microsoft.Silverlight.Testing;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 | using PixelLab.Common;
6 |
7 | namespace PixelLab.Test
8 | {
9 | [TestClass]
10 | public class SortHelperTests : SilverlightTest
11 | {
12 | private const int _testCount = 100;
13 |
14 | [TestMethod]
15 | public void TestComparerFunc()
16 | {
17 | var numbers = getTestNumbers();
18 |
19 | SortHelper.QuickSort(numbers, new Func(reverseSort));
20 |
21 | Assert.IsTrue(numbers.TrueForAllAdjacentPairs((a, b) => a >= b));
22 | }
23 |
24 | [TestMethod]
25 | public void TestComparison()
26 | {
27 | var numbers = getTestNumbers();
28 |
29 | SortHelper.QuickSort(numbers, new Comparison(reverseSort));
30 |
31 | Assert.IsTrue(numbers.TrueForAllAdjacentPairs((a, b) => a >= b));
32 | }
33 |
34 | [TestMethod]
35 | public void TestComparer()
36 | {
37 | var numbers = getTestNumbers();
38 |
39 | SortHelper.QuickSort(numbers, Comparer.Default);
40 |
41 | Assert.IsTrue(numbers.TrueForAllAdjacentPairs((a, b) => a <= b));
42 | }
43 |
44 | [TestMethod]
45 | public void TestDefault()
46 | {
47 | var numbers = getTestNumbers();
48 |
49 | SortHelper.QuickSort(numbers);
50 |
51 | Assert.IsTrue(numbers.TrueForAllAdjacentPairs((a, b) => a <= b));
52 | }
53 |
54 | private static int reverseSort(int a, int b)
55 | {
56 | return b.CompareTo(a);
57 | }
58 |
59 | private static int[] getTestNumbers()
60 | {
61 | var numbers = new int[_testCount];
62 |
63 | for (var i = 0; i < _testCount; i++)
64 | {
65 | numbers[i] = Util.Rnd.Next();
66 | }
67 |
68 | return numbers;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/net40-client/Core/Contract.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using PixelLab.Common;
6 |
7 | namespace PixelLab.Contracts
8 | {
9 | public static class Contract
10 | {
11 | [DebuggerStepThrough]
12 | public static void Requires(bool truth, string message = null)
13 | {
14 | Util.ThrowUnless(truth, message);
15 | }
16 |
17 | [DebuggerStepThrough]
18 | public static void Requires(bool truth, string message) where TException : Exception
19 | {
20 | Util.ThrowUnless(truth, message);
21 | }
22 |
23 | [DebuggerStepThrough]
24 | public static void Requires(bool truth) where TException : Exception, new()
25 | {
26 | Util.ThrowUnless(truth);
27 | }
28 |
29 | public static void Assume(bool truth, string message = null)
30 | {
31 | Debug.Assert(truth, message);
32 | }
33 |
34 | [Conditional("NEVER")]
35 | public static void Ensures(bool truth) { }
36 |
37 | [Conditional("NEVER")]
38 | public static void Invariant(bool truth, string message = null)
39 | {
40 | throw new NotSupportedException();
41 | }
42 |
43 | public static T Result()
44 | {
45 | throw new NotSupportedException();
46 | }
47 |
48 | public static bool ForAll(IEnumerable source, Func predicate)
49 | {
50 | return source.All(predicate);
51 | }
52 | }
53 |
54 | public class PureAttribute : Attribute { }
55 |
56 | public class ContractClassAttribute : Attribute
57 | {
58 | public ContractClassAttribute(Type contractType) { }
59 | }
60 |
61 | public class ContractClassForAttribute : Attribute
62 | {
63 | public ContractClassForAttribute(Type contractForType) { }
64 | }
65 |
66 | public class ContractInvariantMethodAttribute : Attribute { }
67 | }
68 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/VisualTreeViewer/VisualTreeItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows;
4 | using System.Windows.Media;
5 | #if CONTRACTS_FULL
6 | using System.Diagnostics.Contracts;
7 | #else
8 | using PixelLab.Contracts;
9 | #endif
10 |
11 | namespace PixelLab.Wpf.Demo
12 | {
13 | public class VisualTreeItem
14 | {
15 | public VisualTreeItem(DependencyObject element)
16 | {
17 | Contract.Requires(element != null);
18 |
19 | m_element = element;
20 | }
21 |
22 | public IEnumerable Children
23 | {
24 | get
25 | {
26 | if (_children == null)
27 | {
28 | _children = new List(VisualTreeHelper.GetChildrenCount(m_element));
29 | for (int i = 0; i < VisualTreeHelper.GetChildrenCount(m_element); i++)
30 | {
31 | _children.Add(new VisualTreeItem(VisualTreeHelper.GetChild(m_element, i)));
32 | }
33 | }
34 | return _children;
35 | }
36 | }
37 |
38 | public string Name
39 | {
40 | get
41 | {
42 | FrameworkElement fe = m_element as FrameworkElement;
43 | if (fe != null && !String.IsNullOrEmpty(fe.Name))
44 | {
45 | return TypeName + ":" + fe.Name;
46 | }
47 | else
48 | {
49 | return TypeName;
50 | }
51 | }
52 | }
53 |
54 | public string TypeName
55 | {
56 | get
57 | {
58 | return m_element.GetType().Name;
59 | }
60 | }
61 |
62 | public override string ToString()
63 | {
64 | return Name;
65 | }
66 |
67 | private List _children;
68 | private readonly DependencyObject m_element;
69 | }
70 | }
--------------------------------------------------------------------------------
/net40-client/Bot/OrgTreeItem.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 |
4 | namespace PixelLab.Wpf
5 | {
6 | public class OrgTreeItem : HeaderedItemsControl
7 | {
8 | static OrgTreeItem()
9 | {
10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(OrgTreeItem),
11 | new FrameworkPropertyMetadata(typeof(OrgTreeItem)));
12 | }
13 |
14 | #region DPs
15 |
16 | private static readonly DependencyPropertyKey DepthPropertyKey =
17 | DependencyProperty.RegisterReadOnly("Depth", typeof(int), typeof(OrgTreeItem), new UIPropertyMetadata(0));
18 |
19 | public static readonly DependencyProperty DepthProperty = DepthPropertyKey.DependencyProperty;
20 |
21 | public static readonly DependencyProperty IsExpandedProperty =
22 | DependencyProperty.Register("IsExpanded", typeof(bool), typeof(OrgTreeItem),
23 | new FrameworkPropertyMetadata(false));
24 |
25 | public bool IsExpanded
26 | {
27 | get { return (bool)GetValue(IsExpandedProperty); }
28 | set { SetValue(IsExpandedProperty, value); }
29 | }
30 |
31 | public int Depth
32 | {
33 | get { return (int)GetValue(DepthProperty); }
34 | private set { SetValue(DepthPropertyKey, value); }
35 | }
36 |
37 | #endregion
38 |
39 | #region overrides
40 |
41 | protected override DependencyObject GetContainerForItemOverride()
42 | {
43 | return new OrgTreeItem();
44 | }
45 |
46 | protected override bool IsItemItsOwnContainerOverride(object item)
47 | {
48 | return item is OrgTreeItem;
49 | }
50 |
51 | protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
52 | {
53 | ((OrgTreeItem)element).Depth = Depth + 1;
54 | base.PrepareContainerForItemOverride(element, item);
55 | }
56 |
57 | #endregion
58 | }
59 | }
--------------------------------------------------------------------------------
/net40-client/Core/CastList.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | #if CONTRACTS_FULL
3 | using System.Diagnostics.Contracts;
4 | #else
5 | using PixelLab.Contracts;
6 | #endif
7 |
8 | namespace PixelLab.Common
9 | {
10 | ///
11 | /// A wrapper around an
12 | /// which projects the contents as a read-only .
13 | ///
14 | /// The type of the source .
15 | ///
16 | /// The type of the target
17 | /// Must be assignable from .
18 | ///
19 | ///
20 | /// Like , this class
21 | /// is a wrapper. Changes to the source collection will
22 | /// be reflected.
23 | ///
24 | public class CastList : ListBase
25 | where TFrom : TTo
26 | {
27 | ///
28 | /// Creats a new .
29 | ///
30 | /// The source collection.
31 | public CastList(IList from)
32 | {
33 | Contract.Requires(from != null);
34 | m_source = from;
35 | }
36 |
37 | ///
38 | /// Gets the element at the specified index.
39 | ///
40 | protected override TTo GetItem(int index)
41 | {
42 | return m_source[index];
43 | }
44 |
45 | ///
46 | /// Gets the number of contained elements.
47 | ///
48 | public override int Count
49 | {
50 | get { return m_source.Count; }
51 | }
52 |
53 | #region Implementation
54 |
55 | [ContractInvariantMethod]
56 | void ObjectInvariant()
57 | {
58 | Contract.Invariant(m_source != null);
59 | }
60 |
61 | private readonly IList m_source;
62 |
63 | #endregion
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/sl4/Test/PropertyWatcherTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Silverlight.Testing;
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
4 | using PixelLab.Common;
5 | using PixelLab.Test.Helpers;
6 |
7 | namespace PixelLab.Test
8 | {
9 | [TestClass]
10 | public class PropertyWatcherTest : SilverlightTest
11 | {
12 | [TestMethod]
13 | public void TestWatch()
14 | {
15 | var changed = false;
16 |
17 | var testInstance = new TestChangeable();
18 |
19 | var watcher = testInstance.AddWatcher("Foo", () => changed = true);
20 |
21 | Assert.IsTrue(watcher.IsWatching("Foo"));
22 |
23 | Assert.IsFalse(changed);
24 | testInstance.Foo = 1;
25 | Assert.IsTrue(changed);
26 |
27 | // test dupe watcher not allowed...
28 | AssertPlus.ExceptionThrown(() =>
29 | {
30 | watcher.AddWatcher("Foo", () => { });
31 | });
32 |
33 | // Clear out the foo watch and try again
34 | watcher.StopWatching("Foo");
35 |
36 | changed = false;
37 | watcher.AddWatcher("Foo", () => changed = true);
38 | testInstance.Foo = 5;
39 |
40 | Assert.IsTrue(changed);
41 |
42 | watcher.StopWatchingAll();
43 |
44 | Assert.IsFalse(watcher.IsWatching("Foo"));
45 |
46 | int changeCount = 0;
47 | watcher.AddWatcher(new[] { "Foo", "Bar", "Baz" }, () => { changeCount++; });
48 | Assert.IsTrue(watcher.IsWatching("Foo"));
49 | Assert.IsTrue(watcher.IsWatching("Bar"));
50 | Assert.IsTrue(watcher.IsWatching("Baz"));
51 |
52 | testInstance.Foo = 10;
53 | testInstance.Bar = 11;
54 | testInstance.Baz = 12;
55 |
56 | Assert.AreEqual(3, changeCount);
57 |
58 | watcher.StopWatchingAll();
59 |
60 | Assert.IsFalse(watcher.IsWatching("Foo"));
61 | Assert.IsFalse(watcher.IsWatching("Bar"));
62 | Assert.IsFalse(watcher.IsWatching("Baz"));
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/net40-client/Bot.Demo/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/sl4/SL4.Demo/ModalControlPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Media;
4 | using PixelLab.Common;
5 | using PixelLab.Demo.Core;
6 |
7 | namespace PixelLab.SL.Demo
8 | {
9 | [DemoMetadata("Modal Control")]
10 | public partial class ModalControlPage : UserControl
11 | {
12 | private int _count = 0;
13 |
14 | public ModalControlPage()
15 | {
16 | InitializeComponent();
17 |
18 | _rootButton.Click += (sender, args) => openModal();
19 |
20 | _modalControl.SetTarget(_rootButton);
21 | }
22 |
23 | private void openModal()
24 | {
25 | var thickness = new Thickness(3);
26 |
27 | var text = new TextBlock { Text = "Modal at level {0}".DoFormat(++_count), Margin = thickness, Padding = thickness };
28 |
29 | var openButton = new Button { Content = "Open another...", Margin = thickness, Padding = thickness };
30 | openButton.Click += (sender, args) => openModal();
31 |
32 | var closeButton = new Button { Content = "Close me!", Margin = thickness, Padding = thickness };
33 |
34 | var stack = new StackPanel();
35 | stack.Children.Add(text);
36 | stack.Children.Add(openButton);
37 | stack.Children.Add(closeButton);
38 |
39 | var border = new Border
40 | {
41 | BorderBrush = Colors.Black.ToCachedBrush(),
42 | BorderThickness = new Thickness(2),
43 | CornerRadius = new CornerRadius(3),
44 | Padding = thickness,
45 | Child = stack,
46 | Background = ColorHelper.HsbToRgb(Util.Rnd.NextFloat(), 0.6f, 1).ToBrush()
47 | };
48 |
49 | var topLeft = this.GetLocationFromRootVisual() + new Vector(Util.Rnd.Next(500), Util.Rnd.Next(500));
50 | var token = _modalControl.Open(border, ModalPosition.TopLeft, topLeft);
51 |
52 | closeButton.Click += (sender, args) =>
53 | {
54 | _modalControl.Close(token);
55 | _count--;
56 | };
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/net40-client/Core/SortedObservableEnumerable.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Collections.Specialized;
3 | using System.Linq;
4 | using PixelLab.Contracts;
5 |
6 | namespace PixelLab.Common
7 | {
8 | public class SortedObservableEnumerable : Changeable, IEnumerable, INotifyCollectionChanged where TSource : class, IEnumerable, INotifyCollectionChanged
9 | {
10 | private readonly TSource _source;
11 | private IComparer _comparer;
12 |
13 | public SortedObservableEnumerable(TSource source, IComparer comparer = null)
14 | {
15 | Contract.Requires(source != null);
16 | _source = source;
17 | _comparer = comparer;
18 | _source.CollectionChanged += (sender, args) =>
19 | {
20 | OnCollectionChanged();
21 | };
22 | }
23 |
24 | public IComparer Comparer
25 | {
26 | get { return _comparer; }
27 | set
28 | {
29 | if (UpdateProperty("Comparer", ref _comparer, value))
30 | {
31 | OnCollectionChanged();
32 | }
33 | }
34 | }
35 |
36 | public IEnumerator GetEnumerator()
37 | {
38 | if (_comparer == null)
39 | {
40 | return _source.GetEnumerator();
41 | }
42 | else
43 | {
44 | return _source.OrderBy(a => a, _comparer).GetEnumerator();
45 | }
46 | }
47 |
48 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
49 | {
50 | return this.GetEnumerator();
51 | }
52 |
53 | public event NotifyCollectionChangedEventHandler CollectionChanged;
54 |
55 | protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args = null)
56 | {
57 | var handler = CollectionChanged;
58 | if (handler != null)
59 | {
60 | handler(this, args ?? new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/net40-client/Core/Changeable.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | #if CONTRACTS_FULL
3 | using System.Diagnostics.Contracts;
4 | #else
5 | using PixelLab.Contracts;
6 | #endif
7 | using System.Collections.Generic;
8 |
9 | namespace PixelLab.Common
10 | {
11 | public abstract class Changeable : INotifyPropertyChanged
12 | {
13 | #if DEBUG
14 | public Changeable()
15 | {
16 | this.VerifyPropertyNamesOnChange();
17 | }
18 | #endif
19 |
20 | public event PropertyChangedEventHandler PropertyChanged;
21 |
22 | protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
23 | {
24 | Contract.Requires(args != null);
25 | var handler = this.PropertyChanged;
26 | if (handler != null)
27 | {
28 | handler(this, args);
29 | }
30 | }
31 |
32 | protected void OnPropertyChanged(string propertyName)
33 | {
34 | Contract.Requires(!propertyName.IsNullOrWhiteSpace());
35 | this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
36 | }
37 |
38 | ///
39 | /// Helper method for raising the PropertyChanged event.
40 | ///
41 | /// The type of the property that has changed.
42 | /// The name of the property that has changed.
43 | /// The original value of the property that has changed.
44 | /// The new value of the property that has changed.
45 | /// True if the property was update; otherwise false.
46 | protected virtual bool UpdateProperty(
47 | string propertyName,
48 | ref T propertyValue,
49 | T value)
50 | {
51 | if (EqualityComparer.Default.Equals(propertyValue, value))
52 | {
53 | return false;
54 | }
55 | else
56 | {
57 | propertyValue = value;
58 | this.OnPropertyChanged(propertyName);
59 | return true;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/sl4/SL4/Helpers_Phone.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | #if CONTRACTS_FULL
3 | using System.Diagnostics.Contracts;
4 | #else
5 | using PixelLab.Contracts;
6 | #endif
7 | using System.Windows;
8 | using System.Windows.Data;
9 | using System.Windows.Media.Imaging;
10 |
11 | namespace PixelLab.SL
12 | {
13 | public static class Helpers
14 | {
15 | public static void WatchDataContextChanged(this FrameworkElement element, Action