Browse Source

Merge branch 'master' into xaml-control-themes

Conflicts:
	src/Markup/Perspex.Markup.Xaml/Context/PerspexWiringContext.cs
pull/297/head
Steven Kirk 11 years ago
parent
commit
7daea7db27
  1. 6
      docs/intro.md
  2. 4
      docs/styles.md
  3. 1
      nuget/template/Perspex.Desktop.nuspec
  4. 1
      nuget/template/Perspex.nuspec
  5. 4
      samples/XamlTestApplication/XamlTestApplication.csproj
  6. 250
      samples/XamlTestApplicationPcl/Views/MainWindow.paml
  7. 3
      samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj
  8. BIN
      samples/XamlTestApplicationPcl/pattern.jpg
  9. 1
      src/Markup/Perspex.Markup.Xaml/Context/PerspexWiringContext.cs
  10. 30
      src/Markup/Perspex.Markup.Xaml/Converters/GeometryTypeConverter.cs
  11. 1
      src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj
  12. 3
      src/Perspex.Controls/GridSplitter.cs
  13. 3
      src/Perspex.HtmlRenderer/Properties/AssemblyInfo.cs
  14. 2
      src/Perspex.SceneGraph/Media/Geometry.cs
  15. 18
      src/Windows/Perspex.Win32/WindowImpl.cs

6
docs/intro.md

@ -35,7 +35,7 @@ I'm not a big fan of DependencyProperty. My first thought was that I'd rather no
like this at all and just use basic INPC but DPs give you two important features: Inheritance and
Attached Properties. So the challenge became to improve it.
Delaring a DP in WPF looks something like this:
Declaring a DependencyProperty in WPF looks something like this:
```csharp
public static readonly DependencyProperty PropertyDeclaration =
@ -198,7 +198,7 @@ all controls in the the visual tree of type CheckBox*". A more complex selector:
new Style(x => x.OfType<CheckBox>().Class(":checked").Template().Id("checkMark"))
```
This selector matches "*all controls with Id == "checkMark" in the template of a CheckBox with the
This selector matches *"all controls with Id == "checkMark" in the template of a CheckBox with the
class `:checked`"*. Each control has an Id property, and Ids in templates are considered to be in a
separate namespace.
@ -215,7 +215,7 @@ different look-and-feel.
## XAML
As you can see, all of the examples here are defined in code - but a XAML implementation is being
worked on. The current progress can be reviewed at https://github.com/SuperJMN/Perspex.
worked on. The current progress can be reviewed at [https://github.com/SuperJMN/Perspex](https://github.com/SuperJMN/Perspex).
## That's all for now

4
docs/styles.md

@ -31,9 +31,9 @@ Make all `Button`s in a `StackPanel` have a blue `Background`:
This is very similar to WPF, except `TargetType` is replaced by `Selector`.
*Note that currently (as of Alpha 2) you **always** need to specify the fully
_Note that currently (as of Alpha 2) you **always** need to specify the fully
qualified property name (i.e. `Button.Background` instead of simply
`Background`). This restriction will be lifted in future.*
`Background`). This restriction will be lifted in future._
## Style Classes

1
nuget/template/Perspex.Desktop.nuspec

@ -24,6 +24,7 @@
<dependency id="SharpDX" version="2.6.3"/>
<dependency id="SharpDX.Direct2D1" version="2.6.3"/>
<dependency id="SharpDX.DXGI" version="2.6.3"/>
<dependency id="Perspex" version="#VERSION#" />
</dependencies>
</metadata>
</package>

1
nuget/template/Perspex.nuspec

@ -21,7 +21,6 @@
<dependency id="Rx-Linq" version="2.2.5" />
<dependency id="Rx-Main" version="2.2.5" />
<dependency id="Rx-PlatformServices" version="2.2.5" />
<dependency id="Perspex" version="#VERSION#" />
</dependencies>
</metadata>
</package>

4
samples/XamlTestApplication/XamlTestApplication.csproj

