Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EllipseGeometry"/> class.
        /// </summary>
        /// <param name="rect">The rectangle that the ellipse should fill.</param>
        public EllipseGeometry(Rect rect)
        {
            IPlatformRenderInterface factory = PerspexLocator.Current.GetService <IPlatformRenderInterface>();
            IStreamGeometryImpl      impl    = factory.CreateStreamGeometry();

            using (IStreamGeometryContextImpl ctx = impl.Open())
            {
                double controlPointRatio = (Math.Sqrt(2) - 1) * 4 / 3;
                var    center            = rect.Center;
                var    radius            = new Vector(rect.Width / 2, rect.Height / 2);

                var x0 = center.X - radius.X;
                var x1 = center.X - (radius.X * controlPointRatio);
                var x2 = center.X;
                var x3 = center.X + (radius.X * controlPointRatio);
                var x4 = center.X + radius.X;

                var y0 = center.Y - radius.Y;
                var y1 = center.Y - (radius.Y * controlPointRatio);
                var y2 = center.Y;
                var y3 = center.Y + (radius.Y * controlPointRatio);
                var y4 = center.Y + radius.Y;

                ctx.BeginFigure(new Point(x2, y0), true);
                ctx.BezierTo(new Point(x3, y0), new Point(x4, y1), new Point(x4, y2));
                ctx.BezierTo(new Point(x4, y3), new Point(x3, y4), new Point(x2, y4));
                ctx.BezierTo(new Point(x1, y4), new Point(x0, y3), new Point(x0, y2));
                ctx.BezierTo(new Point(x0, y1), new Point(x1, y0), new Point(x2, y0));
                ctx.EndFigure(true);
            }

            PlatformImpl = impl;
        }
