Пример #1
0
        //Закрепить или открепить вспомогательную плитку
        private async void PinToStart_Click(object sender, RoutedEventArgs e)
        {
            if (SecondaryTile.Exists(SecondaryTileID))
            {
                //Открепить
                SecondaryTile secondaryTile = new SecondaryTile(SecondaryTileID);

                await secondaryTile.RequestDeleteAsync();

                ToggleAppBarButton();
            }
            else
            {
                //Закрепить
                Uri           square150x150Logo       = new Uri("ms-appx:///Assets/Icon360.png");
                string        DisplayNameAndArguments = this.GroupTitle.Text;
                TileSize      newTileDesiredSize      = TileSize.Square150x150;
                SecondaryTile secondaryTile           = new SecondaryTile(SecondaryTileID, DisplayNameAndArguments, DisplayNameAndArguments, square150x150Logo, newTileDesiredSize);

                secondaryTile.VisualElements.Square71x71Logo             = new Uri("ms-appx:///Assets/Icon170.png");
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

                await secondaryTile.RequestCreateAsync();

                BadgeUpdaterForSecondaryTile();

                ToggleAppBarButton();
            }
        }
        internal void PopulateElement(Element_TileBinding binding, TileSize size)
        {
            // Assign properties
            binding.TextStacking = TextStacking;

            // Add the background image if there's one
            if (BackgroundImage != null)
            {
                // We pull up the overlay value from there
                binding.Overlay = BackgroundImage.Overlay;
                
                // And add it as a child
                binding.Children.Add(BackgroundImage.ConvertToElement());
            }

            // Add the peek image if there's one
            if (PeekImage != null)
            {
                var el = PeekImage.ConvertToElement();

                // If peek overlay needs to be specified
                if (ShouldSpecifyPeekOverlay(binding, PeekImage))
                    el.Overlay = PeekImage.Overlay;

                binding.Children.Add(el);
            }

            // And then add all the children
            foreach (var child in Children)
            {
                binding.Children.Add(ConvertToBindingChildElement(child));
            }
        }
Пример #3
0
    public void OnRenderObject()
    {
        CreateLineMaterial();
        lineMaterial.SetPass(0);

        TileSize size = LevelManager.ActiveWorld.GetSize();

        Vector2 origin = LevelManager.ActiveWorld.GetWorldPositionFromGrid(new GridPosition(0, 0));

        transform.position = origin;

        GL.PushMatrix();

        GL.MultMatrix(transform.localToWorldMatrix);

        GL.Begin(GL.LINES);

        GL.Color(GridColour);

        for (int x = 0; x < size.Width; x++)
        {
            for (int y = 0; y < size.Height; y++)
            {
                GL.Vertex3(x, y, Z_DRAW);
                GL.Vertex3(x, y + 1, Z_DRAW);
                GL.Vertex3(x, y, Z_DRAW);
                GL.Vertex3(x + 1, y, Z_DRAW);
            }
        }

        GL.End();
        GL.PopMatrix();
    }
Пример #4
0
        protected int LayoutTileColumn(int columnIndex, int startIndex, int maxVerticalCellCount, int maxHorizontalCellCount, ref int rowCount)
        {
            maxVerticalCellCount = Math.Max(2, maxVerticalCellCount);
            int currentColumn = 0;
            int currentRow    = 0;
            int rowSpan       = 0;

            rowCount = 0;
            for (int i = startIndex; i < Children.Count; i++)
            {
                TileSize tileSize   = VerticalTilePanel.GetTileSize(Children[i]);
                int      columnSpan = tileSize == TileSize.Small ? 1 : 2;
                if (columnSpan > maxHorizontalCellCount)
                {
                    return(-1);
                }
                if (currentColumn + columnSpan > maxHorizontalCellCount)
                {
                    currentRow   += rowSpan;
                    rowCount     += rowSpan;
                    currentColumn = 0;
                }
                rowSpan = tileSize == TileSize.Large ? 2 : 1;
                if (currentRow + rowSpan > maxVerticalCellCount)
                {
                    return(i - 1);
                }
                VerticalTilePanel.SetColumn(Children[i], columnIndex + currentColumn);
                VerticalTilePanel.SetRow(Children[i], currentRow);
                currentColumn += columnSpan;
            }

            return(Children.Count - 1);
        }
Пример #5
0
        public static async Task PinSecondaryTileAsync(string id, string displayName, string arguments, TileSize tileSize)
        {
            if(IsPinned(id))
            {
                return;
            }

            Uri logo = new Uri("ms-appx:///assets/Logo.scale-100.jpg");
            Uri wideLogo = new Uri("ms-appx:///assets/WideLogo.scale-100.jpg");

            SecondaryTile secondaryTile = new SecondaryTile(id,
                                                            displayName,
                                                            "MGTV://" + arguments,
                                                            logo,
                                                            tileSize);

            secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true;
            secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true;

            secondaryTile.VisualElements.Wide310x150Logo = wideLogo;
            secondaryTile.VisualElements.Square150x150Logo = logo;

            secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

            await secondaryTile.RequestCreateAsync();
        }
