/// <summary>
 /// This method uses the GPU to copy texture data between two locations.
 /// Both the source and the destination may reference texture data located within either a buffer resource or a texture resource.
 /// </summary>
 /// <param name="destination">Specifies the destination <see cref="TextureCopyLocation"/>. The subresource referred to must be in the <see cref="ResourceStates.CopyDestination"/> state.</param>
 /// <param name="destinationX">The x-coordinate of the upper left corner of the destination region.</param>
 /// <param name="destinationY">The y-coordinate of the upper left corner of the destination region. For a 1D subresource, this must be zero.</param>
 /// <param name="destinationZ">The z-coordinate of the upper left corner of the destination region. For a 1D or 2D subresource, this must be zero.</param>
 /// <param name="source">Specifies the source D3D12_TEXTURE_COPY_LOCATION. The subresource referred to must be in the D3D12_RESOURCE_STATE_COPY_SOURCE state.</param>
 /// <param name="sourceBox">Specifies an optional <see cref="Box"/> that sets the size of the source texture to copy.</param>
 public void CopyTextureRegion(
     TextureCopyLocation destination,
     int destinationX, int destinationY, int destinationZ,
     TextureCopyLocation source, Box?sourceBox = null)
 {
     CopyTextureRegion_(destination, destinationX, destinationY, destinationZ, source, sourceBox);
 }
 public GetObjectsInSpaceItem(CastTypeEnum castType, Metadata.TypeInfo selectedTypeOnly, bool visibleOnly, Box box)
 {
     this.CastType         = castType;
     this.SelectedTypeOnly = selectedTypeOnly;
     this.VisibleOnly      = visibleOnly;
     this.Box = box;
 }
        private void Layout(Element el, Box?viewport = null)
        {
            var layouter = new LayoutProcessor();

            layouter.ViewPort = viewport ?? new Box(0, 0, 640, 360);
            layouter.Process(el);
        }
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            // Create boxes for base, delimeter, and script atoms.
            var baseBox      = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment);
            var delimeterBox = DelimiterFactory.CreateBox(this.Symbol.Name, baseBox.Width, environment);
            Box?scriptBox    = this.Script == null ? null : this.Script.CreateBox(this.Over ?
                                                                                  environment.GetSuperscriptStyle() : environment.GetSubscriptStyle());

            // Create centered horizontal box if any box is smaller than maximum width.
            var maxWidth = GetMaxWidth(baseBox, delimeterBox, scriptBox);

            if (Math.Abs(maxWidth - baseBox.Width) > TexUtilities.FloatPrecision)
            {
                baseBox = new HorizontalBox(baseBox, maxWidth, TexAlignment.Center);
            }
            if (Math.Abs(maxWidth - delimeterBox.Height - delimeterBox.Depth) > TexUtilities.FloatPrecision)
            {
                delimeterBox = new VerticalBox(delimeterBox, maxWidth, TexAlignment.Center);
            }
            if (scriptBox != null && Math.Abs(maxWidth - scriptBox.Width) > TexUtilities.FloatPrecision)
            {
                scriptBox = new HorizontalBox(scriptBox, maxWidth, TexAlignment.Center);
            }

            return(new OverUnderBox(baseBox, delimeterBox, scriptBox, this.Kern.CreateBox(environment).Height, this.Over));
        }
Exemple #5
0
 protected virtual void InitGraphicBox(Game game, Color color)
 {
     graphicBox = new Box(
         game,
         new Rectangle(0, 0, 0, 0),
         color
         );
 }
Exemple #6
0
 public unsafe void ReadFromSubresource <T>(
     T[] destination, int destinationRowPitch, int destinationDepthPitch,
     ID3D11Resource sourceResource, int sourceSubresource, Box?sourceBox = null) where T : unmanaged
 {
     ReadFromSubresource(
         (IntPtr)Unsafe.AsPointer(ref destination[0]), destinationRowPitch, destinationDepthPitch,
         sourceResource, sourceSubresource, sourceBox);
 }
        private static double GetMaxWidth(Box baseBox, Box delimeterBox, Box?scriptBox)
        {
            var maxWidth = Math.Max(baseBox.Width, delimeterBox.Height + delimeterBox.Depth);

            if (scriptBox != null)
            {
                maxWidth = Math.Max(maxWidth, scriptBox.Width);
            }
            return(maxWidth);
        }
Exemple #8
0
 private static Box?ChangeWidth(Box?box, double maxWidth)
 {
     if (box != null && Math.Abs(maxWidth - box.Width) > TexUtilities.FloatPrecision)
     {
         return(new HorizontalBox(box, maxWidth, TexAlignment.Center));
     }
     else
     {
         return(box);
     }
 }
