protected GeometryGroup(string name, Direct2DDevice device, FillMode fillMode, SharpDX.Direct2D1.Geometry[] geometries) : base(name, device) { Contract.Requires <ArgumentNullException>(geometries != null, "geometries"); Contract.Requires <InvalidOperationException>(geometries.Length > 0, "At least one geometry needed"); Resource = new SharpDX.Direct2D1.GeometryGroup(Device, GetD2DFlag(fillMode), geometries.ToArray()); }
Brush CreateColorResource(Direct2DDevice device, ColorResource colorResource) { var resource = Brush.FromColorResource(device, colorResource); AddResource(resource, colorResource.Shared); return(resource); }
internal static IAnimationCurve FromColor4Curve <TGradientBrush>(Direct2DDevice device, Color4Curve originalCurve, TGradientBrush originalBrush) where TGradientBrush : GradientBrush { var styleService = device.Services.GetService <IStyleService>(); var match = Regex.Match(originalCurve.TargetProperty, @"\w*\[(?<index>\d+)\]"); int index = int.Parse(match.Groups["index"].Value); var newCurve = new GradientBrushCurve() { Name = originalCurve.Name }; int keyFrameIndex = 0; foreach (var keyframe in originalCurve) { var newGradient = (Gradient)originalBrush.Gradient.CopyAs(string.Format("{0}.Keyframe{1:D2}", newCurve.Name, keyFrameIndex++)); newGradient.GradientStops[index].Color = keyframe.Value; var newBrush = Brush.FromColorResource(device, newGradient); newBrush.Initialize(); styleService.AddResource(newBrush); var newKeyFrame = new GradientBrushKeyFrame() { Time = keyframe.Time, Value = (TGradientBrush)newBrush }; newCurve.AddKeyFrame(newKeyFrame); } newCurve.TargetName = originalCurve.TargetName; newCurve.TargetProperty = originalCurve.TargetProperty.Split('.')[0]; return(newCurve); }
public static SolidColorBrush New(string name, Direct2DDevice device, SolidColor solidColorBrush) { var brushProperties = new BrushProperties() { Opacity = solidColorBrush.Opacity }; return(new SolidColorBrush(name, device, solidColorBrush, new SharpDX.Direct2D1.SolidColorBrush(device, solidColorBrush.Color, brushProperties))); }
public static Brush FromColorResource(Direct2DDevice device, ColorResource colorResource) { switch (colorResource.Type) { case ColorType.SolidColor: return(SolidColorBrush.New(colorResource.Name, device, (SolidColor)colorResource)); case ColorType.LinearGradient: return(LinearGradientBrush.New(colorResource.Name, device, (LinearGradient)colorResource)); case ColorType.RadialGradient: return(RadialGradientBrush.New(colorResource.Name, device, (RadialGradient)colorResource)); default: throw new ArgumentOutOfRangeException(string.Format("Brush type '{0}' is not valid", colorResource.Type)); } }
public static LinearGradientBrush New(string name, Direct2DDevice device, LinearGradient linearGradient) { using (var d2dGradientStopCollection = new SharpDX.Direct2D1.GradientStopCollection(device, linearGradient.GradientStops.Select(gs => (SharpDX.Direct2D1.GradientStop)gs).ToArray(), (SharpDX.Direct2D1.ExtendMode)linearGradient.GradientStops.ExtendMode)) { var lgbProperties = new LinearGradientBrushProperties() { StartPoint = linearGradient.StartPoint, EndPoint = linearGradient.EndPoint }; var brushProperties = new BrushProperties() { Opacity = linearGradient.Opacity }; var brush = new SharpDX.Direct2D1.LinearGradientBrush(device, lgbProperties, brushProperties, d2dGradientStopCollection); return(new LinearGradientBrush(name, device, linearGradient, brush)); } }
public Overlay(IServiceRegistry services) : base(VisualStyle.Empty) { Contract.Requires <ArgumentNullException>(services != null, "services"); this.services = services; device = services.GetService <IDirect2DService>().Direct2DDevice; IsInside = true; IsFocusable = true; TextTheme = DefaultTextTheme; styleService = ToDispose(services.GetService <IStyleService>()); theme = styleService.GetTheme(DefaultControlTheme); EnteredElement = this; FocusedElement = this; }
public static RadialGradientBrush New(string name, Direct2DDevice device, RadialGradient radialGradient) { using (var d2dGradientStopCollection = new SharpDX.Direct2D1.GradientStopCollection(device, radialGradient.GradientStops.Select(gs => (SharpDX.Direct2D1.GradientStop)gs).ToArray(), (SharpDX.Direct2D1.ExtendMode)radialGradient.GradientStops.ExtendMode)) { var rgbProperties = new RadialGradientBrushProperties { Center = radialGradient.Center, GradientOriginOffset = radialGradient.OriginOffset, RadiusX = radialGradient.RadiusX, RadiusY = radialGradient.RadiusY }; var brushProperties = new BrushProperties() { Opacity = radialGradient.Opacity }; var brush = new SharpDX.Direct2D1.RadialGradientBrush(device, rgbProperties, brushProperties, d2dGradientStopCollection); return(new RadialGradientBrush(name, device, radialGradient, brush)); } }
public static PathGeometry New(string name, Direct2DDevice device) { return(new PathGeometry(name, device)); }
private SolidColorBrush(string name, Direct2DDevice device, SolidColor solidColor, SharpDX.Direct2D1.SolidColorBrush brush) : base(name, device, solidColor, brush) { colorResource = solidColor; resource = brush; }
protected Brush(string name, Direct2DDevice device, ColorResource colorResource, SharpDX.Direct2D1.Brush brush) : base(name, device) { ColorResource = colorResource; Resource = brush; }
private RadialGradientBrush(string name, Direct2DDevice device, RadialGradient radialGradient, SharpDX.Direct2D1.RadialGradientBrush brush) : base(name, device, radialGradient, brush) { resource = brush; colorResource = radialGradient; }
protected Geometry(string name, Direct2DDevice device) : base(name, device) { }
private LinearGradientBrush(string name, Direct2DDevice device, LinearGradient linearGradient, SharpDX.Direct2D1.LinearGradientBrush brush) : base(name, device, linearGradient, brush) { resource = brush; colorResource = linearGradient; }
protected GradientBrush(string name, Direct2DDevice device, Gradient gradient, SharpDX.Direct2D1.Brush brush) : base(name, device, gradient, brush) { ColorResource = gradient; }
protected PathGeometry(string name, Direct2DDevice device) : base(name, device) { Resource = new SharpDX.Direct2D1.PathGeometry(device); }
public static GeometryGroup New(string name, Direct2DDevice device, FillMode fillMode, IEnumerable <Geometry> geometries) { var nativeGeometries = geometries.Select(geometry => (SharpDX.Direct2D1.Geometry)geometry).ToArray(); return(new GeometryGroup(name, device, fillMode, nativeGeometries)); }