Пример #6
0
        public sealed override bool Overlaps(Collider collider, out CollisionResult result)
        {
            if (base.Overlaps(collider, out result))
            {
                if (collider is ShapeCollider)
                {
                    var collide = false;
                    var shape   = (collider as ShapeCollider).Shape;
                    var region  = shape.Bounds
                                  .ToGrid(TileSize.ToVector2(), AbsolutePosition);

                    foreach (var location in PlotRegion(region))
                    {
                        Manifold hit      = default;
                        var      tile     = GetTileShape(location);
                        var      overlaps = tile?.Overlaps(shape, out hit) ?? false;

                        if (overlaps)
                        {
                            hit.Normal = -hit.Normal;
                            result.Add(hit);
                            collide = true;
                        }
                    }

                    if (collide)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #7
0
        internal void PopulateElement(Element_TileBinding binding, TileSize size)
        {
            // Assign properties
            binding.TextStacking = TextStacking;

            // Add the background image if there's one
            if (BackgroundImage != null)
            {
                // And add it as a child
                binding.Children.Add(BackgroundImage.ConvertToElement());
            }

            // Add the peek image if there's one
            if (PeekImage != null)
            {
                var el = PeekImage.ConvertToElement();

                binding.Children.Add(el);
            }

            // And then add all the children
            foreach (var child in Children)
            {
                binding.Children.Add(ConvertToBindingChildElement(child));
            }
        }
Пример #8
0
        /// <summary>
        /// Set the text stacking (vertical alignment) of the entire binding element.
        /// </summary>
        /// <param name="textStacking">Text Stacking Option</param>
        /// <param name="size">The tile size that the peek image should be applied to. Default to all currently supported tile size.</param>
        /// <returns>The current instance of <see cref="TileContentBuilder"/></returns>
        public TileContentBuilder SetTextStacking(TileTextStacking textStacking, TileSize size = AllSize)
        {
            // Set to any available tile at the moment of calling.
            if (size.HasFlag(TileSize.Small) && SmallTile != null)
            {
                GetAdaptiveTileContent(SmallTile).TextStacking = textStacking;
            }

            if (size.HasFlag(TileSize.Medium) && MediumTile != null)
            {
                GetAdaptiveTileContent(MediumTile).TextStacking = textStacking;
            }

            if (size.HasFlag(TileSize.Wide) && WideTile != null)
            {
                GetAdaptiveTileContent(WideTile).TextStacking = textStacking;
            }

            if (size.HasFlag(TileSize.Large) && LargeTile != null)
            {
                GetAdaptiveTileContent(LargeTile).TextStacking = textStacking;
            }

            return(this);
        }
Пример #9
0
        /// <summary>
        /// Set the tile's activation arguments for chasable tile notification.
        /// </summary>
        /// <param name="args">App-Defined custom arguments that will be passed in when the user click on the tile when this tile notification is being displayed.</param>
        /// <param name="size">The tile size that the custom argument should be applied to. Default to all currently supported tile size.</param>
        /// <returns>The current instance of <see cref="TileContentBuilder"/></returns>
        public TileContentBuilder SetActivationArgument(string args, TileSize size = AllSize)
        {
            if (size == AllSize)
            {
                Visual.Arguments = args;
            }
            else
            {
                if (size.HasFlag(TileSize.Small) && SmallTile != null)
                {
                    SmallTile.Arguments = args;
                }

                if (size.HasFlag(TileSize.Medium) && MediumTile != null)
                {
                    MediumTile.Arguments = args;
                }

                if (size.HasFlag(TileSize.Wide) && WideTile != null)
                {
                    WideTile.Arguments = args;
                }

                if (size.HasFlag(TileSize.Large) && LargeTile != null)
                {
                    LargeTile.Arguments = args;
                }
            }

            return(this);
        }
Пример #10
0
        private void InitializeTileSizeList()
        {
            _tileSizeList.Items.Clear();
            _availableSizes.Clear();

            if (_tileController != null)
            {
                foreach (TilePoolPresenter pool in _tileController.TilePoolList)
                {
                    if (_availableSizes.Exists(sz => { return(sz.Width == pool.TilePool.TileWidth && sz.Height == pool.TilePool.TileHeight); }))
                    {
                        continue;
                    }

                    TileSize size = new TileSize(pool.TilePool.TileWidth, pool.TilePool.TileHeight);
                    _availableSizes.Add(size);
                    _tileSizeList.Items.Add(size);
                }
            }

            if (_brush != null)
            {
                if (!_availableSizes.Exists(sz => { return(sz.Width == _brush.TileWidth && sz.Height == _brush.TileHeight); }))
                {
                    TileSize brushSize = new TileSize(_brush.TileWidth, _brush.TileHeight);
                    _availableSizes.Add(brushSize);
                    _tileSizeList.Items.Add(brushSize);
                }
            }

            SelectCurrentTileSize();
        }
Пример #11
0
        private static AdaptiveText GetTileAdaptiveText(TileContentBuilder builder, TileSize size)
        {
            TileBinding tileBinding;

            switch (size)
            {
            case TileSize.Small:
                tileBinding = builder.Content.Visual.TileSmall;
                break;

            case TileSize.Medium:
                tileBinding = builder.Content.Visual.TileMedium;
                break;

            case TileSize.Wide:
                tileBinding = builder.Content.Visual.TileWide;
                break;

            case TileSize.Large:
                tileBinding = builder.Content.Visual.TileLarge;
                break;

            default:
                return(null);
            }

            var content = (TileBindingContentAdaptive)tileBinding.Content;

            return(content.Children.FirstOrDefault() as AdaptiveText);
        }
Пример #12
0
        private async void btnSecTile_Click(object sender, RoutedEventArgs e)
        {
            Windows.Foundation.Rect rect = GetElementRect((FrameworkElement)sender);

            if (SecondaryTile.Exists("MyUnicTileID"))
            {
                SecondaryTile secondaryTile = new SecondaryTile("MyUnicTileID");

                bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);

                ToggleAppBarButton(isUnpinned);
            }
            else
            {
                // Pin
                Uri    square150x150Logo       = new Uri("ms-appx:///Assets/Square150x150Logo.png");
                string tileActivationArguments = "Secondary tile was pinned at = " + DateTime.Now.ToLocalTime().ToString();
                string displayName             = "App Template";

                TileSize      newTileDesiredSize = TileSize.Square150x150;
                SecondaryTile secondaryTile      = new SecondaryTile("MyUnicTileID",
                                                                     displayName,
                                                                     tileActivationArguments,
                                                                     square150x150Logo,
                                                                     newTileDesiredSize);

                secondaryTile.VisualElements.Square44x44Logo             = new Uri("ms-appx:///Assets/Square44x44Logo.png");
                secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                secondaryTile.VisualElements.ForegroundText = ForegroundText.Light;

                bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, Windows.UI.Popups.Placement.Above);

                ToggleAppBarButton(!isPinned);
            }
        }
        internal void PopulateElement(Element_TileBinding binding, TileSize size)
        {
            binding.Presentation = TilePresentation.People;

            foreach (var img in Images)
                binding.Children.Add(img.ConvertToElement());
        }
Пример #14
0
        /// <summary>
        /// Add a tile layout size that the notification will be displayed on.
        /// </summary>
        /// <param name="size">The size of tile that the notification will be displayed on.</param>
        /// <param name="tileContent">Specialized tile content. Use for special tile template. Default to NULL.</param>
        /// <returns>The current instance of <see cref="TileContentBuilder"/></returns>
        public TileContentBuilder AddTile(TileSize size, ITileBindingContent tileContent = null)
        {
            if (size.HasFlag(TileSize.Small))
            {
                SmallTile         = new TileBinding();
                SmallTile.Content = tileContent ?? new TileBindingContentAdaptive();
            }

            if (size.HasFlag(TileSize.Medium))
            {
                MediumTile         = new TileBinding();
                MediumTile.Content = tileContent ?? new TileBindingContentAdaptive();
            }

            if (size.HasFlag(TileSize.Wide))
            {
                WideTile         = new TileBinding();
                WideTile.Content = tileContent ?? new TileBindingContentAdaptive();
            }

            if (size.HasFlag(TileSize.Large))
            {
                LargeTile         = new TileBinding();
                LargeTile.Content = tileContent ?? new TileBindingContentAdaptive();
            }

            return(this);
        }
Пример #15
0
        /// <summary>
        /// Set the name that will be used to override the application's name on the tile notification.
        /// </summary>
        /// <param name="displayName">Custom name to display on the tile in place of the application's name</param>
        /// <param name="size">The tile size that <paramref name="displayName"/> parameter should be applied to. Default to all currently supported tile size.</param>
        /// <returns>The current instance of <see cref="TileContentBuilder"/></returns>
        public TileContentBuilder SetDisplayName(string displayName, TileSize size = AllSize)
        {
            if (size == AllSize)
            {
                // Set on visual.
                Visual.DisplayName = displayName;
            }
            else
            {
                if (size.HasFlag(TileSize.Small) && SmallTile != null)
                {
                    SmallTile.DisplayName = displayName;
                }

                if (size.HasFlag(TileSize.Medium) && MediumTile != null)
                {
                    MediumTile.DisplayName = displayName;
                }

                if (size.HasFlag(TileSize.Wide) && WideTile != null)
                {
                    WideTile.DisplayName = displayName;
                }

                if (size.HasFlag(TileSize.Large) && LargeTile != null)
                {
                    LargeTile.DisplayName = displayName;
                }
            }

            return(this);
        }
Пример #16
0
        /// <summary>
        /// Set how the tile notification should display the application branding.
        /// </summary>
        /// <param name="branding">How branding should appear on the tile</param>
        /// <param name="size">The tile size that the <paramref name="branding"/> parameter should be applied to. Default to all currently supported tile size.</param>
        /// <returns>The current instance of <see cref="TileContentBuilder"/></returns>
        public TileContentBuilder SetBranding(TileBranding branding, TileSize size = AllSize)
        {
            if (size == AllSize)
            {
                // Set on visual.
                Visual.Branding = branding;
            }
            else
            {
                if (size.HasFlag(TileSize.Small) && SmallTile != null)
                {
                    SmallTile.Branding = branding;
                }

                if (size.HasFlag(TileSize.Medium) && MediumTile != null)
                {
                    MediumTile.Branding = branding;
                }

                if (size.HasFlag(TileSize.Wide) && WideTile != null)
                {
                    WideTile.Branding = branding;
                }

                if (size.HasFlag(TileSize.Large) && LargeTile != null)
                {
                    LargeTile.Branding = branding;
                }
            }

            return(this);
        }
        /// <summary>
        /// This should only be called once. For new tile notification content, create a new instance of this element.
        /// </summary>
        /// <param name="tileSize"></param>
        /// <param name="tilePixelSize"></param>
        /// <param name="visualElements"></param>
        /// <param name="isBrandingVisible"></param>
        /// <param name="binding"></param>
        public void InitializeFromXml(TileSize tileSize, PreviewTileVisualElements visualElements, bool isBrandingVisible, AdaptiveBinding binding)
        {
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }


            PreviewTileNotificationRaw raw = new PreviewTileNotificationRaw();

            raw.InitializeFromXml(tileSize, visualElements, isBrandingVisible, binding);

            if (raw.UsingPeek)
            {
                base.Content = new PeekDisplayerControl()
                {
                    PreviewTileNotificationRaw = raw,
                    PeekStartsOn = PeekContentDisplayed.Content
                }
            }
            ;

            else
            {
                base.Content = raw;
            }
        }