Esempio n. 2
0
 public TestServices With(
     IAssetLoader assetLoader              = null,
     IFocusManager focusManager            = null,
     IInputManager inputManager            = null,
     Func <IKeyboardDevice> keyboardDevice = null,
     ILayoutManager layoutManager          = null,
     IRuntimePlatform platform             = null,
     IRenderer renderer = null,
     IPlatformRenderInterface renderInterface = null,
     IRenderLoop renderLoop = null,
     IScheduler scheduler   = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     return(new TestServices(
                assetLoader: assetLoader ?? AssetLoader,
                focusManager: focusManager ?? FocusManager,
                inputManager: inputManager ?? InputManager,
                keyboardDevice: keyboardDevice ?? KeyboardDevice,
                layoutManager: layoutManager ?? LayoutManager,
                platform: platform ?? Platform,
                renderer: renderer ?? Renderer,
                renderInterface: renderInterface ?? RenderInterface,
                renderLoop: renderLoop ?? RenderLoop,
                scheduler: scheduler ?? Scheduler,
                standardCursorFactory: standardCursorFactory ?? StandardCursorFactory,
                styler: styler ?? Styler,
                theme: theme ?? Theme,
                threadingInterface: threadingInterface ?? ThreadingInterface,
                windowingPlatform: windowingPlatform ?? WindowingPlatform));
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TopLevel"/> class.
        /// </summary>
        /// <param name="impl">The platform-specific window implementation.</param>
        /// <param name="dependencyResolver">
        /// The dependency resolver to use. If null the default dependency resolver will be used.
        /// </param>
        public TopLevel(ITopLevelImpl impl, IAvaloniaDependencyResolver dependencyResolver)
        {
            if (impl == null)
            {
                throw new InvalidOperationException(
                          "Could not create window implementation: maybe no windowing subsystem was initialized?");
            }

            PlatformImpl = impl;

            dependencyResolver = dependencyResolver ?? AvaloniaLocator.Current;
            var styler = TryGetService <IStyler>(dependencyResolver);

            _accessKeyHandler          = TryGetService <IAccessKeyHandler>(dependencyResolver);
            _inputManager              = TryGetService <IInputManager>(dependencyResolver);
            _keyboardNavigationHandler = TryGetService <IKeyboardNavigationHandler>(dependencyResolver);
            _renderInterface           = TryGetService <IPlatformRenderInterface>(dependencyResolver);
            _globalStyles              = TryGetService <IGlobalStyles>(dependencyResolver);

            Renderer = impl.CreateRenderer(this);

            if (Renderer != null)
            {
                Renderer.SceneInvalidated += SceneInvalidated;
            }

            impl.SetInputRoot(this);

            impl.Closed         = HandleClosed;
            impl.Input          = HandleInput;
            impl.Paint          = HandlePaint;
            impl.Resized        = HandleResized;
            impl.ScalingChanged = HandleScalingChanged;

            _keyboardNavigationHandler?.SetOwner(this);
            _accessKeyHandler?.SetOwner(this);

            if (_globalStyles is object)
            {
                _globalStyles.GlobalStylesAdded   += ((IStyleHost)this).StylesAdded;
                _globalStyles.GlobalStylesRemoved += ((IStyleHost)this).StylesRemoved;
            }

            styler?.ApplyStyles(this);

            ClientSize = impl.ClientSize;

            this.GetObservable(PointerOverElementProperty)
            .Select(
                x => (x as InputElement)?.GetObservable(CursorProperty) ?? Observable.Empty <Cursor>())
            .Switch().Subscribe(cursor => PlatformImpl?.SetCursor(cursor?.PlatformCursor));

            if (((IStyleHost)this).StylingParent is IResourceProvider applicationResources)
            {
                WeakSubscriptionManager.Subscribe(
                    applicationResources,
                    nameof(IResourceProvider.ResourcesChanged),
                    this);
            }
        }
Esempio n. 4
0
 public TestServices(
     IAssetLoader assetLoader              = null,
     IFocusManager focusManager            = null,
     IInputManager inputManager            = null,
     Func <IKeyboardDevice> keyboardDevice = null,
     ILayoutManager layoutManager          = null,
     IRuntimePlatform platform             = null,
     IRenderer renderer = null,
     IPlatformRenderInterface renderInterface = null,
     IRenderLoop renderLoop = null,
     IScheduler scheduler   = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowingPlatform windowingPlatform           = null)
 {
     AssetLoader           = assetLoader;
     FocusManager          = focusManager;
     InputManager          = inputManager;
     KeyboardDevice        = keyboardDevice;
     LayoutManager         = layoutManager;
     Platform              = platform;
     Renderer              = renderer;
     RenderInterface       = renderInterface;
     RenderLoop            = renderLoop;
     Scheduler             = scheduler;
     StandardCursorFactory = standardCursorFactory;
     Styler             = styler;
     Theme              = theme;
     ThreadingInterface = threadingInterface;
     WindowingPlatform  = windowingPlatform;
 }
Esempio n. 5
0
 public TestServices(
     IAssetLoader assetLoader                     = null,
     IInputManager inputManager                   = null,
     ILayoutManager layoutManager                 = null,
     IPclPlatformWrapper platformWrapper          = null,
     IPlatformRenderInterface renderInterface     = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     AssetLoader           = assetLoader;
     InputManager          = inputManager;
     LayoutManager         = layoutManager;
     PlatformWrapper       = platformWrapper;
     RenderInterface       = renderInterface;
     StandardCursorFactory = standardCursorFactory;
     Styler             = styler;
     Theme              = theme;
     ThreadingInterface = threadingInterface;
     WindowImpl         = windowImpl;
     WindowingPlatform  = windowingPlatform;
 }
Esempio n. 6
0
 public TestServices(
     IAssetLoader assetLoader = null,
     IFocusManager focusManager = null,
     IInputManager inputManager = null,
     Func<IKeyboardDevice> keyboardDevice = null,
     ILayoutManager layoutManager = null,
     IPclPlatformWrapper platformWrapper = null,
     IPlatformRenderInterface renderInterface = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler = null,
     Func<Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     AssetLoader = assetLoader;
     FocusManager = focusManager;
     InputManager = inputManager;
     KeyboardDevice = keyboardDevice;
     LayoutManager = layoutManager;
     PlatformWrapper = platformWrapper;
     RenderInterface = renderInterface;
     StandardCursorFactory = standardCursorFactory;
     Styler = styler;
     Theme = theme;
     ThreadingInterface = threadingInterface;
     WindowImpl = windowImpl;
     WindowingPlatform = windowingPlatform;
 }
Esempio n. 7
0
 public TestServices With(
     IAssetLoader assetLoader                     = null,
     IInputManager inputManager                   = null,
     ILayoutManager layoutManager                 = null,
     IPclPlatformWrapper platformWrapper          = null,
     IPlatformRenderInterface renderInterface     = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     return(new TestServices(
                assetLoader: assetLoader ?? AssetLoader,
                inputManager: inputManager ?? InputManager,
                layoutManager: layoutManager ?? LayoutManager,
                platformWrapper: platformWrapper ?? PlatformWrapper,
                renderInterface: renderInterface ?? RenderInterface,
                standardCursorFactory: standardCursorFactory ?? StandardCursorFactory,
                styler: styler ?? Styler,
                theme: theme ?? Theme,
                threadingInterface: threadingInterface ?? ThreadingInterface,
                windowImpl: windowImpl ?? WindowImpl,
                windowingPlatform: windowingPlatform ?? WindowingPlatform));
 }
Esempio n. 8
0
 public TestServices(
     IAssetLoader assetLoader                      = null,
     IFocusManager focusManager                    = null,
     IInputManager inputManager                    = null,
     Func <IKeyboardDevice> keyboardDevice         = null,
     IKeyboardNavigationHandler keyboardNavigation = null,
     Func <IMouseDevice> mouseDevice               = null,
     IRuntimePlatform platform                     = null,
     IPlatformRenderInterface renderInterface      = null,
     IRenderLoop renderLoop = null,
     IScheduler scheduler   = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     AssetLoader           = assetLoader;
     FocusManager          = focusManager;
     InputManager          = inputManager;
     KeyboardDevice        = keyboardDevice;
     KeyboardNavigation    = keyboardNavigation;
     MouseDevice           = mouseDevice;
     Platform              = platform;
     RenderInterface       = renderInterface;
     Scheduler             = scheduler;
     StandardCursorFactory = standardCursorFactory;
     Styler             = styler;
     Theme              = theme;
     ThreadingInterface = threadingInterface;
     WindowImpl         = windowImpl;
     WindowingPlatform  = windowingPlatform;
 }
Esempio n. 9
0
 public TestServices With(
     IAssetLoader assetLoader                      = null,
     IFocusManager focusManager                    = null,
     IInputManager inputManager                    = null,
     Func <IKeyboardDevice> keyboardDevice         = null,
     IKeyboardNavigationHandler keyboardNavigation = null,
     Func <IMouseDevice> mouseDevice               = null,
     IRuntimePlatform platform                     = null,
     IPlatformRenderInterface renderInterface      = null,
     IRenderLoop renderLoop = null,
     IScheduler scheduler   = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     return(new TestServices(
                assetLoader: assetLoader ?? AssetLoader,
                focusManager: focusManager ?? FocusManager,
                inputManager: inputManager ?? InputManager,
                keyboardDevice: keyboardDevice ?? KeyboardDevice,
                keyboardNavigation: keyboardNavigation ?? KeyboardNavigation,
                mouseDevice: mouseDevice ?? MouseDevice,
                platform: platform ?? Platform,
                renderInterface: renderInterface ?? RenderInterface,
                scheduler: scheduler ?? Scheduler,
                standardCursorFactory: standardCursorFactory ?? StandardCursorFactory,
                styler: styler ?? Styler,
                theme: theme ?? Theme,
                threadingInterface: threadingInterface ?? ThreadingInterface,
                windowingPlatform: windowingPlatform ?? WindowingPlatform,
                windowImpl: windowImpl ?? WindowImpl));
 }
Esempio n. 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PolylineGeometry"/> class.
        /// </summary>
        public PolylineGeometry()
        {
            IPlatformRenderInterface factory = AvaloniaLocator.Current.GetService <IPlatformRenderInterface>();

            PlatformImpl = factory.CreateStreamGeometry();

            Points = new Points();
        }
Esempio n. 11
0
        private void OnPointerPressed(object sender, PointerEventArgs e)
        {
            IPlatformRenderInterface platform = Locator.Current.GetService <IPlatformRenderInterface>();

            this.CaretIndex = platform.TextService.GetCaretIndex(
                this.textBoxView.FormattedText,
                e.GetPosition(this.textBoxView),
                this.ActualSize);
        }
Esempio n. 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TopLevel"/> class.
        /// </summary>
        /// <param name="impl">The platform-specific window implementation.</param>
        /// <param name="dependencyResolver">
        /// The dependency resolver to use. If null the default dependency resolver will be used.
        /// </param>
        public TopLevel(ITopLevelImpl impl, IAvaloniaDependencyResolver dependencyResolver)
        {
            if (impl == null)
            {
                throw new InvalidOperationException(
                          "Could not create window implementation: maybe no windowing subsystem was initialized?");
            }

            PlatformImpl       = impl;
            dependencyResolver = dependencyResolver ?? AvaloniaLocator.Current;
            var styler = TryGetService <IStyler>(dependencyResolver);

            _accessKeyHandler          = TryGetService <IAccessKeyHandler>(dependencyResolver);
            _inputManager              = TryGetService <IInputManager>(dependencyResolver);
            _keyboardNavigationHandler = TryGetService <IKeyboardNavigationHandler>(dependencyResolver);
            _applicationLifecycle      = TryGetService <IApplicationLifecycle>(dependencyResolver);
            _renderInterface           = TryGetService <IPlatformRenderInterface>(dependencyResolver);

            var renderLoop      = TryGetService <IRenderLoop>(dependencyResolver);
            var rendererFactory = TryGetService <IRendererFactory>(dependencyResolver);

            Renderer = rendererFactory?.CreateRenderer(this, renderLoop);

            PlatformImpl.SetInputRoot(this);
            PlatformImpl.Activated       = HandleActivated;
            PlatformImpl.Deactivated     = HandleDeactivated;
            PlatformImpl.Closed          = HandleClosed;
            PlatformImpl.Input           = HandleInput;
            PlatformImpl.Paint           = Renderer != null ? (Action <Rect>)Renderer.Render : null;
            PlatformImpl.Resized         = HandleResized;
            PlatformImpl.ScalingChanged  = HandleScalingChanged;
            PlatformImpl.PositionChanged = HandlePositionChanged;

            _keyboardNavigationHandler?.SetOwner(this);
            _accessKeyHandler?.SetOwner(this);
            styler?.ApplyStyles(this);

            ClientSize = PlatformImpl.ClientSize;
            this.GetObservable(ClientSizeProperty).Skip(1).Subscribe(x => PlatformImpl.ClientSize = x);
            this.GetObservable(PointerOverElementProperty)
            .Select(
                x => (x as InputElement)?.GetObservable(CursorProperty) ?? Observable.Empty <Cursor>())
            .Switch().Subscribe(cursor => PlatformImpl.SetCursor(cursor?.PlatformCursor));

            if (_applicationLifecycle != null)
            {
                _applicationLifecycle.OnExit += OnApplicationExiting;
            }
        }
Esempio n. 13
0
        public RectangleGeometry(Rect rect)
        {
            IPlatformRenderInterface factory = Locator.Current.GetService <IPlatformRenderInterface>();
            IStreamGeometryImpl      impl    = factory.CreateStreamGeometry();

            using (IStreamGeometryContextImpl context = impl.Open())
            {
                context.BeginFigure(rect.TopLeft, true);
                context.LineTo(rect.TopRight);
                context.LineTo(rect.BottomRight);
                context.LineTo(rect.BottomLeft);
                context.EndFigure(true);
            }

            this.PlatformImpl = impl;
        }
Esempio n. 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LineGeometry"/> class.
        /// </summary>
        /// <param name="startPoint">The start point.</param>
        /// <param name="endPoint">The end point.</param>
        public LineGeometry(Point startPoint, Point endPoint)
        {
            _startPoint = startPoint;
            _endPoint   = endPoint;
            IPlatformRenderInterface factory = AvaloniaLocator.Current.GetService <IPlatformRenderInterface>();
            IStreamGeometryImpl      impl    = factory.CreateStreamGeometry();

            using (IStreamGeometryContextImpl context = impl.Open())
            {
                context.BeginFigure(_startPoint, false);
                context.LineTo(_endPoint);
                context.EndFigure(false);
            }

            PlatformImpl = impl;
        }
Esempio n. 15
0
        public Form1()
        {
            InitializeComponent();

            _render = new PlatformRenderInterface();
            PerspexLocator.CurrentMutable.Bind <IPlatformRenderInterface>().ToConstant(_render);
            _geometry     = new StreamGeometry();
            _rbitmap      = new RenderTargetBitmap(50, 50);
            _renderTarget = _render.CreateRenderer(new PlatformHandle(Handle, "HWND"), ClientSize.Width,
                                                   ClientSize.Height);
            var timer = new Timer()
            {
                Interval = 20
            };

            timer.Tick += delegate { Invalidate(); };
            timer.Start();
            components.Add(timer);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);

            using (var ctx = _geometry.Open())
            {
                ctx.BeginFigure(new Point(10, 10), true);
                ctx.LineTo(new Point(40, 25));
                ctx.BezierTo(new Point(50, 45), new Point(43, 48), new Point(20, 90));
                ctx.LineTo(new Point(10, 60));
                ctx.EndFigure(true);
            }

            _text =
                new FormattedText(
                    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum",
                    "Arial", 25, FontStyle.Normal, TextAlignment.Left, FontWeight.Normal);

            _text.Constraint = new Size(400, double.PositiveInfinity);

            using (var ctx = _rbitmap.CreateDrawingContext())
                ctx.DrawRectangle(new Pen(new SolidColorBrush(Colors.Aqua)), new Rect(10, 10, 30, 30), 5);

            _bitmap = new Bitmap(@"C:\Users\keks\Desktop\phoenix.png");
        }
