示例#1
0
    //-------∽-★-∽------∽-★-∽--------∽-★-∽Layout∽-★-∽--------∽-★-∽------∽-★-∽--------//

    void ShowLayout()
    {
        LayoutParam param = new LayoutParam {
        };

        param.padding = new Padding(20, 20, 20, 20);
        param.itemGap = new Vector2(50, 50);
        param.divNum  = 2;

        GameObject itemGo    = GameObjUtil.FindChild(m_scrollViewItemList.gameObject, "Image_mask/Container_content/Container_Item");
        GameObject container = GameObjUtil.GetParent(itemGo);

        itemGo.SetActive(false);

        for (var i = 0; i < 10; ++i)
        {
            GameObject item = GameObjUtil.Instantiate(itemGo);

            item.SetActive(true);
            GameObjUtil.ChangeParent(item, container);

            LayoutUtil.LayItem(param, i, item);

            m_idx2item[i] = item;
        }
    }
示例#2
0
        public Vector GetRepulsionForce(Point uPos, Point vPos, Size uSize, Size vSize, double repulsionRange)
        {
            var c_u = LayoutUtil.GetClippingPoint(uSize, uPos, vPos);
            var c_v = LayoutUtil.GetClippingPoint(vSize, vPos, uPos);

            var positionVector = (uPos - vPos);

            if (positionVector.Length == 0)
            {
                return(new Vector());
            }
            positionVector.Normalize();
            var F = c_u - c_v;
            var isSameDirection = LayoutUtil.IsSameDirection(positionVector, F);
            var Fr = new Vector();

            /*if (isSameDirection)
             * {*/
            if (F.Length > repulsionRange)
            {
                return(new Vector());
            }
            double length = Math.Max(1, F.Length);

            length = Math.Pow(isSameDirection ? length : 1 / length, isSameDirection ? 2 : 1);
            Fr     = parameters.RepulsionConstant / length * positionVector;
            return(Fr);
        }
        TransformLayoutCore
        (
            IGraph graph,
            LayoutContext originalLayoutContext,
            LayoutContext newLayoutContext
        )
        {
            Debug.Assert(graph != null);
            Debug.Assert(originalLayoutContext != null);
            Debug.Assert(newLayoutContext != null);
            AssertValid();

            // We want the graph to remain stationary, with the polar origin always
            // at the center of the graph rectangle.  Also, no scaling should occur
            // as the window changes size.

            Rectangle oOriginalGraphRectangle =
                originalLayoutContext.GraphRectangle;

            Rectangle oNewGraphRectangle =
                newLayoutContext.GraphRectangle;

            Matrix oMatrix = new Matrix();

            oMatrix.Translate(
                (oNewGraphRectangle.Width - oOriginalGraphRectangle.Width) / 2F,
                (oNewGraphRectangle.Height - oOriginalGraphRectangle.Height) / 2F
                );

            LayoutUtil.TransformVertexLocations(graph, oMatrix);
        }
示例#4
0
        TransformGroupRectangles
        (
            IGraph graph,
            LayoutContext originalLayoutContext,
            LayoutContext newLayoutContext
        )
        {
            Debug.Assert(graph != null);
            Debug.Assert(originalLayoutContext != null);
            Debug.Assert(newLayoutContext != null);

            GroupLayoutDrawingInfo oGroupLayoutDrawingInfo;

            if (TryGetGroupLayoutDrawingInfo(graph, out oGroupLayoutDrawingInfo))
            {
                // Replace the metadata value's group rectangles with a transformed
                // set of group rectangles.

                Matrix oTransformationMatrix =
                    LayoutUtil.GetRectangleTransformation(
                        originalLayoutContext.GraphRectangle,
                        newLayoutContext.GraphRectangle
                        );

                foreach (GroupInfo oGroupInfo in
                         oGroupLayoutDrawingInfo.GroupsToDraw)
                {
                    oGroupInfo.Rectangle = LayoutUtil.TransformRectangle(
                        oGroupInfo.Rectangle, oTransformationMatrix);
                }
            }
        }