Exemple #9
0
 public unsafe void ReadFromSubresource <T>(
     T[] destination, int destinationRowPitch, int destinationDepthPitch,
     ID3D11Resource sourceResource, int sourceSubresource, Box?sourceBox = null) where T : unmanaged
 {
     fixed(void *destinationPtr = &destination[0])
     {
         ReadFromSubresource(
             (IntPtr)destinationPtr, destinationRowPitch, destinationDepthPitch,
             sourceResource, sourceSubresource, sourceBox);
     }
 }
 // Defines equality using the BoxSameDimensions equality comparer.
 public bool Equals(Box?other)
 {
     if (new BoxSameDimensions().Equals(this, other))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #11
0
        /// <summary>
        /// Versucht anhand des Inputs mit den gegebenen Daten die einzig passende Box zu ermitteln
        /// </summary>
        public static bool TryFindExactBox(string input, [NotNullWhen(true)] out Box?box)
        {
            box = null;
            var boxes = FindBoxes(input).Take(2).ToArray();

            if (boxes.Length != 1)
            {
                return(false);
            }
            box = boxes[0];
            return(true);
        }
 public override bool Equals(Box?b1, Box?b2)
 {
     if (b1.Height == b2.Height && b1.Length == b2.Length &&
         b1.Width == b2.Width)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 private void SelectEntity(Vector2 position)
 {
     if (GetEntityAtPosition(position) is IEntity entity)
     {
         selectedEntity    = entity;
         selectedEntityBox = new Box(Map.Game, entity.HitBox.ToRectangle(), Color.OrangeRed);
     }
     else
     {
         selectedEntity    = null;
         selectedEntityBox = null;
     }
 }
Exemple #14
0
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            // Create box for base atom.
            var baseBox = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment);

            // Create boxes for over and under atoms.
            Box?overBox = null, underBox = null;
            var maxWidth = baseBox.Width;

            if (this.OverAtom != null)
            {
                overBox  = this.OverAtom.CreateBox(this.OverScriptSmaller ? environment.GetSubscriptStyle() : environment);
                maxWidth = Math.Max(maxWidth, overBox.Width);
            }

            if (this.UnderAtom != null)
            {
                underBox = this.UnderAtom.CreateBox(this.UnderScriptSmaller ? environment.GetSubscriptStyle() : environment);
                maxWidth = Math.Max(maxWidth, underBox.Width);
            }

            // Create result box.
            var resultBox = new VerticalBox();

            environment.LastFontId = baseBox.GetLastFontId();

            // Create and add box for over atom.
            if (this.OverAtom != null)
            {
                resultBox.Add(ChangeWidth(overBox !, maxWidth));
                resultBox.Add(new SpaceAtom(null, this.OverSpaceUnit, 0, this.OverSpace, 0).CreateBox(environment));
            }

            // Add box for base atom.
            resultBox.Add(ChangeWidth(baseBox, maxWidth));

            double totalHeight = resultBox.Height + resultBox.Depth - baseBox.Depth;

            // Create and add box for under atom.
            if (this.UnderAtom != null)
            {
                resultBox.Add(new SpaceAtom(null, this.OverSpaceUnit, 0, this.UnderSpace, 0).CreateBox(environment));
                resultBox.Add(ChangeWidth(underBox !, maxWidth));
            }

            resultBox.Depth  = resultBox.Height + resultBox.Depth - totalHeight;
            resultBox.Height = totalHeight;

            return(resultBox);
        }
Exemple #15
0
        public OverUnderBox(Box baseBox, Box delimiterBox, Box?scriptBox, double kern, bool over)
            : base()
        {
            this.BaseBox      = baseBox;
            this.DelimiterBox = delimiterBox;
            this.ScriptBox    = scriptBox;
            this.Kern         = kern;
            this.Over         = over;

            // Calculate dimensions of box.
            this.Width  = baseBox.Width;
            this.Height = baseBox.Height + (over ? delimiterBox.Width : 0.0) +
                          (over && scriptBox != null ? scriptBox.Height + scriptBox.Depth + kern : 0.0);
            this.Depth = baseBox.Depth + (over ? 0.0 : delimiterBox.Width) +
                         (!over && scriptBox != null ? scriptBox.Height + scriptBox.Depth + kern : 0.0);
        }
Exemple #16
0
        public void Reset()
        {
            if (mode != LazyThreadSafetyMode.None)
            {
                lock (syncLock)
                {
                    this.box = null;
                }
            }
            else
            {
                this.box = null;
            }

            Interlocked.Increment(ref Invalidations);
            OnReset?.Invoke(this, null);
        }