Esempio n. 16
0
        public Window()
        {
            IPlatformRenderInterface factory = Locator.Current.GetService <IPlatformRenderInterface>();

            this.CreateWindow();
            Size clientSize = this.ClientSize;

            this.LayoutManager = new LayoutManager(this);
            this.RenderManager = new RenderManager();
            this.renderer      = factory.CreateRenderer(this.Handle, (int)clientSize.Width, (int)clientSize.Height);
            this.inputManager  = Locator.Current.GetService <IInputManager>();
            this.Template      = ControlTemplate.Create <Window>(this.DefaultTemplate);

            this.LayoutManager.LayoutNeeded.Subscribe(x =>
            {
                WindowsDispatcher.CurrentDispatcher.BeginInvoke(
                    DispatcherPriority.Render,
                    () =>
                {
                    this.LayoutManager.ExecuteLayoutPass();
                    this.renderer.Render(this);
                    this.RenderManager.RenderFinished();
                });
            });

            this.RenderManager.RenderNeeded
            .Where(_ => !this.LayoutManager.LayoutQueued)
            .Subscribe(x =>
            {
                WindowsDispatcher.CurrentDispatcher.BeginInvoke(
                    DispatcherPriority.Render,
                    () =>
                {
                    if (!this.LayoutManager.LayoutQueued)
                    {
                        this.renderer.Render(this);
                        this.RenderManager.RenderFinished();
                    }
                });
            });
        }