示例#5
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateLayoutWithFixedSize()
        {
            int itemCount = vChildItems.Count;

            if (itemCount == 0)
            {
                return;
            }

            bool  isRev             = (Arrangement == ArrangementType.OuterToInner);
            float relSumThickness   = 0;
            float paddedOuterRadius = OuterRadius - Padding.OuterRadius;
            float paddedInnerRadius = InnerRadius + Padding.InnerRadius;
            float availDeg          = ArcDegrees - Padding.StartDegree - Padding.EndDegree;
            float availThick        = paddedOuterRadius - paddedInnerRadius - Padding.Between * (itemCount - 1);
            float innerRadius       = paddedInnerRadius;
            float paddedStartDeg    = StartingDegree + (Padding.StartDegree - Padding.EndDegree) / 2;

            Vector2 anchorPos = LayoutUtil.GetRelativeAnchorPosition(RectAnchor);

            anchorPos.x *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).x);
            anchorPos.y *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).y);

            for (int i = 0; i < itemCount; i++)
            {
                HoverLayoutArcGroupChild item = vChildItems[i];
                relSumThickness += item.RelativeThickness;
            }

            for (int i = 0; i < itemCount; i++)
            {
                int childI = (isRev ? itemCount - i - 1 : i);
                HoverLayoutArcGroupChild item = vChildItems[childI];
                ILayoutableArc           elem = item.Elem;
                float elemRelThick            = availThick * item.RelativeThickness / relSumThickness;
                float elemRelArcDeg           = availDeg * item.RelativeArcDegrees;
                float radiusOffset            = elemRelThick * item.RelativeRadiusOffset;
                float elemStartDeg            = paddedStartDeg + elemRelArcDeg * item.RelativeStartDegreeOffset;

                elem.SetArcLayout(
                    innerRadius + elemRelThick + radiusOffset,
                    innerRadius + radiusOffset,
                    elemRelArcDeg,
                    this
                    );

                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".x", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".y", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalRotation, this);

                Vector3 localPos = elem.transform.localPosition;
                localPos.x = anchorPos.x;
                localPos.y = anchorPos.y;

                elem.transform.localPosition = localPos;
                elem.transform.localRotation = Quaternion.AngleAxis(elemStartDeg, Vector3.back);

                innerRadius += elemRelThick + Padding.Between;
            }
        }
示例#6
0
        private Vector GetRepulsionForce(Point uPos, Point vPos, Size uSize, Size vSize, double repulsionRange)
        {
            var positionVector = (uPos - vPos);

            if (positionVector.Length == 0)
            {
                var compensationVector = new Vector(rnd.NextDouble(), rnd.NextDouble());
                positionVector = compensationVector * 2;
                uPos          += compensationVector;
                vPos          -= compensationVector;
            }
            positionVector.Normalize();

            var c_u = LayoutUtil.GetClippingPoint(uSize, uPos, vPos);
            var c_v = LayoutUtil.GetClippingPoint(vSize, vPos, uPos);

            var F = c_u - c_v;
            var isSameDirection = LayoutUtil.IsSameDirection(positionVector, F);
            var Fr = new Vector();

            if (isSameDirection && F.Length > repulsionRange)
            {
                return(new Vector());
            }
            double length = Math.Max(1, F.Length);

            //double length = F.LengthSquared;
            length = Math.Pow(isSameDirection ? length / (Parameters.IdealEdgeLength * 2.0) : 1 / length, 2);
            Fr     = Parameters.RepulsionConstant / length * positionVector * _phaseDependentRepulsionMultiplier;
            return(Fr);
        }
示例#7
0
        public void BiLayerCrossCountTest()
        {
            IEnumerable <Pair> pairs = new Pair[]
            {
                new Pair()
                {
                    First = 0, Second = 1, Weight = 2
                },
                new Pair()
                {
                    First = 0, Second = 2, Weight = 3
                },
                new Pair()
                {
                    First = 3, Second = 0, Weight = 2
                },
                new Pair()
                {
                    First = 3, Second = 1, Weight = 4
                },
                new Pair()
                {
                    First = 5, Second = 0, Weight = 3
                }
            };
            int firstLayerVertexCount  = 26;
            int secondLayerVertexCount = 3;
            int expected = 49;
            int actual   = LayoutUtil.BiLayerCrossCount(pairs, firstLayerVertexCount, secondLayerVertexCount);

            Assert.AreEqual(expected, actual);
        }