Exemple #17
0
        public static Box?BuildBoundingBox(this IEnumerable <Coordinate> coordinates)
        {
            using (var enumerator = coordinates.GetEnumerator())
            {
                Box?box = null;
                while (enumerator.MoveNext())
                {
                    if (box == null)
                    {
                        box = new Box(enumerator.Current, enumerator.Current);
                    }
                    else
                    {
                        box = box.Value.ExpandWith(enumerator.Current.Latitude, enumerator.Current.Longitude);
                    }
                }

                return(box);
            }
        }
Exemple #18
0
        private static List <FtpDirectory> FindDirectory(List <FtpDirectory> directories, Box?box, string name)
        {
            FtpDirectory?       idMatch      = null;
            FtpDirectory?       directMatch  = null;
            List <FtpDirectory> roughMatches = new List <FtpDirectory>();

            foreach (FtpDirectory directory in directories)
            {
                if (box != null && BoxDatabase.FindBoxes(directory.Name).Any(x => x == box))
                {
                    idMatch = directory;
                    break;
                }
                else if (directory.Name.Equals(name, StringComparison.OrdinalIgnoreCase))
                {
                    directMatch = directory;
                }
                else if (directory.Name.IndexOf(name, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    roughMatches.Add(directory);
                }
            }
            return(idMatch == null && directMatch == null ? roughMatches : new List <FtpDirectory> {
                idMatch ?? directMatch !
            });
        public void Update()
        {
            toolbar?.Update();
            cursor.Update();
            frame.Update();
            selectedEntityBox?.Update();

            #region Draw tile/entity

            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                // Select a tile in the bar
                bool clickedOnBarElement = false;

                if (toolbar != null)
                {
                    foreach (ToolbarButton button in toolbar.Buttons)
                    {
                        // Click on a toolbar button
                        if (button.HitBox.Contains(cursor.Position))
                        {
                            cursor.Type = CursorType.Crosshair;

                            clickedOnBarElement        = true;
                            toolbar.SelectedTileId     = button.Id;
                            toolbar.SelectedGroupName  = button.GroupName;
                            toolbar.SelectedButtonType = button.Type;
                            toolbar.SelectedTileset    = button.Tileset;

                            if (button.Type == ToolbarButtonType.Tile)
                            {
                                selectedEntity    = null;
                                selectedEntityBox = null;
                            }
                            if (button.Type == ToolbarButtonType.Entity && button is EntityToolbarButton toolbarButton)
                            {
                                selectedEntity             = null;
                                selectedEntityBox          = null;
                                toolbar.SelectedEntityType = toolbarButton.EntityType;
                            }
                            if (button.Type == ToolbarButtonType.Selection)
                            {
                                cursor.Type = CursorType.Arrow;
                            }

                            break;
                        }
                    }

                    if (!clickedOnBarElement)
                    {
                        var drawerPosition = GetGridSnapedPosition();

                        // Draw a tile
                        if (toolbar.SelectedButtonType == ToolbarButtonType.Tile && !TileAlreadyAtPosition(drawerPosition))
                        {
                            DrawSelectedTile(drawerPosition);
                        }

                        // Draw an entity
                        if (toolbar.SelectedButtonType == ToolbarButtonType.Entity && GetEntityAtPosition(drawerPosition) == null)
                        {
                            DrawSelectedEntity(drawerPosition);
                        }

                        // Select an entity
                        if (toolbar.SelectedButtonType == ToolbarButtonType.Selection)
                        {
                            hasPressedAnEntity = true;
                        }
                    }
                }

                if (selectedEntity != null && selectedEntity.HitBox.Contains(cursor.InGamePosition))
                {
                    isMovingAnEntity = true;
                }
            }

            if (Mouse.GetState().LeftButton == ButtonState.Released)
            {
                if (toolbar != null)
                {
                    // Select an entity
                    if (hasPressedAnEntity && toolbar.SelectedButtonType == ToolbarButtonType.Selection)
                    {
                        SelectEntity(cursor.InGamePosition);
                        hasPressedAnEntity = false;
                    }
                }

                isMovingAnEntity = false;
            }

            #endregion

            #region Erase a tile/entity

            if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                Vector2 eraserPosition = GetGridSnapedPosition();

                foreach (KeyValuePair <string, IEntity> entity in Map.CurrentMapSection.Entities)
                {
                    if (entity.Value.Position == eraserPosition)
                    {
                        Map.CurrentMapSection.Entities.Remove(entity.Key);
                        hasErasedAnEntity = true;
                        break;
                    }
                }

                if (!hasErasedAnEntity)
                {
                    foreach (Tile tile in Map.CurrentMapSection.ForegroundTiles)
                    {
                        if (tile.Position == eraserPosition)
                        {
                            Map.CurrentMapSection.ForegroundTiles.Remove(tile);
                            UpdateTilesTypes();
                            break;
                        }
                    }
                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Delete) || Keyboard.GetState().IsKeyDown(Keys.Back))
            {
                if (selectedEntity != null)
                {
                    Map.CurrentMapSection.Entities.Remove(selectedEntity.Name);
                    selectedEntity    = null;
                    selectedEntityBox = null;
                }
            }

            if (hasErasedAnEntity && Mouse.GetState().RightButton == ButtonState.Released)
            {
                hasErasedAnEntity = false;
            }

            #endregion

            #region Move an entity

            if (isMovingAnEntity && selectedEntity != null && selectedEntityBox != null)
            {
                selectedEntity.Position  = GetGridSnapedPosition();
                selectedEntityBox.Bounds = selectedEntity.HitBox.ToRectangle();
            }

            #endregion

            #region Move player

            if (Keyboard.GetState().IsKeyDown(Keys.Left))
            {
                Map.Player?.MoveLeft(2f);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Right))
            {
                Map.Player?.MoveRight(2f);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Up))
            {
                Map.Player?.MoveUp(2f);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Down))
            {
                Map.Player?.MoveDown(2f);
            }

            #endregion
        }