@ -104,6 +104,10 @@
<Project>{7062AE20-5DCC-4442-9645-8195BDECE63E}</Project>
<Name>Perspex.Diagnostics</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Perspex.HtmlRenderer\Perspex.HtmlRenderer.csproj">
<Project>{5fb2b005-0a7f-4dad-add4-3ed01444e63d}</Project>
<Name>Perspex.HtmlRenderer</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Perspex.Input\Perspex.Input.csproj">
<Project>{62024B2D-53EB-4638-B26B-85EEAA54866E}</Project>
<Name>Perspex.Input</Name>

250
samples/XamlTestApplicationPcl/Views/MainWindow.paml

@ -1,106 +1,198 @@
<Window x:Class="XamlTestApplication.MainWindow"
xmlns="https://github.com/perspex"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:XamlTestApplication.ViewModels;assembly=XamlTestApplicationPcl"
Title="Perspex Test Application" Height="350" Width="525" SizeToContent="WidthAndHeight" >
Title="Perspex Test Application" Width="800" Height="600">
<Grid RowDefinitions="Auto,*,Auto" ColumnDefinitions="*,*">
<TabControl Grid.Row="1" Grid.ColumnSpan="2" Padding="5">
<TabControl.Transition>
<PageSlide Duration="0.25" />
</TabControl.Transition>
<TabItem Header="Buttons">
<StackPanel HorizontalAlignment="Center" Width="200" VerticalAlignment="Center">
<StackPanel.Styles>
<Style Selector="Button.italic">
<Setter Property="TextBlock.FontStyle" Value="Italic"/>
</Style>
</StackPanel.Styles>
<Button Content="Button" />
<Button Content="Button" Background="#119EDA" ToolTip.Tip="Goodbye Cruel World!" />
<Button Content="Default" IsDefault="True" />
<Button Content="Disabled" IsEnabled="False" Classes="italic"/>
<Button Content="Disabled" IsEnabled="False" Background="#119eda" />
<ToggleButton Content="Toggle" />
<ToggleButton Content="Toggle" IsEnabled="False" />
<CheckBox Content="Checkbox" />
<RadioButton Content="RadioButton 1" IsChecked="True" />
<RadioButton Content="RadioButton 2" />
</StackPanel>
<ScrollViewer CanScrollHorizontally="False">
<StackPanel Margin="10" Gap="4">
<TextBlock Text="Button" FontWeight="Medium" FontSize="20" Foreground="#212121" />
<TextBlock Text="A button control" FontSize="13" Foreground="#727272" Margin="0,0,0,10" />
<Button Content="Button" Width="150" />
<Button Content="Button" Width="150" IsEnabled="False" />
<TextBlock Text="ToggleButton" Margin="0, 40, 0, 0" FontSize="20" Foreground="#212121" />
<TextBlock Text="A toggle button control" FontSize="13" Foreground="#727272" Margin="0,0,0,10" />
<ToggleButton Width="150" IsChecked="True" Content="On" />
<ToggleButton Width="150" IsChecked="False" Content="Off" />
</StackPanel>
</ScrollViewer>
</TabItem>
<TabItem Header="Text">
<StackPanel HorizontalAlignment="Center" Width="200" VerticalAlignment="Center">
<TextBlock TextWrapping="Wrap" TextAlignment="Center">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin venenatis dui quis libero suscipit tincidunt.
</TextBlock>
<TextBlock Text="Italic text." TextWrapping="Wrap" TextAlignment="Left" FontStyle="Italic" />
<TextBlock TextWrapping="Wrap" TextAlignment="Right" FontWeight="Bold">Bold text.</TextBlock>
<TextBox Text="A non-wrapping text box. Lorem ipsum dolor sit amet." TextWrapping="NoWrap" />
<TextBox
Text="A wrapping text box. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin venenatis dui quis libero suscipit tincidunt. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin venenatis dui quis libero suscipit tincidunt."
TextWrapping="Wrap" MaxHeight="100" AcceptsReturn="True" />
<StackPanel Margin="10" Gap="4">
<TextBlock Text="TextBlock" FontWeight="Medium" FontSize="20" Foreground="#212121" />
<TextBlock Text="A control for displaying text."
FontSize="13"
Foreground="#727272"
Margin="0, 0, 0, 10" />
<TextBlock Text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit." FontSize="11" />
<TextBlock Text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit." FontSize="11"
FontWeight="Medium" />
<TextBlock Text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit." FontSize="11"
FontWeight="Bold" />
<TextBlock Text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit." FontSize="11"
FontStyle="Italic" />
<TextBlock Margin="0,40,0,0" Text="HtmlLabel" FontWeight="Medium" FontSize="20"
Foreground="#212121" />
<TextBlock Text="A label capable of displaying HTML content" FontSize="13" Foreground="#727272"
Margin="0, 0, 0, 10" />
<!--PLEASE, FIX <HtmlLabel /> -->
</StackPanel>
</TabItem>
<TabItem Header="Input">
<ScrollViewer CanScrollHorizontally="False">
<StackPanel Margin="10" Gap="4">
<TextBlock Text="TextBlock" FontWeight="Medium" FontSize="20" Foreground="#212121" />
<TextBlock Text="A text box control"
FontSize="13"
Foreground="#727272"
Margin="0, 0, 0, 10" />
<TextBox Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit." Width="200" />
<TextBox Width="200" Watermark="Watermark" />
<TextBox Width="200" Watermark="Floating Watermark" UseFloatingWatermark="True" />
<TextBox AcceptsReturn="True" TextWrapping="Wrap" Width="200" Height="150"
Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est." />
<TextBlock Margin="0, 40, 0, 0" Text="CheckBox" FontWeight="Medium" FontSize="20"
Foreground="#212121" />
<TextBlock Text="A check box control" FontSize="13" Foreground="#727272" Margin="0, 0, 0, 10" />
<CheckBox IsChecked="True" Margin="0, 0, 0, 5" Content="Checked" />
<CheckBox IsChecked="False" Content="Unchecked" />
<TextBlock Margin="0, 40, 0, 0" Text="RadioButton" FontWeight="Medium" FontSize="20"
Foreground="#212121" />
<TextBlock Text="A radio button control" FontSize="13" Foreground="#727272"
Margin="0, 0, 0, 10" />
<RadioButton IsChecked="True" Content="Option 1" />
<RadioButton IsChecked="False" Content="Option 2" />
<RadioButton IsChecked="False" Content="Option 3" />
</StackPanel>
</ScrollViewer>
</TabItem>
<TabItem Header="Images">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<ScrollViewer Height="200" Width="200" HorizontalScrollBarVisibility="Visible">
<Image Source="github_icon.png" Height="500" Width="400" />
</ScrollViewer>
<StackPanel Margin="10" Gap="4" HorizontalAlignment="Center">
<TextBlock Text="Carousel" FontWeight="Medium" FontSize="20" Foreground="#212121" />
<TextBlock Text="An items control that displays its items as pages that fill the controls."
FontSize="13"
Foreground="#727272" Margin="0, 0, 0, 10" />
<StackPanel Name="carouselVisual" Orientation="Horizontal">
<Button VerticalAlignment="Center" Margin="5">
<Button.Content>
<Path Fill="Black"
Data="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z" />
</Button.Content>
</Button>
<Carousel Width="400" Height="400">
<Carousel.Transition>
<PageSlide Duration="0.25" />
</Carousel.Transition>
<Image Source="github_icon.png" Width="400" Height="400" />
<Image Source="pattern.jpg" Width="400" Height="400" />
</Carousel>
<Button VerticalAlignment="Center" Margin="5">
<Button.Content>
<Path Fill="Black"
Data="M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z" />
</Button.Content>
</Button>
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Header="Lists">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<ListBox Items="{Binding Items}" SelectionMode="Multiple">
<ListBox.DataTemplates>
<DataTemplate DataType="vm:TestItem">
<ListBox Items="{Binding Items}" SelectionMode="Multiple">
<ListBox.DataTemplates>
<DataTemplate DataType="vm:TestItem">
<StackPanel>
<TextBlock Text="{Binding Header}" FontSize="24" />
<TextBlock Text="{Binding SubHeader}" />
</StackPanel>
</DataTemplate>
</ListBox.DataTemplates>
</ListBox>
<DropDown VerticalAlignment="Center" SelectedIndex="0">
<StackPanel>
<TextBlock Text="{Binding Header}" FontSize="24"/>
<TextBlock Text="{Binding SubHeader}"/>
<TextBlock Text="Item 1" FontSize="24" />
<TextBlock Text="Item 1 Value" />
</StackPanel>
</DataTemplate>
</ListBox.DataTemplates>
</ListBox>
<DropDown VerticalAlignment="Center" SelectedIndex="0">
<StackPanel>
<TextBlock Text="Item 1" FontSize="24" />
<TextBlock Text="Item 1 Value" />
</StackPanel>
<StackPanel>
<TextBlock Text="Item 2" FontSize="24" />
<TextBlock Text="Item 2 Value" />
</StackPanel>
</DropDown>
<TreeView Items="{Binding Nodes}">
<TreeView.DataTemplates>
<TreeDataTemplate DataType="vm:TestNode" ItemsSource="{Binding Children}">
<StackPanel>
<TextBlock Text="{Binding Header}" FontSize="24"/>
<TextBlock Text="{Binding SubHeader}"/>
<TextBlock Text="Item 2" FontSize="24" />
<TextBlock Text="Item 2 Value" />
</StackPanel>
</TreeDataTemplate>
</TreeView.DataTemplates>
</TreeView>
</DropDown>
<TreeView Items="{Binding Nodes}">
<TreeView.DataTemplates>
<TreeDataTemplate DataType="vm:TestNode" ItemsSource="{Binding Children}">
<StackPanel>
<TextBlock Text="{Binding Header}" FontSize="24" />
<TextBlock Text="{Binding SubHeader}" />
</StackPanel>
</TreeDataTemplate>
</TreeView.DataTemplates>
</TreeView>
</StackPanel>
</TabItem>
<TabItem Header="Layout">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel>
<Button HorizontalAlignment="Left" Content="Left Aligned" />
<Button HorizontalAlignment="Center" Content="Center Aligned" />
<Button HorizontalAlignment="Right" Content="Right Aligned" />
<Button HorizontalAlignment="Stretch" Content="Stretch" />
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Button VerticalAlignment="Top" Content="Top Aligned" />
<Button VerticalAlignment="Center" Content="Center Aligned" />
<Button VerticalAlignment="Bottom" Content="Bottom Aligned" />
<Button VerticalAlignment="Stretch" Content="Stretch" />
<ScrollViewer CanScrollHorizontally="False">
<StackPanel Margin="10" Gap="4">
<TextBlock Text="Grid" FontWeight="Medium" FontSize="20" Foreground="#212121" />
<TextBlock Text="Lays out child controls according to a grid."
FontSize="13"
Foreground="#727272"
Margin="0, 0, 0, 10" />
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto" Width="300">
<Rectangle Grid.ColumnSpan="2" Fill="#FF5722" Height="200" Margin="2.5" />
<Rectangle Grid.Row="1" Fill="#FF5722" Height="100" Margin="2.5" />
<Rectangle Grid.Row="1" Grid.Column="1" Fill="#FF5722" Height="100" Margin="2.5" />
</Grid>
<TextBlock Text="StackPanel" FontWeight="Medium" FontSize="20" Foreground="#212121" />
<TextBlock Text="A panel which lays out its children horizontally or vertically."
FontSize="13"
Foreground="#727272"
Margin="0, 0, 0, 10" />
<StackPanel Gap="4" Width="300">
<Rectangle Fill="#FFC107" Height="50" />
<Rectangle Fill="#FFC107" Height="50" />
<Rectangle Fill="#FFC107" Height="50" />
</StackPanel>
<TextBlock Text="Canvas" FontWeight="Medium" FontSize="20" Foreground="#212121" />
<TextBlock Text="A panel which lays out its children by explicit coordinates."
FontSize="13"
Foreground="#727272"
Margin="0, 0, 0, 10" />
<Canvas Width="300" Height="200" Background="Yellow">
<Rectangle Fill="Blue" Width="63" Height="41" Canvas.Left="40" Canvas.Top="31" />
<Rectangle Fill="Green" Width="58" Height="58" Canvas.Left="130" Canvas.Top="79" />
</Canvas>
<TextBlock Text="DockPanel" FontWeight="Medium" FontSize="20" Foreground="#212121" />
<TextBlock
Text="A panel which lays docks its children on the sides and optionally fills the remaining space with the last child"
FontSize="13"
Foreground="#727272"
Margin="0, 0, 0, 10" />
<DockPanel Width="300" Height="300">
<Rectangle Fill="Red" Width="25" DockPanel.Dock="Left" />
<Rectangle Fill="Green" Height="25" DockPanel.Dock="Top" />
<Rectangle Fill="Blue" Width="25" DockPanel.Dock="Right" />
<Rectangle Fill="Yellow" Height="25" DockPanel.Dock="Bottom" />
<Rectangle Fill="Pink" />
</DockPanel>
</StackPanel>
</Grid>
</TabItem>
</ScrollViewer>
</TabItem>
<TabItem Header="Animations">
<Grid>
<Grid.ColumnDefinitions>
@ -114,8 +206,8 @@
<Border Width="100" Height="100">
<Border.Background>
<LinearGradientBrush StartPoint="0%,0%" EndPoint="100%,100%">
<GradientStop Color="Red" Offset="0"/>
<GradientStop Color="Green" Offset="1"/>
<GradientStop Color="Red" Offset="0" />
<GradientStop Color="Green" Offset="1" />
</LinearGradientBrush>
</Border.Background>
<TextBox HorizontalAlignment="Center" VerticalAlignment="Center" Text="hello!"></TextBox>