示例#8
0
        /// <summary>
        /// Updates the cache that contains the result of laying out the label's text.
        /// </summary>
        /// <param name="availableSize">The size of the space that is available for laying out text.</param>
        private void UpdateTextLayoutResult(Size2D availableSize)
        {
            textLayoutCommands.Clear();

            if (textParserResult.Count > 0 && Font.IsLoaded)
            {
                var unconstrainedWidth  = Double.IsPositiveInfinity(availableSize.Width) && HorizontalAlignment != HorizontalAlignment.Stretch;
                var unconstrainedHeight = Double.IsPositiveInfinity(availableSize.Height) && VerticalAlignment != VerticalAlignment.Stretch;

                var constraintX = unconstrainedWidth ? null : (Int32?)Math.Ceiling(Display.DipsToPixels(availableSize.Width));
                var constraintY = unconstrainedHeight ? null : (Int32?)Math.Ceiling(Display.DipsToPixels(availableSize.Height));

                var cursorpos = textLayoutCommands.CursorPosition;

                var textRenderingMode = TextOptions.GetTextRenderingMode(this);
                var textScript        = TextOptions.GetTextScript(this);
                var textLanguage      = TextOptions.GetTextLanguage(this);
                var textDirection     = FlowDirection == FlowDirection.RightToLeft ? TextDirection.RightToLeft : TextDirection.LeftToRight;

                var options  = (textRenderingMode == TextRenderingMode.Shaped) ? TextLayoutOptions.Shape : TextLayoutOptions.None;
                var flags    = LayoutUtil.ConvertAlignmentsToTextFlags(HorizontalContentAlignment, VerticalContentAlignment);
                var settings = new TextLayoutSettings(Font, constraintX, constraintY, flags, options, textDirection, textScript, FontStyle, null, textLanguage);

                View.Resources.TextRenderer.CalculateLayout(textParserResult, textLayoutCommands, settings);
                View.Resources.TextRenderer.UpdateCursor(textLayoutCommands, cursorpos);
            }
        }