Exemple #20
0
 public void Deconstruct(out Box?box, out Cylinder?cylinder, out Sphere?sphere, out Mesh?mesh) =>
 (box, cylinder, sphere, mesh) = (Box, Cylinder, Sphere, Mesh);
        public static Color GetShadowTintForBox(Box B, IShadowCaster CallingShadowCaster = null, Enums.ShadowCasterClass ExcludedClasses = Enums.ShadowCasterClass.None)
        {
            float darkestTint = 1f;

            for (int i = 0; i < VisibleShadowCasters.Count; i++)
            {
                IShadowCaster shadowCaster = VisibleShadowCasters[i];
                if (
                    shadowCaster == CallingShadowCaster ||
                    (
                        ExcludedClasses != Enums.ShadowCasterClass.None &&
                        (shadowCaster.ShadowCasterClass() & ExcludedClasses) != Enums.ShadowCasterClass.None
                    )
                    )
                {
                    continue;
                }
                Box shadowVolume = shadowCaster.GetShadowVolume();
                Box?shadowBox    = shadowVolume.GetIntersectionVolume(B);
                if (shadowBox == null)
                {
                    continue;
                }
                Texture2D shadowTexture = shadowCaster.GetShadowTexture();
                int       x1;
                int       y1;
                int       x2;
                int       y2;
                if (shadowCaster.ShouldTile())
                {
                    x1 = (int)(shadowBox.Value.Left - shadowVolume.Left);
                    y1 = (int)(shadowBox.Value.Back - shadowVolume.Back);
                    x2 = x1 + (int)shadowBox.Value.Width;
                    y2 = y1 + (int)shadowBox.Value.Depth;
                }
                else
                {
                    x1 = (int)Math.Floor((shadowBox.Value.Left - shadowVolume.Left) / shadowVolume.Width * shadowTexture.Width);
                    y1 = (int)Math.Floor((shadowBox.Value.Back - shadowVolume.Back) / shadowVolume.Depth * shadowTexture.Height);
                    x2 = x1 + (int)Math.Floor((shadowBox.Value.Width / shadowVolume.Width) * (shadowTexture.Width - 1));
                    y2 = y1 + (int)Math.Floor((shadowBox.Value.Depth / shadowVolume.Depth) * (shadowTexture.Height - 1));
                }
                float a = GetShadowStrengthOverArea(shadowTexture, x1, y1, x2, y2) * (shadowBox.Value.TopDownSurfaceArea / B.TopDownSurfaceArea) * shadowCaster.GetShadowOpacity();
                if (a > 0)
                {
                    a = 1 - a;
                    if (a < darkestTint)
                    {
                        darkestTint = a;
                    }
                }
            }
            if (darkestTint == 1f)
            {
                return(Color.White);
            }
            float invertDarkest = 1 - darkestTint;

            return(new Color(
                       1 - (invertDarkest - GLOBAL_SHADOW_COLOR.R / 255f * invertDarkest),
                       1 - (invertDarkest - GLOBAL_SHADOW_COLOR.G / 255f * invertDarkest),
                       1 - (invertDarkest - GLOBAL_SHADOW_COLOR.B / 255f * invertDarkest)
                       ));
        }
Exemple #22
0
 private Stage(int _grapplerPosition, Box? _boxInGrappler, List<Stack<Box>> _stacks)
 {
     grapplerPosition = _grapplerPosition;
     boxInGrappler = _boxInGrappler;
     stacks = _stacks;
 }