Esempio n. 17
0
 public Frame(IPlatformRenderInterface renderInterface, Framebuffer.FramebufferFrame frame)
 {
     Time = frame.Time;
     using (var framebuffer = frame.Framebuffer.Lock())
     {
         var writableBitmap = RefCountable.Create(renderInterface.CreateWritableBitmap(framebuffer.Width, framebuffer.Height, framebuffer.Format));
         using (var bitmapBuffer = writableBitmap.Item.Lock())
         {
             unsafe
             {
                 for (int i = 0; i < framebuffer.Height; i++)
                 {
                     Unsafe.CopyBlockUnaligned(
                         (byte *)framebuffer.Address + i * framebuffer.RowBytes,
                         (byte *)bitmapBuffer.Address + i * bitmapBuffer.RowBytes,
                         (uint)bitmapBuffer.RowBytes);
                 }
             }
         }
         FrameBitmap = writableBitmap;
     }
 }
Esempio n. 18
0
        public PolylineGeometry(IList <Point> points, bool isFilled)
        {
            _points   = points;
            _isFilled = isFilled;
            IPlatformRenderInterface factory = PerspexLocator.Current.GetService <IPlatformRenderInterface>();
            IStreamGeometryImpl      impl    = factory.CreateStreamGeometry();

            using (IStreamGeometryContextImpl context = impl.Open())
            {
                if (points.Count > 0)
                {
                    context.BeginFigure(points[0], isFilled);
                    for (int i = 1; i < points.Count; i++)
                    {
                        context.LineTo(points[i]);
                    }
                    context.EndFigure(isFilled);
                }
            }

            PlatformImpl = impl;
        }