Пример #18
0
        /// <summary>
        /// Set the Tile's Peek Image that animate from the top of the tile notification.
        /// </summary>
        /// <param name="peekImage">An instance of <see cref="TilePeekImage"/> for the Tile's peek image </param>
        /// <param name="size">The tile size that the peek image should be applied to. Default to all currently supported tile size.</param>
        /// <returns>The current instance of <see cref="TileContentBuilder"/></returns>
        public TileContentBuilder SetPeekImage(TilePeekImage peekImage, TileSize size = AllSize)
        {
            // Set to any available tile at the moment of calling.
            if (size.HasFlag(TileSize.Small) && SmallTile != null)
            {
                GetAdaptiveTileContent(SmallTile).PeekImage = peekImage;
            }

            if (size.HasFlag(TileSize.Medium) && MediumTile != null)
            {
                GetAdaptiveTileContent(MediumTile).PeekImage = peekImage;
            }

            if (size.HasFlag(TileSize.Wide) && WideTile != null)
            {
                GetAdaptiveTileContent(WideTile).PeekImage = peekImage;
            }

            if (size.HasFlag(TileSize.Large) && LargeTile != null)
            {
                GetAdaptiveTileContent(LargeTile).PeekImage = peekImage;
            }

            return(this);
        }
        /// <summary>
        /// This should only be called once. For new tile notification content, create a new instance of this element.
        /// </summary>
        /// <param name="tileSize"></param>
        /// <param name="tilePixelSize"></param>
        /// <param name="visualElements"></param>
        /// <param name="isBrandingVisible"></param>
        /// <param name="content"></param>
        /// <param name=""></param>
        /// <param name="binding"></param>
        public void Initialize(TileSize tileSize, PreviewTileVisualElements visualElements, bool isBrandingVisible, JsonTileCardContent content, JsonParseTileResult result)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }


            PreviewTileNotificationRaw raw = new PreviewTileNotificationRaw();

            raw.Initialize(tileSize, visualElements, isBrandingVisible, content, result);

            if (raw.UsingPeek)
            {
                base.Content = new PeekDisplayerControl()
                {
                    PreviewTileNotificationRaw = raw,
                    PeekStartsOn = PeekContentDisplayed.Content
                }
            }
            ;

            else
            {
                base.Content = raw;
            }
        }