Exemple #23
0
        private void load()
        {
            Height           = 30;
            RelativeSizeAxes = Axes.X;

            Children = new Drawable[]
            {
                hoverBox = new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = colourProvider.Background3,
                    Alpha            = 0f,
                },
                selectBox = new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = colourProvider.Background4,
                    Alpha            = 0f,
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Left = 18, Right = 10
                    },
                    Child = new GridContainer
                    {
                        RelativeSizeAxes = Axes.Both,
                        ColumnDimensions = new[]
                        {
                            new Dimension(GridSizeMode.AutoSize),
                            new Dimension(),
                            new Dimension(GridSizeMode.AutoSize),
                            new Dimension(GridSizeMode.AutoSize),
                        },
                        Content = new[]
                        {
                            new[]
                            {
                                createIcon(),
                                text = new OsuSpriteText
                                {
                                    Anchor = Anchor.CentreLeft,
                                    Origin = Anchor.CentreLeft,
                                    Text   = channel.Name,
                                    Font   = OsuFont.Torus.With(size: 17, weight: FontWeight.SemiBold),
                                    Colour = colourProvider.Light3,
                                    Margin = new MarginPadding {
                                        Bottom = 2
                                    },
                                    RelativeSizeAxes = Axes.X,
                                    Truncate         = true,
                                },
                                new ChannelListItemMentionPill
                                {
                                    Anchor = Anchor.CentreLeft,
                                    Origin = Anchor.CentreLeft,
                                    Margin = new MarginPadding {
                                        Right = 3
                                    },
                                    Mentions = { BindTarget = Mentions },
                                },
                                close = new ChannelListItemCloseButton
                                {
                                    Anchor = Anchor.CentreLeft,
                                    Origin = Anchor.CentreLeft,
                                    Margin = new MarginPadding {
                                        Right = 3
                                    },
                                    Action = () => OnRequestLeave?.Invoke(channel),
                                }
                            }
                        },
                    },
                },
            };

            Action = () => OnRequestSelect?.Invoke(channel);
        }
        private static void HandleArea(Queue <CallAction> actions, XmlPdfPageArea area)
        {
            Box?  box = null;
            XUnit?_height = null;
            float top, left, right, bottom, width, height;

            top = left = width = height = 0;

            if (area.location != null)
            {
                box = ToPDF(area.location);

                top    = box.Value.Top.Point;
                left   = box.Value.Left.Point;
                right  = box.Value.Right.Point;
                bottom = box.Value.Bottom.Point;

                width  = right - left;
                height = bottom - top;
            }
            if (!string.IsNullOrEmpty(area.height))
            {
                _height = ParseUnit(area.height);
                height  = _height.Value.Point;
            }

            if (box == null && _height == null)
            {
                throw new ArgumentException("Either location or height parameters must be specified for the area", nameof(area));
            }

            if ((area.type == XmlPdfAreaType.flow || area.type == XmlPdfAreaType.@fixed) && box == null)
            {
                throw new ArgumentException("The full location must be set for the flow or fixed area", nameof(area));
            }

            if ((area.type == XmlPdfAreaType.footer || area.type == XmlPdfAreaType.header) && _height == null)
            {
                throw new ArgumentException("The height must be set for the header and footer area", nameof(area));
            }

            switch (area.type)
            {
            case XmlPdfAreaType.flow:
            {
                switch (area.page)
                {
                case XmlPdfPageSide.single:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddDocumentFlowAreaToBothPages(left, top, width, height));
                    break;

                case XmlPdfPageSide.odd:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddDocumentFlowAreaToOddPage(left, top, width, height));
                    break;

                case XmlPdfPageSide.even:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddDocumentFlowAreaToEvenPage(left, top, width, height));
                    break;

                default:
                    throw new ArgumentException($"Not supported page {area.page} in area", nameof(area));
                }
            }
            break;

            case XmlPdfAreaType.header:
            {
                switch (area.page)
                {
                case XmlPdfPageSide.single:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddHeaderToBothPages(height, null));
                    break;

                case XmlPdfPageSide.odd:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddHeaderToOddPage(height, null));
                    break;

                case XmlPdfPageSide.even:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddHeaderToEvenPage(height, null));
                    break;

                default:
                    throw new ArgumentException($"Not supported page {area.page} in area", nameof(area));
                }
            }
            break;

            case XmlPdfAreaType.footer:
            {
                switch (area.page)
                {
                case XmlPdfPageSide.single:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddFooterToBothPages(height, null));
                    break;

                case XmlPdfPageSide.odd:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddFooterToOddPage(height, null));
                    break;

                case XmlPdfPageSide.even:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddFooterToEvenPage(height, null));
                    break;

                default:
                    throw new ArgumentException($"Not supported page {area.page} in area", nameof(area));
                }
            }
            break;

            case XmlPdfAreaType.@fixed:
            {
                switch (area.page)
                {
                case XmlPdfPageSide.single:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddRptAreaToBothPages(left, top, width, height, null));
                    break;

                case XmlPdfPageSide.odd:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddRptAreaToOddPage(left, top, width, height, null));
                    break;

                case XmlPdfPageSide.even:
                    actions.Let <SectionBuilder>(AREABUILDER, SECTIONBUILDER, builder => builder.AddRptAreaToEvenPage(left, top, width, height, null));
                    break;

                default:
                    throw new ArgumentException($"Not supported page {area.page} in area", nameof(area));
                }
            }
            break;

            default:
                throw new ArgumentException($"Not supported area type {area.type}", nameof(area));
            }
        }