示例#9
0
        protected override void FillLabel(HtmlNode node, PageBrush brush)
        {
            var labelNode = node.SelectSingleNodeEx("label");

            if (labelNode == null)
            {
                brush.Draw("<label class=\"control-label\" data-name=\"label\">");
                if (ShowOperation(node))
                {
                    brush.Draw("<button class=\"btn btn-sm green\" data-name=\"addItem\"><i class=\"fa fa-plus\"></i>新增项</button>");
                }
                brush.Draw("</label>");
                return;
            }

            string className = LayoutUtil.GetClassName(labelNode, "control-label");

            brush.DrawFormat("<label class=\"{0}\" data-name=\"label\">{1}", UIUtil.GetClassName(labelNode, className), labelNode.InnerText);
            if (ShowOperation(node))
            {
                brush.Draw(" &nbsp;<button class=\"btn btn-sm green\" data-name=\"addItem\"><i class=\"fa fa-plus\"></i>新增项</button>");
            }
            brush.Draw("</label>");
            brush.DrawLine();
        }
        private double EvaluateEdgeLength(
            CompoundGraph <object, IEdge <object> > compoundGraph,
            CompoundFDPLayoutAlgorithm <object, IEdge <object>, CompoundGraph <object, IEdge <object> > > algorithm,
            Dictionary <object, Size> sizes,
            double idealEdgeLength,
            double nestingFactor)
        {
            double edgeLengthError = 0.0;

            foreach (var edge in compoundGraph.Edges)
            {
                var uPos  = algorithm.VertexPositions[edge.Source];
                var vPos  = algorithm.VertexPositions[edge.Target];
                var uSize = sizes[edge.Source];
                var vSize = sizes[edge.Target];

                var uPoint = LayoutUtil.GetClippingPoint(uSize, uPos, vPos);
                var vPoint = LayoutUtil.GetClippingPoint(vSize, vPos, uPos);

                double length      = (uPoint - vPoint).Length;
                bool   isInterEdge = compoundGraph.GetParent(edge.Source) != compoundGraph.GetParent(edge.Target);
                var    iel         = isInterEdge
                              ? idealEdgeLength *
                                     (algorithm.LevelOfVertex(edge.Source) + algorithm.LevelOfVertex(edge.Target) + 1) *
                                     nestingFactor
                              : idealEdgeLength;
                double err = Math.Pow(length - iel, 2);
                edgeLengthError += err;
            }
            return(edgeLengthError);
        }
        protected virtual void FillBrowseContainer(HtmlNode node, PageBrush brush)
        {
            var browseNode = node.SelectSingleNodeEx("browse");

            if (browseNode != null)
            {
                string className = LayoutUtil.GetClassName(browseNode, "input-browse");
                className = UIUtil.GetClassName(browseNode, className);

                string proxyCode = UIUtil.GetJSONMembers(browseNode, "only", "submit");
                if (!string.IsNullOrEmpty(proxyCode))
                {
                    proxyCode = "{" + proxyCode + "}";
                }

                SealedPainter.CreateNodeCode(brush, "div", className, string.Empty, proxyCode, (pageBrush) =>
                {
                    FillBrowse(node, browseNode, pageBrush);
                },
                                             () =>
                {
                    return("data-name='browseContainer'");
                });
                //html.AppendLine(code);
            }
        }
示例#12
0
        protected override void FillCoreContainer(SealedControl obj, HtmlNode node, PageBrush brush)
        {
            var hasBrowseNode = node.SelectSingleNodeEx("browse") != null;
            var coreNode      = node.SelectSingleNodeEx("core");

            if (coreNode == null)
            {
                throw new WebException("没有指定core节点");
            }
            string className = LayoutUtil.GetClassName(coreNode, "input-extend");
            string styleCode = hasBrowseNode ? "display:none;" : string.Empty;

            if (!string.IsNullOrEmpty(styleCode))
            {
                styleCode = string.Format(" style=\"{0}\"", styleCode);
            }
            SealedPainter.CreateNodeCode(brush, "div", className, styleCode, GetCoreContainerProxyCode(node), (pageBrush) =>
            {
                FillCore(obj, node, coreNode, pageBrush);
            },
                                         () =>
            {
                return("data-name='coreContainer'");
            });
            //html.AppendLine(code);
        }
示例#13
0
        /**
         *
         *  Returns the vertical space required by the horizontal scrollbar.
         *  That's the larger of the MinViewportInset and the hsb's preferred height.
         *
         *  Computing this value is complicated by the fact that if the HSB is currently
         *  HsbVisible=false, then it's scaleX,Y will be 0, and it's preferred size is 0.
         *  For that reason we specify postLayoutTransform=false to getPreferredBoundsHeight()
         *  and then multiply by the original scale factor, _hsbScaleY.
         */
        private float HsbRequiredHeight()
        {
            Scroller      scroller         = GetScroller();
            float         minViewportInset = scroller.MinViewportInset;
            ScrollBarBase hsb = scroller.HorizontalScrollBar;

            return(Math.Max(minViewportInset, LayoutUtil.GetPreferredBoundsHeight(hsb)));
        }
        private string GetClassName(HtmlNode node, bool isSetCoreSuffix)
        {
            var defaultClassName = isSetCoreSuffix
                    ? LayoutUtil.GetClassName(node, "input-group input-extend")
                    : LayoutUtil.GetClassName(node, "input-extend");

            return(UIUtil.GetClassName(node, defaultClassName));
        }