Esempio n. 19
0
        public Form1()
        {
            InitializeComponent();

            _render = new PlatformRenderInterface();
            PerspexLocator.CurrentMutable.Bind<IPlatformRenderInterface>().ToConstant(_render);
            _geometry =  new StreamGeometry();
            _rbitmap = new RenderTargetBitmap(50, 50);
            _renderTarget = _render.CreateRenderer(new PlatformHandle(Handle, "HWND"), ClientSize.Width,
                ClientSize.Height);
            var timer = new Timer() {Interval = 20};
            timer.Tick += delegate { Invalidate(); };
            timer.Start();
            components.Add(timer);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);

            using (var ctx = _geometry.Open())
            {
                ctx.BeginFigure(new Point(10,10), true);
                ctx.LineTo(new Point(40,25));
                ctx.BezierTo(new Point(50, 45), new Point(43, 48), new Point(20, 90));
                ctx.LineTo(new Point(10, 60));
                ctx.EndFigure(true);
            }

            _text =
                new FormattedText(
                    "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum",
                    "Arial", 25, FontStyle.Normal, TextAlignment.Left, FontWeight.Normal);

            _text.Constraint = new Size(400, double.PositiveInfinity);

            using (var ctx = _rbitmap.CreateDrawingContext())
                ctx.DrawRectangle(new Pen(new SolidColorBrush(Colors.Aqua)), new Rect(10, 10, 30, 30), 5);

            _bitmap = new Bitmap(@"C:\Users\keks\Desktop\phoenix.png");
        }