Exemple #25
0
        /// <summary>
        /// Loads a volume from memory.
        /// </summary>
        /// <param name="destPaletteRef"><para>Pointer to a  <see cref="SharpDX.Direct3D9.PaletteEntry"/> structure, the destination palette of 256 colors or <c>null</c>.</para></param>
        /// <param name="destBox"><para>Pointer to a <see cref="SharpDX.Direct3D9.Box"/> structure. Specifies the destination box. Set this parameter to <c>null</c> to specify the entire volume.</para></param>
        /// <param name="srcMemoryPointer"><para>Pointer to the top-left corner of the source volume in memory.</para></param>
        /// <param name="srcFormat"><para>Member of the <see cref="SharpDX.Direct3D9.Format"/> enumerated type, the pixel format of the source volume.</para></param>
        /// <param name="srcRowPitch"><para>Pitch of source image, in bytes. For DXT formats (compressed texture formats), this number should represent the size of one row of cells, in bytes.</para></param>
        /// <param name="srcSlicePitch"><para>Pitch of source image, in bytes. For DXT formats (compressed texture formats), this number should represent the size of one slice of cells, in bytes.</para></param>
        /// <param name="srcPaletteRef"><para>Pointer to a <see cref="SharpDX.Direct3D9.PaletteEntry"/> structure, the source palette of 256 colors or <c>null</c>.</para></param>
        /// <param name="srcBox"><para>Pointer to a <see cref="SharpDX.Direct3D9.Box"/> structure. Specifies the source box. <c>null</c> is not a valid value for this parameter.</para></param>
        /// <param name="filter"><para>A combination of one or more <see cref="SharpDX.Direct3D9.Filter"/> controlling how the image is filtered. Specifying D3DX_DEFAULT for this parameter is the equivalent of specifying <see cref="SharpDX.Direct3D9.Filter.Triangle"/> | <see cref="SharpDX.Direct3D9.Filter.Dither"/>.</para></param>
        /// <param name="colorKey"><para> <see cref="RawColor4"/> value to replace with transparent black, or 0 to disable the color key. This is always a 32-bit ARGB color, independent of the source image format. Alpha is significant and should usually be set to FF for opaque color keys. Thus, for opaque black, the value would be equal to 0xFF000000.</para></param>
        /// <returns>If the function succeeds, the return value is <see cref="SharpDX.Direct3D9.ResultCode.Success"/>. If the function fails, the return value can be one of the following values: <see cref="SharpDX.Direct3D9.ResultCode.InvalidCall"/>, D3DXERR_INVALIDDATA.</returns>
        /// <remarks>
        /// Writing to a non-level-zero surface of the volume texture will not cause the dirty rectangle to be updated. If <see cref="SharpDX.Direct3D9.D3DX9.LoadVolumeFromMemory"/> is called and the texture was not already dirty (this is unlikely under normal usage scenarios), the application needs to explicitly call <see cref="SharpDX.Direct3D9.VolumeTexture.AddDirtyBox"/> on the volume texture.
        /// </remarks>
        /// <unmanaged>HRESULT D3DXLoadVolumeFromMemory([In] IDirect3DVolume9* pDestVolume,[Out, Buffer] const PALETTEENTRY* pDestPalette,[In] const void* pDestBox,[In] const void* pSrcMemory,[In] D3DFORMAT SrcFormat,[In] unsigned int SrcRowPitch,[In] unsigned int SrcSlicePitch,[In, Buffer] const PALETTEENTRY* pSrcPalette,[In] const void* pSrcBox,[In] D3DX_FILTER Filter,[In] int ColorKey)</unmanaged>
        public unsafe void LoadFromMemory(SharpDX.Direct3D9.PaletteEntry[] destPaletteRef, Box?destBox, System.IntPtr srcMemoryPointer, SharpDX.Direct3D9.Format srcFormat, int srcRowPitch, int srcSlicePitch, SharpDX.Direct3D9.PaletteEntry[] srcPaletteRef, Box srcBox, SharpDX.Direct3D9.Filter filter, RawColorBGRA colorKey)
        {
            Box localDestBox;

            if (destBox.HasValue)
            {
                localDestBox = destBox.Value;
            }

            D3DX9.LoadVolumeFromMemory(
                this, destPaletteRef, new IntPtr(&localDestBox), srcMemoryPointer, srcFormat, srcRowPitch, srcSlicePitch, srcPaletteRef, new IntPtr(&srcBox), filter, *(int *)&colorKey);
        }
        protected override Box CreateBoxCore(TexEnvironment environment)
        {
            var texFont = environment.MathFont;
            var style   = environment.Style;

            if ((this.UseVerticalLimits.HasValue && !this.UseVerticalLimits.Value) ||
                (!this.UseVerticalLimits.HasValue && style >= TexStyle.Text))
            {
                // Attach atoms for limits as scripts.
                return(new ScriptsAtom(this.Source, this.BaseAtom, this.LowerLimitAtom, this.UpperLimitAtom)
                       .CreateBox(environment));
            }

            // Create box for base atom.
            Box    baseBox;
            double delta;

            if (this.BaseAtom is SymbolAtom && this.BaseAtom.Type == TexAtomType.BigOperator)
            {
                // Find character of best scale for operator symbol.
                var opChar = texFont.GetCharInfo(((SymbolAtom)this.BaseAtom).Name, style).Value;
                if (style < TexStyle.Text && texFont.HasNextLarger(opChar))
                {
                    opChar = texFont.GetNextLargerCharInfo(opChar, style);
                }
                var charBox = new CharBox(environment, opChar)
                {
                    Source = this.BaseAtom.Source
                };
                charBox.Shift = -(charBox.Height + charBox.Depth) / 2 -
                                environment.MathFont.GetAxisHeight(environment.Style);
                baseBox = new HorizontalBox(charBox);

                delta = opChar.Metrics.Italic;
                if (delta > TexUtilities.FloatPrecision)
                {
                    baseBox.Add(new StrutBox(delta, 0, 0, 0));
                }
            }
            else
            {
                baseBox = new HorizontalBox(this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment));
                delta   = 0;
            }

            // Create boxes for upper and lower limits.
            Box?upperLimitBox = this.UpperLimitAtom == null ? null : this.UpperLimitAtom.CreateBox(
                environment.GetSuperscriptStyle());
            Box?lowerLimitBox = this.LowerLimitAtom == null ? null : this.LowerLimitAtom.CreateBox(
                environment.GetSubscriptStyle());

            // Make all component boxes equally wide.
            var maxWidth = Math.Max(Math.Max(baseBox.Width, upperLimitBox == null ? 0 : upperLimitBox.Width),
                                    lowerLimitBox == null ? 0 : lowerLimitBox.Width);

            baseBox = ChangeWidth(baseBox, maxWidth);
            if (upperLimitBox != null)
            {
                upperLimitBox = ChangeWidth(upperLimitBox, maxWidth);
            }
            if (lowerLimitBox != null)
            {
                lowerLimitBox = ChangeWidth(lowerLimitBox, maxWidth);
            }

            var resultBox  = new VerticalBox();
            var opSpacing5 = texFont.GetBigOpSpacing5(style);
            var kern       = 0d;

            // Create and add box for upper limit.
            if (this.UpperLimitAtom != null)
            {
                resultBox.Add(new StrutBox(0, opSpacing5, 0, 0));
                upperLimitBox !.Shift = delta / 2;
                resultBox.Add(upperLimitBox);
                kern = Math.Max(texFont.GetBigOpSpacing1(style), texFont.GetBigOpSpacing3(style) -
                                upperLimitBox.Depth);
                resultBox.Add(new StrutBox(0, kern, 0, 0));
            }

            // Add box for base atom.
            resultBox.Add(baseBox);

            // Create and add box for lower limit.
            if (this.LowerLimitAtom != null)
            {
                resultBox.Add(new StrutBox(0, Math.Max(texFont.GetBigOpSpacing2(style), texFont.GetBigOpSpacing4(style) -
                                                       lowerLimitBox !.Height), 0, 0));
                lowerLimitBox.Shift = -delta / 2;
                resultBox.Add(lowerLimitBox);
                resultBox.Add(new StrutBox(0, opSpacing5, 0, 0));
            }

            // Adjust height and depth of result box.
            var baseBoxHeight = baseBox.Height;
            var totalHeight   = resultBox.Height + resultBox.Depth;

            if (upperLimitBox != null)
            {
                baseBoxHeight += opSpacing5 + kern + upperLimitBox.Height + upperLimitBox.Depth;
            }
            resultBox.Height = baseBoxHeight;
            resultBox.Depth  = totalHeight - baseBoxHeight;

            return(resultBox);
        }
