/// <inheritdoc />
        /// <summary>
        ///   Class constructor
        /// </summary>
        /// <param name="rect">Screen region</param>
        /// <param name="windowHandle">Attached window handle (unused)</param>
        /// <exception cref="NotSupportedException">Thrown when no video adapters were found</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when the capture region is empty</exception>
        internal DxVideoProvider(Rectangle rect, IntPtr?windowHandle
                                 = null) : base(rect, windowHandle)
        {
            throw new NotImplementedException();

            Log.WriteLine(LogLevel.Debug, "creating DirectX video provider");
            this.direct3d
                = new Direct3D();

            // enumerate adapters
            List <(AdapterInformation Adapter, Rectangle Rectangle, Rectangle Bounds)> intersections
                = (
                      from adapter in this.direct3d.Adapters
                      let info
                          = new MONITORINFO()
                            where User32.GetMonitorInfo(adapter.Monitor, info)
                            let outputRect
                            = Rectangle.FromLTRB(info.rcMonitor.left,
                                                 info.rcMonitor.top,
                                                 info.rcMonitor.right,
                                                 info.rcMonitor.bottom)
                              let intersection
                              = Rectangle.Intersect(rect, outputRect)
                                where intersection != Rectangle.Empty
                                select(adapter, intersection, outputRect)).ToList();

            // make sure we do not capture out of bounds
            CaptureBounds
                = rect;
            if (CaptureBounds.IsEmpty)
            {
                throw new ArgumentOutOfRangeException(nameof(rect));
            }

            // set rectangles for each output
            this.rects
                = intersections.Select(t => t.Rectangle).ToArray();
            this.regions
                = intersections.Select(t => t.Bounds).ToArray();

            // create devices for each adapter
            this.devices
                = intersections.Select(i =>
                                       new Device(this.direct3d,
                                                  i.Adapter.Adapter,
                                                  DeviceType.Hardware,
                                                  User32.GetDesktopWindow(),
                                                  CreateFlags.HardwareVertexProcessing,
                                                  new PresentParameters(i.Bounds.Width, i.Bounds.Height)))
                  .ToArray();

            // create adapter and surface arrays
            this.adapters
                = intersections.Select(t => t.Adapter).ToArray();
            Surfaces
                = new Surface[this.devices.Length];
        }
        public Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
        {
            List <Region> ans = new List <Region>();

            foreach (var stringFormatRange in stringFormat.ranges)
            {
                var size = MeasureString(new String(text.Skip(stringFormatRange.First).Take(stringFormatRange.Length).ToArray()),
                                         font, layoutRect.Size, stringFormat);
                ans.Add(new Region(Rectangle.FromLTRB(0, 0, (int)size.Width, (int)size.Height)));
            }

            return(ans.ToArray());
        }
Beispiel #3
0
        /// <summary>
        /// Helper function to render icon description.  Broken out so that child classes can override this behavior.
        /// </summary>
        /// <param name="drawArgs"></param>
        protected override void RenderDescription(DrawArgs drawArgs, Sprite sprite, Vector3 projectedPoint, int color)
        {
            string description = this.GeneralInfo() + this.DetailedInfo() + this.DescriptionInfo();

            if (description != null)
            {
                // Render description field
                DrawTextFormat format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak | DrawTextFormat.Bottom;
                int            left   = 10;
                if (World.Settings.ShowLayerManager)
                {
                    left += World.Settings.LayerManagerWidth;
                }
                Rectangle rect = Rectangle.FromLTRB(left, 10, drawArgs.screenWidth - 10, drawArgs.screenHeight - 10);

                // Draw description
                rect.Offset(1, -1);
                drawArgs.defaultDrawingFont.DrawText(
                    sprite, description,
                    rect,
                    format, descriptionColor);
            }
        }