示例#15
0
        /**
         *
         *  Returns the vertical space required by the horizontal scrollbar.
         *  That's the larger of the MinViewportInset and the hsb's preferred height.
         *
         *  Computing this value is complicated by the fact that if the HSB is currently
         *  HsbVisible=false, then it's scaleX,Y will be 0, and it's preferred size is 0.
         *  For that reason we specify postLayoutTransform=false to getPreferredBoundsWidth()
         *  and then multiply by the original scale factor, _vsbScaleX.
         */
        private float VsbRequiredWidth()
        {
            Scroller      scroller         = GetScroller();
            float         minViewportInset = scroller.MinViewportInset;
            ScrollBarBase vsb = scroller.VerticalScrollBar;
            float         sx  = (VsbVisible) ? 1 : _vsbScaleX;

            return(Math.Max(minViewportInset, LayoutUtil.GetPreferredBoundsWidth(vsb) * sx));            //vsb.getPreferredBoundsWidth(VsbVisible) * sx);
        }
示例#16
0
 //初始化点位
 private void initLocation()
 {
     this.trainResultLabelPoint = LayoutUtil.getCenterLocation(this, this.trainResultLabel);
     this.imageCenterPoint      = LayoutUtil.getCenterLocation(this, this.imageBox1);
     this.imageLeftPoint        = LayoutUtil.getLeftLocation(this, this.imageBox1);
     this.imageRightPoint       = LayoutUtil.getRightLocation(this, this.imageBox1);
     this.imageUpPoint          = LayoutUtil.getUpLocation(this, this.imageBox1);
     this.imageDownPoint        = LayoutUtil.getDownLocation(this, this.imageBox1);
 }
示例#17
0
        /*protected override void CommitProperties()
         * {
         *  base.CommitProperties();
         *
         *  if (_dataChanged)
         *  {
         *      _dataChanged = false;
         *      if (null != _buttonAdd)
         *          _buttonAdd.Text = null == _data ? string.Empty : _data.ToString();
         *  }
         * }*/

        protected override void Measure()
        {
            base.Measure();

            MeasuredWidth  = _hgroup.GetExplicitOrMeasuredWidth();
            MeasuredHeight = _hgroup.GetExplicitOrMeasuredHeight();

            MeasuredMinWidth  = LayoutUtil.GetMinBoundsWidth(_hgroup);
            MeasuredMinHeight = LayoutUtil.GetMinBoundsHeight(_hgroup);
        }
示例#18
0
        public void GetClippingPoint_Target_Outside_Source_Rect_ClippingPoint_OnBottomSide_Test()
        {
            Size  size     = new Size(10, 10);
            Point s        = new Point(5, 5);
            Point t        = new Point(20, 30);
            Point expected = new Point(8, 10);

            Point actual = LayoutUtil.GetClippingPoint(size, s, t);

            Assert.AreEqual(expected, actual);
        }
        protected override void Measure()
        {
            base.Measure();

            // label has padding of 3 on left and right and padding of 5 on top and bottom.
            MeasuredWidth  = _hGroup.GetExplicitOrMeasuredWidth();      // +6;
            MeasuredHeight = _hGroup.GetExplicitOrMeasuredHeight();     // +10;

            MeasuredMinWidth  = LayoutUtil.GetMinBoundsWidth(_hGroup);  // + 6;
            MeasuredMinHeight = LayoutUtil.GetMinBoundsHeight(_hGroup); // + 10;
        }
示例#20
0
        protected override float PointToValue(float x, float y)
        {
            if (null == Thumb || null == Track)
            {
                return(0);
            }

            var range      = Maximum - Minimum;
            var thumbRange = LayoutUtil.GetLayoutBoundsWidth(Track) - LayoutUtil.GetLayoutBoundsWidth(Thumb);

            return(Minimum + ((thumbRange != 0) ? (x / thumbRange) * range : 0));
        }
