diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/App.config b/Source/Examples/SharpDX.Wpf/SimpleDemo/App.config deleted file mode 100644 index bae5d6d81..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/App.xaml b/Source/Examples/SharpDX.Wpf/SimpleDemo/App.xaml deleted file mode 100644 index 2f0f49ea2..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/App.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/App.xaml.cs b/Source/Examples/SharpDX.Wpf/SimpleDemo/App.xaml.cs deleted file mode 100644 index a43b56a7c..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/App.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; - -namespace SimpleDemo -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - } -} diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/MainViewModel.cs b/Source/Examples/SharpDX.Wpf/SimpleDemo/MainViewModel.cs deleted file mode 100644 index 1195cb4d4..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/MainViewModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace SimpleDemo -{ - using OxyPlot; - using OxyPlot.Axes; - using OxyPlot.Series; - - public class MainViewModel - { - public MainViewModel() - { - var model = new PlotModel { Title = "Hello SharpDX from WPF" }; - model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom }); - model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title="Left Axis Title" }); - var lineSeries = new LineSeries { Title = "LineSeries", MarkerType = MarkerType.Circle }; - lineSeries.Points.Add(new DataPoint(0, 0)); - lineSeries.Points.Add(new DataPoint(10, 18)); - lineSeries.Points.Add(new DataPoint(20, 12)); - lineSeries.Points.Add(new DataPoint(30, 8)); - lineSeries.Points.Add(new DataPoint(40, 15)); - - model.Series.Add(lineSeries); - this.Model = model; - } - - public PlotModel Model { get; private set; } - } -} diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/MainWindow.xaml b/Source/Examples/SharpDX.Wpf/SimpleDemo/MainWindow.xaml deleted file mode 100644 index 43a97f341..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/MainWindow.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/MainWindow.xaml.cs b/Source/Examples/SharpDX.Wpf/SimpleDemo/MainWindow.xaml.cs deleted file mode 100644 index 7ccb389fb..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/MainWindow.xaml.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace SimpleDemo -{ - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow - { - public MainWindow() - { - this.InitializeComponent(); - } - } -} diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/AssemblyInfo.cs b/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/AssemblyInfo.cs deleted file mode 100644 index 8af1a6adb..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SimpleDemo")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SimpleDemo")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Resources.Designer.cs b/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Resources.Designer.cs deleted file mode 100644 index ae17dd6b7..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SimpleDemo.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SimpleDemo.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Resources.resx b/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Resources.resx deleted file mode 100644 index af7dbebba..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Settings.Designer.cs b/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Settings.Designer.cs deleted file mode 100644 index 7918a7597..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SimpleDemo.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Settings.settings b/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Settings.settings deleted file mode 100644 index 033d7a5e9..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/SimpleDemo.csproj b/Source/Examples/SharpDX.Wpf/SimpleDemo/SimpleDemo.csproj deleted file mode 100644 index 2314683b7..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/SimpleDemo.csproj +++ /dev/null @@ -1,127 +0,0 @@ - - - - - Debug - AnyCPU - {48C8FBE0-C817-43BE-AC11-895A69100A86} - WinExe - Properties - SimpleDemo - SimpleDemo - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\..\packages\SharpDX.3.0.2\lib\net45\SharpDX.dll - True - - - ..\..\..\packages\SharpDX.DXGI.3.0.2\lib\net45\SharpDX.DXGI.dll - True - - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - MainWindow.xaml - Code - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - - {92129d21-61e9-4952-ab75-6e5b27c8d3f7} - OxyPlot.SharpDX.Wpf - - - {7a0b35c0-dd17-4964-8e9a-44d6cecdc692} - OxyPlot - - - - - \ No newline at end of file diff --git a/Source/Examples/SharpDX.Wpf/SimpleDemo/packages.config b/Source/Examples/SharpDX.Wpf/SimpleDemo/packages.config deleted file mode 100644 index 20262708e..000000000 --- a/Source/Examples/SharpDX.Wpf/SimpleDemo/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Source/OxyPlot.AppVeyor.sln b/Source/OxyPlot.AppVeyor.sln index 035cc2853..6b934c4cc 100644 --- a/Source/OxyPlot.AppVeyor.sln +++ b/Source/OxyPlot.AppVeyor.sln @@ -23,17 +23,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{215581EE EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleLibrary", "Examples\ExampleLibrary\ExampleLibrary.csproj", "{FACB89E5-53A5-4748-9F5B-E0714EBB37B2}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "OxyPlot.SharpDX", "OxyPlot.SharpDX\OxyPlot.SharpDX.shproj", "{455376C6-4146-497C-BF77-61CBB67F5DF9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OxyPlot.SharpDX.Wpf", "OxyPlot.SharpDX.Wpf\OxyPlot.SharpDX.Wpf.csproj", "{92129D21-61E9-4952-AB75-6E5B27C8D3F7}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OxyPlot.Windows", "OxyPlot.Windows\OxyPlot.Windows.csproj", "{5AA87152-20D5-48F7-AD0F-6E6BAA61FC25}" EndProject Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - OxyPlot.SharpDX\OxyPlot.SharpDX.projitems*{455376c6-4146-497c-bf77-61cbb67f5df9}*SharedItemsImports = 13 - OxyPlot.SharpDX\OxyPlot.SharpDX.projitems*{92129d21-61e9-4952-ab75-6e5b27c8d3f7}*SharedItemsImports = 4 - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|ARM = Debug|ARM @@ -205,30 +197,6 @@ Global {FACB89E5-53A5-4748-9F5B-E0714EBB37B2}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {FACB89E5-53A5-4748-9F5B-E0714EBB37B2}.Release|x64.ActiveCfg = Release|Any CPU {FACB89E5-53A5-4748-9F5B-E0714EBB37B2}.Release|x86.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|ARM.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|ARM.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|iPhone.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|x64.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|x64.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|x86.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|x86.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|Any CPU.Build.0 = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|ARM.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|ARM.Build.0 = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|iPhone.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|iPhone.Build.0 = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|x64.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|x64.Build.0 = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|x86.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|x86.Build.0 = Release|Any CPU {5AA87152-20D5-48F7-AD0F-6E6BAA61FC25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5AA87152-20D5-48F7-AD0F-6E6BAA61FC25}.Debug|Any CPU.Build.0 = Debug|Any CPU {5AA87152-20D5-48F7-AD0F-6E6BAA61FC25}.Debug|ARM.ActiveCfg = Debug|ARM diff --git a/Source/OxyPlot.SharpDX.Wpf/Converters/OxyColorConverter.cs b/Source/OxyPlot.SharpDX.Wpf/Converters/OxyColorConverter.cs deleted file mode 100644 index 61185c503..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/Converters/OxyColorConverter.cs +++ /dev/null @@ -1,82 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Converts from OxyPlot colors to Windows.UI.Color and vice versa. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace OxyPlot.SharpDX.Wpf -{ - using System; - using System.Globalization; - using System.Windows.Data; - using System.Windows.Media; - - /// - /// Converts from OxyPlot colors to Windows.UI.Color and vice versa. - /// - public class OxyColorConverter : IValueConverter - { - /// - /// Converts the specified value. - /// - /// The value. - /// Type of the target. - /// The parameter. - /// The language. - /// The maximum value of the thickness. - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (!(value is OxyColor)) - { - return null; - } - - var color = (OxyColor)value; - if (targetType == typeof(Color)) - { - return color.ToColor(); - } - - if (targetType == typeof(Brush)) - { - return color.ToBrush(); - } - - return null; - } - - /// - /// The convert. - /// - /// The value. - /// The target type. - /// The parameter. - /// The language. - /// The converted value. - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - if (targetType != typeof(OxyColor)) - { - return null; - } - - if (value is Color) - { - var color = (Color)value; - return OxyColor.FromArgb(color.A, color.R, color.G, color.B); - } - - var scb = value as SolidColorBrush; - if (scb != null) - { - var color = scb.Color; - return OxyColor.FromArgb(color.A, color.R, color.G, color.B); - } - - return null; - } - } -} \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/Converters/ThicknessConverter.cs b/Source/OxyPlot.SharpDX.Wpf/Converters/ThicknessConverter.cs deleted file mode 100644 index 34482a6ec..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/Converters/ThicknessConverter.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Converts Thickness to double. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace OxyPlot.SharpDX.Wpf -{ - using System; - using System.Globalization; - using System.Windows; - using System.Windows.Data; - - /// - /// Converts Thickness to double. - /// - /// This is used to convert BorderThickness properties to Path.StrokeThickness (double). - /// The maximum thickness value is used. - public class ThicknessConverter : IValueConverter - { - /// - /// Converts the specified value. - /// - /// The value. - /// Type of the target. - /// The parameter. - /// The language. - /// The maximum value of the thickness. - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is Thickness) - { - var t = (Thickness)value; - if (targetType == typeof(double)) - { - return Math.Max(Math.Max(t.Left, t.Right), Math.Max(t.Top, t.Bottom)); - } - } - - return null; - } - - /// - /// Converts back. - /// - /// The value. - /// Type of the target. - /// The parameter. - /// The language. - /// Not implemented. - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/D3D11Image.cs b/Source/OxyPlot.SharpDX.Wpf/D3D11Image.cs deleted file mode 100644 index 6fd629752..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/D3D11Image.cs +++ /dev/null @@ -1,148 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel -// -// -------------------------------------------------------------------------------------------------------------------- - -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// The original source code can be found here https://github.com/sharpdx/Toolkit/blob/master/Source/Toolkit/SharpDX.Toolkit.Game/Desktop/D3D11Image.cs - -namespace OxyPlot.SharpDX.Wpf -{ - using System; - using System.Windows; - using System.Windows.Interop; - using global::SharpDX.Direct3D11; - using global::SharpDX.Direct3D9; - using DXGIResource = global::SharpDX.DXGI.Resource; - - /// - /// Represents the Direct3D11 Image. - /// - internal class D3D11Image : D3DImage, IDisposable - { - /// - /// The texture. - /// - private Texture texture; - - /// - /// The texture surface handle - /// - private IntPtr textureSurfaceHandle; - - /// - /// Initializes a new instance of the class. Associates an D3D11 render target with the current instance. - /// - /// A valid D3D9 DeviceEx. - /// A valid D3D11 render target. It must be created with the "Shared" flag. - public D3D11Image(DeviceEx device, Texture2D renderTarget) - { - using (var resource = renderTarget.QueryInterface()) - { - var handle = resource.SharedHandle; - - this.texture = new Texture( - device, - renderTarget.Description.Width, - renderTarget.Description.Height, - 1, - Usage.RenderTarget, - Format.A8R8G8B8, - Pool.Default, - ref handle); - } - - using (var surface = this.texture.GetSurfaceLevel(0)) - { - this.textureSurfaceHandle = surface.NativePointer; - this.TrySetBackbufferPointer(this.textureSurfaceHandle); - } - - this.IsFrontBufferAvailableChanged += this.HandleIsFrontBufferAvailableChanged; - } - - /// - /// Marks the surface of element as invalid and requests its presentation on screen. - /// - public void InvalidateRendering() - { - if (this.texture == null) - { - return; - } - - this.Lock(); - this.AddDirtyRect(new Int32Rect(0, 0, this.PixelWidth, this.PixelHeight)); - this.Unlock(); - } - - /// - /// Try to set the back buffer pointer. - /// - /// A pointer to back buffer. - public void TrySetBackbufferPointer(IntPtr ptr) - { - // TODO: use TryLock and check multithreading scenarios - this.Lock(); - try - { - this.SetBackBuffer(D3DResourceType.IDirect3DSurface9, ptr); - } - finally - { - this.Unlock(); - } - } - - /// - /// Disposes associated D3D9 texture. - /// - public void Dispose() - { - if (this.texture != null) - { - this.Dispatcher.BeginInvoke( - (Action)delegate - { - this.IsFrontBufferAvailableChanged -= this.HandleIsFrontBufferAvailableChanged; - this.texture.Dispose(); - this.texture = null; - this.textureSurfaceHandle = IntPtr.Zero; - - this.TrySetBackbufferPointer(IntPtr.Zero); - }, - System.Windows.Threading.DispatcherPriority.Send); - } - } - - /// - /// Front buffer change event handler. - /// - /// The sender. - /// The event args. - private void HandleIsFrontBufferAvailableChanged(object sender, DependencyPropertyChangedEventArgs e) - { - if (this.IsFrontBufferAvailable) - { - this.TrySetBackbufferPointer(this.textureSurfaceHandle); - } - } - } -} \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.csproj b/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.csproj deleted file mode 100644 index bdd89e70c..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.csproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - AnyCPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7} - Library - Properties - OxyPlot.SharpDX.Wpf - OxyPlot.SharpDX.Wpf - v4.5.2 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AnyCPU - true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\OxyPlot.SharpDX.Wpf.XML - true - - - true - - - OxyPlot.SharpDX.Wpf.snk - - - - - - ..\packages\SharpDX.3.0.2\lib\net45\SharpDX.dll - True - - - ..\packages\SharpDX.Direct2D1.3.0.2\lib\net45\SharpDX.Direct2D1.dll - True - - - ..\packages\SharpDX.Direct3D11.3.0.2\lib\net45\SharpDX.Direct3D11.dll - True - - - ..\packages\SharpDX.Direct3D9.3.0.2\lib\net45\SharpDX.Direct3D9.dll - True - - - ..\packages\SharpDX.DXGI.3.0.2\lib\net45\SharpDX.DXGI.dll - True - - - ..\packages\SharpDX.Mathematics.3.0.2\lib\net45\SharpDX.Mathematics.dll - True - - - - - - - - - - - - - - - - - Properties\AssemblyInfo.cs - - - - - - - - - - - Designer - - - - - {7a0b35c0-dd17-4964-8e9a-44d6cecdc692} - OxyPlot - - - - - - - - MSBuild:Compile - Designer - - - - - - \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.csproj.DotSettings b/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.csproj.DotSettings deleted file mode 100644 index 75ca3519f..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.csproj.DotSettings +++ /dev/null @@ -1,6 +0,0 @@ - - True - True - True - True - True \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.nuspec b/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.nuspec deleted file mode 100644 index 567dcdcf7..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.nuspec +++ /dev/null @@ -1,34 +0,0 @@ - - - - OxyPlot.SharpDX.Wpf - OxyPlot for WPF with SharpDX based renderer - $version$ - Oystein Bjorke - OxyPlot is a plotting library for .NET. This package targets WPF applications. - - https://raw.githubusercontent.com/oxyplot/oxyplot/master/LICENSE - http://oxyplot.org/ - https://raw.githubusercontent.com/oxyplot/oxyplot/develop/Icons/OxyPlot_128.png - false - wpf plotting plot charting chart sharpdx - - - - - - - - - - - - - - - - - - - - diff --git a/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.snk b/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.snk deleted file mode 100644 index 0133abf2a..000000000 Binary files a/Source/OxyPlot.SharpDX.Wpf/OxyPlot.SharpDX.Wpf.snk and /dev/null differ diff --git a/Source/OxyPlot.SharpDX.Wpf/PlotImage.cs b/Source/OxyPlot.SharpDX.Wpf/PlotImage.cs deleted file mode 100644 index 6f9c780c4..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/PlotImage.cs +++ /dev/null @@ -1,711 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace OxyPlot.SharpDX.Wpf -{ - using System; - using System.Windows; - using System.Windows.Controls; - using System.Windows.Interop; - using System.Windows.Media; - using System.Windows.Media.Imaging; - using OxyPlot.SharpDX; - using global::SharpDX; - using global::SharpDX.Direct3D; - using global::SharpDX.Direct3D11; - using global::SharpDX.DXGI; - using AlphaMode = global::SharpDX.Direct2D1.AlphaMode; - using D3D11Device = global::SharpDX.Direct3D11.Device; - using D3D9CreateFlags = global::SharpDX.Direct3D9.CreateFlags; - using D3D9Device = global::SharpDX.Direct3D9.DeviceEx; - using D3D9DeviceType = global::SharpDX.Direct3D9.DeviceType; - using D3D9PresentInterval = global::SharpDX.Direct3D9.PresentInterval; - using D3D9PresentParameters = global::SharpDX.Direct3D9.PresentParameters; - using D3D9SwapEffect = global::SharpDX.Direct3D9.SwapEffect; - using Direct3D = global::SharpDX.Direct3D9.Direct3DEx; - using DXGIResource = global::SharpDX.DXGI.Resource; - using PixelFormat = global::SharpDX.Direct2D1.PixelFormat; - using RenderTarget = global::SharpDX.Direct2D1.RenderTarget; - using RenderTargetProperties = global::SharpDX.Direct2D1.RenderTargetProperties; - - /// - /// Control, that renders Plot using SharpDX renderer, renders Tracker using WPF controls. - /// Adds scrolling support. - /// - public class PlotImage : FrameworkElement, System.Windows.Controls.Primitives.IScrollInfo - { - /// - /// DependencyProperty as the backing store for PlotWidth - /// - public static readonly DependencyProperty PlotWidthProperty = - DependencyProperty.Register(nameof(PlotWidth), typeof(double), typeof(PlotImage), new FrameworkPropertyMetadata(double.NaN, FrameworkPropertyMetadataOptions.AffectsMeasure)); - - /// - /// Using a DependencyProperty as the backing store for PlotHeight. - /// - public static readonly DependencyProperty PlotHeightProperty = - DependencyProperty.Register(nameof(PlotHeight), typeof(double), typeof(PlotImage), new FrameworkPropertyMetadata(double.NaN, FrameworkPropertyMetadataOptions.AffectsMeasure)); - - /// - /// DependencyProperty as the backing store for PlotModel - /// - public static readonly DependencyProperty PlotModelProperty = - DependencyProperty.Register(nameof(PlotModel), typeof(IPlotModel), typeof(PlotImage), new PropertyMetadata(null)); - - // stolen from scrollviewer MS source code - - // Scrolling physical "line" metrics. - - /// - /// The scroll line delta. - /// - internal const double ScrollLineDelta = 16.0; // Default physical amount to scroll with one Up/Down/Left/Right key - - /// - /// The mouse wheel delta/ - /// - internal const double MouseWheelDelta = 48.0; // Default physical amount to scroll with one MouseWheel. - - /// - /// The Direct3D11 device. - /// - private D3D11Device d3d11Device; - - /// - /// The Direct3D9 device. - /// - private D3D9Device d3d9Device; - - /// - /// The render target. - /// - private RenderTarget renderTarget; - - /// - /// The oxy render target. - /// - private readonly CacherRenderContext oxyRenderContext; - - /// - /// The image source. - /// - private D3D11Image imageSource; - - /// - /// The overlay transform. - /// - private readonly TranslateTransform overlayTransform; - - /// - /// The extent. - /// - private Size extent; - - /// - /// The viewport. - /// - private Size viewport; - - /// - /// The offset vector. - /// - private Vector offset; - - /// - /// The placeholder image for design time. - /// - private BitmapImage designModeImage; - - /// - /// Initializes a new instance of the class. - /// - public PlotImage() - { - this.oxyRenderContext = new CacherRenderContext(); - this.overlayTransform = new TranslateTransform(); - this.Overlay = new Canvas - { - RenderTransform = this.overlayTransform, - }; - - this.AddVisualChild(this.Overlay); - this.AddLogicalChild(this.Overlay); - - this.Loaded += (s, e) => this.Dispatcher.Invoke(this.InvalidateVisual, System.Windows.Threading.DispatcherPriority.Background); - this.Unloaded += (s, e) => this.OnUnloaded(); - } - - /// - /// Gets or sets the plot model. - /// - public IPlotModel PlotModel - { - get { return (IPlotModel)this.GetValue(PlotModelProperty); } - set { this.SetValue(PlotModelProperty, value); } - } - - /// - /// Gets or sets the plot height. - /// - public double PlotHeight - { - get { return (double)this.GetValue(PlotHeightProperty); } - set { this.SetValue(PlotHeightProperty, value); } - } - - /// - /// Gets or sets the plot width. - /// - public double PlotWidth - { - get { return (double)this.GetValue(PlotWidthProperty); } - set { this.SetValue(PlotWidthProperty, value); } - } - - /// - /// Gets or sets a value indicating whether scrolling on the vertical axis is possible. - /// - public bool CanVerticallyScroll - { - get; set; - } - - /// - /// Gets or sets a value indicating whether scrolling on the vertical axis is possible. - /// - public bool CanHorizontallyScroll - { - get; set; - } - - /// - /// Gets the horizontal size of the extent. - /// - public double ExtentWidth => this.extent.Width; - - /// - /// Gets the vertical size of the extent. - /// - public double ExtentHeight => this.extent.Height; - - /// - /// Gets the horizontal size of the viewport for this content. - /// - public double ViewportWidth => this.viewport.Width; - - /// - /// Gets the vertical size of the viewport for this content. - /// - public double ViewportHeight => this.viewport.Height; - - /// - /// Gets the horizontal offset of the scrolled content. - /// - public double HorizontalOffset => this.offset.X; - - /// - /// Gets the vertical offset of the scrolled content. - /// - public double VerticalOffset => this.offset.Y; - - /// - /// Gets the offset vector of the scrolled content. - /// - public Vector Offset => this.offset; - - /// - /// Gets or sets a System.Windows.Controls.ScrollViewer element that controls scrolling behavior. - /// - public ScrollViewer ScrollOwner { get; set; } - - /// - /// Gets the overlay canvas. - /// - internal Canvas Overlay { get; } - - /// - /// Gets the number of visual child elements within this element. - /// - protected override int VisualChildrenCount => 1; - - /// - /// Renders to surface. - /// - /// Indicates whether on not surface should be recreated. - /// Indicates whether on not render units should be recreated. - public void Render(bool invalidateSurface, bool invalidateUnits) - { - if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) - { - return; - } - - if (!this.IsLoaded) - { - return; - } - - if (invalidateSurface || this.renderTarget == null) - { - this.CleanResources(); - this.InitRendering(); - - invalidateUnits = true; - } - - if (this.PlotModel == null) - { - return; - } - - if (invalidateUnits) - { - this.oxyRenderContext.ResetRenderUnits(); - - // Creates renderUnits that can be rendered later - this.PlotModel.Render(this.oxyRenderContext, this.extent.Width, this.extent.Height); - } - - var backColor = OxyColors.White; - if (!this.PlotModel.Background.IsUndefined()) - { - backColor = this.PlotModel.Background; - } - - this.renderTarget.BeginDraw(); - this.renderTarget.Clear(backColor.ToDXColor()); - this.oxyRenderContext.Render(new RectangleF((float)this.offset.X, (float)this.offset.Y, (float)this.viewport.Width, (float)this.viewport.Height)); // TODO: add clip rectangle - this.renderTarget.EndDraw(); - - this.d3d11Device.ImmediateContext.Flush(); - - this.imageSource.Lock(); - this.imageSource.AddDirtyRect(new Int32Rect() - { - X = 0, - Y = 0, - Height = this.imageSource.PixelHeight, - Width = this.imageSource.PixelWidth - }); - this.imageSource.Unlock(); - } - - /// - /// Scrolls up within content by one logical unit. - /// - public void LineUp() - { - this.AddOffset(0, -ScrollLineDelta); - } - - /// - /// Scrolls down within content by one logical unit. - /// - public void LineDown() - { - this.AddOffset(0, ScrollLineDelta); - } - - /// - /// Scrolls left within content by one logical unit. - /// - public void LineLeft() - { - this.AddOffset(-ScrollLineDelta, 0); - } - - /// - /// Scrolls right within content by one logical unit. - /// - public void LineRight() - { - this.AddOffset(ScrollLineDelta, 0); - } - - /// - /// Scrolls up within content by one page. - /// - public void PageUp() - { - this.AddOffset(0, -this.viewport.Height); - } - - /// - /// Scrolls down within content by one page. - /// - public void PageDown() - { - this.AddOffset(0, this.viewport.Height); - } - - /// - /// Scrolls left within content by one page. - /// - public void PageLeft() - { - this.AddOffset(-this.viewport.Height, 0); - } - - /// - /// Scrolls right within content by one page. - /// - public void PageRight() - { - this.AddOffset(this.viewport.Height, 0); - } - - /// - /// Scrolls up within content after a user clicks the wheel button on a mouse. - /// - public void MouseWheelUp() - { - this.AddOffset(0, -MouseWheelDelta); - } - - /// - /// Scrolls down within content after a user clicks the wheel button on a mouse. - /// - public void MouseWheelDown() - { - this.AddOffset(0, MouseWheelDelta); - } - - /// - /// Scrolls left within content after a user clicks the wheel button on a mouse. - /// - public void MouseWheelLeft() - { - this.AddOffset(-MouseWheelDelta, 0); - } - - /// - /// Scrolls right within content after a user clicks the wheel button on a mouse. - /// - public void MouseWheelRight() - { - this.AddOffset(MouseWheelDelta, 0); - } - - /// - /// Sets the amount of horizontal offset. - /// - /// The degree to which content is horizontally offset from the containing viewport. - public void SetHorizontalOffset(double offset) - { - this.offset.X = offset; - this.InvalidateVisual(); - } - - /// - /// Sets the amount of vertical offset. - /// - /// The degree to which content is vertically offset from the containing viewport. - public void SetVerticalOffset(double offset) - { - this.offset.Y = offset; - this.InvalidateVisual(); - } - - /// - /// Forces content to scroll until the coordinate space of a System.Windows.Media.Visual - /// object is visible. - /// - /// A System.Windows.Media.Visual that becomes visible. - /// A bounding rectangle that identifies the coordinate space to make visible. - /// A that is visible. - public Rect MakeVisible(Visual visual, Rect rectangle) - { - return rectangle; - - // TODO: implement this???????? - } - - /// - /// Invalidates current instance. - /// - internal void Invalidate() - { - this.Render(false, true); - this.InvalidateVisual(); - } - - /// - /// Overrides System.Windows.Media.Visual.GetVisualChild(), and returns a child at the specified index from a collection of child elements. - /// - /// The zero-based index of the requested child element in the collection. - /// The requested child element. This should not return null; if the provided index is out of range, an exception is thrown. - protected override Visual GetVisualChild(int index) - { - if (index != 0) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - - return this.Overlay; - } - - /// - /// When overridden in a derived class, participates in rendering operations that - /// are directed by the layout system. The rendering instructions for this element - /// are not used directly when this method is invoked, and are instead preserved - /// for later asynchronous use by layout and drawing. - /// - /// The drawing instructions for a specific element. This context is provided to the layout system. - protected override void OnRender(DrawingContext drawingContext) - { - base.OnRender(drawingContext); - if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) - { - if (this.designModeImage == null) - { - var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("OxyPlot.SharpDX.Wpf.Resources.designmode.png"); - - this.designModeImage = new BitmapImage(); - - this.designModeImage.BeginInit(); - this.designModeImage.StreamSource = stream; - this.designModeImage.EndInit(); - } - - drawingContext.DrawImage(this.designModeImage, new Rect(0, 0, this.ActualWidth, this.ActualHeight)); - } - - if (this.imageSource != null) - { - drawingContext.DrawImage(this.imageSource, new Rect(0, 0, this.imageSource.Width, this.imageSource.Height)); - } - } - - /// - /// When overridden in a derived class, measures the size in layout required for - /// child elements and determines a size for the System.Windows.FrameworkElement-derived - /// class. - /// - /// The available size that this element can give to child elements. Infinity can - /// be specified as a value to indicate that the element will size to whatever content - /// is available. - /// - /// The size that this element determines it needs during layout, based on its calculations - /// of child element sizes. - protected override Size MeasureOverride(Size availableSize) - { - double desiredHeight; - double desiredWidth; - - if (!double.IsNaN(this.PlotHeight)) - { - this.extent.Height = this.PlotHeight; - desiredHeight = Math.Min(this.PlotHeight, availableSize.Height); - } - else - { - this.extent.Height = !double.IsInfinity(availableSize.Height) ? availableSize.Height : 1; - desiredHeight = this.extent.Height; - } - - if (!double.IsNaN(this.PlotWidth)) - { - this.extent.Width = this.PlotWidth; - desiredWidth = Math.Min(this.PlotWidth, availableSize.Width); - } - else - { - this.extent.Width = !double.IsInfinity(availableSize.Width) ? availableSize.Width : 1; - desiredWidth = this.extent.Width; - } - - var desired = new Size(desiredWidth, desiredHeight); - - this.Overlay.Measure(desired); - if (this.ScrollOwner != null) - { - this.ScrollOwner.InvalidateScrollInfo(); - } - - return desired; - } - - /// - /// When overridden in a derived class, positions child elements and determines a - /// size for a System.Windows.FrameworkElement derived class. - /// - /// - /// The final area within the parent that this element should use to arrange itself - /// and its children. - /// - /// The actual size used. - protected override Size ArrangeOverride(Size finalSize) - { - var overlaySize = this.extent; - - if (!this.CanVerticallyScroll) - { - overlaySize.Height = finalSize.Height; - this.offset.Y = 0; - } - else - { - this.overlayTransform.Y = -this.offset.Y; - } - - if (!this.CanHorizontallyScroll) - { - overlaySize.Width = finalSize.Width; - this.offset.X = 0; - } - else - { - this.overlayTransform.X = -this.offset.X; - } - - this.Overlay.Arrange(new Rect(overlaySize)); - - bool sizeChanged = this.viewport != finalSize; - - this.viewport = finalSize; - - if (this.ScrollOwner != null) - { - this.ScrollOwner.InvalidateScrollInfo(); - } - - this.Render(sizeChanged, false); - - return finalSize; - } - - /// - /// Initializes DirectX rendering resources. - /// - private void InitRendering() - { - double dpiScale = 1.0; // default value for 96 dpi - - var hwndTarget = PresentationSource.FromVisual(this).CompositionTarget as HwndTarget; - if (hwndTarget != null) - { - dpiScale = hwndTarget.TransformToDevice.M11; - } - - int surfWidth = (int)(this.viewport.Width < 0 ? 0 : Math.Ceiling(this.viewport.Width * dpiScale)); - int surfHeight = (int)(this.viewport.Height < 0 ? 0 : Math.Ceiling(this.viewport.Height * dpiScale)); - - var windowHandle = (new WindowInteropHelper(Window.GetWindow(this))).Handle; - - this.d3d11Device = new D3D11Device( - DriverType.Hardware, - DeviceCreationFlags.BgraSupport, - FeatureLevel.Level_11_0, - FeatureLevel.Level_10_1, - FeatureLevel.Level_10_0, - FeatureLevel.Level_9_3, - FeatureLevel.Level_9_2, - FeatureLevel.Level_9_1); - - var backBuffer = new Texture2D( - this.d3d11Device, - new Texture2DDescription - { - Height = surfHeight, - Width = surfWidth, - ArraySize = 1, - MipLevels = 1, - Format = Format.B8G8R8A8_UNorm, - SampleDescription = { Count = 1, Quality = 0 }, - Usage = ResourceUsage.Default, - OptionFlags = ResourceOptionFlags.Shared, - BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, - CpuAccessFlags = 0 - }); - - var surface = backBuffer.QueryInterface(); - this.renderTarget = new RenderTarget( - this.oxyRenderContext.D2DFactory, - surface, - new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied))); - - this.d3d9Device = new D3D9Device( - new Direct3D(), - 0, - D3D9DeviceType.Hardware, - windowHandle, - D3D9CreateFlags.HardwareVertexProcessing | D3D9CreateFlags.Multithreaded | D3D9CreateFlags.FpuPreserve, - new D3D9PresentParameters(surfWidth, surfHeight) - { - PresentationInterval = D3D9PresentInterval.Immediate, - DeviceWindowHandle = windowHandle, - SwapEffect = D3D9SwapEffect.Discard, - Windowed = true - }); - - this.imageSource = new D3D11Image(this.d3d9Device, backBuffer); - - this.oxyRenderContext.ResetRenderTarget(this.renderTarget); - } - - /// - /// Free used resources. - /// - private void CleanResources() - { - this.oxyRenderContext.ResetRenderTarget(null); - - this.d3d11Device?.ImmediateContext.ClearState(); - this.d3d11Device?.ImmediateContext.Flush(); - - this.imageSource?.Dispose(); - this.d3d9Device?.Dispose(); - this.renderTarget?.Dispose(); - this.d3d11Device?.Dispose(); - - this.imageSource = null; - this.d3d9Device = null; - this.renderTarget = null; - this.d3d11Device = null; - } - - /// - /// Called when control unloaded. - /// - private void OnUnloaded() - { - this.CleanResources(); - } - - /// - /// Changes offset by , vector. - /// - /// The X axis delta. - /// The Y axis delta. - private void AddOffset(double deltaX, double deltaY) - { - this.offset.X += deltaX; - this.offset.Y += deltaY; - - if (this.offset.X < 0) - { - this.offset.X = 0; - } - - if (this.offset.X + this.viewport.Width > this.extent.Width) - { - this.offset.X = Math.Max(0, this.extent.Width - this.viewport.Width); - } - - if (this.offset.Y < 0) - { - this.offset.Y = 0; - } - - if (this.offset.Y + this.viewport.Height > this.extent.Height) - { - this.offset.Y = Math.Max(0, this.extent.Height - this.viewport.Height); - } - - this.InvalidateVisual(); - } - } -} diff --git a/Source/OxyPlot.SharpDX.Wpf/PlotView.cs b/Source/OxyPlot.SharpDX.Wpf/PlotView.cs deleted file mode 100644 index ccdc78ec4..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/PlotView.cs +++ /dev/null @@ -1,752 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -------------------------------------------------------------------------------------------------------------------- -namespace OxyPlot.SharpDX.Wpf -{ - using System; - using System.Collections.ObjectModel; - using System.Linq; - using System.Threading; - using System.Windows; - using System.Windows.Controls; - using System.Windows.Input; - using System.Windows.Media.Imaging; - - /// - /// Represents a control that displays a using SharpDX based renderer. - /// - [TemplatePart(Name = PartPlotImage, Type = typeof(PlotImage))] - public class PlotView : Control, IPlotView - { - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty ControllerProperty = - DependencyProperty.Register("Controller", typeof(IPlotController), typeof(PlotView), new PropertyMetadata(null)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty DefaultTrackerTemplateProperty = - DependencyProperty.Register( - "DefaultTrackerTemplate", typeof(ControlTemplate), typeof(PlotView), new PropertyMetadata(null)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty HandleRightClicksProperty = - DependencyProperty.Register("HandleRightClicks", typeof(bool), typeof(PlotView), new PropertyMetadata(true)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty IsMouseWheelEnabledProperty = - DependencyProperty.Register("IsMouseWheelEnabled", typeof(bool), typeof(PlotView), new PropertyMetadata(true)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty ModelProperty = DependencyProperty.Register( - "Model", typeof(PlotModel), typeof(PlotView), new PropertyMetadata(null, ModelChanged)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty ZoomRectangleTemplateProperty = - DependencyProperty.Register( - "ZoomRectangleTemplate", typeof(ControlTemplate), typeof(PlotView), new PropertyMetadata(null)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty PlotHeightProperty = - DependencyProperty.Register("PlotHeight", typeof(double), typeof(PlotView), new PropertyMetadata(double.NaN)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty PlotWidthProperty = - DependencyProperty.Register("PlotWidth", typeof(double), typeof(PlotView), new PropertyMetadata(double.NaN)); - - /// - /// The Grid PART constant. - /// - private const string PartPlotImage = "PART_PlotImage"; - - /// - /// The model lock. - /// - private readonly object modelLock = new object(); - - /// - /// The tracker definitions. - /// - private readonly ObservableCollection trackerDefinitions; - - /// - /// The mouse down point. - /// - private ScreenPoint mouseDownPoint; - - /// - /// The current model. - /// - private PlotModel currentModel; - - /// - /// The current tracker. - /// - private FrameworkElement currentTracker; - - /// - /// The default controller. - /// - private IPlotController defaultController; - - /// - /// The zoom control. - /// - private ContentControl zoomRectangle; - - /// - /// Plot DirectX rendering goes here - /// - private PlotImage plotImage; - - /// - /// Invalidate count. - /// - private int invalidated = 0; - - /// - /// Initializes static members of the class. - /// - static PlotView() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(PlotView), new FrameworkPropertyMetadata(typeof(PlotView))); - global::SharpDX.Configuration.EnableReleaseOnFinalizer = true; -#if DEBUG - // global::SharpDX.Configuration.EnableReleaseOnFinalizer EnableObjectTracking = true; -#endif - } - - /// - /// Initializes a new instance of the class. - /// - public PlotView() - { - this.DefaultStyleKey = typeof(PlotView); - - this.trackerDefinitions = new ObservableCollection(); - } - - /// - /// Gets or sets the plot height - /// - public double PlotHeight - { - get { return (double)this.GetValue(PlotHeightProperty); } - set { this.SetValue(PlotHeightProperty, value); } - } - - /// - /// Gets or sets the plot width - /// - public double PlotWidth - { - get { return (double)this.GetValue(PlotWidthProperty); } - set { this.SetValue(PlotWidthProperty, value); } - } - - /// - /// Gets or sets the PlotView controller. - /// - /// The PlotView controller. - public IPlotController Controller - { - get { return (IPlotController)this.GetValue(ControllerProperty); } - set { this.SetValue(ControllerProperty, value); } - } - - /// - /// Gets or sets the default tracker template. - /// - public ControlTemplate DefaultTrackerTemplate - { - get - { - return (ControlTemplate)this.GetValue(DefaultTrackerTemplateProperty); - } - - set - { - this.SetValue(DefaultTrackerTemplateProperty, value); - } - } - - /// - /// Gets or sets a value indicating whether to handle right clicks. - /// - public bool HandleRightClicks - { - get - { - return (bool)this.GetValue(HandleRightClicksProperty); - } - - set - { - this.SetValue(HandleRightClicksProperty, value); - } - } - - /// - /// Gets or sets a value indicating whether IsMouseWheelEnabled. - /// - public bool IsMouseWheelEnabled - { - get - { - return (bool)this.GetValue(IsMouseWheelEnabledProperty); - } - - set - { - this.SetValue(IsMouseWheelEnabledProperty, value); - } - } - - /// - /// Gets or sets the to show. - /// - /// The . - public PlotModel Model - { - get - { - return (PlotModel)this.GetValue(ModelProperty); - } - - set - { - this.SetValue(ModelProperty, value); - } - } - - /// - /// Gets or sets the zoom rectangle template. - /// - /// The zoom rectangle template. - public ControlTemplate ZoomRectangleTemplate - { - get - { - return (ControlTemplate)this.GetValue(ZoomRectangleTemplateProperty); - } - - set - { - this.SetValue(ZoomRectangleTemplateProperty, value); - } - } - - /// - /// Gets the tracker definitions. - /// - /// The tracker definitions. - public ObservableCollection TrackerDefinitions - { - get - { - return this.trackerDefinitions; - } - } - - /// - /// Gets the actual model in the view. - /// - /// - /// The actual model. - /// - Model IView.ActualModel - { - get - { - return this.Model; - } - } - - /// - /// Gets the actual model. - /// - /// The actual model. - public PlotModel ActualModel - { - get - { - return this.currentModel; - } - } - - /// - /// Gets the actual controller. - /// - /// - /// The actual . - /// - IController IView.ActualController - { - get - { - return this.ActualController; - } - } - - /// - /// Gets the coordinates of the client area of the view. - /// - public OxyRect ClientArea - { - get - { - return new OxyRect(0, 0, this.ActualWidth, this.ActualHeight); - } - } - - /// - /// Gets the actual PlotView controller. - /// - /// The actual PlotView controller. - public IPlotController ActualController - { - get - { - return this.Controller ?? (this.defaultController ?? (this.defaultController = new PlotController())); - } - } - - /// - /// Hides the tracker. - /// - public void HideTracker() - { - if (this.currentTracker != null) - { - this.plotImage.Overlay.Children.Remove(this.currentTracker); - this.currentTracker = null; - } - } - - /// - /// Hides the zoom rectangle. - /// - public void HideZoomRectangle() - { - this.zoomRectangle.Visibility = Visibility.Collapsed; - } - - /// - /// Invalidate the PlotView (not blocking the UI thread) - /// - /// if set to true, the data collections will be updated. - public void InvalidatePlot(bool update = true) - { - this.UpdateModel(update); - if (this.plotImage != null) - { - this.plotImage.PlotModel = this.ActualModel; - - if (Interlocked.Exchange(ref this.invalidated, 1) == 1) - { - return; - } - - this.Dispatcher.InvokeAsync( - () => - { - this.plotImage.Invalidate(); - this.invalidated = 0; - }, - System.Windows.Threading.DispatcherPriority.Background); - } - } - - /// - /// Sets the cursor. - /// - /// The cursor. - public void SetCursorType(OxyPlot.CursorType cursor) - { - var type = Cursors.Arrow; - switch (cursor) - { - case OxyPlot.CursorType.Default: - type = null; - break; - case OxyPlot.CursorType.Pan: - type = Cursors.Hand; - break; - case OxyPlot.CursorType.ZoomHorizontal: - type = Cursors.SizeWE; - break; - case OxyPlot.CursorType.ZoomVertical: - type = Cursors.SizeNS; - break; - case OxyPlot.CursorType.ZoomRectangle: - type = Cursors.SizeNWSE; - break; - } - - Mouse.OverrideCursor = type; - } - - /// - /// Shows the tracker. - /// - /// The tracker data. - public void ShowTracker(TrackerHitResult trackerHitResult) - { - if (trackerHitResult == null) - { - this.HideTracker(); - return; - } - - var trackerTemplate = this.DefaultTrackerTemplate; - if (trackerHitResult.Series != null && !string.IsNullOrEmpty(trackerHitResult.Series.TrackerKey)) - { - var match = this.TrackerDefinitions.FirstOrDefault(t => t.TrackerKey == trackerHitResult.Series.TrackerKey); - if (match != null) - { - trackerTemplate = match.TrackerTemplate; - } - } - - if (trackerTemplate == null) - { - this.HideTracker(); - return; - } - - var tracker = new ContentControl { Template = trackerTemplate }; - - if (tracker != this.currentTracker) - { - this.HideTracker(); - this.plotImage.Overlay.Children.Add(tracker); - this.currentTracker = tracker; - } - - if (this.currentTracker != null) - { - this.currentTracker.DataContext = trackerHitResult; - } - } - - /// - /// Shows the zoom rectangle. - /// - /// The rectangle. - public void ShowZoomRectangle(OxyRect r) - { - this.zoomRectangle.Width = r.Width; - this.zoomRectangle.Height = r.Height; - Canvas.SetLeft(this.zoomRectangle, r.Left); - Canvas.SetTop(this.zoomRectangle, r.Top); - this.zoomRectangle.Template = this.ZoomRectangleTemplate; - this.zoomRectangle.Visibility = Visibility.Visible; - } - - /// - /// Renders the PlotView to a bitmap. - /// - /// A bitmap. - public WriteableBitmap ToBitmap() - { - throw new NotImplementedException(); - } - - /// - /// Stores text on the clipboard. - /// - /// The text. - void IPlotView.SetClipboardText(string text) - { - Clipboard.SetText(text); - } - - /// - /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class. - /// - public override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) - { - return; - } - - this.plotImage = (PlotImage)this.GetTemplateChild(PartPlotImage); - - this.zoomRectangle = new ContentControl(); - this.plotImage.Overlay.Children.Add(this.zoomRectangle); - } - - /// - /// Called before the event occurs. - /// - /// The data for the event. - protected override void OnKeyDown(KeyEventArgs e) - { - base.OnKeyDown(e); - if (e.Handled) - { - return; - } - - var args = new OxyKeyEventArgs { ModifierKeys = Keyboard.GetModifierKeys(), Key = e.Key.Convert() }; - e.Handled = this.ActualController.HandleKeyDown(this, args); - } - - /// - /// Called when the event occurs. - /// - /// The data for the event. - protected override void OnManipulationStarted(ManipulationStartedEventArgs e) - { - base.OnManipulationStarted(e); - if (e.Handled) - { - return; - } - - e.Handled = this.ActualController.HandleTouchStarted(this, e.ToTouchEventArgs(this, this.plotImage, this.plotImage.Offset)); - } - - /// - /// Called when the event occurs. - /// - /// The data for the event. - protected override void OnManipulationDelta(ManipulationDeltaEventArgs e) - { - base.OnManipulationDelta(e); - if (e.Handled) - { - return; - } - - e.Handled = this.ActualController.HandleTouchDelta(this, e.ToTouchEventArgs(this, this.plotImage, this.plotImage.Offset)); - } - - /// - /// Called when the event occurs. - /// - /// The data for the event. - protected override void OnManipulationCompleted(ManipulationCompletedEventArgs e) - { - base.OnManipulationCompleted(e); - if (e.Handled) - { - return; - } - - e.Handled = this.ActualController.HandleTouchCompleted(this, e.ToTouchEventArgs(this, this.plotImage, this.plotImage.Offset)); - } - - /// - /// Called before the event occurs to provide handling for the event in a derived class without attaching a delegate. - /// - /// A that contains the event data. - protected override void OnMouseWheel(MouseWheelEventArgs e) - { - base.OnMouseWheel(e); - if (e.Handled || !this.IsMouseWheelEnabled) - { - return; - } - - e.Handled = this.ActualController.HandleMouseWheel(this, e.ToMouseWheelEventArgs(this, this.plotImage.Offset)); - } - - /// - /// Invoked when an unhandled MouseDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. - /// - /// The that contains the event data. This event data reports details about the mouse button that was pressed and the handled state. - protected override void OnMouseDown(MouseButtonEventArgs e) - { - base.OnMouseDown(e); - if (e.Handled) - { - return; - } - - this.Focus(); - this.CaptureMouse(); - - // store the mouse down point, check it when mouse button is released to determine if the context menu should be shown - this.mouseDownPoint = e.GetPosition(this).ToScreenPoint(); - - e.Handled = this.ActualController.HandleMouseDown(this, e.ToMouseDownEventArgs(this, this.plotImage.Offset)); - } - - /// - /// Invoked when an unhandled MouseMove attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. - /// - /// The that contains the event data. - protected override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - if (e.Handled) - { - return; - } - - e.Handled = this.ActualController.HandleMouseMove(this, e.ToMouseEventArgs(this, this.plotImage.Offset)); - } - - /// - /// Invoked when an unhandled MouseUp routed event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. - /// - /// The that contains the event data. The event data reports that the mouse button was released. - protected override void OnMouseUp(MouseButtonEventArgs e) - { - base.OnMouseUp(e); - if (e.Handled) - { - return; - } - - this.ReleaseMouseCapture(); - - e.Handled = this.ActualController.HandleMouseUp(this, e.ToMouseReleasedEventArgs(this, this.plotImage.Offset)); - - // Open the context menu - var p = e.GetPosition(this).ToScreenPoint(); - var d = p.DistanceTo(this.mouseDownPoint); - - if (this.ContextMenu != null) - { - if (Math.Abs(d) < 1e-8 && e.ChangedButton == MouseButton.Right) - { - // TODO: why is the data context not passed to the context menu?? - this.ContextMenu.DataContext = this.DataContext; - this.ContextMenu.PlacementTarget = this; - this.ContextMenu.Visibility = Visibility.Visible; - this.ContextMenu.IsOpen = true; - } - else - { - this.ContextMenu.Visibility = Visibility.Collapsed; - this.ContextMenu.IsOpen = false; - } - } - } - - /// - /// Invoked when an unhandled  attached event is raised on this element. Implement this method to add class handling for this event. - /// - /// The that contains the event data. - protected override void OnMouseEnter(MouseEventArgs e) - { - base.OnMouseEnter(e); - if (e.Handled) - { - return; - } - - e.Handled = this.ActualController.HandleMouseEnter(this, e.ToMouseEventArgs(this, this.plotImage.Offset)); - } - - /// - /// Invoked when an unhandled  attached event is raised on this element. Implement this method to add class handling for this event. - /// - /// The that contains the event data. - protected override void OnMouseLeave(MouseEventArgs e) - { - base.OnMouseEnter(e); - if (e.Handled) - { - return; - } - - e.Handled = this.ActualController.HandleMouseLeave(this, e.ToMouseEventArgs(this, this.plotImage.Offset)); - } - - /// - /// Called when the property is changed. - /// - /// The sender. - /// The instance containing the event data. - private static void ModelChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) - { - ((PlotView)sender).OnModelChanged(); - } - - /// - /// Invokes the specified action on the UI Thread (without blocking the calling thread). - /// - /// The action. - private void BeginInvoke(Action action) - { - this.Dispatcher.InvokeAsync(action, System.Windows.Threading.DispatcherPriority.Background); - } - - /// - /// Called when the control is loaded. - /// - /// The sender. - /// The instance containing the event data. - private void OnLoaded(object sender, RoutedEventArgs e) - { - this.InvalidatePlot(); - } - - /// - /// Called when the size of the control is changed. - /// - /// The sender. - /// The instance containing the event data. - private void OnSizeChanged(object sender, SizeChangedEventArgs e) - { - this.InvalidatePlot(false); - } - - /// - /// Called when the model is changed. - /// - private void OnModelChanged() - { - lock (this.modelLock) - { - if (this.currentModel != null) - { - ((IPlotModel)this.currentModel).AttachPlotView(null); - this.currentModel = null; - } - - if (this.Model != null) - { - ((IPlotModel)this.Model).AttachPlotView(this); - this.currentModel = this.Model; - } - } - - this.InvalidatePlot(); - } - - /// - /// Updates the model. - /// - /// if set to true, the data collections will be updated. - private void UpdateModel(bool update) - { - if (this.ActualModel != null) - { - ((IPlotModel)this.ActualModel).Update(update); - } - } - } -} \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/Properties/AssemblyDescription.cs b/Source/OxyPlot.SharpDX.Wpf/Properties/AssemblyDescription.cs deleted file mode 100644 index ec1d56b8b..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/Properties/AssemblyDescription.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -------------------------------------------------------------------------------------------------------------------- - -using System; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Markup; - -[assembly: AssemblyTitle("OxyPlot for WPF with SharpDX based renderer")] -[assembly: AssemblyDescription("OxyPlot controls for WPF with SharpDX based renderer")] -[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] - -[assembly: CLSCompliant(false)] - -[assembly: XmlnsPrefix("http://oxyplot.org/sharpdx/wpf", "oxydx")] -[assembly: XmlnsDefinition("http://oxyplot.org/sharpdx/wpf", "OxyPlot.SharpDX.Wpf")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("92129d21-61e9-4952-ab75-6e5b27c8d3f7")] \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/Resources/designmode.png b/Source/OxyPlot.SharpDX.Wpf/Resources/designmode.png deleted file mode 100644 index a59eff62b..000000000 Binary files a/Source/OxyPlot.SharpDX.Wpf/Resources/designmode.png and /dev/null differ diff --git a/Source/OxyPlot.SharpDX.Wpf/Themes/Generic.xaml b/Source/OxyPlot.SharpDX.Wpf/Themes/Generic.xaml deleted file mode 100644 index c31b8dba2..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/Themes/Generic.xaml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/Tracker/TrackerControl.cs b/Source/OxyPlot.SharpDX.Wpf/Tracker/TrackerControl.cs deleted file mode 100644 index 9051a67d0..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/Tracker/TrackerControl.cs +++ /dev/null @@ -1,725 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace OxyPlot.SharpDX.Wpf -{ - using System; - using System.Windows; - using System.Windows.Controls; - using System.Windows.Media; - using System.Windows.Shapes; - - /// - /// Provides a tracker control. - /// - public class TrackerControl : ContentControl - { - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty HorizontalLineVisibilityProperty = - DependencyProperty.Register( - "HorizontalLineVisibility", - typeof(Visibility), - typeof(TrackerControl), - new PropertyMetadata(Visibility.Visible)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty VerticalLineVisibilityProperty = - DependencyProperty.Register( - "VerticalLineVisibility", - typeof(Visibility), - typeof(TrackerControl), - new PropertyMetadata(Visibility.Visible)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty LineStrokeProperty = DependencyProperty.Register( - "LineStroke", typeof(Brush), typeof(TrackerControl), new PropertyMetadata(null)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty LineExtentsProperty = DependencyProperty.Register( - "LineExtents", typeof(OxyRect), typeof(TrackerControl), new PropertyMetadata(new OxyRect())); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty LineDashArrayProperty = DependencyProperty.Register( - "LineDashArray", typeof(DoubleCollection), typeof(TrackerControl), new PropertyMetadata(null)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty BorderEdgeModeProperty = DependencyProperty.Register( - "BorderEdgeMode", typeof(EdgeMode), typeof(TrackerControl)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty ShowPointerProperty = DependencyProperty.Register( - "ShowPointer", typeof(bool), typeof(TrackerControl), new PropertyMetadata(true)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( - "CornerRadius", typeof(double), typeof(TrackerControl), new PropertyMetadata(0.0)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty DistanceProperty = DependencyProperty.Register( - "Distance", typeof(double), typeof(TrackerControl), new PropertyMetadata(7.0)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty CanCenterHorizontallyProperty = - DependencyProperty.Register( - "CanCenterHorizontally", typeof(bool), typeof(TrackerControl), new PropertyMetadata(true)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty CanCenterVerticallyProperty = - DependencyProperty.Register( - "CanCenterVertically", typeof(bool), typeof(TrackerControl), new PropertyMetadata(true)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty PositionProperty = DependencyProperty.Register( - "Position", - typeof(ScreenPoint), - typeof(TrackerControl), - new PropertyMetadata(new ScreenPoint(), PositionChanged)); - - /// - /// The path part. - /// - private const string PartPath = "PART_Path"; - - /// - /// The content part. - /// - private const string PartContent = "PART_Content"; - - /// - /// The content container part. - /// - private const string PartContentcontainer = "PART_ContentContainer"; - - /// - /// The horizontal line part. - /// - private const string PartHorizontalline = "PART_HorizontalLine"; - - /// - /// The vertical line part. - /// - private const string PartVerticalline = "PART_VerticalLine"; - - /// - /// The content. - /// - private ContentPresenter content; - - /// - /// The horizontal line. - /// - private Line horizontalLine; - - /// - /// The path. - /// - private Path path; - - /// - /// The content container. - /// - private Grid contentContainer; - - /// - /// The vertical line. - /// - private Line verticalLine; - - /// - /// Initializes static members of the class. - /// - static TrackerControl() - { - DefaultStyleKeyProperty.OverrideMetadata( - typeof(TrackerControl), new FrameworkPropertyMetadata(typeof(TrackerControl))); - } - - /// - /// Gets or sets BorderEdgeMode. - /// - public EdgeMode BorderEdgeMode - { - get - { - return (EdgeMode)this.GetValue(BorderEdgeModeProperty); - } - - set - { - this.SetValue(BorderEdgeModeProperty, value); - } - } - - /// - /// Gets or sets HorizontalLineVisibility. - /// - public Visibility HorizontalLineVisibility - { - get - { - return (Visibility)this.GetValue(HorizontalLineVisibilityProperty); - } - - set - { - this.SetValue(HorizontalLineVisibilityProperty, value); - } - } - - /// - /// Gets or sets VerticalLineVisibility. - /// - public Visibility VerticalLineVisibility - { - get - { - return (Visibility)this.GetValue(VerticalLineVisibilityProperty); - } - - set - { - this.SetValue(VerticalLineVisibilityProperty, value); - } - } - - /// - /// Gets or sets LineStroke. - /// - public Brush LineStroke - { - get - { - return (Brush)this.GetValue(LineStrokeProperty); - } - - set - { - this.SetValue(LineStrokeProperty, value); - } - } - - /// - /// Gets or sets LineExtents. - /// - public OxyRect LineExtents - { - get - { - return (OxyRect)this.GetValue(LineExtentsProperty); - } - - set - { - this.SetValue(LineExtentsProperty, value); - } - } - - /// - /// Gets or sets LineDashArray. - /// - public DoubleCollection LineDashArray - { - get - { - return (DoubleCollection)this.GetValue(LineDashArrayProperty); - } - - set - { - this.SetValue(LineDashArrayProperty, value); - } - } - - /// - /// Gets or sets a value indicating whether to show a 'pointer' on the border. - /// - public bool ShowPointer - { - get - { - return (bool)this.GetValue(ShowPointerProperty); - } - - set - { - this.SetValue(ShowPointerProperty, value); - } - } - - /// - /// Gets or sets the corner radius (only used when ShowPoint=false). - /// - public double CornerRadius - { - get - { - return (double)this.GetValue(CornerRadiusProperty); - } - - set - { - this.SetValue(CornerRadiusProperty, value); - } - } - - /// - /// Gets or sets the distance of the content container from the trackers Position. - /// - public double Distance - { - get - { - return (double)this.GetValue(DistanceProperty); - } - - set - { - this.SetValue(DistanceProperty, value); - } - } - - /// - /// Gets or sets a value indicating whether the tracker can center its content box horizontally. - /// - public bool CanCenterHorizontally - { - get - { - return (bool)this.GetValue(CanCenterHorizontallyProperty); - } - - set - { - this.SetValue(CanCenterHorizontallyProperty, value); - } - } - - /// - /// Gets or sets a value indicating whether the tracker can center its content box vertically. - /// - public bool CanCenterVertically - { - get - { - return (bool)this.GetValue(CanCenterVerticallyProperty); - } - - set - { - this.SetValue(CanCenterVerticallyProperty, value); - } - } - - /// - /// Gets or sets Position of the tracker. - /// - public ScreenPoint Position - { - get - { - return (ScreenPoint)this.GetValue(PositionProperty); - } - - set - { - this.SetValue(PositionProperty, value); - } - } - - /// - /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class. - /// - public override void OnApplyTemplate() - { - base.OnApplyTemplate(); - this.path = this.GetTemplateChild(PartPath) as Path; - this.content = this.GetTemplateChild(PartContent) as ContentPresenter; - this.contentContainer = this.GetTemplateChild(PartContentcontainer) as Grid; - this.horizontalLine = this.GetTemplateChild(PartHorizontalline) as Line; - this.verticalLine = this.GetTemplateChild(PartVerticalline) as Line; - - if (this.contentContainer == null) - { - throw new InvalidOperationException(string.Format("The TrackerControl template must contain a content container with name +'{0}'", PartContentcontainer)); - } - - if (this.path == null) - { - throw new InvalidOperationException(string.Format("The TrackerControl template must contain a Path with name +'{0}'", PartPath)); - } - - if (this.content == null) - { - throw new InvalidOperationException(string.Format("The TrackerControl template must contain a ContentPresenter with name +'{0}'", PartContent)); - } - - this.UpdatePositionAndBorder(); - } - - /// - /// Called when the position is changed. - /// - /// The sender. - /// The instance containing the event data. - private static void PositionChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) - { - ((TrackerControl)sender).OnPositionChanged(e); - } - - /// - /// Called when the position is changed. - /// - /// The dependency property changed event args. - // ReSharper disable once UnusedParameter.Local - private void OnPositionChanged(DependencyPropertyChangedEventArgs e) - { - this.UpdatePositionAndBorder(); - } - - /// - /// Update the position and border of the tracker. - /// - private void UpdatePositionAndBorder() - { - if (this.contentContainer == null) - { - return; - } - - Canvas.SetLeft(this.contentContainer, this.Position.X); - Canvas.SetTop(this.contentContainer, this.Position.Y); - FrameworkElement parent = this; - while (!(parent is Canvas) && parent != null) - { - parent = VisualTreeHelper.GetParent(parent) as FrameworkElement; - } - - if (parent == null) - { - return; - } - - // throw new InvalidOperationException("The TrackerControl must have a Canvas parent."); - double canvasWidth = parent.ActualWidth; - double canvasHeight = parent.ActualHeight; - - this.content.Measure(new Size(canvasWidth, canvasHeight)); - this.content.Arrange(new Rect(0, 0, this.content.DesiredSize.Width, this.content.DesiredSize.Height)); - - double contentWidth = this.content.DesiredSize.Width; - double contentHeight = this.content.DesiredSize.Height; - - // Minimum allowed margins around the tracker - const double MarginLimit = 10; - - var ha = HorizontalAlignment.Center; - if (this.CanCenterHorizontally) - { - if (this.Position.X - (contentWidth / 2) < MarginLimit) - { - ha = HorizontalAlignment.Left; - } - - if (this.Position.X + (contentWidth / 2) > canvasWidth - MarginLimit) - { - ha = HorizontalAlignment.Right; - } - } - else - { - ha = this.Position.X < canvasWidth / 2 ? HorizontalAlignment.Left : HorizontalAlignment.Right; - } - - var va = VerticalAlignment.Center; - if (this.CanCenterVertically) - { - if (this.Position.Y - (contentHeight / 2) < MarginLimit) - { - va = VerticalAlignment.Top; - } - - if (ha == HorizontalAlignment.Center) - { - va = VerticalAlignment.Bottom; - if (this.Position.Y - contentHeight < MarginLimit) - { - va = VerticalAlignment.Top; - } - } - - if (va == VerticalAlignment.Center && this.Position.Y + (contentHeight / 2) > canvasHeight - MarginLimit) - { - va = VerticalAlignment.Bottom; - } - - if (va == VerticalAlignment.Top && this.Position.Y + contentHeight > canvasHeight - MarginLimit) - { - va = VerticalAlignment.Bottom; - } - } - else - { - va = this.Position.Y < canvasHeight / 2 ? VerticalAlignment.Top : VerticalAlignment.Bottom; - } - - double dx = ha == HorizontalAlignment.Center ? -0.5 : ha == HorizontalAlignment.Left ? 0 : -1; - double dy = va == VerticalAlignment.Center ? -0.5 : va == VerticalAlignment.Top ? 0 : -1; - - Thickness margin; - this.path.Data = this.ShowPointer - ? this.CreatePointerBorderGeometry(ha, va, contentWidth, contentHeight, out margin) - : this.CreateBorderGeometry(ha, va, contentWidth, contentHeight, out margin); - - this.content.Margin = margin; - - this.contentContainer.Measure(new Size(canvasWidth, canvasHeight)); - Size contentSize = this.contentContainer.DesiredSize; - - this.contentContainer.RenderTransform = new TranslateTransform - { - X = dx * contentSize.Width, - Y = dy * contentSize.Height - }; - - ScreenPoint pos = this.Position; - - if (this.horizontalLine != null) - { - if (this.LineExtents.Width > 0) - { - this.horizontalLine.X1 = this.LineExtents.Left; - this.horizontalLine.X2 = this.LineExtents.Right; - } - else - { - this.horizontalLine.X1 = 0; - this.horizontalLine.X2 = canvasWidth; - } - - this.horizontalLine.Y1 = pos.Y; - this.horizontalLine.Y2 = pos.Y; - } - - if (this.verticalLine != null) - { - if (this.LineExtents.Width > 0) - { - this.verticalLine.Y1 = this.LineExtents.Top; - this.verticalLine.Y2 = this.LineExtents.Bottom; - } - else - { - this.verticalLine.Y1 = 0; - this.verticalLine.Y2 = canvasHeight; - } - - this.verticalLine.X1 = pos.X; - this.verticalLine.X2 = pos.X; - } - } - - /// - /// Create the border geometry. - /// - /// The horizontal alignment. - /// The vertical alignment. - /// The width. - /// The height. - /// The margin. - /// The border geometry. - private Geometry CreateBorderGeometry( - HorizontalAlignment ha, VerticalAlignment va, double width, double height, out Thickness margin) - { - double m = this.Distance; - var rect = new Rect( - ha == HorizontalAlignment.Left ? m : 0, va == VerticalAlignment.Top ? m : 0, width, height); - margin = new Thickness - { - Left = ha == HorizontalAlignment.Left ? m : 0, - Top = va == VerticalAlignment.Top ? m : 0, - Right = ha == HorizontalAlignment.Right ? m : 0, - Bottom = va == VerticalAlignment.Bottom ? m : 0 - }; - return new RectangleGeometry { Rect = rect /*, RadiusX = this.CornerRadius, RadiusY = this.CornerRadius*/ }; - } - - /// - /// Creates a border geometry with a 'pointer'. - /// - /// The horizontal alignment. - /// The vertical alignment. - /// The width. - /// The height. - /// The margin. - /// The border geometry. - private Geometry CreatePointerBorderGeometry( - HorizontalAlignment ha, VerticalAlignment va, double width, double height, out Thickness margin) - { - Point[] points = null; - double m = this.Distance; - margin = new Thickness(); - - if (ha == HorizontalAlignment.Center && va == VerticalAlignment.Bottom) - { - double x0 = 0; - double x1 = width; - double x2 = (x0 + x1) / 2; - double y0 = 0; - double y1 = height; - margin = new Thickness { Bottom = m }; - points = new[] - { - new Point(x0, y0), new Point(x1, y0), new Point(x1, y1), new Point(x2 + (m / 2), y1), - new Point(x2, y1 + m), new Point(x2 - (m / 2), y1), new Point(x0, y1) - }; - } - - if (ha == HorizontalAlignment.Center && va == VerticalAlignment.Top) - { - double x0 = 0; - double x1 = width; - double x2 = (x0 + x1) / 2; - double y0 = m; - double y1 = m + height; - margin = new Thickness { Top = m }; - points = new[] - { - new Point(x0, y0), new Point(x2 - (m / 2), y0), new Point(x2, 0), new Point(x2 + (m / 2), y0), - new Point(x1, y0), new Point(x1, y1), new Point(x0, y1) - }; - } - - if (ha == HorizontalAlignment.Left && va == VerticalAlignment.Center) - { - double x0 = m; - double x1 = m + width; - double y0 = 0; - double y1 = height; - double y2 = (y0 + y1) / 2; - margin = new Thickness { Left = m }; - points = new[] - { - new Point(0, y2), new Point(x0, y2 - (m / 2)), new Point(x0, y0), new Point(x1, y0), - new Point(x1, y1), new Point(x0, y1), new Point(x0, y2 + (m / 2)) - }; - } - - if (ha == HorizontalAlignment.Right && va == VerticalAlignment.Center) - { - double x0 = 0; - double x1 = width; - double y0 = 0; - double y1 = height; - double y2 = (y0 + y1) / 2; - margin = new Thickness { Right = m }; - points = new[] - { - new Point(x1 + m, y2), new Point(x1, y2 + (m / 2)), new Point(x1, y1), new Point(x0, y1), - new Point(x0, y0), new Point(x1, y0), new Point(x1, y2 - (m / 2)) - }; - } - - if (ha == HorizontalAlignment.Left && va == VerticalAlignment.Top) - { - m *= 0.67; - double x0 = m; - double x1 = m + width; - double y0 = m; - double y1 = m + height; - margin = new Thickness { Left = m, Top = m }; - points = new[] - { - new Point(0, 0), new Point(m * 2, y0), new Point(x1, y0), new Point(x1, y1), new Point(x0, y1), - new Point(x0, m * 2) - }; - } - - if (ha == HorizontalAlignment.Right && va == VerticalAlignment.Top) - { - m *= 0.67; - double x0 = 0; - double x1 = width; - double y0 = m; - double y1 = m + height; - margin = new Thickness { Top = m, Right = m }; - points = new[] - { - new Point(x1 + m, 0), new Point(x1, y0 + m), new Point(x1, y1), new Point(x0, y1), - new Point(x0, y0), new Point(x1 - m, y0) - }; - } - - if (ha == HorizontalAlignment.Left && va == VerticalAlignment.Bottom) - { - m *= 0.67; - double x0 = m; - double x1 = m + width; - double y0 = 0; - double y1 = height; - margin = new Thickness { Left = m, Bottom = m }; - points = new[] - { - new Point(0, y1 + m), new Point(x0, y1 - m), new Point(x0, y0), new Point(x1, y0), - new Point(x1, y1), new Point(x0 + m, y1) - }; - } - - if (ha == HorizontalAlignment.Right && va == VerticalAlignment.Bottom) - { - m *= 0.67; - double x0 = 0; - double x1 = width; - double y0 = 0; - double y1 = height; - margin = new Thickness { Right = m, Bottom = m }; - points = new[] - { - new Point(x1 + m, y1 + m), new Point(x1 - m, y1), new Point(x0, y1), new Point(x0, y0), - new Point(x1, y0), new Point(x1, y1 - m) - }; - } - - if (points == null) - { - return null; - } - - var pointCollection = new PointCollection(); - foreach (var point in points) - { - pointCollection.Add(point); - } - - var segments = new PathSegmentCollection { new PolyLineSegment { Points = pointCollection } }; - var pf = new PathFigure { StartPoint = points[0], Segments = segments, IsClosed = true }; - return new PathGeometry { Figures = new PathFigureCollection { pf } }; - } - } -} diff --git a/Source/OxyPlot.SharpDX.Wpf/Tracker/TrackerDefinition.cs b/Source/OxyPlot.SharpDX.Wpf/Tracker/TrackerDefinition.cs deleted file mode 100644 index 9947239ac..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/Tracker/TrackerDefinition.cs +++ /dev/null @@ -1,67 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace OxyPlot.SharpDX.Wpf -{ - using System.Windows; - using System.Windows.Controls; - - /// - /// Represents a tracker definition. - /// - /// The tracker definitions make it possible to show different trackers for different series. - /// The property is matched with the - /// in the TrackerDefinitions collection in the control. - public class TrackerDefinition : DependencyObject - { - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty TrackerKeyProperty = DependencyProperty.Register( - "TrackerKey", typeof(string), typeof(TrackerDefinition), new PropertyMetadata(null)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty TrackerTemplateProperty = - DependencyProperty.Register("TrackerTemplate", typeof(ControlTemplate), typeof(TrackerDefinition), new PropertyMetadata(null)); - - /// - /// Gets or sets the tracker key. - /// - /// The Plot will use this property to find the TrackerDefinition that matches the TrackerKey of the current series. - public string TrackerKey - { - get - { - return (string)this.GetValue(TrackerKeyProperty); - } - - set - { - this.SetValue(TrackerKeyProperty, value); - } - } - - /// - /// Gets or sets the tracker template. - /// - /// The tracker control will be added/removed from the Tracker overlay as necessary. - /// The DataContext of the tracker will be set to a TrackerHitResult with the current tracker data. - public ControlTemplate TrackerTemplate - { - get - { - return (ControlTemplate)this.GetValue(TrackerTemplateProperty); - } - - set - { - this.SetValue(TrackerTemplateProperty, value); - } - } - } -} diff --git a/Source/OxyPlot.SharpDX.Wpf/Utilities/ConverterExtensions.cs b/Source/OxyPlot.SharpDX.Wpf/Utilities/ConverterExtensions.cs deleted file mode 100644 index 46a859422..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/Utilities/ConverterExtensions.cs +++ /dev/null @@ -1,524 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Extension method used to convert to/from Windows/Windows.Media classes. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace OxyPlot.SharpDX.Wpf -{ - using System; - using System.Windows; - using System.Windows.Input; - using System.Windows.Media; - using Color4 = global::SharpDX.Color4; - using DXColor = global::SharpDX.Color; - using HorizontalAlignment = OxyPlot.HorizontalAlignment; - using VerticalAlignment = OxyPlot.VerticalAlignment; - - /// - /// Extension method used to convert to/from Windows/Windows.Media classes. - /// - internal static class ConverterExtensions - { - /// - /// Byte to float converting coefficient. - /// - private static readonly float ByteToFloat = 1f / 255f; - - /// - /// Calculate the distance between two points. - /// - /// The first point. - /// The second point. - /// The distance. - public static double DistanceTo(this Point p1, Point p2) - { - double dx = p1.X - p2.X; - double dy = p1.Y - p2.Y; - return Math.Sqrt((dx * dx) + (dy * dy)); - } - - /// - /// Converts an to a . - /// - /// The color. - /// A . - public static Brush ToBrush(this OxyColor c) - { - return !c.IsUndefined() ? new SolidColorBrush(c.ToColor()) : null; - } - - /// - /// Converts an to a . - /// - /// The color. - /// A Color. - public static Color ToColor(this OxyColor c) - { - return Color.FromArgb(c.A, c.R, c.G, c.B); - } - - /// - /// Converts an to a . - /// - /// The color. - /// A Color. - public static Color4 ToColor4(this OxyColor c) - { - return new Color4(c.R * ByteToFloat, c.G * ByteToFloat, c.B * ByteToFloat, c.A * ByteToFloat); - } - - /// - /// Converts an to a . - /// - /// The color. - /// A Color. - public static DXColor ToDXColor(this OxyColor c) - { - return new DXColor(c.R, c.G, c.B, c.A); - } - - /// - /// Converts an OxyThickness to a Thickness. - /// - /// The thickness. - /// A instance. - public static Thickness ToThickness(this OxyThickness c) - { - return new Thickness(c.Left, c.Top, c.Right, c.Bottom); - } - - /// - /// Converts a ScreenVector to a Vector. - /// - /// The c. - /// A instance. - public static Vector ToVector(this ScreenVector c) - { - return new Vector(c.X, c.Y); - } - - /// - /// Converts a HorizontalAlignment to a HorizontalAlignment. - /// - /// The alignment. - /// A HorizontalAlignment. - public static HorizontalAlignment ToHorizontalAlignment(this System.Windows.HorizontalAlignment alignment) - { - switch (alignment) - { - case System.Windows.HorizontalAlignment.Center: - return HorizontalAlignment.Center; - case System.Windows.HorizontalAlignment.Right: - return HorizontalAlignment.Right; - default: - return HorizontalAlignment.Left; - } - } - - /// - /// Converts a HorizontalAlignment to a VerticalAlignment. - /// - /// The alignment. - /// A VerticalAlignment. - public static VerticalAlignment ToVerticalAlignment(this System.Windows.VerticalAlignment alignment) - { - switch (alignment) - { - case System.Windows.VerticalAlignment.Center: - return VerticalAlignment.Middle; - case System.Windows.VerticalAlignment.Top: - return VerticalAlignment.Top; - default: - return VerticalAlignment.Bottom; - } - } - - /// - /// Converts a Color to an OxyColor. - /// - /// The color. - /// An OxyColor. - public static OxyColor ToOxyColor(this Color color) - { - return OxyColor.FromArgb(color.A, color.R, color.G, color.B); - } - - /// - /// Converts a to an . - /// - /// The brush. - /// An . - public static OxyColor ToOxyColor(this Brush brush) - { - var scb = brush as SolidColorBrush; - return scb != null ? scb.Color.ToOxyColor() : OxyColors.Undefined; - } - - /// - /// Converts a Thickness to an . - /// - /// The thickness. - /// An . - public static OxyThickness ToOxyThickness(this Thickness t) - { - return new OxyThickness(t.Left, t.Top, t.Right, t.Bottom); - } - - /// - /// Converts a to a . - /// - /// The point. - /// A . - public static ScreenPoint ToScreenPoint(this Point pt) - { - return new ScreenPoint(pt.X, pt.Y); - } - - /// - /// Converts a Point array to a ScreenPoint array. - /// - /// The points. - /// A ScreenPoint array. - public static ScreenPoint[] ToScreenPointArray(this Point[] points) - { - if (points == null) - { - return null; - } - - var pts = new ScreenPoint[points.Length]; - for (int i = 0; i < points.Length; i++) - { - pts[i] = points[i].ToScreenPoint(); - } - - return pts; - } - - /// - /// Converts the specified vector to a ScreenVector. - /// - /// The vector. - /// A . - public static ScreenVector ToScreenVector(this Vector vector) - { - return new ScreenVector(vector.X, vector.Y); - } - - /// - /// Converts the specified key. - /// - /// The key to convert. - /// The converted key. - public static OxyKey Convert(this Key k) - { - switch (k) - { - case Key.A: - return OxyKey.A; - case Key.Add: - return OxyKey.Add; - case Key.B: - return OxyKey.B; - case Key.Back: - return OxyKey.Backspace; - case Key.C: - return OxyKey.C; - case Key.D: - return OxyKey.D; - case Key.D0: - return OxyKey.D0; - case Key.D1: - return OxyKey.D1; - case Key.D2: - return OxyKey.D2; - case Key.D3: - return OxyKey.D3; - case Key.D4: - return OxyKey.D4; - case Key.D5: - return OxyKey.D5; - case Key.D6: - return OxyKey.D6; - case Key.D7: - return OxyKey.D7; - case Key.D8: - return OxyKey.D8; - case Key.D9: - return OxyKey.D9; - case Key.Decimal: - return OxyKey.Decimal; - case Key.Delete: - return OxyKey.Delete; - case Key.Divide: - return OxyKey.Divide; - case Key.Down: - return OxyKey.Down; - case Key.E: - return OxyKey.E; - case Key.End: - return OxyKey.End; - case Key.Enter: - return OxyKey.Enter; - case Key.Escape: - return OxyKey.Escape; - case Key.F: - return OxyKey.F; - case Key.F1: - return OxyKey.F1; - case Key.F10: - return OxyKey.F10; - case Key.F11: - return OxyKey.F11; - case Key.F12: - return OxyKey.F12; - case Key.F2: - return OxyKey.F2; - case Key.F3: - return OxyKey.F3; - case Key.F4: - return OxyKey.F4; - case Key.F5: - return OxyKey.F5; - case Key.F6: - return OxyKey.F6; - case Key.F7: - return OxyKey.F7; - case Key.F8: - return OxyKey.F8; - case Key.F9: - return OxyKey.F9; - case Key.G: - return OxyKey.G; - case Key.H: - return OxyKey.H; - case Key.Home: - return OxyKey.Home; - case Key.I: - return OxyKey.I; - case Key.Insert: - return OxyKey.Insert; - case Key.J: - return OxyKey.J; - case Key.K: - return OxyKey.K; - case Key.L: - return OxyKey.L; - case Key.Left: - return OxyKey.Left; - case Key.M: - return OxyKey.M; - case Key.Multiply: - return OxyKey.Multiply; - case Key.N: - return OxyKey.N; - case Key.NumPad0: - return OxyKey.NumPad0; - case Key.NumPad1: - return OxyKey.NumPad1; - case Key.NumPad2: - return OxyKey.NumPad2; - case Key.NumPad3: - return OxyKey.NumPad3; - case Key.NumPad4: - return OxyKey.NumPad4; - case Key.NumPad5: - return OxyKey.NumPad5; - case Key.NumPad6: - return OxyKey.NumPad6; - case Key.NumPad7: - return OxyKey.NumPad7; - case Key.NumPad8: - return OxyKey.NumPad8; - case Key.NumPad9: - return OxyKey.NumPad9; - case Key.O: - return OxyKey.O; - case Key.P: - return OxyKey.P; - case Key.PageDown: - return OxyKey.PageDown; - case Key.PageUp: - return OxyKey.PageUp; - case Key.Q: - return OxyKey.Q; - case Key.R: - return OxyKey.R; - case Key.Right: - return OxyKey.Right; - case Key.S: - return OxyKey.S; - case Key.Space: - return OxyKey.Space; - case Key.Subtract: - return OxyKey.Subtract; - case Key.T: - return OxyKey.T; - case Key.Tab: - return OxyKey.Tab; - case Key.U: - return OxyKey.U; - case Key.Up: - return OxyKey.Up; - case Key.V: - return OxyKey.V; - case Key.W: - return OxyKey.W; - case Key.X: - return OxyKey.X; - case Key.Y: - return OxyKey.Y; - case Key.Z: - return OxyKey.Z; - default: - return OxyKey.Unknown; - } - } - - /// - /// Converts the specified button. - /// - /// The button to convert. - /// The converted mouse button. - public static OxyMouseButton Convert(this MouseButton button) - { - switch (button) - { - case MouseButton.Left: - return OxyMouseButton.Left; - case MouseButton.Middle: - return OxyMouseButton.Middle; - case MouseButton.Right: - return OxyMouseButton.Right; - case MouseButton.XButton1: - return OxyMouseButton.XButton1; - case MouseButton.XButton2: - return OxyMouseButton.XButton2; - default: - return OxyMouseButton.None; - } - } - - /// - /// Converts to for a mouse wheel event. - /// - /// The instance containing the event data. - /// The that the event is relative to. - /// The offset that event is relative to. - /// A containing the converted event arguments. - public static OxyMouseWheelEventArgs ToMouseWheelEventArgs(this MouseWheelEventArgs e, IInputElement relativeTo, Vector offset) - { - return new OxyMouseWheelEventArgs - { - Position = (e.GetPosition(relativeTo) + offset).ToScreenPoint(), - ModifierKeys = Keyboard.GetModifierKeys(), - Delta = e.Delta - }; - } - - /// - /// Converts to for a mouse down event. - /// - /// The instance containing the event data. - /// The that the event is relative to. - /// The offset that event is relative to. - /// A containing the converted event arguments. - public static OxyMouseDownEventArgs ToMouseDownEventArgs(this MouseButtonEventArgs e, IInputElement relativeTo, Vector offset) - { - return new OxyMouseDownEventArgs - { - ChangedButton = e.ChangedButton.Convert(), - ClickCount = e.ClickCount, - Position = (e.GetPosition(relativeTo) + offset).ToScreenPoint(), - ModifierKeys = Keyboard.GetModifierKeys() - }; - } - - /// - /// Converts to for a mouse up event. - /// - /// The instance containing the event data. - /// The that the event is relative to. - /// The offset that event is relative to. - /// A containing the converted event arguments. - public static OxyMouseEventArgs ToMouseReleasedEventArgs(this MouseButtonEventArgs e, IInputElement relativeTo, Vector offset) - { - return new OxyMouseEventArgs - { - Position = (e.GetPosition(relativeTo) + offset).ToScreenPoint(), - ModifierKeys = Keyboard.GetModifierKeys() - }; - } - - /// - /// Converts to for a mouse event. - /// - /// The instance containing the event data. - /// The that the event is relative to. - /// The offset that event is relative to. - /// A containing the converted event arguments. - public static OxyMouseEventArgs ToMouseEventArgs(this MouseEventArgs e, IInputElement relativeTo, Vector offset) - { - return new OxyMouseEventArgs - { - Position = (e.GetPosition(relativeTo) + offset).ToScreenPoint(), - ModifierKeys = Keyboard.GetModifierKeys() - }; - } - - /// - /// Converts to for a touch started event. - /// - /// The instance containing the event data. - /// The that is event source - /// The that the event is relative to. - /// The offset that event is relative to. - /// A containing the converted event arguments. - public static OxyTouchEventArgs ToTouchEventArgs(this ManipulationStartedEventArgs e, FrameworkElement source, FrameworkElement relativeTo, Vector offset) - { - return new OxyTouchEventArgs - { - Position = (source.TranslatePoint(e.ManipulationOrigin, relativeTo) + offset).ToScreenPoint(), - }; - } - - /// - /// Converts to for a touch delta event. - /// - /// The instance containing the event data. - /// The that is event source - /// The that the event is relative to. - /// The offset that event is relative to. - /// A containing the converted event arguments. - public static OxyTouchEventArgs ToTouchEventArgs(this ManipulationDeltaEventArgs e, FrameworkElement source, FrameworkElement relativeTo, Vector offset) - { - // TODO: does relativeTo rotation affects delta? - return new OxyTouchEventArgs - { - Position = (source.TranslatePoint(e.ManipulationOrigin, relativeTo) + offset).ToScreenPoint(), - DeltaTranslation = e.DeltaManipulation.Translation.ToScreenVector(), - DeltaScale = e.DeltaManipulation.Scale.ToScreenVector() - }; - } - - /// - /// Converts to for a touch completed event. - /// - /// The instance containing the event data. - /// The that is event source - /// The that the event is relative to. - /// The offset that event is relative to. - /// A containing the converted event arguments. - public static OxyTouchEventArgs ToTouchEventArgs(this ManipulationCompletedEventArgs e, FrameworkElement source, FrameworkElement relativeTo, Vector offset) - { - return new OxyTouchEventArgs - { - Position = (source.TranslatePoint(e.ManipulationOrigin, relativeTo) + offset).ToScreenPoint(), - }; - } - } -} \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/Utilities/Keyboard.cs b/Source/OxyPlot.SharpDX.Wpf/Utilities/Keyboard.cs deleted file mode 100644 index e47dd4fa9..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/Utilities/Keyboard.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Provides utility methods related to the keyboard. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace OxyPlot.SharpDX.Wpf -{ - using System.Windows.Input; - - /// - /// Provides utility methods related to the keyboard. - /// - internal static class Keyboard - { - /// - /// Gets the current modifier keys. - /// - /// A value. - public static OxyModifierKeys GetModifierKeys() - { - var modifiers = OxyModifierKeys.None; - if (System.Windows.Input.Keyboard.IsKeyDown(Key.LeftShift) || System.Windows.Input.Keyboard.IsKeyDown(Key.RightShift)) - { - modifiers |= OxyModifierKeys.Shift; - } - - if (System.Windows.Input.Keyboard.IsKeyDown(Key.LeftCtrl) || System.Windows.Input.Keyboard.IsKeyDown(Key.RightCtrl)) - { - modifiers |= OxyModifierKeys.Control; - } - - if (System.Windows.Input.Keyboard.IsKeyDown(Key.LeftAlt) || System.Windows.Input.Keyboard.IsKeyDown(Key.RightAlt)) - { - modifiers |= OxyModifierKeys.Alt; - } - - if (System.Windows.Input.Keyboard.IsKeyDown(Key.LWin) || System.Windows.Input.Keyboard.IsKeyDown(Key.RWin)) - { - modifiers |= OxyModifierKeys.Windows; - } - - return modifiers; - } - } -} \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.Wpf/packages.config b/Source/OxyPlot.SharpDX.Wpf/packages.config deleted file mode 100644 index 97c6dc562..000000000 --- a/Source/OxyPlot.SharpDX.Wpf/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX.sln b/Source/OxyPlot.SharpDX.sln deleted file mode 100644 index a75132676..000000000 --- a/Source/OxyPlot.SharpDX.sln +++ /dev/null @@ -1,95 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OxyPlot", "OxyPlot\OxyPlot.csproj", "{7A0B35C0-DD17-4964-8E9A-44D6CECDC692}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Change log", "Change log", "{4334530D-EBDE-4F04-838A-DA5A8A598124}" - ProjectSection(SolutionItems) = preProject - ..\AUTHORS = ..\AUTHORS - ..\CHANGELOG.md = ..\CHANGELOG.md - ..\CONTRIBUTORS = ..\CONTRIBUTORS - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{06B2EDA4-A30B-493A-A0A1-9DA28A2F4B0B}" - ProjectSection(SolutionItems) = preProject - ..\.github\CONTRIBUTING.md = ..\.github\CONTRIBUTING.md - ..\README.md = ..\README.md - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OxyPlot.SharpDX.Wpf", "OxyPlot.SharpDX.Wpf\OxyPlot.SharpDX.Wpf.csproj", "{92129D21-61E9-4952-AB75-6E5B27C8D3F7}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "OxyPlot.SharpDX", "OxyPlot.SharpDX\OxyPlot.SharpDX.shproj", "{455376C6-4146-497C-BF77-61CBB67F5DF9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDemo", "Examples\SharpDX.Wpf\SimpleDemo\SimpleDemo.csproj", "{48C8FBE0-C817-43BE-AC11-895A69100A86}" -EndProject -Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - OxyPlot.SharpDX\OxyPlot.SharpDX.projitems*{455376c6-4146-497c-bf77-61cbb67f5df9}*SharedItemsImports = 13 - OxyPlot.SharpDX\OxyPlot.SharpDX.projitems*{92129d21-61e9-4952-ab75-6e5b27c8d3f7}*SharedItemsImports = 4 - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|ARM = Debug|ARM - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|ARM = Release|ARM - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Debug|ARM.ActiveCfg = Debug|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Debug|ARM.Build.0 = Debug|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Debug|x64.ActiveCfg = Debug|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Debug|x64.Build.0 = Debug|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Debug|x86.ActiveCfg = Debug|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Debug|x86.Build.0 = Debug|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Release|Any CPU.Build.0 = Release|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Release|ARM.ActiveCfg = Release|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Release|ARM.Build.0 = Release|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Release|x64.ActiveCfg = Release|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Release|x64.Build.0 = Release|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Release|x86.ActiveCfg = Release|Any CPU - {7A0B35C0-DD17-4964-8E9A-44D6CECDC692}.Release|x86.Build.0 = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|ARM.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|ARM.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|x64.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|x64.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|x86.ActiveCfg = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Debug|x86.Build.0 = Debug|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|Any CPU.Build.0 = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|ARM.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|ARM.Build.0 = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|x64.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|x64.Build.0 = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|x86.ActiveCfg = Release|Any CPU - {92129D21-61E9-4952-AB75-6E5B27C8D3F7}.Release|x86.Build.0 = Release|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Debug|Any CPU.Build.0 = Debug|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Debug|ARM.ActiveCfg = Debug|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Debug|ARM.Build.0 = Debug|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Debug|x64.ActiveCfg = Debug|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Debug|x64.Build.0 = Debug|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Debug|x86.ActiveCfg = Debug|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Debug|x86.Build.0 = Debug|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Release|Any CPU.ActiveCfg = Release|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Release|Any CPU.Build.0 = Release|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Release|ARM.ActiveCfg = Release|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Release|ARM.Build.0 = Release|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Release|x64.ActiveCfg = Release|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Release|x64.Build.0 = Release|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Release|x86.ActiveCfg = Release|Any CPU - {48C8FBE0-C817-43BE-AC11-895A69100A86}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Source/OxyPlot.SharpDX/CacherRenderContext.cs b/Source/OxyPlot.SharpDX/CacherRenderContext.cs deleted file mode 100644 index acc758bb8..000000000 --- a/Source/OxyPlot.SharpDX/CacherRenderContext.cs +++ /dev/null @@ -1,733 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Represents class, that implements IRenderContext and caches render units to use them later render -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace OxyPlot.SharpDX -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using global::SharpDX; - using global::SharpDX.Direct2D1; - using global::SharpDX.DirectWrite; - using global::SharpDX.WIC; - using Bitmap = global::SharpDX.Direct2D1.Bitmap; - using BitmapInterpolationMode = global::SharpDX.Direct2D1.BitmapInterpolationMode; - using D2DFactory = global::SharpDX.Direct2D1.Factory; - using DWFactory = global::SharpDX.DirectWrite.Factory; - using dx = global::SharpDX; - using WICFactory = global::SharpDX.WIC.ImagingFactory; - - /// - /// Represents class, that implements IRenderContext and caches render units to use them later render - /// - internal class CacherRenderContext : IRenderContext, IDisposable - { - /// - /// The brush cache. - /// - private readonly Dictionary brushCache = new Dictionary(); - - /// - /// The images in use - /// - private readonly HashSet imagesInUse = new HashSet(); - - /// - /// The image cache - /// - private readonly Dictionary imageCache = new Dictionary(); - - /// - /// The Direct2D factory - /// - private D2DFactory d2dFactory; - - /// - /// The DirectWrite factory - /// - private DWFactory dwtFactory; - - /// - /// The WIC factory - /// - private WICFactory wicFactory; - - /// - /// The render target - /// - private RenderTarget renderTarget; - - /// - /// Units that will be rendered on Render call - /// - private List renderUnits = new List(); - - /// - /// The current tool tip - /// - private string currentToolTip; - - /// - /// The clip rectangle. - /// - private RectangleF clipRect; - - /// - /// Initializes a new instance of the class. - /// - public CacherRenderContext() - { - this.d2dFactory = new D2DFactory(); - this.dwtFactory = new DWFactory(); - this.wicFactory = new WICFactory(); - this.RendersToScreen = true; - } - - /// - /// Gets a value indicating whether to paint the background. - /// - /// true if the background should be painted; otherwise, false. - public bool PaintBackground - { - get - { - return false; - } - } - - /// - /// Gets or sets a value indicating whether the context renders to screen. - /// - /// true if the context renders to screen; otherwise, false. - public bool RendersToScreen { get; set; } - - /// - /// Gets or sets the Direct2D factory - /// - public D2DFactory D2DFactory - { - get - { - return this.d2dFactory; - } - - set - { - this.d2dFactory = value; - } - } - - /// - /// Draws an ellipse. - /// - /// The rectangle. - /// The fill color. - /// The stroke color. - /// The thickness. - public void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness) - { - var el = rect.ToEllipse(); - - this.renderUnits.Add(new EllipseRenderUnit(el, this.GetBrush(stroke), this.GetBrush(fill), (float)thickness)); - } - - /// - /// Draws the collection of ellipses, where all have the same stroke and fill. - /// This performs better than calling DrawEllipse multiple times. - /// - /// The rectangles. - /// The fill color. - /// The stroke color. - /// The stroke thickness. - public void DrawEllipses(IList rectangles, OxyColor fill, OxyColor stroke, double thickness) - { - var ellipseGeometries = rectangles.Select(x => new EllipseGeometry(this.d2dFactory, x.ToEllipse())).ToArray(); - var group = new GeometryGroup(this.d2dFactory, FillMode.Alternate, ellipseGeometries); - - this.renderUnits.Add(new GeometryRenderUnit(group, this.GetBrush(stroke), this.GetBrush(fill), (float)thickness, null)); - - foreach (var geometry in ellipseGeometries) - { - geometry.Dispose(); - } - } - - /// - /// Draws the polyline from the specified points. - /// - /// The points. - /// The stroke color. - /// The stroke thickness. - /// The dash array. - /// The line join type. - /// if set to true the shape will be aliased. - public void DrawLine( - IList points, - OxyColor stroke, - double thickness, - double[] dashArray, - OxyPlot.LineJoin lineJoin, - bool aliased) - { - var path = new PathGeometry(this.d2dFactory); - var sink = path.Open(); - sink.BeginFigure(points[0].ToVector2(aliased), new FigureBegin()); - - sink.AddLines(points.Skip(1).Select(pt => (dx.Mathematics.Interop.RawVector2)pt.ToVector2(aliased)).ToArray()); - sink.EndFigure(new FigureEnd()); - sink.Close(); - sink.Dispose(); - - var strokeStyle = this.GetStroke(dashArray, lineJoin); - - this.renderUnits.Add(new GeometryRenderUnit(path, this.GetBrush(stroke), null, (float)thickness, strokeStyle)); - } - - /// - /// Draws the multiple line segments defined by points (0,1) (2,3) (4,5) etc. - /// This should have better performance than calling DrawLine for each segment. - /// - /// The points. - /// The stroke color. - /// The stroke thickness. - /// The dash array. - /// The line join type. - /// if set to true the shape will be aliased. - public void DrawLineSegments( - IList points, - OxyColor stroke, - double thickness, - double[] dashArray, - OxyPlot.LineJoin lineJoin, - bool aliased) - { - var path = new PathGeometry(this.d2dFactory); - var sink = path.Open(); - for (int i = 0; i + 1 < points.Count; i += 2) - { - sink.BeginFigure(points[i].ToVector2(aliased), new FigureBegin()); - - sink.AddLine(points[i + 1].ToVector2(aliased)); - sink.EndFigure(new FigureEnd()); - } - - sink.Close(); - sink.Dispose(); - - var strokeStyle = this.GetStroke(dashArray, lineJoin); - - this.renderUnits.Add(new GeometryRenderUnit(path, this.GetBrush(stroke), null, (float)thickness, strokeStyle)); - } - - /// - /// Draws the polygon from the specified points. The polygon can have stroke and/or fill. - /// - /// The points. - /// The fill color. - /// The stroke color. - /// The stroke thickness. - /// The dash array. - /// The line join type. - /// if set to true the shape will be aliased. - public void DrawPolygon( - IList points, - OxyColor fill, - OxyColor stroke, - double thickness, - double[] dashArray, - OxyPlot.LineJoin lineJoin, - bool aliased) - { - var path = new PathGeometry(this.d2dFactory); - var sink = path.Open(); - sink.BeginFigure(points[0].ToVector2(aliased), new FigureBegin()); - - sink.AddLines(points.Skip(1).Select(pt => (dx.Mathematics.Interop.RawVector2)pt.ToVector2(aliased)).ToArray()); - sink.EndFigure(new FigureEnd()); - sink.Close(); - sink.Dispose(); - - var strokeStyle = this.GetStroke(dashArray, lineJoin); - - this.renderUnits.Add(new GeometryRenderUnit(path, this.GetBrush(stroke), this.GetBrush(fill), (float)thickness, strokeStyle)); - } - - /// - /// Draws a collection of polygons, where all polygons have the same stroke and fill. - /// This performs better than calling DrawPolygon multiple times. - /// - /// The polygons. - /// The fill color. - /// The stroke color. - /// The stroke thickness. - /// The dash array. - /// The line join type. - /// if set to true the shape will be aliased. - public void DrawPolygons( - IList> polygons, - OxyColor fill, - OxyColor stroke, - double thickness, - double[] dashArray, - OxyPlot.LineJoin lineJoin, - bool aliased) - { - var path = new PathGeometry(this.d2dFactory); - var sink = path.Open(); - foreach (var points in polygons) - { - sink.BeginFigure(points[0].ToVector2(aliased), new FigureBegin()); - - sink.AddLines(points.Skip(1).Select(pt => (dx.Mathematics.Interop.RawVector2)pt.ToVector2(aliased)).ToArray()); - sink.EndFigure(new FigureEnd()); - } - - sink.Close(); - sink.Dispose(); - - var strokeStyle = this.GetStroke(dashArray, lineJoin); - this.renderUnits.Add(new GeometryRenderUnit(path, this.GetBrush(stroke), this.GetBrush(fill), (float)thickness, strokeStyle)); - } - - /// - /// Draws the rectangle. - /// - /// The rectangle. - /// The fill color. - /// The stroke color. - /// The stroke thickness. - public void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness) - { - this.renderUnits.Add(new RectangleRenderUnit(rect.ToRectangleF(), this.GetBrush(stroke), this.GetBrush(fill), (float)thickness)); - } - - /// - /// Draws a collection of rectangles, where all have the same stroke and fill. - /// This performs better than calling DrawRectangle multiple times. - /// - /// The rectangles. - /// The fill color. - /// The stroke color. - /// The stroke thickness. - public void DrawRectangles(IList rectangles, OxyColor fill, OxyColor stroke, double thickness) - { - var rectangleGeometries = rectangles.Select(x => new RectangleGeometry(this.d2dFactory, x.ToRectangleF())).ToArray(); - var group = new GeometryGroup(this.d2dFactory, FillMode.Winding, rectangleGeometries); - - this.renderUnits.Add(new GeometryRenderUnit(group, this.GetBrush(stroke), this.GetBrush(fill), (float)thickness, null)); - - foreach (var rectangle in rectangleGeometries) - { - rectangle.Dispose(); - } - } - - /// - /// Draws the text. - /// - /// The position. - /// The text. - /// The fill color. - /// The font family. - /// Size of the font. - /// The font weight. - /// The rotation angle. - /// The horizontal alignment. - /// The vertical alignment. - /// The maximum size of the text. - public void DrawText( - ScreenPoint p, - string text, - OxyColor fill, - string fontFamily, - double fontSize, - double fontWeight, - double rotate, - OxyPlot.HorizontalAlignment halign, - OxyPlot.VerticalAlignment valign, - OxySize? maxSize) - { - if (string.IsNullOrWhiteSpace(fontFamily)) - { - fontFamily = "Arial"; - } - - if (text == null) - { - text = string.Empty; - } - - var format = new TextFormat(this.dwtFactory, fontFamily, GetFontWeight(fontWeight), FontStyle.Normal, FontStretch.Normal, (float)fontSize); - var maxWidth = 1000f; - var maxHeight = 1000f; - if (maxSize != null) - { - maxHeight = (float)maxSize.Value.Height; - maxWidth = (float)maxSize.Value.Width; - } - - var layout = new TextLayout(this.dwtFactory, text, format, maxWidth, maxHeight); - - var size = new Size2F(layout.Metrics.Width, layout.Metrics.Height); - if (maxSize != null) - { - if (size.Width > maxSize.Value.Width) - { - size.Width = (float)maxSize.Value.Width; - } - - if (size.Height > maxSize.Value.Height) - { - size.Height = (float)maxSize.Value.Height; - } - } - - float dx = 0; - if (halign == OxyPlot.HorizontalAlignment.Center) - { - dx = -size.Width / 2; - } - - if (halign == OxyPlot.HorizontalAlignment.Right) - { - dx = -size.Width; - } - - float dy = 0; - if (valign == OxyPlot.VerticalAlignment.Middle) - { - dy = -size.Height / 2; - } - - if (valign == OxyPlot.VerticalAlignment.Bottom) - { - dy = -size.Height; - } - - this.renderUnits.Add(new TextRenderUnit(layout, this.GetBrush(fill), Matrix3x2.Translation(dx, dy) * Matrix3x2.Rotation(MathUtil.DegreesToRadians((float)rotate)) * Matrix3x2.Translation(p.ToVector2()))); - format.Dispose(); - } - - /// - /// Measures the text. - /// - /// The text. - /// The font family. - /// Size of the font. - /// The font weight. - /// The text size. - public OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight) - { - if (string.IsNullOrWhiteSpace(fontFamily)) - { - fontFamily = "Arial"; - } - - if (text == null) - { - text = string.Empty; - } - - var format = new TextFormat(this.dwtFactory, fontFamily, GetFontWeight(fontWeight), FontStyle.Normal, FontStretch.Normal, (float)fontSize); - - var layout = new TextLayout(this.dwtFactory, text, format, 1000f, 1000f); - var res = new OxySize(layout.Metrics.Width, layout.Metrics.Height); - - format.Dispose(); - layout.Dispose(); - - return res; - } - - /// - /// Sets the tool tip for the following items. - /// - /// The text in the tooltip. - public void SetToolTip(string text) - { - this.currentToolTip = text; - } - - /// - /// Draws the specified portion of the specified at the specified location and with the specified size. - /// - /// The source. - /// The x-coordinate of the upper-left corner of the portion of the source image to draw. - /// The y-coordinate of the upper-left corner of the portion of the source image to draw. - /// Width of the portion of the source image to draw. - /// Height of the portion of the source image to draw. - /// The x-coordinate of the upper-left corner of drawn image. - /// The y-coordinate of the upper-left corner of drawn image. - /// The width of the drawn image. - /// The height of the drawn image. - /// The opacity. - /// interpolate if set to true. - public void DrawImage( - OxyImage source, - double srcX, - double srcY, - double srcWidth, - double srcHeight, - double destX, - double destY, - double destWidth, - double destHeight, - double opacity, - bool interpolate) - { - if (destWidth <= 0 || destHeight <= 0 || srcWidth <= 0 || srcHeight <= 0) - { - return; - } - - var bmp = this.GetBitmap(source); - - this.renderUnits.Add( - new ImageRenderUnit( - bmp, - new RectangleF((float)srcX, (float)srcY, (float)srcWidth, (float)srcHeight), - new RectangleF((float)destX, (float)destY, (float)destWidth, (float)destHeight), - (float)opacity, - interpolate ? BitmapInterpolationMode.Linear : BitmapInterpolationMode.NearestNeighbor)); - } - - /// - /// Sets the clipping rectangle. - /// - /// The clipping rectangle. - /// True if the clipping rectangle was set. - public bool SetClip(OxyRect clippingRect) - { - this.clipRect = clippingRect.ToRectangleF(); - return true; - } - - /// - /// Resets the clipping rectangle. - /// - public void ResetClip() - { - } - - /// - /// Cleans up resources not in use. - /// - /// This method is called at the end of each rendering. - public void CleanUp() - { - // Find the images in the cache that has not been used since last call to this method - var imagesToRelease = this.imageCache.Keys.Where(i => !this.imagesInUse.Contains(i)).ToList(); - - // Remove the images from the cache - foreach (var i in imagesToRelease) - { - this.imageCache.Remove(i); - } - - this.imagesInUse.Clear(); - } - - /// - /// On changing renderTarget (on resize for example), this method should be called. - /// Clears invalid for new renderTarget resources (like brushes). - /// - /// The render target. - public void ResetRenderTarget(RenderTarget renderTarget) - { - this.ResetRenderUnits(); - - if (this.renderTarget == renderTarget) - { - return; - } - - foreach (var brush in this.brushCache.Values) - { - brush.Dispose(); - } - - this.brushCache.Clear(); - - foreach (var image in this.imageCache.Values) - { - image.Dispose(); - } - - this.imageCache.Clear(); - - this.imagesInUse.Clear(); - - this.renderTarget = renderTarget; - } - - /// - /// On plot invalidate this method should be called - /// Clear current cached geometries - /// - public void ResetRenderUnits() - { - foreach (var unit in this.renderUnits) - { - unit.Dispose(); - } - - this.renderUnits.Clear(); - } - - /// - /// Renders cached render units. - /// This method should be called on redraw required - /// - /// The viewport. - public void Render(RectangleF viewport) - { - if (this.renderTarget == null) - { - return; - } - - var original = this.renderTarget.Transform; - - this.renderTarget.Transform = original * Matrix3x2.Translation(-viewport.X, -viewport.Y); - - // TODO: can be optimized to use something like quad-tree - // https://en.wikipedia.org/wiki/Quadtree - foreach (var unit in this.renderUnits) - { - if (unit.CheckBounds(viewport)) - { - unit.Render(this.renderTarget); - } - } - - this.renderTarget.Transform = original; - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting - /// unmanaged resources. - /// - public void Dispose() - { - foreach (var item in this.brushCache.Values) - { - item.Dispose(); - } - - foreach (var item in this.imageCache.Values) - { - item.Dispose(); - } - - this.imageCache.Clear(); - this.brushCache.Clear(); - if (this.renderTarget != null) - { - this.renderTarget.Dispose(); - } - - foreach (var unit in this.renderUnits) - { - unit.Dispose(); - } - - this.renderUnits.Clear(); - - // d2dFactory.Dispose(); - this.dwtFactory.Dispose(); - this.wicFactory.Dispose(); - - this.renderTarget = null; - this.d2dFactory = null; - this.dwtFactory = null; - this.wicFactory = null; - } - - /// - /// Gets the font weight. - /// - /// The font weight. - /// A - private static FontWeight GetFontWeight(double fontWeight) - { - return fontWeight > (int)FontWeight.Normal ? FontWeight.Bold : FontWeight.Normal; - } - - /// - /// Gets the stroke. - /// - /// The dashes array. - /// The line join type. - /// Returns stroke stroke style. - private StrokeStyle GetStroke(double[] dashArray, OxyPlot.LineJoin lineJoin) - { - if (dashArray == null) - { - return new StrokeStyle(this.d2dFactory, new StrokeStyleProperties { LineJoin = lineJoin.ToDXLineJoin() }); - } - - return new StrokeStyle(this.d2dFactory, new StrokeStyleProperties { LineJoin = lineJoin.ToDXLineJoin(), DashStyle = DashStyle.Custom }, dashArray.Select(x => (float)x).ToArray()); - } - - /// - /// Get the brush with color. - /// - /// The color. - /// Return the brush. - private Brush GetBrush(OxyColor color) - { - if (!color.IsVisible()) - { - return null; - } - - Brush brush; - if (!this.brushCache.TryGetValue(color, out brush)) - { - brush = new SolidColorBrush(this.renderTarget, color.ToDXColor()); - this.brushCache.Add(color, brush); - } - - return brush; - } - - /// - /// Gets bitmap. - /// - /// The image. - /// Returns bitmap. - private Bitmap GetBitmap(OxyImage image) - { - if (image == null) - { - return null; - } - - if (!this.imagesInUse.Contains(image)) - { - this.imagesInUse.Add(image); - } - - Bitmap res; - using (var stream = new MemoryStream(image.GetData())) - { - var decoder = new BitmapDecoder(this.wicFactory, stream, DecodeOptions.CacheOnDemand); - var frame = decoder.GetFrame(0); - var converter = new FormatConverter(this.wicFactory); - converter.Initialize(frame, dx.WIC.PixelFormat.Format32bppPRGBA); - - res = Bitmap.FromWicBitmap(this.renderTarget, converter); - } - - this.imageCache.Add(image, res); - return res; - } - } -} diff --git a/Source/OxyPlot.SharpDX/OxyPlot.SharpDX.projitems b/Source/OxyPlot.SharpDX/OxyPlot.SharpDX.projitems deleted file mode 100644 index 3d9092f59..000000000 --- a/Source/OxyPlot.SharpDX/OxyPlot.SharpDX.projitems +++ /dev/null @@ -1,21 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - 455376c6-4146-497c-bf77-61cbb67f5df9 - - - OxyPlot.SharpDX - - - - - - - - - - - - \ No newline at end of file diff --git a/Source/OxyPlot.SharpDX/OxyPlot.SharpDX.shproj b/Source/OxyPlot.SharpDX/OxyPlot.SharpDX.shproj deleted file mode 100644 index 5747af4fc..000000000 --- a/Source/OxyPlot.SharpDX/OxyPlot.SharpDX.shproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - 455376c6-4146-497c-bf77-61cbb67f5df9 - 14.0 - - - - - - - - diff --git a/Source/OxyPlot.SharpDX/RenderUnits/EllipseRenderUnit.cs b/Source/OxyPlot.SharpDX/RenderUnits/EllipseRenderUnit.cs deleted file mode 100644 index 7595c89dc..000000000 --- a/Source/OxyPlot.SharpDX/RenderUnits/EllipseRenderUnit.cs +++ /dev/null @@ -1,97 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Represents a Ellipse IRenderUnit implementation. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace OxyPlot.SharpDX -{ - using global::SharpDX; - using global::SharpDX.Direct2D1; - - /// - /// Represents a Ellipse IRenderUnit implementation. - /// - internal class EllipseRenderUnit : IRenderUnit - { - /// - /// The bounds. - /// - private readonly RectangleF bounds; - - /// - /// The ellipse. - /// - private readonly Ellipse ellipse; - - /// - /// The thickness; - /// - private readonly float thickness; - - /// - /// The stroke. - /// - private Brush stroke; - - /// - /// The fill. - /// - private Brush fill; - - /// - /// Initializes a new instance of the class. - /// - /// The ellipse. - /// The stroke. - /// The fill. - /// The thickness. - public EllipseRenderUnit(Ellipse ellipse, Brush stroke, Brush fill, float thickness) - { - this.ellipse = ellipse; - this.bounds = new RectangleF(ellipse.Point.X - ellipse.RadiusX, ellipse.Point.Y - ellipse.RadiusY, ellipse.RadiusX * 2, ellipse.RadiusY * 2); - this.stroke = stroke; - this.fill = fill; - this.thickness = thickness; - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting - /// unmanaged resources. - /// - public void Dispose() - { - this.stroke = null; - this.fill = null; - } - - /// - /// Renders ellipse represented by current instance to render target. - /// - /// The render target. - public void Render(RenderTarget renderTarget) - { - if (this.stroke != null) - { - renderTarget.DrawEllipse(this.ellipse, this.stroke, this.thickness); - } - - if (this.fill != null) - { - renderTarget.FillEllipse(this.ellipse, this.fill); - } - } - - /// - /// Checks if current instance bounds intersects with viewport or not. - /// - /// The viewport. - /// Return True if bounds intersects with viewport, otherwise False. - public bool CheckBounds(RectangleF viewport) - { - return viewport.Intersects(this.bounds); - } - } -} diff --git a/Source/OxyPlot.SharpDX/RenderUnits/GeometryRenderUnit.cs b/Source/OxyPlot.SharpDX/RenderUnits/GeometryRenderUnit.cs deleted file mode 100644 index b134ec6f1..000000000 --- a/Source/OxyPlot.SharpDX/RenderUnits/GeometryRenderUnit.cs +++ /dev/null @@ -1,121 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Represents a Geometry IRenderUnit implementation. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace OxyPlot.SharpDX -{ - using global::SharpDX; - using global::SharpDX.Direct2D1; - - /// - /// Represents a Geometry IRenderUnit implementation. - /// - internal class GeometryRenderUnit : IRenderUnit - { - /// - /// The geometry. - /// - private Geometry geometry; - - /// - /// The bounds. - /// - private RectangleF bounds; - - /// - /// The fill. - /// - private Brush fill; - - /// - /// The stroke. - /// - private Brush stroke; - - /// - /// The stroke style. - /// - private StrokeStyle strokeStyle; - - /// - /// The stroke width. - /// - private readonly float strokeWidth; - - /// - /// Initializes a new instance of the class. - /// - /// The geometry. - /// The stroke. - /// The fill. - /// The stroke width. - /// The stroke style. - public GeometryRenderUnit(Geometry geometry, Brush stroke, Brush fill, float strokeWidth, StrokeStyle strokeStyle) - { - this.geometry = geometry; - this.fill = fill; - this.stroke = stroke; - this.strokeWidth = strokeWidth; - this.strokeStyle = strokeStyle; - var raw = geometry.GetBounds(); - this.bounds = new RectangleF(raw.Left, raw.Top, raw.Right - raw.Left, raw.Bottom - raw.Top); - } - - /// - /// Renders geometry represented by current instance to render target. - /// - /// The render target. - public void Render(RenderTarget renderTarget) - { - if (this.stroke != null) - { - if (this.strokeStyle != null) - { - renderTarget.DrawGeometry(this.geometry, this.stroke, this.strokeWidth, this.strokeStyle); - } - else - { - renderTarget.DrawGeometry(this.geometry, this.stroke, this.strokeWidth); - } - } - - if (this.fill != null) - { - renderTarget.FillGeometry(this.geometry, this.fill); - } - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting - /// unmanaged resources. - /// - public void Dispose() - { - if (this.strokeStyle != null) - { - this.strokeStyle.Dispose(); - } - - this.geometry.Dispose(); - - this.fill = null; - this.geometry = null; - this.stroke = null; - this.strokeStyle = null; - } - - /// - /// Checks if current instance bounds intersects with viewport or not. - /// - /// The viewport. - /// Return True if bounds intersects with viewport, otherwise False. - public bool CheckBounds(RectangleF viewport) - { - return this.bounds.Intersects(viewport); - } - } -} diff --git a/Source/OxyPlot.SharpDX/RenderUnits/IRenderUnit.cs b/Source/OxyPlot.SharpDX/RenderUnits/IRenderUnit.cs deleted file mode 100644 index 95cb210c8..000000000 --- a/Source/OxyPlot.SharpDX/RenderUnits/IRenderUnit.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Represents a IRenderUnit definition. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace OxyPlot.SharpDX -{ - using System; - using global::SharpDX; - using global::SharpDX.Direct2D1; - - /// - /// Represents a IRenderUnit definition. - /// - internal interface IRenderUnit : IDisposable - { - /// - /// Renders image represented by current instance to render target. - /// - /// The render target. - void Render(RenderTarget renderTarget); - - /// - /// Checks if current instance bounds intersects with viewport or not. - /// - /// The viewport. - /// Return True if bounds intersects with viewport, otherwise False. - bool CheckBounds(RectangleF viewport); - } -} diff --git a/Source/OxyPlot.SharpDX/RenderUnits/ImageRenderUnit.cs b/Source/OxyPlot.SharpDX/RenderUnits/ImageRenderUnit.cs deleted file mode 100644 index 470c2c92c..000000000 --- a/Source/OxyPlot.SharpDX/RenderUnits/ImageRenderUnit.cs +++ /dev/null @@ -1,94 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Represents a Image IRenderUnit implementation. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace OxyPlot.SharpDX -{ - using global::SharpDX; - using global::SharpDX.Direct2D1; - - /// - /// Represents a Image IRenderUnit implementation. - /// - internal class ImageRenderUnit : IRenderUnit - { - /// - /// The bitmap. - /// - private Bitmap bitmap; - - /// - /// The source rectangle. - /// - private readonly RectangleF src; - - /// - /// The destination rectangle. - /// - private readonly RectangleF dest; - - /// - /// The opacity. - /// - private readonly float opacity; - - /// - /// The interpolation mode. - /// - private readonly BitmapInterpolationMode mode; - - /// - /// Initializes a new instance of the class. - /// - /// The bitmap. - /// The source rectangle. - /// The destination rectangle. - /// The opacity. - /// The interpolation mode. - public ImageRenderUnit( - Bitmap bitmap, - RectangleF src, - RectangleF dest, - float opacity, - BitmapInterpolationMode mode) - { - this.bitmap = bitmap; - this.src = src; - this.dest = dest; - this.opacity = opacity; - this.mode = mode; - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting - /// unmanaged resources. - /// - public void Dispose() - { - this.bitmap = null; - } - - /// - /// Renders image represented by current instance to render target. - /// - /// The render target. - public void Render(RenderTarget renderTarget) - { - renderTarget.DrawBitmap(this.bitmap, this.dest, this.opacity, this.mode, this.src); - } - - /// - /// Checks if current instance bounds intersects with viewport or not. - /// - /// The viewport. - /// Return True if bounds intersects with viewport, otherwise False. - public bool CheckBounds(RectangleF viewport) - { - return viewport.Intersects(this.dest); - } - } -} diff --git a/Source/OxyPlot.SharpDX/RenderUnits/RectangleRenderUnit.cs b/Source/OxyPlot.SharpDX/RenderUnits/RectangleRenderUnit.cs deleted file mode 100644 index 3ace58485..000000000 --- a/Source/OxyPlot.SharpDX/RenderUnits/RectangleRenderUnit.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Represents a Rectangle IRenderUnit implementation. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace OxyPlot.SharpDX -{ - using global::SharpDX; - using global::SharpDX.Direct2D1; - - /// - /// Represents a Rectangle IRenderUnit implementation. - /// - internal class RectangleRenderUnit : IRenderUnit - { - /// - /// The rectangle. - /// - private readonly RectangleF rectangle; - - /// - /// The stroke. - /// - private Brush stroke; - - /// - /// The fill. - /// - private Brush fill; - - /// - /// The thickness. - /// - private readonly float thickness; - - /// - /// Initializes a new instance of the class. - /// - /// The rectangle. - /// The stroke. - /// The fill. - /// The thickness. - public RectangleRenderUnit(RectangleF rectangle, Brush stroke, Brush fill, float thickness) - { - this.rectangle = rectangle; - this.stroke = stroke; - this.fill = fill; - this.thickness = thickness; - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting - /// unmanaged resources. - /// - public void Dispose() - { - this.stroke = null; - this.fill = null; - } - - /// - /// Renders rectangle represented by current instance to render target. - /// - /// The render target. - public void Render(RenderTarget renderTarget) - { - if (this.stroke != null) - { - renderTarget.DrawRectangle(this.rectangle, this.stroke, this.thickness); - } - - if (this.fill != null) - { - renderTarget.FillRectangle(this.rectangle, this.fill); - } - } - - /// - /// Checks if current instance bounds intersects with viewport or not. - /// - /// The viewport. - /// Return True if bounds intersects with viewport, otherwise False. - public bool CheckBounds(RectangleF viewport) - { - return viewport.Intersects(this.rectangle); - } - } -} diff --git a/Source/OxyPlot.SharpDX/RenderUnits/TextRenderUnit.cs b/Source/OxyPlot.SharpDX/RenderUnits/TextRenderUnit.cs deleted file mode 100644 index acebcc8f6..000000000 --- a/Source/OxyPlot.SharpDX/RenderUnits/TextRenderUnit.cs +++ /dev/null @@ -1,98 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Represents a Text IRenderUnit implementation. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace OxyPlot.SharpDX -{ - using global::SharpDX; - using global::SharpDX.Direct2D1; - using global::SharpDX.DirectWrite; - - /// - /// Represents a Text IRenderUnit implementation. - /// - internal class TextRenderUnit : IRenderUnit - { - /// - /// The text transform. - /// - private readonly Matrix3x2 transform; - - /// - /// The text layout. - /// - private readonly TextLayout layout; - - /// - /// The brush. - /// - private Brush brush; - - /// - /// The bounds. - /// - private readonly RectangleF bounds; - - /// - /// Initializes a new instance of the class. - /// - /// The text layout. - /// The brush. - /// The text transform. - public TextRenderUnit(TextLayout textLayout, Brush brush, Matrix3x2 transform) - { - this.layout = textLayout; - this.brush = brush; - this.transform = transform; - - var topleft = Matrix3x2.TransformPoint(transform, new Vector2(0, 0)); - var bottomRight = Matrix3x2.TransformPoint(transform, new Vector2(textLayout.Metrics.Width, textLayout.Metrics.Height)); - - this.bounds = new RectangleF - { - Top = topleft.Y, - Left = topleft.X, - Right = bottomRight.X, - Bottom = bottomRight.Y - }; - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting - /// unmanaged resources. - /// - public void Dispose() - { - this.layout.Dispose(); - this.brush = null; - } - - /// - /// Renders text represented by current instance to render target. - /// - /// The render target. - public void Render(RenderTarget renderTarget) - { - var currentTransform = renderTarget.Transform; - renderTarget.Transform = this.transform * currentTransform; - - renderTarget.DrawTextLayout(new Vector2(), this.layout, this.brush); - - renderTarget.Transform = currentTransform; - } - - /// - /// Checks if current instance bounds intersects with viewport or not. - /// - /// The viewport. - /// Return True if bounds intersects with viewport, otherwise False. - public bool CheckBounds(RectangleF viewport) - { - return viewport.Intersects(this.bounds); - } - } -} diff --git a/Source/OxyPlot.SharpDX/SharpDXOxyExtensions.cs b/Source/OxyPlot.SharpDX/SharpDXOxyExtensions.cs deleted file mode 100644 index 684640931..000000000 --- a/Source/OxyPlot.SharpDX/SharpDXOxyExtensions.cs +++ /dev/null @@ -1,90 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2014 OxyPlot contributors -// -// -// Represents class, that contains SharpDX and Oxy extensions. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace OxyPlot.SharpDX -{ - using global::SharpDX; - using DXLineJoin = global::SharpDX.Direct2D1.LineJoin; - using Ellipse = global::SharpDX.Direct2D1.Ellipse; - - /// - /// Represents class, that contains SharpDX and Oxy extensions. - /// - internal static class SharpDXOxyExtensions - { - /// - /// Converts to . - /// - /// The point to convert, - /// Indicate, whether result should be aliased - /// Return - public static Vector2 ToVector2(this ScreenPoint point, bool aliased = false) - { - // adding 0.5 to get pixel boundary alignment, seems to work - // http://weblogs.asp.net/mschwarz/archive/2008/01/04/silverlight-rectangles-paths-and-line-comparison.aspx - // http://www.wynapse.com/Silverlight/Tutor/Silverlight_Rectangles_Paths_And_Lines_Comparison.aspx - if (aliased) - { - return new Vector2(0.5f + (int)point.X, 0.5f + (int)point.Y); - } - - return new Vector2((float)point.X, (float)point.Y); - } - - /// - /// Converts to . - /// - /// The rectangle to convert. - /// Return - public static Ellipse ToEllipse(this OxyRect rect) - { - return new Ellipse(rect.Center.ToVector2(), (float)rect.Width / 2, (float)rect.Height / 2); - } - - /// - /// Converts to . - /// - /// The rectangle to convert. - /// Return - public static RectangleF ToRectangleF(this OxyRect rect) - { - return new RectangleF((float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height); - } - - /// - /// Converts to . - /// - /// The to convert. - /// Return - public static DXLineJoin ToDXLineJoin(this LineJoin lineJoin) - { - switch (lineJoin) - { - case LineJoin.Miter: - return DXLineJoin.Miter; - case LineJoin.Round: - return DXLineJoin.Round; - case LineJoin.Bevel: - return DXLineJoin.Bevel; - default: - return DXLineJoin.MiterOrBevel; - } - } - - /// - /// Converts to . - /// - /// The color to convert. - /// Return - public static Color4 ToDXColor(this OxyColor color) - { - return new Color4(color.R * 1f / 255f, color.G * 1f / 255f, color.B * 1f / 255f, color.A * 1f / 255f); - } - } -} diff --git a/appveyor.yml b/appveyor.yml index 3b6251a56..6d5b222de 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,7 +25,6 @@ after_build: - NuGet pack Source\OxyPlot.WindowsForms\OxyPlot.WindowsForms.nuspec -version "%GitVersion_NuGetVersion%" -OutputDirectory Source\OxyPlot.WindowsForms\bin\Release - NuGet pack Source\OxyPlot.OpenXml\OxyPlot.OpenXml.nuspec -version "%GitVersion_NuGetVersion%" -OutputDirectory Source\OxyPlot.OpenXml\bin\Release - NuGet pack Source\OxyPlot.Pdf\OxyPlot.Pdf.nuspec -version "%GitVersion_NuGetVersion%" -OutputDirectory Source\OxyPlot.Pdf\bin\Release - - NuGet pack Source\OxyPlot.SharpDX.Wpf\OxyPlot.SharpDX.Wpf.nuspec -version "%GitVersion_NuGetVersion%" -OutputDirectory Source\OxyPlot.SharpDX.Wpf\bin\Release artifacts: - path: '**/bin/Release/**/*.nupkg'