Пример #20
0
        private void InitializeNewBrush()
        {
            string   prototype = _prototypeList.SelectedItem as string;
            TileSize size      = _tileSizeList.SelectedItem as TileSize;

            if (prototype == null || size == null)
            {
                return;
            }

            DynamicTileBrushClass brushClass = Project.DynamicBrushClassRegistry.Lookup(prototype);

            if (brushClass == null)
            {
                return;
            }

            string name = "";

            if (_brush != null)
            {
                name = _brush.Name;
            }

            InitializeBrush(new DynamicTileBrush(name, size.Width, size.Height, brushClass));
        }
Пример #21
0
        private void SelectCurrentTileSize()
        {
            if (_brush == null)
            {
                if (_tileSizeList.Items.Count > 0)
                {
                    _tileSizeList.SelectedIndex = 0;
                }

                _validateController.Validate();
                return;
            }

            for (int i = 0; i < _tileSizeList.Items.Count; i++)
            {
                TileSize item = _tileSizeList.Items[i] as TileSize;
                if (item.Width == _brush.TileWidth && item.Height == _brush.TileHeight)
                {
                    _tileSizeList.SelectedIndex = i;
                    break;
                }
            }

            _validateController.Validate();
        }
Пример #22
0
        protected override Size MeasureOverride(Size availableSize)
        {
            int maxVerticalCellCount = Math.Max(1, (int)(double.IsInfinity(availableSize.Height) ? 100 : availableSize.Height / SmallTileHeight));
            int startIndex           = 0;
            int columnIndex          = 0;
            int rowCount             = 0;

            while (startIndex != Children.Count)
            {
                int newIndex = LayoutTileColumn(columnIndex, startIndex, maxVerticalCellCount, 1, ref rowCount);
                columnIndex++;
                if (newIndex == -1)
                {
                    newIndex = LayoutTileColumn(columnIndex - 1, startIndex, maxVerticalCellCount, 2, ref rowCount);
                    if (newIndex == -1)
                    {
                        throw new InvalidOperationException();
                    }
                    columnIndex++;
                }
                if (startIndex == 0)
                {
                    maxVerticalCellCount = Math.Min(rowCount, maxVerticalCellCount);
                }
                startIndex = newIndex + 1;
            }
            foreach (UIElement child in Children)
            {
                TileSize tileSize   = VerticalTilePanel.GetTileSize(child);
                int      rowSpan    = tileSize == TileSize.Large ? 2 : 1;
                int      columnSpan = tileSize == TileSize.Small ? 1 : 2;
                child.Measure(new Size(columnSpan * SmallTileWidth, rowSpan * SmallTileHeight));
            }
            return(new Size(SmallTileWidth * columnIndex, SmallTileHeight * maxVerticalCellCount));
        }