示例#21
0
        /**
         *
         *  Return true if the specified dimensions provide enough space to layout
         *  the vertical scrollbar (vsb) at its minimum size.   The VSB is assumed
         *  to be non-null and visible.
         *
         *  If includeHSB is false, we check to see if the VSB would fit if the
         *  HSB wasn't visible.
         */
        private bool VsbFits(float w, float h, bool includeHsb)
        {
            if (HsbVisible && includeHsb)
            {
                ScrollBarBase hsb = GetScroller().HorizontalScrollBar;
                w -= LayoutUtil.GetMinBoundsWidth(hsb);
                h -= LayoutUtil.GetPreferredBoundsHeight(hsb);
            }
            ScrollBarBase vsb = GetScroller().VerticalScrollBar;

            return((w >= LayoutUtil.GetPreferredBoundsWidth(vsb)) && (h >= LayoutUtil.GetMinBoundsHeight(vsb)));
        }
        private int EvaluateEdgeCrossing(
            CompoundGraph <object, IEdge <object> > compoundGraph,
            CompoundFDPLayoutAlgorithm <object, IEdge <object>, CompoundGraph <object, IEdge <object> > > algorithm,
            Dictionary <object, Size> sizes)
        {
            int crossings = 0;

            foreach (var edge in compoundGraph.Edges)
            {
                var uPos1  = algorithm.VertexPositions[edge.Source];
                var vPos1  = algorithm.VertexPositions[edge.Target];
                var uSize1 = sizes[edge.Source];
                var vSize1 = sizes[edge.Target];

                var uPoint1 = LayoutUtil.GetClippingPoint(uSize1, uPos1, vPos1);
                var vPoint1 = LayoutUtil.GetClippingPoint(vSize1, vPos1, uPos1);
                foreach (var edge2 in compoundGraph.Edges)
                {
                    if (edge == edge2)
                    {
                        continue;
                    }

                    var uPos2  = algorithm.VertexPositions[edge.Source];
                    var vPos2  = algorithm.VertexPositions[edge.Target];
                    var uSize2 = sizes[edge.Source];
                    var vSize2 = sizes[edge.Target];

                    var uPoint2 = LayoutUtil.GetClippingPoint(uSize2, uPos2, vPos2);
                    var vPoint2 = LayoutUtil.GetClippingPoint(vSize2, vPos2, uPos2);

                    Vector v1 = (vPoint1 - uPoint1);
                    Vector v2 = (vPoint2 - uPoint2);

                    if (v1 == v2 || v1 == -v2)
                    {
                        continue; //parallel edges
                    }
                    var t2 = (uPoint1.Y - uPoint2.Y + (uPoint2.X - uPoint1.X) * v1.Y / v1.X) / (v2.Y - v2.X * v1.Y / v1.X);
                    var t1 = (uPoint2.X - uPoint1.X + t2 * v2.X) / v1.X;

                    var p  = uPoint1 + t1 * v1;
                    var b1 = t1 > 0 && (p - uPoint1).Length < (vPoint1 - uPoint1).Length;
                    var b2 = t2 > 0 && (p - uPoint2).Length < (vPoint2 - uPoint2).Length;

                    if (b1 && b2)
                    {
                        crossings++;
                    }
                }
            }
            return(crossings);
        }
示例#23
0
 private void LoadNasaRSSData(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(FeedsContractType));
         FeedsContractType          feed       = (FeedsContractType)serializer.ReadObject(e.Result) ?? new FeedsContractType();
         LayoutUtil.GenerateDynamicGridSkeleton(3, ContentPanel);
         ///Generating 3 column grid
         int row = 0, col = 0;
         for (int i = 0; i < feed.value.items.Length; i++)
         {
             if (i > 0 && i % 3 == 0)
             {
                 RowDefinition newrow = new RowDefinition();
                 ContentPanel.RowDefinitions.Add(newrow);
                 col = 0;
                 row++;
             }
             Grid grid = new Grid();
             grid.Width      = 145;
             grid.Height     = 145;
             grid.Background = new SolidColorBrush(Color.FromArgb(255, 42, 58, 112));
             TextBlock date = new TextBlock();
             date.Text = DataUtil.UnixTimeStampToDateCustom(feed.value.items[i].published.utime, "MM/dd/yyyy");
             date.VerticalAlignment   = VerticalAlignment.Top;
             date.HorizontalAlignment = HorizontalAlignment.Center;
             Image img = new Image();
             img.Source  = new BitmapImage(new Uri("/Assets/Images/rss.png", UriKind.Relative));
             img.Width   = 100;
             img.Height  = 85;
             img.Opacity = 0.10;
             Grid.SetColumn(grid, col++);
             Grid.SetRow(grid, row);
             grid.Resources.Add("feedindex", i);
             grid.Tap += (o, ev) =>
             {
                 Grid broadcaster = (Grid)o;
                 PhoneApplicationService.Current.State["allfeeds"]  = feed.value.items;
                 PhoneApplicationService.Current.State["feedindex"] = broadcaster.Resources["feedindex"];
                 this.NavigationService.Navigate(new Uri("/RSSDataPage.xaml", UriKind.Relative));
             };
             grid.Children.Add(date);
             grid.Children.Add(img);
             ContentPanel.Children.Add(grid);
         }
     }
     else
     {
         MessageBox.Show(EnumUtil.getEnumDescription(MessagesEnum.ConnectionErrors.NoConnectionError));
     }
     Image.Opacity = 0.0;
 }