3
samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj

@ -51,6 +51,9 @@
<Content Include="github_icon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="pattern.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Markup\Perspex.Markup.Xaml\Perspex.Markup.Xaml.csproj">

BIN
samples/XamlTestApplicationPcl/pattern.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

1
src/Markup/Perspex.Markup.Xaml/Context/PerspexWiringContext.cs

@ -94,6 +94,7 @@ namespace Perspex.Markup.Xaml.Context
new TypeConverterRegistration(typeof(Color), new ColorTypeConverter()),
new TypeConverterRegistration(typeof(Classes), new ClassesTypeConverter()),
new TypeConverterRegistration(typeof(ColumnDefinitions), new ColumnDefinitionsTypeConverter()),
new TypeConverterRegistration(typeof(Geometry), new GeometryTypeConverter()),
new TypeConverterRegistration(typeof(GridLength), new GridLengthTypeConverter()),
new TypeConverterRegistration(typeof(KeyGesture), new KeyGestureConverter()),
new TypeConverterRegistration(typeof(Point), new PointTypeConverter()),

30
src/Markup/Perspex.Markup.Xaml/Converters/GeometryTypeConverter.cs

@ -0,0 +1,30 @@
namespace Perspex.Markup.Xaml.Converters
{
using System;
using System.Globalization;
using Media;
using OmniXaml.TypeConversion;
public class GeometryTypeConverter : ITypeConverter
{
public bool CanConvertFrom(IXamlTypeConverterContext context, Type sourceType)
{
return sourceType == typeof(string);
}
public bool CanConvertTo(IXamlTypeConverterContext context, Type destinationType)
{
return false;
}
public object ConvertFrom(IXamlTypeConverterContext context, CultureInfo culture, object value)
{
return StreamGeometry.Parse((string)value);
}
public object ConvertTo(IXamlTypeConverterContext context, CultureInfo culture, object value, Type destinationType)
{
throw new NotImplementedException();
}
}
}