Esempio n. 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormattedText"/> class.
 /// </summary>
 /// <param name="platform">The platform render interface.</param>
 public FormattedText(IPlatformRenderInterface platform)
 {
     _platform = platform;
 }
Esempio n. 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormattedText"/> class.
 /// </summary>
 public FormattedText()
 {
     _platform = AvaloniaLocator.Current.GetService <IPlatformRenderInterface>();
 }
Esempio n. 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Bitmap"/> class.
        /// </summary>
        /// <param name="stream">The stream to read the bitmap from.</param>
        public Bitmap(Stream stream)
        {
            IPlatformRenderInterface factory = AvaloniaLocator.Current.GetService <IPlatformRenderInterface>();

            PlatformImpl = factory.LoadBitmap(stream);
        }
Esempio n. 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Bitmap"/> class.
        /// </summary>
        /// <param name="fileName">The filename of the bitmap.</param>
        public Bitmap(string fileName)
        {
            IPlatformRenderInterface factory = AvaloniaLocator.Current.GetService <IPlatformRenderInterface>();

            PlatformImpl = factory.LoadBitmap(fileName);
        }
Esempio n. 24
0
        /// <summary>
        /// Creates a platform-specific imlementation for a <see cref="RenderTargetBitmap"/>.
        /// </summary>
        /// <param name="width">The width of the bitmap.</param>
        /// <param name="height">The height of the bitmap.</param>
        /// <returns>The platform-specific implementation.</returns>
        private static IBitmapImpl CreateImpl(int width, int height)
        {
            IPlatformRenderInterface factory = PerspexLocator.Current.GetService <IPlatformRenderInterface>();

            return(factory.CreateRenderTargetBitmap(width, height));
        }
Esempio n. 25
0
        /// <summary>
        /// Creates a Bitmap scaled to a specified size from the current bitmap.
        /// </summary>
        /// <param name="destinationSize">The destination size.</param>
        /// <param name="interpolationMode">The <see cref="BitmapInterpolationMode"/> to use should any scaling be required.</param>
        /// <returns>An instance of the <see cref="Bitmap"/> class.</returns>
        public Bitmap CreateScaledBitmap(PixelSize destinationSize, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality)
        {
            IPlatformRenderInterface factory = AvaloniaLocator.Current.GetService <IPlatformRenderInterface>();

            return(new Bitmap(factory.ResizeBitmap(PlatformImpl.Item, destinationSize, interpolationMode)));
        }