示例#24
0
        protected override void Measure()
        {
            base.Measure();

            //Debug.Log("Measuring... LabelDisplay: " + LabelDisplay);

            // label has padding of 3 on left and right and padding of 5 on top and bottom.
            MeasuredWidth  = LayoutUtil.GetPreferredBoundsWidth(LabelDisplay) + 6;
            MeasuredHeight = LayoutUtil.GetPreferredBoundsHeight(LabelDisplay) + 10;

            MeasuredMinWidth  = LayoutUtil.GetMinBoundsWidth(LabelDisplay) + 6;
            MeasuredMinHeight = LayoutUtil.GetMinBoundsHeight(LabelDisplay) + 10;
        }
示例#25
0
        public void GetClippingPoint_Target_Inside_Source_Rect_ClippingPoint_OnBottomSide_Test()
        {
            Size  size     = new Size(10, 10);
            Point s        = new Point(5, 5);
            Point t        = new Point(5.3, 5.5);
            Point expected = new Point(8, 10);

            Point  actual  = LayoutUtil.GetClippingPoint(size, s, t);
            double epsilon = 0.0000001;

            Assert.IsTrue(Math.Abs(expected.X - actual.X) < epsilon);
            Assert.IsTrue(Math.Abs(expected.Y - actual.Y) < epsilon);
        }
        protected virtual void FillHelp(HtmlNode node, PageBrush brush)
        {
            var helpNode = node.SelectSingleNodeEx("help");

            if (helpNode == null)
            {
                return;
            }
            string className = LayoutUtil.GetClassName(helpNode, "help-block");

            brush.DrawFormat("<span class=\"{0}\" data-name=\"help\">{1}</span>", UIUtil.GetClassName(helpNode, className), helpNode.InnerText);
            brush.DrawLine();
        }
示例#27
0
    GleePointToTransformedPointF
    (
        Microsoft.Glee.Splines.Point oGleePoint,
        Matrix oTransformationMatrix
    )
    {
        Debug.Assert(oGleePoint != null);
        Debug.Assert(oTransformationMatrix != null);
        AssertValid();

        PointF oPointF =
            new PointF( (Single)oGleePoint.X,  (Single)oGleePoint.Y );

        return ( LayoutUtil.TransformPointF(oPointF, oTransformationMatrix) );
    }