1
src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj

@ -46,6 +46,7 @@
<Compile Include="Context\PerspexAttachableXamlMember.cs" />
<Compile Include="Context\PerspexContentPropertyProvider.cs" />
<Compile Include="Converters\ColorTypeConverter.cs" />
<Compile Include="Converters\GeometryTypeConverter.cs" />
<Compile Include="Converters\KeyGestureConverter.cs" />
<Compile Include="Converters\RelativePointTypeConverter.cs" />
<Compile Include="Converters\PointTypeConverter.cs" />

3
src/Perspex.Controls/GridSplitter.cs

@ -27,8 +27,9 @@ namespace Perspex.Controls
if (_grid != null && col > 0)
{
var size = _grid.ColumnDefinitions[col - 1].ActualWidth + e.Vector.X;
_grid.ColumnDefinitions[col - 1].Width = new GridLength(
_grid.ColumnDefinitions[col - 1].ActualWidth + e.Vector.X,
Math.Max(0, size),
GridUnitType.Pixel);
}
}

3
src/Perspex.HtmlRenderer/Properties/AssemblyInfo.cs

@ -2,6 +2,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Perspex.Metadata;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
@ -28,3 +29,5 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: XmlnsDefinition("https://github.com/perspex", "Perspex.Controls.Html")]

