当前位置: 首页>>代码示例>>C#>>正文


C# NodeViewData.GetTotalSize方法代码示例

本文整理汇总了C#中Behaviac.Design.NodeViewData.GetTotalSize方法的典型用法代码示例。如果您正苦于以下问题:C# NodeViewData.GetTotalSize方法的具体用法?C# NodeViewData.GetTotalSize怎么用?C# NodeViewData.GetTotalSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Behaviac.Design.NodeViewData的用法示例。


在下文中一共展示了NodeViewData.GetTotalSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CenterNode

        /// <summary>
        /// Centres the given node in the view.
        /// </summary>
        /// <param name="node">The node which will be centred.</param>
        internal void CenterNode(NodeViewData node) {
            _maintainNodePosition = node;

            // we use the existing maintain position stuff for that
            RectangleF bbox = node.IsFSM ? node.GetTotalBoundingBox() : node.BoundingBox;

            float width = bbox.Width <= 0.0f ? node.MinWidth : bbox.Width;
            float height = bbox.Height <= 0.0f ? node.MinHeight : bbox.Height;

            // Scale the whole graph to the suitable size in the view.
            float viewWidth = ClientSize.Width - 30;
            float viewHeight = ClientSize.Height - 30;
            bool isWidthScale = false;

            if (viewWidth > 0 && viewHeight > 0) {
                SizeF totalSize = node.GetTotalSize(_nodeLayoutManager.Padding.Width, int.MaxValue);
                float scale = 1.0f;

                if (totalSize.Width / totalSize.Height < viewWidth / viewHeight) {
                    scale = viewHeight / totalSize.Height;
                    isWidthScale = false;
                }

                else {
                    scale = viewWidth / totalSize.Width;
                    isWidthScale = true;
                }

                const float MinScale = 0.1f;
                const float MaxScale = 2.0f;

                if (scale < MinScale) {
                    _nodeLayoutManager.Scale = MinScale;
                }

                else if (scale > MaxScale) {
                    _nodeLayoutManager.Scale = MaxScale;
                }

                else {
                    _nodeLayoutManager.Scale = scale;
                }
            }

            if (node.IsFSM)
            {
                if (isWidthScale)
                    _graphOrigin = new PointF(0.0f, ClientSize.Height * 0.5f - height * 0.5f * _nodeLayoutManager.Scale);
                else
                    _graphOrigin = new PointF(ClientSize.Width * 0.5f - width * 0.5f * _nodeLayoutManager.Scale, 0.0f);
            }
            else
            {
                _graphOrigin = new PointF(20.0f, ClientSize.Height * 0.5f - height * 0.5f);
            }

            Invalidate();
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:62,代码来源:BehaviorTreeView.cs

示例2: CenterNode

        /// <summary>
        /// Centres the given node in the view.
        /// </summary>
        /// <param name="node">The node which will be centred.</param>
        internal void CenterNode(NodeViewData node)
        {
            _maintainNodePosition = node;

            // we use the existing maintain position stuff for that
            RectangleF bbox = node.BoundingBox;

            // if the node was not yet shown there is no bounding box so we simply use the min height for that
            float height = bbox.Height <= 0.0f ? node.MinHeight : bbox.Height;

            _graphOrigin = new PointF(20.0f, ClientSize.Height * 0.5f - height * 0.5f);

            // Scale the whole graph to the suitable size in the view.
            float viewWidth = ClientSize.Width - 30;
            float viewHeight = ClientSize.Height - 30;

            if (viewWidth > 0 && viewHeight > 0)
            {
                SizeF totalSize = node.GetTotalSize(_nodeLayoutManager.Padding.Width, int.MaxValue);
                float scale = 1.0f;

                if (totalSize.Width / totalSize.Height < viewWidth / viewHeight)
                    scale = viewHeight / totalSize.Height;
                else
                    scale = viewWidth / totalSize.Width;

                const float MinScale = 0.1f;
                const float MaxScale = 2.0f;

                if (scale < MinScale)
                    _nodeLayoutManager.Scale = MinScale;
                else if (scale > MaxScale)
                    _nodeLayoutManager.Scale = MaxScale;
                else
                    _nodeLayoutManager.Scale = scale;
            }

            Invalidate();
        }
开发者ID:KeyleXiao,项目名称:behaviac,代码行数:43,代码来源:BehaviorTreeView.cs


注:本文中的Behaviac.Design.NodeViewData.GetTotalSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。