Exemple #27
0
        private void DrawShadows()
        {
            if (shadowReceiverMode != ShadowReceiverMode.Exact)
            {
                return;
            }

            DisposableList <IShadowCaster> shadowCasters = ShadowCasterHelper.VisibleShadowCasters;

            for (int i = 0; i < shadowCasters.Count; i++)
            {
                IShadowCaster shadowCaster = shadowCasters[i];
                Box           shadowVolume = shadowCaster.GetShadowVolume();
                Box?          shadowBox    = shadowVolume.GetIntersectionVolume(BackingBox.B);
                if (shadowBox == null || (!BackingBox.B.isRamp && shadowBox.Value.Top < BackingBox.Top))
                {
                    continue;
                }
                Texture2D shadowTexture = shadowCaster.GetShadowTexture();
                int       xIndex;
                int       yIndex;
                int       sourceWidth;
                int       sourceHeight;
                if (shadowCaster.ShouldTile())
                {
                    xIndex       = (int)(shadowBox.Value.Left - shadowVolume.Left);
                    yIndex       = (int)(shadowBox.Value.Back - shadowVolume.Back);
                    sourceWidth  = (int)shadowBox?.Width;
                    sourceHeight = (int)shadowBox?.Depth;
                }
                else
                {
                    xIndex       = (int)Math.Round((shadowBox.Value.Left - shadowVolume.Left) / shadowVolume.Width * shadowTexture.Width);
                    yIndex       = (int)Math.Round((shadowBox.Value.Back - shadowVolume.Back) / shadowVolume.Depth * shadowTexture.Height);
                    sourceWidth  = (int)Math.Round(shadowBox.Value.Width / shadowVolume.Width * shadowTexture.Width);
                    sourceHeight = (int)Math.Round(shadowBox.Value.Depth / shadowVolume.Depth * shadowTexture.Height);
                }
                float opacity = (1f - (shadowVolume.Top - BackingBox.B.Top) / shadowVolume.Height) * shadowCaster.GetShadowOpacity();
                if (!BackingBox.B.isRamp)
                {
                    GameService.GetService <IRenderService>().PushAlphaFragment(
                        RenderService.AlphaStacks.Shadows,
                        shadowTexture,
                        new Rectangle((int)Math.Round(shadowBox.Value.Left), (int)Math.Round(shadowBox.Value.Back - shadowBox.Value.Top), (int)Math.Round(shadowBox.Value.Width), (int)Math.Round(shadowBox.Value.Depth)),
                        new Rectangle(xIndex, yIndex, sourceWidth, sourceHeight),
                        IsTiling: shadowCaster.ShouldTile(),
                        Tint: Color.White * opacity
                        );
                    if (shadowBox.Value.Front == BackingBox.B.Front)
                    {
                        GameService.GetService <IRenderService>().PushAlphaFragment(
                            RenderService.AlphaStacks.Shadows,
                            shadowTexture,
                            new Rectangle((int)Math.Round(shadowBox.Value.Left), (int)Math.Round(shadowBox.Value.Front - shadowBox.Value.Top), (int)Math.Round(shadowBox.Value.Width), (int)Math.Round(shadowBox.Value.Height)),
                            new Rectangle(xIndex, yIndex + sourceHeight - 1, sourceWidth, 1),
                            IsTiling: shadowCaster.ShouldTile(),
                            Tint: Color.White * opacity
                            );
                    }
                }
                else
                {
                    GameService.GetService <IRenderService>().PushAlphaFragment(
                        RenderService.AlphaStacks.Shadows,
                        shadowTexture,
                        new Rectangle((int)Math.Round(shadowBox.Value.Left), ((int)shadowBox.Value.Back - (int)BackingBox.Back) / 2 + (int)Math.Round(shadowBox.Value.Back - BackingBox.B.Top), (int)Math.Round(shadowBox.Value.Width), (int)Math.Round(shadowBox.Value.Depth * 1.5f)),
                        new Rectangle(xIndex, yIndex, sourceWidth, sourceHeight),
                        IsTiling: shadowCaster.ShouldTile(),
                        Tint: Color.White * opacity
                        );
                }
            }
        }