2
src/Perspex.SceneGraph/Media/Geometry.cs

@ -8,7 +8,7 @@ namespace Perspex.Media
{
/// <summary>
/// Defines a geometric shape.
/// </summary>
/// </summary>
public abstract class Geometry : PerspexObject
{
/// <summary>

18
src/Windows/Perspex.Win32/WindowImpl.cs

@ -337,7 +337,7 @@ namespace Perspex.Win32
: msg == (int)UnmanagedMethods.WindowsMessage.WM_RBUTTONDOWN
? RawMouseEventType.RightButtonDown
: RawMouseEventType.MiddleButtonDown,
new Point((uint) lParam & 0xffff, (uint) lParam >> 16), GetMouseModifiers(wParam));
PointFromLParam(lParam), GetMouseModifiers(wParam));
break;
case UnmanagedMethods.WindowsMessage.WM_LBUTTONUP:
@ -352,7 +352,7 @@ namespace Perspex.Win32
: msg == (int) UnmanagedMethods.WindowsMessage.WM_RBUTTONUP
? RawMouseEventType.RightButtonUp
: RawMouseEventType.MiddleButtonUp,
new Point((uint) lParam & 0xffff, (uint) lParam >> 16), GetMouseModifiers(wParam));
PointFromLParam(lParam), GetMouseModifiers(wParam));
break;
case UnmanagedMethods.WindowsMessage.WM_MOUSEMOVE:
@ -374,7 +374,8 @@ namespace Perspex.Win32
timestamp,
_owner,
RawMouseEventType.Move,
new Point((uint)lParam & 0xffff, (uint)lParam >> 16), GetMouseModifiers(wParam));
PointFromLParam(lParam), GetMouseModifiers(wParam));
break;
case UnmanagedMethods.WindowsMessage.WM_MOUSEWHEEL:
@ -382,7 +383,7 @@ namespace Perspex.Win32
WindowsMouseDevice.Instance,
timestamp,
_owner,
ScreenToClient((uint)lParam & 0xffff, (uint)lParam >> 16),
ScreenToClient(PointFromLParam(lParam)),
new Vector(0, ((int)wParam >> 16) / wheelDelta), GetMouseModifiers(wParam));
break;
@ -483,9 +484,14 @@ namespace Perspex.Win32
Handle = new PlatformHandle(_hwnd, PlatformConstants.WindowHandleType);
}
private Point ScreenToClient(uint x, uint y)
private Point PointFromLParam(IntPtr lParam)
{
var p = new UnmanagedMethods.POINT { X = (int)x, Y = (int)y };
return new Point((short)((int)lParam & 0xffff), (short)((int)lParam >> 16));
}
private Point ScreenToClient(Point point)
{
var p = new UnmanagedMethods.POINT { X = (int)point.X, Y = (int)point.Y };
UnmanagedMethods.ScreenToClient(_hwnd, ref p);
return new Point(p.X, p.Y);
}

Loading…
Cancel
Save