Пример #23
0
        private async void TransparentTileBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (isTransparentTilePinned != isPinned(this.TransparentTileBox.SelectedItem.ToString()))
            {
                if (isPinned(this.TransparentTileBox.SelectedItem.ToString()) == true)
                {
                    //Закрепить
                    Uri           square150x150Logo  = new Uri("ms-appx:///Assets/Icon360.png");
                    TileSize      newTileDesiredSize = TileSize.Square150x150;
                    SecondaryTile secondaryTile      = new SecondaryTile(TransparentTileID, "ListBox", "App", square150x150Logo, newTileDesiredSize);

                    secondaryTile.VisualElements.Square71x71Logo             = new Uri("ms-appx:///Assets/Icon170.png");
                    secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                    secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;

                    await secondaryTile.RequestCreateAsync();

                    isTransparentTilePinned = true;
                }
                else
                {
                    //Открепить
                    SecondaryTile secondaryTile = new SecondaryTile(TransparentTileID);

                    await secondaryTile.RequestDeleteAsync();

                    isTransparentTilePinned = false;
                }
            }
        }
Пример #24
0
        public async Task <string> CreateSchemeBitmapAsync(Scheme scheme, TileSize size)
        {
            var width = size == TileSize.Square ? 150 : 310;

            var bitmap = new WriteableBitmap(width, 150);

            var columnWidth = width / scheme.Colours.Count;

            var x = 0;

            for (int i = 0; i < scheme.Colours.Count; i++)
            {
                var colour = scheme.Colours[i];

                if (i == scheme.Colours.Count - 1) // last column
                {
                    columnWidth = width - ((scheme.Colours.Count - 1) * columnWidth);
                }

                bitmap.FillRectangle(x, 0, x + columnWidth, 150, colour.ToSystemColor(255));

                x += columnWidth;
            }

            var file = await CreateImageFileAsync(scheme, size);

            await bitmap.SaveToFile(file, BitmapEncoder.PngEncoderId);

            return(String.Format("ms-appdata:///local/{0}", file.Name));
        }
