├── .gitattributes
├── .gitignore
├── Avalonia.Direct2D1
├── Avalonia.Direct2D1.csproj
├── Direct2D1PlatformInterface.cs
├── HwndSource.cs
├── HwndSourceParameters.cs
├── Input
│ ├── KeyInterop.cs
│ ├── Win32KeyboardDevice.cs
│ └── Win32MouseDevice.cs
├── Interop
│ └── UnmanagedMethods.cs
├── Media
│ ├── Direct2D1DrawingContext.cs
│ ├── Direct2D1FormattedText.cs
│ ├── Direct2D1StreamGeometry.cs
│ ├── Direct2D1StreamGeometryContext.cs
│ ├── Imaging
│ │ ├── Direct2D1RenderTargetBitmap.cs
│ │ ├── WicBitmapDecoder.cs
│ │ ├── WicBitmapEncoder.cs
│ │ └── WicBitmapSource.cs
│ └── MediaExtensions.cs
├── Properties
│ └── AssemblyInfo.cs
├── Settings.StyleCop
├── WindowMessageDispatcher.cs
└── packages.config
├── Avalonia.RenderTests
├── Avalonia.RenderTests.csproj
├── Properties
│ └── AssemblyInfo.cs
├── TestBase.cs
├── app.config
└── packages.config
├── Avalonia.UnitTests
├── Avalonia.UnitTests.csproj
├── Data
│ ├── BindingExpressionTests.cs
│ └── PropertyPathParserTests.cs
├── Media
│ └── PathMarkupParserTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── app.config
└── packages.config
├── Avalonia.sln
├── Avalonia
├── Animation
│ └── Animatable.cs
├── Application.cs
├── Avalonia.csproj
├── AvaloniaCollection.cs
├── AvaloniaSpecificAttribute.cs
├── ContentElement.cs
├── Controls
│ ├── Border.cs
│ ├── Button.cs
│ ├── CheckBox.cs
│ ├── ColumnDefinition.cs
│ ├── ColumnDefinitionCollection.cs
│ ├── ContentControl.cs
│ ├── ContentPresenter.cs
│ ├── Control.cs
│ ├── ControlTemplate.cs
│ ├── Decorator.cs
│ ├── DefinitionBase.cs
│ ├── GenerationState.cs
│ ├── Grid.cs
│ ├── Image.cs
│ ├── ItemCollection.cs
│ ├── ItemContainerGenerator.cs
│ ├── ItemsControl.cs
│ ├── ItemsPanelTemplate.cs
│ ├── ItemsPresenter.cs
│ ├── Panel.cs
│ ├── Primitives
│ │ ├── ButtonBase.cs
│ │ ├── GeneratorDirection.cs
│ │ ├── GeneratorPosition.cs
│ │ ├── IItemContainerGenerator.cs
│ │ ├── IRecyclingItemContainerGenerator.cs
│ │ ├── ItemsChangedEventArgs.cs
│ │ ├── Popup.cs
│ │ ├── PopupRoot.cs
│ │ ├── Selector.cs
│ │ ├── TextBoxBase.cs
│ │ └── ToggleButton.cs
│ ├── RangeCollection - Copy.cs
│ ├── RangeCollection.cs
│ ├── RowDefinition.cs
│ ├── RowDefinitionCollection.cs
│ ├── SelectionChangedEventArgs.cs
│ ├── StackPanel.cs
│ ├── TemplateContent.cs
│ ├── TextBlock.cs
│ ├── TextBox.cs
│ ├── TextBoxView.cs
│ ├── UIElementCollection.cs
│ ├── UserControl.cs
│ └── VirtualizingPanel.cs
├── CornerRadius.cs
├── CornerRadiusConverter.cs
├── Data
│ ├── Binding.cs
│ ├── BindingBase.cs
│ ├── BindingExpression.cs
│ ├── BindingExpressionBase.cs
│ ├── BindingOperations.cs
│ ├── CollectionView.cs
│ ├── CollectionViewSource.cs
│ ├── CurrentChangingEventArgs.cs
│ ├── EnumerableCollectionView.cs
│ ├── GroupDescription.cs
│ ├── ICollectionView.cs
│ ├── IPropertyPathParser.cs
│ ├── ListCollectionView.cs
│ ├── PropertyPathParser.cs
│ ├── PropertyPathToken.cs
│ ├── RelativeSource.cs
│ └── UpdateSourceTrigger.cs
├── DataTemplate.cs
├── DataTemplateKey.cs
├── DependencyObject.cs
├── DependencyObjectType.cs
├── DependencyProperty.cs
├── DependencyPropertyChangedEventArgs.cs
├── DependencyPropertyConverter.cs
├── DependencyPropertyKey.cs
├── Document
│ └── TextElement.cs
├── EventManager.cs
├── Expression.cs
├── FlowDirection.cs
├── FontStretch.cs
├── FontStyle.cs
├── FontStyles.cs
├── FontWeight.cs
├── FontWeights.cs
├── FrameworkContentElement.cs
├── FrameworkElement.cs
├── FrameworkElementFactory.cs
├── FrameworkPropertyMetadata.cs
├── FrameworkTemplate.cs
├── Freezable.cs
├── GridLength.cs
├── GridLengthConverter.cs
├── IInputElement.cs
├── IObservableDependencyObject.cs
├── ITopLevelWindow.cs
├── IWeakEventListener.cs
├── Input
│ ├── InputDevice.cs
│ ├── InputEventArgs.cs
│ ├── InputManager.cs
│ ├── Key.cs
│ ├── KeyEventArgs.cs
│ ├── Keyboard.cs
│ ├── KeyboardDevice.cs
│ ├── KeyboardEventArgs.cs
│ ├── KeyboardFocusChangedEventArgs.cs
│ ├── Mouse.cs
│ ├── MouseButtonEventArgs.cs
│ ├── MouseDevice.cs
│ ├── MouseEventArgs.cs
│ ├── PreProcessInputEventArgs.cs
│ ├── TextComposition.cs
│ ├── TextCompositionEventArgs.cs
│ └── TextCompositionManager.cs
├── Interop
│ └── WindowInteropHelper.cs
├── LayoutManager.cs
├── LocalValueEntry.cs
├── LocalValueEnumerator.cs
├── LogicalTreeHelper.cs
├── Media
│ ├── Brush.cs
│ ├── BrushConverter.cs
│ ├── Color.cs
│ ├── Colors.cs
│ ├── DrawingContext.cs
│ ├── FontFamily.cs
│ ├── FontFamilyConverter.cs
│ ├── FormattedText.cs
│ ├── Geometry.cs
│ ├── GeometryConverter.cs
│ ├── HitTestParameters.cs
│ ├── HitTestResult.cs
│ ├── ImageSource.cs
│ ├── ImageSourceConverter.cs
│ ├── Imaging
│ │ ├── BitmapDecoder.cs
│ │ ├── BitmapEncoder.cs
│ │ ├── BitmapFrame.cs
│ │ ├── BitmapSource.cs
│ │ ├── JpegBitmapDecoder.cs
│ │ ├── PngBitmapDecoder.cs
│ │ ├── PngBitmapEncoder.cs
│ │ └── RenderTargetBitmap.cs
│ ├── Matrix.cs
│ ├── MatrixTransform.cs
│ ├── PathMarkupParser.cs
│ ├── Pen.cs
│ ├── PixelFormat.cs
│ ├── PixelFormats.cs
│ ├── PointHitTestParameters.cs
│ ├── PointHitTestResult.cs
│ ├── RectangleGeometry.cs
│ ├── SolidColorBrush.cs
│ ├── StreamGeometry.cs
│ ├── StreamGeometryContext.cs
│ ├── Stretch.cs
│ ├── Transform.cs
│ ├── TranslateTransform.cs
│ ├── Typeface.cs
│ ├── Visual.cs
│ ├── VisualTreeHelper.cs
│ └── XamlReader.cs
├── NameScope.cs
├── Platform
│ ├── BitmapContainerFormat.cs
│ ├── IPlatformBitmapDecoder.cs
│ ├── IPlatformBitmapEncoder.cs
│ ├── IPlatformBitmapSource.cs
│ ├── IPlatformDispatcher.cs
│ ├── IPlatformFormattedText.cs
│ ├── IPlatformRenderTargetBitmap.cs
│ ├── IPlatformStreamGeometry.cs
│ ├── PlatformInterface.cs
│ ├── PlatformPresentationSource.cs
│ ├── RawKeyEventArgs.cs
│ └── RawMouseEventArgs.cs
├── Point.cs
├── PresentationSource.cs
├── Properties
│ └── AssemblyInfo.cs
├── PropertyMetadata.cs
├── PropertyPath.cs
├── Rect.cs
├── Renderer.cs
├── ResourceDictionary.cs
├── ResourceKey.cs
├── ResourceReferenceKeyNotFoundException.cs
├── Resources
│ └── StreamResourceInfo.cs
├── RoutedEvent.cs
├── RoutedEventArgs.cs
├── Setter.cs
├── SetterBase.cs
├── SetterBaseCollection.cs
├── Settings.StyleCop
├── Shapes
│ ├── Path.cs
│ ├── Rectangle.cs
│ └── Shape.cs
├── Size.cs
├── Style.cs
├── TemplateBindingExtension.cs
├── TemplateContentLoader.cs
├── TemplateKey.cs
├── TemplatePartAttribute.cs
├── Themes
│ └── Generic.xaml
├── Thickness.cs
├── ThicknessConverter.cs
├── Threading
│ ├── Dispatcher.cs
│ ├── DispatcherEventArgs.cs
│ ├── DispatcherFrame.cs
│ ├── DispatcherHookEventArgs.cs
│ ├── DispatcherHooks.cs
│ ├── DispatcherObject.cs
│ ├── DispatcherOperation.cs
│ ├── DispatcherProcessingDisabled.cs
│ ├── DispatcherTimer.cs
│ ├── DispatcherUnhandledExceptionEventArgs.cs
│ └── DispatcherUnhandledExceptionFilterEventArgs.cs
├── Trigger.cs
├── TriggerBase.cs
├── TriggerCollection.cs
├── UIElement.cs
├── UIPropertyMetadata.cs
├── Utils
│ ├── DoubleKeyedDictionary.cs
│ ├── IListenCollectionChanged.cs
│ ├── IWeakListener.cs
│ ├── PackUri.cs
│ └── WeakCollectionChangedListener.cs
├── Vector.cs
├── Window.cs
└── packages.config
├── README.md
├── Test
├── App.config
├── App.cs
├── MainWindow.cs
├── MainWindow.xaml
├── Properties
│ └── AssemblyInfo.cs
├── Test.csproj
├── abc_horiz.png
├── abc_vert.png
└── github_icon.png
├── TestFiles
├── .gitignore
├── Controls
│ └── Border
│ │ ├── CornerRadius_Uniform.expected.png
│ │ ├── CornerRadius_Uniform.xaml
│ │ ├── Fill.expected.png
│ │ ├── Fill.xaml
│ │ ├── Fill_Stroke.expected.png
│ │ ├── Fill_Stroke.xaml
│ │ ├── Fill_TransparentStroke.expected.png
│ │ ├── Fill_TransparentStroke.xaml
│ │ ├── Stroke_13px.expected.png
│ │ ├── Stroke_13px.xaml
│ │ ├── Stroke_1px.expected.png
│ │ ├── Stroke_1px.xaml
│ │ ├── Stroke_2px.expected.png
│ │ ├── Stroke_2px.xaml
│ │ ├── Stroke_3px.expected.png
│ │ ├── Stroke_3px.xaml
│ │ ├── Stroke_4px.expected.png
│ │ └── Stroke_4px.xaml
├── Media
│ └── DrawingContext
│ │ ├── DrawGeometry_Cubic_Besier_Curve.expected.png
│ │ ├── DrawGeometry_Rectangle_Fill.expected.png
│ │ ├── DrawRectangle_Fill.expected.png
│ │ ├── DrawRectangle_Fill_Stroke.expected.png
│ │ ├── DrawRectangle_Fill_Transparent_Stroke.expected.png
│ │ ├── DrawRectangle_Stroke_1px.expected.png
│ │ ├── DrawRectangle_Stroke_2px.expected.png
│ │ └── DrawText_Various_Sizes.expected.png
└── Shapes
│ ├── Path
│ ├── Cubic_Besier_Curve.expected.png
│ ├── Cubic_Besier_Curve.xaml
│ ├── Triangle_Fill.expected.png
│ ├── Triangle_Fill.xaml
│ ├── Triangle_Offset_Top.expected.png
│ ├── Triangle_Offset_Top.xaml
│ ├── Triangle_Uniform.expected.png
│ ├── Triangle_Uniform.xaml
│ ├── Triangle_UniformToFill.expected.png
│ └── Triangle_UniformToFill.xaml
│ └── Rectangle
│ ├── CornerRadius_Uniform.expected.png
│ ├── CornerRadius_Uniform.xaml
│ ├── Fill.expected.png
│ ├── Fill.xaml
│ ├── Fill_Stroke.expected.png
│ ├── Fill_Stroke.xaml
│ ├── Fill_TransparentStroke.expected.png
│ ├── Fill_TransparentStroke.xaml
│ ├── Stroke_13px.expected.png
│ ├── Stroke_13px.xaml
│ ├── Stroke_1px.expected.png
│ ├── Stroke_1px.xaml
│ ├── Stroke_2px.expected.png
│ ├── Stroke_2px.xaml
│ ├── Stroke_3px.expected.png
│ ├── Stroke_3px.xaml
│ ├── Stroke_4px.expected.png
│ └── Stroke_4px.xaml
├── Wpf.RenderTests
├── Controls
│ └── BorderTests.cs
├── Media
│ └── DrawingContextTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── Shapes
│ ├── PathTests.cs
│ └── RectangleTests.cs
├── TestBase.cs
├── Wpf.RenderTests.csproj
└── packages.config
├── Wpf.UnitTests
├── Controls
│ ├── ContentControlTests.cs
│ ├── ContentControl_MeasureArrangeTests.cs
│ ├── ItemsControlTests.cs
│ └── Primitives
│ │ └── SelectorTests.cs
├── Data
│ ├── CollectionViewSourceTests.cs
│ └── CollectionViewTests.cs
├── DependencyObjectTests_Inheritance.cs
├── DependencyPropertyTests_AddOwner.cs
├── DependencyPropertyTests_GetMetadata.cs
├── DependencyPropertyTests_IsValidType.cs
├── DependencyPropertyTests_Register.cs
├── DependencyPropertyTests_RegisterAttached.cs
├── FrameworkElement_MeasureArrangeTests.cs
├── FrameworkElement_TemplateTests.cs
├── Input
│ └── WpfInputManagerTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── Shapes
│ └── RectangleTests.cs
├── UIElement_MeasureArrangeTests.cs
└── Wpf.UnitTests.csproj
├── licence.md
└── packages
├── Magick.NET-Q16-x86.6.8.6.801
├── Magick.NET-Q16-x86.6.8.6.801.nupkg
├── Magick.NET-Q16-x86.6.8.6.801.nuspec
├── Readme.txt
└── lib
│ ├── net20
│ ├── Magick.NET-x86.dll
│ └── Magick.NET-x86.xml
│ └── net40-client
│ ├── Magick.NET-x86.dll
│ └── Magick.NET-x86.xml
├── Moq.4.0.10827
├── License.txt
├── Moq.4.0.10827.nupkg
├── Moq.4.0.10827.nuspec
├── Moq.chm
└── lib
│ ├── NET35
│ ├── Moq.dll
│ └── Moq.xml
│ ├── NET40
│ ├── Moq.dll
│ └── Moq.xml
│ └── Silverlight4
│ ├── Castle.Core.dll
│ ├── Moq.Silverlight.dll
│ └── Moq.Silverlight.xml
├── SharpDX.2.5.0
├── SharpDX.2.5.0.nupkg
├── SharpDX.2.5.0.nuspec
└── lib
│ ├── net20
│ ├── SharpDX.dll
│ └── SharpDX.xml
│ ├── net40
│ ├── SharpDX.dll
│ └── SharpDX.xml
│ └── win8
│ ├── SharpDX.dll
│ └── SharpDX.xml
├── SharpDX.D3DCompiler.2.5.0
├── SharpDX.D3DCompiler.2.5.0.nupkg
├── SharpDX.D3DCompiler.2.5.0.nuspec
└── lib
│ ├── net20
│ ├── SharpDX.D3DCompiler.dll
│ └── SharpDX.D3DCompiler.xml
│ ├── net40
│ ├── SharpDX.D3DCompiler.dll
│ └── SharpDX.D3DCompiler.xml
│ └── win8
│ ├── SharpDX.D3DCompiler.dll
│ └── SharpDX.D3DCompiler.xml
├── SharpDX.DXGI.2.5.0
├── SharpDX.DXGI.2.5.0.nupkg
├── SharpDX.DXGI.2.5.0.nuspec
└── lib
│ ├── net20
│ ├── SharpDX.DXGI.dll
│ └── SharpDX.DXGI.xml
│ ├── net40
│ ├── SharpDX.DXGI.dll
│ └── SharpDX.DXGI.xml
│ └── win8
│ ├── SharpDX.DXGI.dll
│ └── SharpDX.DXGI.xml
├── SharpDX.Direct2D1.2.5.0
├── SharpDX.Direct2D1.2.5.0.nupkg
├── SharpDX.Direct2D1.2.5.0.nuspec
└── lib
│ ├── net20
│ ├── SharpDX.Direct2D1.dll
│ └── SharpDX.Direct2D1.xml
│ ├── net40
│ ├── SharpDX.Direct2D1.dll
│ └── SharpDX.Direct2D1.xml
│ └── win8
│ ├── SharpDX.Direct2D1.dll
│ └── SharpDX.Direct2D1.xml
├── SharpDX.Direct3D10.2.5.0
├── SharpDX.Direct3D10.2.5.0.nupkg
├── SharpDX.Direct3D10.2.5.0.nuspec
└── lib
│ ├── net20
│ ├── SharpDX.Direct3D10.dll
│ └── SharpDX.Direct3D10.xml
│ └── net40
│ ├── SharpDX.Direct3D10.dll
│ └── SharpDX.Direct3D10.xml
├── StyleCop.MSBuild.4.7.44.1
└── tools
│ ├── StyleCop.CSharp.Rules.dll
│ ├── StyleCop.CSharp.dll
│ ├── StyleCop.dll
│ ├── de-DE
│ └── StyleCop.CSharp.Rules.resources.dll
│ ├── en-GB
│ └── StyleCop.CSharp.Rules.resources.dll
│ ├── fr-FR
│ └── StyleCop.CSharp.Rules.resources.dll
│ ├── pl-PL
│ └── StyleCop.CSharp.Rules.resources.dll
│ ├── pt-BR
│ └── StyleCop.CSharp.Rules.resources.dll
│ └── ru-RU
│ └── StyleCop.CSharp.Rules.resources.dll
└── repositories.config
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/Avalonia.Direct2D1/HwndSourceParameters.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Direct2D1
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Threading.Tasks;
14 |
15 | public struct HwndSourceParameters
16 | {
17 | public HwndSourceParameters(string name)
18 | : this()
19 | {
20 | this.WindowName = name;
21 | }
22 |
23 | public HwndSourceParameters(string name, int width, int height)
24 | : this()
25 | {
26 | this.WindowName = name;
27 | this.Width = width;
28 | this.Height = height;
29 | }
30 |
31 | public bool AdjustSizingForNonClientArea { get; set; }
32 |
33 | public int ExtendedWindowStyle { get; set; }
34 |
35 | public int Height { get; set; }
36 |
37 | public IntPtr ParentWindow { get; set; }
38 |
39 | public int PositionX { get; set; }
40 |
41 | public int PositionY { get; set; }
42 |
43 | public int Width { get; set; }
44 |
45 | public int WindowClassStyle { get; set; }
46 |
47 | public string WindowName { get; set; }
48 |
49 | public int WindowStyle { get; set; }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Avalonia.Direct2D1/Media/Direct2D1StreamGeometry.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Direct2D1.Media
8 | {
9 | using Avalonia.Media;
10 | using Avalonia.Platform;
11 | using SharpDX.Direct2D1;
12 |
13 | public class Direct2D1StreamGeometry : IPlatformStreamGeometry
14 | {
15 | public Direct2D1StreamGeometry(PathGeometry impl)
16 | {
17 | this.Direct2DGeometry = impl;
18 | }
19 |
20 | public Rect Bounds
21 | {
22 | get { return this.Direct2DGeometry.GetBounds().ToAvalonia(); }
23 | }
24 |
25 | public PathGeometry Direct2DGeometry
26 | {
27 | get;
28 | private set;
29 | }
30 |
31 | public void Dispose()
32 | {
33 | this.Direct2DGeometry.Dispose();
34 | }
35 |
36 | public Rect GetRenderBounds(Pen pen, double tolerance, ToleranceType type)
37 | {
38 | float strokeWidth = (pen != null) ? (float)pen.Thickness : 0f;
39 | return this.Direct2DGeometry.GetWidenedBounds(strokeWidth, (float)tolerance).ToAvalonia();
40 | }
41 |
42 | public StreamGeometryContext Open()
43 | {
44 | return new Direct2D1StreamGeometryContext(this.Direct2DGeometry.Open());
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Avalonia.Direct2D1/Media/Imaging/Direct2D1RenderTargetBitmap.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Direct2D1.Media.Imaging
8 | {
9 | using System;
10 | using Avalonia.Direct2D1.Media;
11 | using Avalonia.Media;
12 | using Avalonia.Platform;
13 | using SharpDX.Direct2D1;
14 | using SharpDX.WIC;
15 | using WicBitmap = SharpDX.WIC.Bitmap;
16 |
17 | public class Direct2D1RenderTargetBitmap : WicBitmapSource, IPlatformRenderTargetBitmap
18 | {
19 | private Factory d2dFactory;
20 |
21 | private WicRenderTarget target;
22 |
23 | public Direct2D1RenderTargetBitmap(
24 | Factory d2dFactory,
25 | ImagingFactory wicFactory,
26 | SharpDX.WIC.Bitmap bitmap)
27 | : base(wicFactory, bitmap)
28 | {
29 | double dpiX;
30 | double dpiY;
31 |
32 | this.d2dFactory = d2dFactory;
33 | bitmap.GetResolution(out dpiX, out dpiY);
34 |
35 | this.target = new WicRenderTarget(
36 | d2dFactory,
37 | bitmap,
38 | new RenderTargetProperties
39 | {
40 | DpiX = (float)dpiX,
41 | DpiY = (float)dpiY,
42 | });
43 | }
44 |
45 | public DrawingContext CreateDrawingContext()
46 | {
47 | return new Direct2D1DrawingContext(this.d2dFactory, this.target);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Avalonia.Direct2D1/Media/Imaging/WicBitmapEncoder.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Direct2D1.Media.Imaging
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.IO;
12 | using System.Linq;
13 | using Avalonia.Media.Imaging;
14 | using Avalonia.Platform;
15 | using SharpDX.WIC;
16 |
17 | public class WicBitmapEncoder : IPlatformBitmapEncoder
18 | {
19 | private static readonly Guid[] FormatGuids = new[]
20 | {
21 | ContainerFormatGuids.Bmp,
22 | ContainerFormatGuids.Png,
23 | ContainerFormatGuids.Ico,
24 | ContainerFormatGuids.Jpeg,
25 | ContainerFormatGuids.Tiff,
26 | ContainerFormatGuids.Gif,
27 | ContainerFormatGuids.Wmp,
28 | };
29 |
30 | private SharpDX.WIC.BitmapEncoder wicImpl;
31 |
32 | public WicBitmapEncoder(ImagingFactory factory, BitmapContainerFormat format)
33 | {
34 | this.wicImpl = new SharpDX.WIC.BitmapEncoder(factory, FormatGuids[(int)format]);
35 | }
36 |
37 | public void Save(IEnumerable frames, Stream stream)
38 | {
39 | this.wicImpl.Initialize(stream);
40 |
41 | foreach (WicBitmapSource source in frames.Select(x => x.PlatformImpl))
42 | {
43 | BitmapFrameEncode frame = new BitmapFrameEncode(this.wicImpl);
44 | frame.Initialize();
45 | frame.WriteSource(source.WicImpl);
46 | frame.Commit();
47 | }
48 |
49 | this.wicImpl.Commit();
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Avalonia.Direct2D1/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | using System.Reflection;
8 | using System.Runtime.CompilerServices;
9 | using System.Runtime.InteropServices;
10 |
11 | // General Information about an assembly is controlled through the following
12 | // set of attributes. Change these attribute values to modify the information
13 | // associated with an assembly.
14 | [assembly: AssemblyTitle("Avalonia.Direct2D1")]
15 | [assembly: AssemblyDescription("")]
16 | [assembly: AssemblyConfiguration("")]
17 | [assembly: AssemblyCompany("")]
18 | [assembly: AssemblyProduct("Avalonia.Direct2D1")]
19 | [assembly: AssemblyCopyright("Copyright © 2013")]
20 | [assembly: AssemblyTrademark("")]
21 | [assembly: AssemblyCulture("")]
22 |
23 | // Setting ComVisible to false makes the types in this assembly not visible
24 | // to COM components. If you need to access a type in this assembly from
25 | // COM, set the ComVisible attribute to true on that type.
26 | [assembly: ComVisible(false)]
27 |
28 | // The following GUID is for the ID of the typelib if this project is exposed to COM
29 | [assembly: Guid("720f8422-49a1-4743-b11d-e9d14ca32af9")]
30 |
31 | // Version information for an assembly consists of the following four values:
32 | //
33 | // Major Version
34 | // Minor Version
35 | // Build Number
36 | // Revision
37 | //
38 | // You can specify all the values or you can default the Build and Revision Numbers
39 | // by using the '*' as shown below:
40 | // [assembly: AssemblyVersion("1.0.*")]
41 | [assembly: AssemblyVersion("1.0.0.0")]
42 | [assembly: AssemblyFileVersion("1.0.0.0")]
43 |
--------------------------------------------------------------------------------
/Avalonia.Direct2D1/WindowMessageDispatcher.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Direct2D1
8 | {
9 | using System;
10 | using Avalonia.Direct2D1.Interop;
11 | using Avalonia.Interop;
12 | using Avalonia.Platform;
13 | using Avalonia.Threading;
14 |
15 | public class WindowMessageDispatcher : IPlatformDispatcher
16 | {
17 | public void ProcessMessage()
18 | {
19 | UnmanagedMethods.MSG msg;
20 | UnmanagedMethods.GetMessage(out msg, IntPtr.Zero, 0, 0);
21 | UnmanagedMethods.TranslateMessage(ref msg);
22 | UnmanagedMethods.DispatchMessage(ref msg);
23 | }
24 |
25 | public void SendMessage()
26 | {
27 | IntPtr result = UnmanagedMethods.PostMessage(
28 | IntPtr.Zero,
29 | (int)UnmanagedMethods.WindowsMessage.WM_DISPATCH_WORK_ITEM,
30 | IntPtr.Zero,
31 | IntPtr.Zero);
32 | }
33 |
34 | private IntPtr GetHwnd()
35 | {
36 | return new WindowInteropHelper(Application.Current.MainWindow).Handle;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Avalonia.Direct2D1/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Avalonia.RenderTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Avalonia.RenderTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Avalonia.RenderTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("29b43034-6fed-41cd-83b9-465dfbb99875")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Avalonia.RenderTests/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Avalonia.RenderTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Avalonia.UnitTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Avalonia.UnitTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Avalonia.UnitTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("37528eb1-1443-479a-af57-958c57f7d261")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Avalonia.UnitTests/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Avalonia.UnitTests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Avalonia/Animation/Animatable.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Animation
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Threading.Tasks;
14 |
15 | public class Animatable : Freezable
16 | {
17 | protected override Freezable CreateInstanceCore()
18 | {
19 | throw new NotImplementedException();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Avalonia/AvaloniaSpecificAttribute.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Threading.Tasks;
14 |
15 | public class AvaloniaSpecificAttribute : Attribute
16 | {
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Avalonia/ContentElement.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia
8 | {
9 | public class ContentElement : DependencyObject
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Avalonia/Controls/Button.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | using Avalonia.Controls.Primitives;
10 |
11 | public class Button : ButtonBase
12 | {
13 | static Button()
14 | {
15 | DefaultStyleKeyProperty.OverrideMetadata(typeof(Button), new FrameworkPropertyMetadata(typeof(Button)));
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Avalonia/Controls/CheckBox.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | using Avalonia.Controls.Primitives;
10 |
11 | public class CheckBox : ToggleButton
12 | {
13 | static CheckBox()
14 | {
15 | DefaultStyleKeyProperty.OverrideMetadata(typeof(CheckBox), new FrameworkPropertyMetadata(typeof(CheckBox)));
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Avalonia/Controls/ColumnDefinitionCollection.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | public class ColumnDefinitionCollection : AvaloniaCollection
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Avalonia/Controls/ControlTemplate.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | using System;
10 | using System.Windows.Markup;
11 | using Avalonia.Media;
12 |
13 | public class ControlTemplate : FrameworkTemplate
14 | {
15 | public ControlTemplate()
16 | {
17 | this.Triggers = new TriggerCollection();
18 | }
19 |
20 | [AmbientAttribute]
21 | public Type TargetType
22 | {
23 | get;
24 | set;
25 | }
26 |
27 | public TriggerCollection Triggers
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | internal override FrameworkElement CreateVisualTree(DependencyObject parent)
34 | {
35 | FrameworkElement result = base.CreateVisualTree(parent);
36 |
37 | foreach (TriggerBase trigger in this.Triggers)
38 | {
39 | trigger.Attach(result, parent);
40 | }
41 |
42 | return result;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Avalonia/Controls/DefinitionBase.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | public class DefinitionBase : FrameworkContentElement
10 | {
11 | public static readonly DependencyProperty SharedSizeGroupProperty =
12 | DependencyProperty.Register(
13 | "SharedSizeGroup",
14 | typeof(string),
15 | typeof(DefinitionBase),
16 | new FrameworkPropertyMetadata(
17 | null,
18 | FrameworkPropertyMetadataOptions.Inherits));
19 |
20 | public string SharedSizeGroup
21 | {
22 | get { return (string)this.GetValue(SharedSizeGroupProperty); }
23 | set { this.SetValue(SharedSizeGroupProperty, value); }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Avalonia/Controls/GenerationState.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | using System;
10 | using Avalonia.Controls.Primitives;
11 |
12 | internal class GenerationState : IDisposable
13 | {
14 | public bool AllowStartAtRealizedItem { get; set; }
15 |
16 | public GeneratorDirection Direction { get; set; }
17 |
18 | public ItemContainerGenerator Generator { get; set; }
19 |
20 | public GeneratorPosition Position { get; set; }
21 |
22 | public int Step
23 | {
24 | get { return this.Direction == GeneratorDirection.Forward ? 1 : -1; }
25 | }
26 |
27 | public void Dispose()
28 | {
29 | this.Generator.GenerationState = null;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Avalonia/Controls/ItemsPanelTemplate.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | public class ItemsPanelTemplate : FrameworkTemplate
10 | {
11 | public ItemsPanelTemplate()
12 | {
13 | }
14 |
15 | public ItemsPanelTemplate(FrameworkElementFactory root)
16 | {
17 | this.VisualTree = root;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Avalonia/Controls/Primitives/GeneratorDirection.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls.Primitives
8 | {
9 | public enum GeneratorDirection
10 | {
11 | Forward,
12 | Backward
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Avalonia/Controls/Primitives/GeneratorPosition.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls.Primitives
8 | {
9 | using System;
10 |
11 | public struct GeneratorPosition
12 | {
13 | public GeneratorPosition(int index, int offset)
14 | : this()
15 | {
16 | this.Index = index;
17 | this.Offset = offset;
18 | }
19 |
20 | public int Index
21 | {
22 | get;
23 | set;
24 | }
25 |
26 | public int Offset
27 | {
28 | get;
29 | set;
30 | }
31 |
32 | public static bool operator ==(GeneratorPosition gp1, GeneratorPosition gp2)
33 | {
34 | return gp1.Index == gp2.Index && gp1.Offset == gp2.Offset;
35 | }
36 |
37 | public static bool operator !=(GeneratorPosition gp1, GeneratorPosition gp2)
38 | {
39 | return !(gp1 == gp2);
40 | }
41 |
42 | public override bool Equals(object o)
43 | {
44 | return o is GeneratorPosition && this == ((GeneratorPosition)o);
45 | }
46 |
47 | public override int GetHashCode()
48 | {
49 | return this.Index + this.Offset;
50 | }
51 |
52 | public override string ToString()
53 | {
54 | return string.Format("GeneratorPosition ({0},{1})", this.Index, this.Offset);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Avalonia/Controls/Primitives/IItemContainerGenerator.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls.Primitives
8 | {
9 | using System;
10 |
11 | public interface IItemContainerGenerator
12 | {
13 | DependencyObject GenerateNext(out bool isNewlyRealized);
14 |
15 | GeneratorPosition GeneratorPositionFromIndex(int itemIndex);
16 |
17 | ItemContainerGenerator GetItemContainerGeneratorForPanel(Panel panel);
18 |
19 | int IndexFromGeneratorPosition(GeneratorPosition position);
20 |
21 | void PrepareItemContainer(DependencyObject container);
22 |
23 | void Remove(GeneratorPosition position, int count);
24 |
25 | void RemoveAll();
26 |
27 | IDisposable StartAt(
28 | GeneratorPosition position,
29 | GeneratorDirection direction,
30 | bool allowStartAtRealizedItem);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Avalonia/Controls/Primitives/IRecyclingItemContainerGenerator.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls.Primitives
8 | {
9 | public interface IRecyclingItemContainerGenerator : IItemContainerGenerator
10 | {
11 | void Recycle(GeneratorPosition position, int count);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Avalonia/Controls/Primitives/ItemsChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls.Primitives
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Collections.Specialized;
12 | using System.Linq;
13 | using System.Text;
14 | using System.Threading.Tasks;
15 |
16 | public delegate void ItemsChangedEventHandler(object sender, ItemsChangedEventArgs e);
17 |
18 | public class ItemsChangedEventArgs : EventArgs
19 | {
20 | internal ItemsChangedEventArgs()
21 | {
22 | }
23 |
24 | public NotifyCollectionChangedAction Action
25 | {
26 | get;
27 | internal set;
28 | }
29 |
30 | public int ItemCount
31 | {
32 | get;
33 | internal set;
34 | }
35 |
36 | public int ItemUICount
37 | {
38 | get;
39 | internal set;
40 | }
41 |
42 | public GeneratorPosition OldPosition
43 | {
44 | get;
45 | internal set;
46 | }
47 |
48 | public GeneratorPosition Position
49 | {
50 | get;
51 | internal set;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Avalonia/Controls/Primitives/TextBoxBase.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls.Primitives
8 | {
9 | using System;
10 | using Avalonia.Media;
11 |
12 | [TemplatePartAttribute(Name = "PART_ContentHost", Type = typeof(FrameworkElement))]
13 | public class TextBoxBase : Control
14 | {
15 | public static readonly DependencyProperty CaretBrushProperty =
16 | DependencyProperty.Register(
17 | "CaretBrush",
18 | typeof(Brush),
19 | typeof(TextBoxBase),
20 | new FrameworkPropertyMetadata(
21 | null,
22 | FrameworkPropertyMetadataOptions.AffectsRender));
23 |
24 | public Brush CaretBrush
25 | {
26 | get { return (Brush)this.GetValue(CaretBrushProperty); }
27 | set { this.SetValue(CaretBrushProperty, value); }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Avalonia/Controls/Primitives/ToggleButton.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls.Primitives
8 | {
9 | using System.ComponentModel;
10 | using Avalonia.Input;
11 |
12 | public class ToggleButton : ButtonBase
13 | {
14 | public static readonly DependencyProperty IsCheckedProperty =
15 | DependencyProperty.Register(
16 | "IsChecked",
17 | typeof(bool?),
18 | typeof(ToggleButton),
19 | new FrameworkPropertyMetadata(
20 | false,
21 | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
22 |
23 | public bool? IsChecked
24 | {
25 | get { return (bool?)this.GetValue(IsCheckedProperty); }
26 | set { this.SetValue(IsCheckedProperty, value); }
27 | }
28 |
29 | protected override void OnClick()
30 | {
31 | bool? isChecked = this.IsChecked;
32 | this.IsChecked = isChecked.HasValue ? !isChecked : false;
33 | base.OnClick();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Avalonia/Controls/RowDefinitionCollection.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | public class RowDefinitionCollection : AvaloniaCollection
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Avalonia/Controls/SelectionChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | using System;
10 | using System.Collections;
11 |
12 | public delegate void SelectionChangedEventHandler(object sender, SelectionChangedEventArgs e);
13 |
14 | public class SelectionChangedEventArgs : RoutedEventArgs
15 | {
16 | public SelectionChangedEventArgs(RoutedEvent id, IList removedItems, IList addedItems)
17 | : base(id)
18 | {
19 | this.AddedItems = addedItems;
20 | this.RemovedItems = removedItems;
21 | }
22 |
23 | public IList AddedItems { get; private set; }
24 |
25 | public IList RemovedItems { get; private set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Avalonia/Controls/TemplateContent.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Xaml;
14 |
15 | public class TemplateContent
16 | {
17 | private XamlNodeList nodeList;
18 |
19 | private Dictionary typesByName;
20 |
21 | internal TemplateContent(XamlNodeList nodeList, Dictionary typesByName)
22 | {
23 | this.nodeList = nodeList;
24 | this.typesByName = typesByName;
25 | }
26 |
27 | internal Type GetTypeForName(string name)
28 | {
29 | Type result;
30 |
31 | if (!this.typesByName.TryGetValue(name, out result))
32 | {
33 | throw new KeyNotFoundException(string.Format(
34 | "Element '{0}' not found in TemplateContent.",
35 | name));
36 | }
37 |
38 | return result;
39 | }
40 |
41 | internal object Load()
42 | {
43 | return Avalonia.Media.XamlReader.Load(this.nodeList.GetReader());
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Avalonia/Controls/UserControl.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | public class UserControl : ContentControl
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Avalonia/Controls/VirtualizingPanel.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Controls
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Threading.Tasks;
14 |
15 | public class VirtualizingPanel : Panel
16 | {
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Avalonia/CornerRadius.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.ComponentModel;
12 | using System.Linq;
13 | using System.Text;
14 | using System.Threading.Tasks;
15 |
16 | [TypeConverter(typeof(CornerRadiusConverter))]
17 | public struct CornerRadius
18 | {
19 | public CornerRadius(double uniformRadius)
20 | : this()
21 | {
22 | this.BottomLeft = this.BottomRight = this.TopLeft = this.TopRight = uniformRadius;
23 | }
24 |
25 | public CornerRadius(double topLeft, double topRight, double bottomRight, double bottomLeft)
26 | : this()
27 | {
28 | this.TopLeft = topLeft;
29 | this.TopRight = topRight;
30 | this.BottomLeft = bottomLeft;
31 | this.BottomRight = bottomRight;
32 | }
33 |
34 | public double BottomLeft { get; set; }
35 |
36 | public double BottomRight { get; set; }
37 |
38 | public double TopLeft { get; set; }
39 |
40 | public double TopRight { get; set; }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Avalonia/CornerRadiusConverter.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.ComponentModel;
12 | using System.Linq;
13 | using System.Text;
14 | using System.Threading.Tasks;
15 |
16 | public class CornerRadiusConverter : TypeConverter
17 | {
18 | public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
19 | {
20 | return sourceType == typeof(string);
21 | }
22 |
23 | public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
24 | {
25 | char[] separators = new char[] { ' ', ',' };
26 | string[] components = value.ToString().Split(separators, StringSplitOptions.RemoveEmptyEntries);
27 |
28 | if (components.Length == 1)
29 | {
30 | return new CornerRadius(double.Parse(components[0]));
31 | }
32 | else
33 | {
34 | if (components.Length == 4)
35 | {
36 | return new CornerRadius(
37 | double.Parse(components[0]),
38 | double.Parse(components[1]),
39 | double.Parse(components[2]),
40 | double.Parse(components[3]));
41 | }
42 | else
43 | {
44 | throw new NotSupportedException("Value is not valid: must contain one or four delineated lengths.");
45 | }
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Avalonia/Data/Binding.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Data
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Threading.Tasks;
14 |
15 | public class Binding : BindingBase
16 | {
17 | public Binding()
18 | {
19 | }
20 |
21 | public Binding(string path)
22 | {
23 | this.Path = new PropertyPath(path);
24 | }
25 |
26 | public PropertyPath Path { get; set; }
27 |
28 | public RelativeSource RelativeSource { get; set; }
29 |
30 | public object Source { get; set; }
31 |
32 | public override object ProvideValue(IServiceProvider serviceProvider)
33 | {
34 | return this;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Avalonia/Data/BindingBase.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Data
8 | {
9 | using System;
10 | using System.Windows.Markup;
11 |
12 | public abstract class BindingBase : MarkupExtension
13 | {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Avalonia/Data/BindingExpressionBase.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Data
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using System.Threading.Tasks;
14 |
15 | public abstract class BindingExpressionBase : Expression, IWeakEventListener
16 | {
17 | private bool evaluated;
18 | private object value;
19 |
20 | public BindingExpressionBase(DependencyObject target, DependencyProperty dp)
21 | {
22 | this.Target = target;
23 | this.TargetProperty = dp;
24 | }
25 |
26 | public DependencyObject Target { get; private set; }
27 |
28 | public DependencyProperty TargetProperty { get; private set; }
29 |
30 | bool IWeakEventListener.ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
31 | {
32 | throw new NotImplementedException();
33 | }
34 |
35 | public object GetValue()
36 | {
37 | if (!this.evaluated)
38 | {
39 | this.value = this.Evaluate();
40 | this.evaluated = true;
41 | }
42 |
43 | return this.value;
44 | }
45 |
46 | protected void Invalidate()
47 | {
48 | this.evaluated = false;
49 | this.value = null;
50 | this.Target.InvalidateProperty(this.TargetProperty);
51 | }
52 |
53 | protected abstract object Evaluate();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Avalonia/Data/BindingOperations.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Data
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Diagnostics.Contracts;
12 | using System.Linq;
13 | using System.Text;
14 | using System.Threading.Tasks;
15 |
16 | public static class BindingOperations
17 | {
18 | public static BindingExpressionBase SetBinding(
19 | DependencyObject target,
20 | DependencyProperty dp,
21 | BindingBase binding)
22 | {
23 | Binding b = binding as Binding;
24 |
25 | if (b == null)
26 | {
27 | throw new NotSupportedException("Unsupported binding type.");
28 | }
29 |
30 | return target.SetBinding(dp, b);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Avalonia/Data/CollectionViewSource.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright 2013 MIT Licence. See licence.md for more information.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | namespace Avalonia.Data
8 | {
9 | using System.Collections;
10 | using System.Collections.Generic;
11 | using System.Runtime.CompilerServices;
12 |
13 | public class CollectionViewSource : DependencyObject
14 | {
15 | private static ConditionalWeakTable