Esempio n. 26
0
        /// <summary>
        /// Loads a Bitmap from a stream and decodes at the desired height. Aspect ratio is maintained.
        /// This is more efficient than loading and then resizing.
        /// </summary>
        /// <param name="stream">The stream to read the bitmap from. This can be any supported image format.</param>
        /// <param name="height">The desired height of the resulting bitmap.</param>
        /// <param name="interpolationMode">The <see cref="BitmapInterpolationMode"/> to use should any scaling be required.</param>
        /// <returns>An instance of the <see cref="Bitmap"/> class.</returns>
        public static Bitmap DecodeToHeight(Stream stream, int height, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality)
        {
            IPlatformRenderInterface factory = AvaloniaLocator.Current.GetService <IPlatformRenderInterface>();

            return(new Bitmap(factory.LoadBitmapToHeight(stream, height, interpolationMode)));
        }
Esempio n. 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Bitmap"/> class.
        /// </summary>
        /// <param name="width">The width of the bitmap, in pixels.</param>
        /// <param name="height">The height of the bitmap, in pixels.</param>
        public Bitmap(int width, int height)
        {
            IPlatformRenderInterface factory = Locator.Current.GetService <IPlatformRenderInterface>();

            PlatformImpl = factory.CreateBitmap(width, height);
        }
Esempio n. 28
0
 public TestServices With(
     IAssetLoader assetLoader = null,
     IFocusManager focusManager = null,
     IInputManager inputManager = null,
     Func<IKeyboardDevice> keyboardDevice = null,
     ILayoutManager layoutManager = null,
     IPclPlatformWrapper platformWrapper = null,
     IPlatformRenderInterface renderInterface = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler = null,
     Func<Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     return new TestServices(
         assetLoader: assetLoader ?? AssetLoader,
         focusManager: focusManager ?? FocusManager,
         inputManager: inputManager ?? InputManager,
         keyboardDevice: keyboardDevice ?? KeyboardDevice,
         layoutManager: layoutManager ?? LayoutManager,
         platformWrapper: platformWrapper ?? PlatformWrapper,
         renderInterface: renderInterface ?? RenderInterface,
         standardCursorFactory: standardCursorFactory ?? StandardCursorFactory,
         styler: styler ?? Styler,
         theme: theme ?? Theme,
         threadingInterface: threadingInterface ?? ThreadingInterface,
         windowImpl: windowImpl ?? WindowImpl,
         windowingPlatform: windowingPlatform ?? WindowingPlatform);
 }
 public DefaultRenderLayerFactory(IPlatformRenderInterface renderInterface)
 {
     _renderInterface = renderInterface;
 }
Esempio n. 30
0
        /// <summary>
        /// Creates a platform-specific implementation for a <see cref="RenderTargetBitmap"/>.
        /// </summary>
        /// <param name="size">The size of the bitmap in device pixels.</param>
        /// <param name="dpi">The DPI of the bitmap.</param>
        /// <returns>The platform-specific implementation.</returns>
        private static IRenderTargetBitmapImpl CreateImpl(PixelSize size, Vector dpi)
        {
            IPlatformRenderInterface factory = AvaloniaLocator.Current.GetRequiredService <IPlatformRenderInterface>();

            return(factory.CreateRenderTargetBitmap(size, dpi));
        }
Esempio n. 31
0
        /// <summary>
        /// Creates a platform-specific imlementation for a <see cref="RenderTargetBitmap"/>.
        /// </summary>
        /// <param name="width">The width of the bitmap.</param>
        /// <param name="height">The height of the bitmap.</param>
        /// <param name="dpiX">The horizontal DPI of the bitmap.</param>
        /// <param name="dpiY">The vertical DPI of the bitmap.</param>
        /// <returns>The platform-specific implementation.</returns>
        private static IBitmapImpl CreateImpl(int width, int height, double dpiX, double dpiY)
        {
            IPlatformRenderInterface factory = AvaloniaLocator.Current.GetService <IPlatformRenderInterface>();

            return(factory.CreateRenderTargetBitmap(width, height, dpiX, dpiY));
        }
Esempio n. 32
0
 public PlatformCameraProviderAdapter(IPlatformRenderInterface renderInterface, IPlatformFramebufferPlayerProvider playerProvider)
 {
     provider             = playerProvider;
     this.renderInterface = renderInterface;
 }
Esempio n. 33
0
        public StreamGeometry()
        {
            IPlatformRenderInterface factory = Locator.Current.GetService <IPlatformRenderInterface>();

            this.PlatformImpl = factory.CreateStreamGeometry();
        }