Ejemplo n.º 1
0
        private void GetZMost(ref int zMost)
        {
            if (OwnerRegion == null)
            {
                return;
            }

            IRegions regions = OwnerRegion.GetChildRegions(_viewGuid);

            foreach (IRegion region in regions)
            {
                IRegionStyle regionStyle = region.GetRegionStyle(_viewGuid);

                // If region is hamburger menu, use the button location and size to caculate.
                if (region is IHamburgerMenu)
                {
                    IHamburgerMenu menu = region as IHamburgerMenu;
                    regionStyle = menu.MenuButton.GetRegionStyle(_viewGuid);
                }

                if (regionStyle != null)
                {
                    zMost = Math.Max(regionStyle.Z, zMost);
                }
            }
        }
Ejemplo n.º 2
0
        private void GetBottomMost(ref double bottomMost)
        {
            if (OwnerRegion == null)
            {
                return;
            }

            IRegions regions = OwnerRegion.GetChildRegions(_viewGuid);

            foreach (IRegion region in regions)
            {
                IRegionStyle regionStyle = region.GetRegionStyle(_viewGuid);

                // If region is hamburger menu, use the button location and size to caculate.
                if (region is IHamburgerMenu)
                {
                    IHamburgerMenu menu = region as IHamburgerMenu;
                    regionStyle = menu.MenuButton.GetRegionStyle(_viewGuid);
                }

                if (regionStyle != null)
                {
                    if (regionStyle.Rotate == 0)
                    {
                        bottomMost = Math.Max(regionStyle.Y + regionStyle.Height, bottomMost);
                    }
                    else
                    {
                        double x     = regionStyle.X;
                        double y     = regionStyle.Y;
                        double xc    = (regionStyle.X * 2 + regionStyle.Width) / 2;
                        double yc    = (regionStyle.Y * 2 + regionStyle.Height) / 2;
                        double angle = Math.Abs(regionStyle.Rotate) % 180;
                        if (angle > 90)
                        {
                            angle = 180 - angle;
                        }
                        double Kc = Math.Cos(angle * Math.PI / 180);
                        double Ks = Math.Sin(angle * Math.PI / 180);

                        double yr     = yc - (Ks * (xc - x) + Kc * (yc - y));
                        double height = regionStyle.Height + (y - yr) * 2;
                        bottomMost = Math.Max(yr + height, bottomMost);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("{");

            if (_adaptiveView != _group.ParentDocument.AdaptiveViewSet.Base)
            {
                builder.AppendFormat("\"adaptiveViewID\":\"{0}\",", _adaptiveView.Guid);
            }

            IRegionStyle groupStyle = _group.GetRegionStyle(_adaptiveView.Guid);

            if (groupStyle != null)
            {
                builder.AppendFormat("\"width\":\"{0}px\",", Math.Round(groupStyle.Width));
                builder.AppendFormat("\"height\":\"{0}px\",", Math.Round(groupStyle.Height));
            }

            // If this is top group, generate absolute location value.
            if (_group.ParentGroup == null)
            {
                builder.AppendFormat("\"top\":\"{0}px\",", Math.Round(groupStyle.Y));
                builder.AppendFormat("\"left\":\"{0}px\",", Math.Round(groupStyle.X));
            }
            else
            {
                // Child group, generate relative location value, relative to top level parent group.
                IGroup       topLevelParentGroup      = GetTopLevelParentGroup(_group);
                IRegionStyle topLevelParentGroupStyle = topLevelParentGroup.GetRegionStyle(_adaptiveView.Guid);

                builder.AppendFormat("\"top\":\"{0}px\",", Math.Round(groupStyle.Y - topLevelParentGroupStyle.Y));
                builder.AppendFormat("\"left\":\"{0}px\",", Math.Round(groupStyle.X - topLevelParentGroupStyle.X));
            }

            // In current design, Z-Order doesn't support adaptive view.
            //builder.AppendFormat("\"z-index\":{0},", groupStyle.Z);
            IRegionStyle groupBaseViewStyle = _group.RegionStyle;

            builder.AppendFormat("\"z-index\":{0},", groupBaseViewStyle.Z);

            // http://bts1.navercorp.com/nhnbts/browse/DSTUDIO-1357
            // The "display" of group is none only if all child widgets is hidden.
            string visibility = "block";

            if (HasVisibleChildWidget(_group, _adaptiveView, true) == false)
            {
                visibility = "none";
            }
            builder.AppendFormat("\"display\":\"{0}\",", visibility);

            string position = "absolute";

            if (HasUnfixedChildWidget(_group, _adaptiveView, true) == false)
            {
                position = "fixed";
            }
            builder.AppendFormat("\"position\":\"{0}\",", position);

            JsHelper.RemoveLastComma(builder);

            builder.Append("}");

            return(builder.ToString());
        }