示例#28
0
        /// <summary>
        /// Updates the cache which contains the element's laid-out text.
        /// </summary>
        /// <param name="availableSize">The amount of space in which the element's text can be laid out.</param>
        private void UpdateTextLayoutCache(Size2D availableSize)
        {
            if (textLayoutCommands != null)
            {
                textLayoutCommands.Clear();
            }

            if (View == null)
            {
                return;
            }

            var content = Content;

            var contentElement = content as UIElement;

            if (contentElement == null)
            {
                if (textLayoutCommands == null)
                {
                    textLayoutCommands = new TextLayoutCommandStream();
                }

                var font      = GetValue <SourcedResource <UltravioletFont> >(TextElement.FontProperty);
                var fontStyle = GetValue <UltravioletFontStyle>(TextElement.FontStyleProperty);
                if (font.IsLoaded)
                {
                    var availableSizeInPixels = Display.DipsToPixels(availableSize);

                    var cursorpos = textLayoutCommands.CursorPosition;

                    var textRenderingMode = TextOptions.GetTextRenderingMode(this);
                    var textScript        = TextOptions.GetTextScript(this);
                    var textLanguage      = TextOptions.GetTextLanguage(this);
                    var textDirection     = FlowDirection == FlowDirection.RightToLeft ? TextDirection.RightToLeft : TextDirection.LeftToRight;

                    var options  = (textRenderingMode == TextRenderingMode.Shaped) ? TextLayoutOptions.Shape : TextLayoutOptions.None;
                    var flags    = LayoutUtil.ConvertAlignmentsToTextFlags(HorizontalAlignment, VerticalAlignment);
                    var settings = new TextLayoutSettings(font,
                                                          (Int32)Math.Ceiling(availableSizeInPixels.Width),
                                                          (Int32)Math.Ceiling(availableSizeInPixels.Height), flags, options, textDirection, textScript, fontStyle, null, textLanguage);

                    View.Resources.TextRenderer.CalculateLayout(textParserResult, textLayoutCommands, settings);
                    View.Resources.TextRenderer.UpdateCursor(textLayoutCommands, cursorpos);
                }
            }
        }
示例#29
0
        private Vector GetSpringForce(double idealLength, Point uPos, Point vPos, Size uSize, Size vSize)
        {
            var positionVector = (uPos - vPos);

            if (positionVector.Length == 0)
            {
                var compensationVector = new Vector(_random.NextDouble(), _random.NextDouble());
                positionVector = compensationVector * 2;
                uPos          += compensationVector;
                vPos          -= compensationVector;
            }

            positionVector.Normalize();

            //get the clipping points
            var c_u = LayoutUtil.GetClippingPoint(uSize, uPos, vPos);
            var c_v = LayoutUtil.GetClippingPoint(vSize, vPos, uPos);

            Vector F = (c_u - c_v);
            bool   isSameDirection = LayoutUtil.IsSameDirection(positionVector, F);
            double length          = 0;

            if (isSameDirection)
            {
                length = F.Length - idealLength;
            }
            else
            {
                length = F.Length + idealLength;
            }

            if (F.Length == 0)
            {
                F = -positionVector;
            }
            F.Normalize();
            if (length > 0)
            {
                F *= -1;
            }

            var Fs = Math.Pow(length / (idealLength), 2) / Parameters.ElasticConstant * F;

            return(Fs);
        }
示例#30
0
        /// <summary>
        /// Updates the cache that contains the result of laying out the label's text.
        /// </summary>
        /// <param name="availableSize">The size of the space that is available for laying out text.</param>
        private void UpdateTextLayoutResult(Size2D availableSize)
        {
            textLayoutCommands.Clear();

            if (textParserResult.Count > 0 && Font.IsLoaded)
            {
                var unconstrainedWidth  = Double.IsPositiveInfinity(availableSize.Width) && HorizontalAlignment != HorizontalAlignment.Stretch;
                var unconstrainedHeight = Double.IsPositiveInfinity(availableSize.Height) && VerticalAlignment != VerticalAlignment.Stretch;

                var constraintX = unconstrainedWidth  ? null : (Int32?)Math.Ceiling(Display.DipsToPixels(availableSize.Width));
                var constraintY = unconstrainedHeight ? null : (Int32?)Math.Ceiling(Display.DipsToPixels(availableSize.Height));

                var flags    = LayoutUtil.ConvertAlignmentsToTextFlags(HorizontalContentAlignment, VerticalContentAlignment);
                var settings = new TextLayoutSettings(Font, constraintX, constraintY, flags, FontStyle);

                View.Resources.TextRenderer.CalculateLayout(textParserResult, textLayoutCommands, settings);
            }
        }