Пример #25
0
        public bool ContainsTags(Collider collider, T attributes)
        {
            var canCollide = collider != null &&
                             collider != this &&
                             IsCollidable &&
                             collider.IsCollidable;

            if (canCollide)
            {
                if (collider is ShapeCollider)
                {
                    var shape  = (collider as ShapeCollider).Shape;
                    var region = shape.Bounds
                                 .ToGrid(TileSize.ToVector2(), AbsolutePosition);

                    foreach (var location in PlotRegion(region))
                    {
                        if (HasTags(location, attributes))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #26
0
        public bool Overlaps(Collider collider, T attributes)
        {
            var canCollide = collider != null &&
                             collider != this &&
                             IsCollidable &&
                             collider.IsCollidable;

            if (canCollide)
            {
                if (collider is ShapeCollider)
                {
                    var shape  = (collider as ShapeCollider).Shape;
                    var region = shape.Bounds
                                 .ToGrid(TileSize.ToVector2(), AbsolutePosition);

                    foreach (var location in PlotRegion(region))
                    {
                        var tile     = GetTileShape(location);
                        var overlaps = tile?.Overlaps(shape) ?? false;
                        if (overlaps && HasAttributes(location, attributes))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #27
0
        public bool Overlaps(Shape shape, T attributes, out CollisionResult result)
        {
            result = new CollisionResult(this);

            var collide = false;

            if (IsCollidable && shape != null)
            {
                var region = shape.Bounds
                             .ToGrid(TileSize.ToVector2(), AbsolutePosition);

                foreach (var location in PlotRegion(region))
                {
                    Manifold hit      = default;
                    var      tile     = GetTileShape(location);
                    var      overlaps = tile?.Overlaps(shape, out hit) ?? false;

                    if (overlaps && HasTags(location, attributes))
                    {
                        hit.Normal = -hit.Normal;
                        result.Add(hit);
                        collide = true;
                    }
                }
            }

            return(collide);
        }
        internal void PopulateElement(Element_TileBinding binding, TileSize size)
        {
            // Assign properties
            binding.TextStacking = TextStacking;

            // Add the background image if there's one
            if (BackgroundImage != null)
            {
                // We pull up the overlay value from there
                binding.Overlay = BackgroundImage.Overlay;

                // And add it as a child
                binding.Children.Add(BackgroundImage.ConvertToElement());
            }

            // Add the peek image if there's one
            if (PeekImage != null)
            {
                var el = PeekImage.ConvertToElement();

                // If peek overlay needs to be specified
                if (ShouldSpecifyPeekOverlay(binding, PeekImage))
                {
                    el.Overlay = PeekImage.Overlay;
                }

                binding.Children.Add(el);
            }

            // And then add all the children
            foreach (var child in Children)
            {
                binding.Children.Add(ConvertToBindingChildElement(child));
            }
        }
Пример #29
0
        public bool CastRay(
            Vector2 origin,
            Vector2 normal,
            float distance,
            T attributes,
            out Raycast hit)
        {
            hit = default;

            if (IsCollidable)
            {
                var tileSize = TileSize.ToVector2();
                var gStart   = origin.ToGrid(tileSize, AbsolutePosition);
                var gEnd     = (origin + normal * distance).ToGrid(tileSize, AbsolutePosition);

                foreach (var location in PlotLine(gStart, gEnd))
                {
                    var tile        = GetTileShape(location);
                    var hitDetected = tile?.CastRay(origin, normal, distance, out hit) ?? false;
                    if (hitDetected && HasTags(location, attributes))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #30
0
        private void UpdateTileSize()
        {
            switch (TileSize)
            {
            case TileSize.Small:
                this.TilePixelSize = TileDensity.Small;
                break;

            case TileSize.Medium:
                this.TilePixelSize = TileDensity.Medium;
                break;

            case TileSize.Wide:
                this.TilePixelSize = TileDensity.Wide;
                break;

            case TileSize.Large:
                this.TilePixelSize = TileDensity.Large;
                break;

            default:
                throw new NotImplementedException(TileSize.ToString());
            }

            UpdateBranding();
        }
        public static async Task <string> ResizeForTile(string name, TileSize size)
        {
            var _SubName  = "Media";
            var _Local    = ApplicationData.Current.LocalFolder;
            var _LocalSub = await _Local.CreateFolderAsync(_SubName, CreationCollisionOption.OpenIfExists);

            var _Installed    = Windows.ApplicationModel.Package.Current.InstalledLocation;
            var _InstalledSub = await _Installed.GetFolderAsync(_SubName);

            var _Source = await _InstalledSub.GetFileAsync(name);

            var _FileName  = System.IO.Path.GetFileNameWithoutExtension(_Source.Name);
            var _Extension = System.IO.Path.GetExtension(_Source.Name).TrimStart('.');

            var _STDFile = await _LocalSub.CreateFileAsync(_Source.Name, CreationCollisionOption.OpenIfExists);

            if (size == TileSize.Square)
            {
                await Resize(_Source, _STDFile, (uint)150, (uint)150);
            }
            else
            {
                await Resize(_Source, _STDFile, (uint)310, (uint)150);
            }

            return("ms-appdata:///local/Media/" + name);
        }
Пример #32
0
        void Update()
        {
            tileSizeText.text           = TileSize.ToString("F1");
            EstimateAggressionText.text = EstimateAggression.ToString("F2");

            Path path = FastPath.FindPathImmediate(Start, End);

            if (path.ValidPath)
            {
                InvalidPathIndicator.gameObject.SetActive(false);
            }
            else
            {
                InvalidPathIndicator.gameObject.SetActive(true);
            }

            if (DrawMap)
            {
                FastPath.DrawMapInEditor(FastPath.DefaultMap);
            }
            if (DrawPath)
            {
                path.DrawPath();
            }
            RaycastHit hit;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                if (hit.collider.tag != "Enemy")               // && (hit.collider.tag != "NonWalkable" || hit.collider.gameObject == Obstacle.gameObject))
                {
                    Obstacle.transform.position = new Vector3(hit.point.x, enemyY, hit.point.z);

                    Path p = FastPath.FindPathImmediate(Start, End, FastPath.IndexesBetween(FastPath.DefaultMap, Obstacle.bounds.min, Obstacle.bounds.max));

                    if (p.ValidPath)
                    {
                        ObstacleRenderer.material.color = Color.green;
                        if (Input.GetMouseButtonDown(0))
                        {
                            GameObject instance = (GameObject)Object.Instantiate(Obstacle.gameObject, new Vector3(hit.point.x, enemyY, hit.point.z), Quaternion.identity);
                            instance.GetComponent <MeshRenderer>().material = new Material(ObstacleRenderer.material);
                            FastPath.Update(FastPath.DefaultMap, FastPath.IndexesBetween(FastPath.DefaultMap, Obstacle.bounds.min, Obstacle.bounds.max));
                        }
                    }
                    else
                    {
                        ObstacleRenderer.material.color = Color.red;
                    }
                    if (DrawPath)
                    {
                        p.DrawPath();
                    }
                }
                else
                {
                    ObstacleRenderer.material.color = Color.red;
                }
            }
        }
Пример #33
0
        public SimpleTile GetTile(Vector2 point)
        {
            var location = point
                           .ToGrid(TileSize.ToVector2(), AbsolutePosition)
                           .ToPoint();

            return(new SimpleTile(location, Map[location]));
        }
 internal void PopulateElement(Element_TileBinding binding, TileSize size)
 {
     if (Icon != null)
     {
         var element = Icon.ConvertToElement();
         element.Id = 1;
         binding.Children.Add(element);
     }
 }
Пример #35
0
 public TransitionDispatcher(TransitioningContentControl transCtrl,string dispatcherName, DispatcherTimer timer, string imageLogo, string imageText , TileSize transTileSize )
 {
     TransTimer = timer;
     ImageLogo = imageLogo;
     ImageText = imageText;
     TransControl = transCtrl;
     TransTileSize = transTileSize;
     TransTimer.Tag = dispatcherName;
 }
        internal void PopulateElement(Element_TileBinding binding, TileSize size)
        {
            binding.Presentation = TilePresentation.Contact;

            // Small size doesn't display the text, so no reason to include it in the payload
            if (Text != null && size != TileSize.Small)
                binding.Children.Add(Text.ConvertToElement());

            if (Image != null)
                binding.Children.Add(Image.ConvertToElement());
        }
        internal TileTemplateNameV3 GetTemplateName(TileSize size)
        {
            switch (size)
            {
                case TileSize.Small:
                    return TileTemplateNameV3.TileSquare71x71IconWithBadge;

                case TileSize.Medium:
                    return TileTemplateNameV3.TileSquare150x150IconWithBadge;

                default:
                    throw new ArgumentException("The Iconic template is only supported on Small and Medium tiles.");
            }
        }
Пример #38
0
        public static TileTemplateNameV3 Convert(TileSize size)
        {
            switch (size)
            {
                case TileSize.Small:
                    return TileTemplateNameV3.TileSmall;

                case TileSize.Medium:
                    return TileTemplateNameV3.TileMedium;

                case TileSize.Wide:
                    return TileTemplateNameV3.TileWide;

                case TileSize.Large:
                    return TileTemplateNameV3.TileLarge;

                default:
                    throw new NotImplementedException();
            }
        }
        internal Element_TileBinding ConvertToElement(TileSize size)
        {
            TileTemplateNameV3 templateName = GetTemplateName(Content, size);
            

            Element_TileBinding binding = new Element_TileBinding(templateName)
            {
                Language = Language,
                BaseUri = BaseUri,
                Branding = Branding,
                AddImageQuery = AddImageQuery,
                DisplayName = DisplayName,
                ContentId = ContentId

                // LockDetailedStatus gets populated by TileVisual
            };

            PopulateElement(Content, binding, size);

            return binding;
        }
Пример #40
0
        /// <summary>
        /// Constructor containing info for pinning a tile.
        /// </summary>
        /// <param name="tileId">The Id of the tile to pin.</param>
        /// <param name="displayName">The display name for the tile.</param>
        /// <param name="logoUri">The Uri to the tile logo.</param>
        /// <param name="wideLogoUri">The Uri to the wide tile logo.</param>
        /// <param name="tileSize">The size of the tile.</param>
        /// <param name="anchorElement">The anchor element that the pin request dialog will display next to.</param>
        /// <param name="requestPlacement">The Placement value that tells where the pin request dialog displays in relation to anchorElement.</param>
        /// <param name="arguments">Optional arguments to provide for when the tile is activated.</param>
        public TileInfo(
			string tileId,
			string displayName,
			Uri logoUri,
			Uri wideLogoUri,
			TileSize tileSize,
			Windows.UI.Xaml.FrameworkElement anchorElement,
			Placement requestPlacement,
			string arguments = null)
        {
            this.TileId = tileId;
            this.DisplayName = displayName;
            this.Arguments = arguments;
            this.LogoUri = logoUri;
            this.WideLogoUri = wideLogoUri;
            this.TileSize = tileSize;

            this.AnchorElement = anchorElement;
            this.RequestPlacement = requestPlacement;

            this.Arguments = arguments;
        }
        private static void PopulateElement(ITileBindingContent bindingContent, Element_TileBinding binding, TileSize size)
        {
            if (bindingContent == null)
                return;

            if (bindingContent is TileBindingContentAdaptive)
                (bindingContent as TileBindingContentAdaptive).PopulateElement(binding, size);

            else if (bindingContent is TileBindingContentContact)
                (bindingContent as TileBindingContentContact).PopulateElement(binding, size);

            else if (bindingContent is TileBindingContentIconic)
                (bindingContent as TileBindingContentIconic).PopulateElement(binding, size);

            else if (bindingContent is TileBindingContentPeople)
                (bindingContent as TileBindingContentPeople).PopulateElement(binding, size);

            else if (bindingContent is TileBindingContentPhotos)
                (bindingContent as TileBindingContentPhotos).PopulateElement(binding, size);

            else
                throw new NotImplementedException("Unknown binding content type: " + bindingContent.GetType());
        }
Пример #42
0
        private void InitializeTileSizeList()
        {
            _tileSizeList.Items.Clear();
            _availableSizes.Clear();

            if (_tileController != null) {
                foreach (TilePoolPresenter pool in _tileController.TilePoolList) {
                    if (_availableSizes.Exists(sz => { return sz.Width == pool.TilePool.TileWidth && sz.Height == pool.TilePool.TileHeight; }))
                        continue;

                    TileSize size = new TileSize(pool.TilePool.TileWidth, pool.TilePool.TileHeight);
                    _availableSizes.Add(size);
                    _tileSizeList.Items.Add(size);
                }
            }

            if (_brush != null) {
                if (!_availableSizes.Exists(sz => { return sz.Width == _brush.TileWidth && sz.Height == _brush.TileHeight; })) {
                    TileSize brushSize = new TileSize(_brush.TileWidth, _brush.TileHeight);
                    _availableSizes.Add(brushSize);
                    _tileSizeList.Items.Add(brushSize);
                }
            }

            SelectCurrentTileSize();
        }
        private static TileTemplateNameV3 GetTemplateName(ITileBindingContent bindingContent, TileSize size)
        {
            if (bindingContent == null)
                return TileSizeToAdaptiveTemplateConverter.Convert(size);


            if (bindingContent is TileBindingContentAdaptive)
                return (bindingContent as TileBindingContentAdaptive).GetTemplateName(size);

            else if (bindingContent is TileBindingContentContact)
                return (bindingContent as TileBindingContentContact).GetTemplateName(size);

            else if (bindingContent is TileBindingContentIconic)
                return (bindingContent as TileBindingContentIconic).GetTemplateName(size);

            else if (bindingContent is TileBindingContentPeople)
                return (bindingContent as TileBindingContentPeople).GetTemplateName(size);

            else if (bindingContent is TileBindingContentPhotos)
                return (bindingContent as TileBindingContentPhotos).GetTemplateName(size);

            throw new NotImplementedException("Unknown binding content type: " + bindingContent.GetType());
        }
        /// <summary>
        /// Creates a map image for a tile.
        /// </summary>
        private static async Task<string> CreateTileMapImageAsync(string tileId, double latitude, double longitude, int width, int height, TileSize tileSize)
        {
            // Get the image from Bing and save to disk.
            string tileImageFile = string.Format("{0}-{1}.png", tileId, tileSize.ToString());
            string tileImagePath = Path.Combine("Tiles", tileImageFile);

            bool fileExists = false;
            try
            {
                var file = await ApplicationData.Current.LocalFolder.GetFileAsync(tileImagePath);
                fileExists = true;
            }
            catch
            {
            }

            // Create the file:
            if (!fileExists)
            {
                BingMapsServiceHelper bingMapsHelper = new BingMapsServiceHelper();
                using (var memoryStream = await bingMapsHelper.GetStaticImageBytesAsync(
                    latitude,
                    longitude,
                    width,
                    height))
                {
                    IStorageFile storageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(tileImagePath, CreationCollisionOption.ReplaceExisting);
                    using (var stream = await storageFile.OpenStreamForWriteAsync())
                    {
                        memoryStream.WriteTo(stream);
                    }
                }
            }

            return tileImageFile;
        }
        private Uri ProcessImageForTile(string fileLocation, string fileName, TileSize ts)
        {
            IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication();
            const string shellDirectory = "Shared\\ShellContent";
            store.CreateDirectory(shellDirectory);
            StreamResourceInfo sri = Application.GetResourceStream(new Uri(fileLocation, UriKind.Relative));
            BitmapImage bmi = new BitmapImage();
            bmi.SetSource(sri.Stream);

            WriteableBitmap wbmp = new WriteableBitmap(bmi);
            string imagePath = shellDirectory + "\\" + fileName + ".jpg";
            if (ts == TileSize.Icon)
                imagePath = shellDirectory + "\\" + fileName + ".png";
            if (store.FileExists(imagePath))
                store.DeleteFile(imagePath);
            int imgWidth = 159;
            int imgHeight = 159;
            if (ts == TileSize.Medium)
                imgWidth = imgHeight = 336;
            else if (ts == TileSize.Wide)
            {
                imgWidth = 691;
                imgHeight = 336;
            }
            else if (ts == TileSize.Icon)
                imgWidth = imgHeight = 202;
        
            using (IsolatedStorageFileStream stream = store.OpenFile(imagePath, System.IO.FileMode.OpenOrCreate))
            {
                wbmp.SaveJpeg(stream, imgWidth, imgHeight, 0, 100);
                return new Uri("isostore:/" + imagePath.Replace('\\', '/')); 
            }
        }
 internal TileTemplateNameV3 GetTemplateName(TileSize size)
 {
     return TileSizeToAdaptiveTemplateConverter.Convert(size);
 }