コード例 #1
0
        /// <summary>
        /// Provides the behavior for the "Arrange" pass of layout
        /// </summary>
        /// <param name="finalSize">The final area within the parent that this object should use to arrange itself and its children</param>
        /// <returns>The actual size that is used after the element is arranged in layout.</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            var angle = 2 * Math.PI / Children.Count;

            var minDistance = 80;
            var maxDistance = Math.Max(minDistance, (Math.Min(finalSize.Width, finalSize.Height) - OrbitView.MaxItemSize) / 2);

            var elementsProperties = new List <OrbitViewElementProperties>();

            for (var i = 0; i < Children.Count; i++)
            {
                // UNO TODO
                if (Children.ElementAt(i) is UIElement element)
                {
                    OrbitViewDataItem orbitViewDataItem = null;
                    if (element is FrameworkElement)
                    {
                        orbitViewDataItem = ((FrameworkElement)element).DataContext as OrbitViewDataItem;
                    }

                    var d = orbitViewDataItem != null && orbitViewDataItem.Distance >= 0 ? orbitViewDataItem.Distance : 0.5;
                    d = Math.Min(d, 1d);

                    var distance = (d * (maxDistance - minDistance)) + minDistance;
                    var x        = distance * Math.Cos((angle * i) + (angle / 2));
                    var y        = distance * Math.Sin((angle * i) + (angle / 2));

                    var x_normalized = (finalSize.Width / 2) + x - (element.DesiredSize.Width / 2);
                    var y_normalized = (finalSize.Height / 2) - y - (element.DesiredSize.Height / 2);
                    var point        = new Point(x_normalized, y_normalized);

                    element.Arrange(point.ToRect(element.DesiredSize));

                    var elementProperties = new OrbitViewElementProperties()
                    {
                        XYFromCenter       = new Point(x, y),
                        DistanceFromCenter = distance,
                        Element            = element
                    };
                    elementsProperties.Add(elementProperties);

                    if (ItemArranged != null)
                    {
                        var args = new OrbitViewPanelItemArrangedArgs()
                        {
                            ElementProperties = elementProperties,
                            ItemIndex         = i
                        };
                        ItemArranged.Invoke(this, args);
                    }
                }
            }

            ItemsArranged?.Invoke(this, new OrbitViewPanelItemsArrangedArgs()
            {
                Elements = elementsProperties
            });

            return(finalSize);
        }
コード例 #2
0
        private async Task dibujarCaja(dynamic ubicacion, dynamic tagName, dynamic probability)
        {
            contador += 1;
            SolidColorBrush solidColorBrush = new SolidColorBrush();


            solidColorBrush.Color = Windows.UI.Colors.Yellow;


            Rectangle rectangle = new Rectangle();
            Thickness thickness = new Thickness();

            string tagEncontrado = (string)tagName;

            rectangle.Fill   = null;
            rectangle.Stroke = solidColorBrush;



            var constanteAmplitudWidth  = width;
            var constanteAmplitudHeight = heigth;

            double ubicacionLeft   = (double)ubicacion.left * constanteAmplitudWidth;
            double ubicacionTop    = (double)ubicacion.top * constanteAmplitudHeight;
            double ubicacionWidth  = (double)ubicacion.width * constanteAmplitudWidth;
            double ubicacionHeight = (double)ubicacion.height * constanteAmplitudHeight;
            Point  pointCaja       = new Point();

            pointCaja.X = ubicacionLeft;
            pointCaja.Y = ubicacionTop;
            Size sizeCaja = new Size();

            sizeCaja.Width  = ubicacionWidth;
            sizeCaja.Height = ubicacionHeight;

            var items = await CortarImagenesTageadas.ImagenACortar(pointCaja, sizeCaja, storageFile, imagePreview.ActualWidth);

            Items.Add(new Tuple <ImageSource, Point, Size>(items, pointCaja, sizeCaja));
            //lstViewImagenesTageadas.ItemTemplate.SetValue(WidthProperty, sizeCaja.Width);
            //lstViewImagenesTageadas.ItemTemplate.SetValue(HeightProperty, sizeCaja.Height);

            Microsoft.Toolkit.Uwp.UI.Controls.OrbitViewDataItem orbitViewDataItem = new Microsoft.Toolkit.Uwp.UI.Controls.OrbitViewDataItem();
            orbitViewDataItem.Distance = ubicacionLeft / 10;
            orbitViewDataItem.Diameter = (double)probability * (double)2;
            orbitViewDataItem.Label    = tagEncontrado + " - " + contador.ToString();

            BitmapImage bitmapImage = new BitmapImage();
            Uri         uri         = new Uri("ms-appx:///Assets/Icono1240.png");

            bitmapImage.UriSource = uri;



            orbitViewDataItem.Image = bitmapImage;
            orbitViewDataItem.Item  = tagEncontrado + " - " + probability.ToString();
            orbitViewDataItemCollection.Add(orbitViewDataItem);

            Guid guid;

            guid = Guid.NewGuid();
            resultadosDistancia.Add(new Tuple <OrbitViewDataItemCollection, Guid>(orbitViewDataItemCollection, guid));
            //orbitViewDataItemsList.Add(orbitViewDataItem);

            thickness.Left   = ubicacionLeft;
            thickness.Top    = ubicacionTop;
            rectangle.Margin = thickness;
            rectangle.Width  = ubicacionWidth;
            rectangle.Height = ubicacionHeight;
            cnvCanvas.Children.Add(rectangle);


            Thickness thicknessTexto = new Thickness();

            thicknessTexto.Left = ubicacionLeft;
            thicknessTexto.Top  = ubicacionTop - 10;

            string textoResultado = probability * 100;

            SolidColorBrush solidColorBrushTexto   = new SolidColorBrush();
            SolidColorBrush solidColorBrushTextoBG = new SolidColorBrush();

            solidColorBrushTextoBG.Color = Windows.UI.Colors.Transparent;
            solidColorBrushTexto.Color   = Windows.UI.Colors.Black;


            TextBox textBox = new TextBox();

            textBox.Text                    = (string)tagName + " - " + textoResultado.Substring(0, 4).ToString() + " %";
            textBox.Margin                  = thicknessTexto;
            textBox.FontSize                = 10;
            textBox.Padding                 = new Thickness(0, 0, 0, 0);
            textBox.BorderThickness         = new Thickness(0, 0, 0, 0);
            textBox.FocusVisualPrimaryBrush = solidColorBrushTexto;
            textBox.Foreground              = solidColorBrushTexto;
            textBox.Background              = solidColorBrush;
            textBox.Height                  = 13;
            textBox.MaxHeight               = 13;
            textBox.MinHeight               = 13;
            textBox.MaxLength               = 10;

            cnvCanvas.Children.Add(textBox);
        }