Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DiagramItem" /> class.
        /// </summary>
        /// <param name="definition">The definition.</param>
        /// <param name="diagramContext">The diagram context.</param>
        internal DiagramItem(DiagramItemDefinition definition, DiagramContext diagramContext)
        {
            Definition = definition;
            DiagramContext = diagramContext;
            ContainingDiagramCanvas = Output;

            initialize();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DiagramItem" /> class.
        /// </summary>
        /// <param name="definition">The definition.</param>
        /// <param name="parentItem">The parent item.</param>
        /// <param name="slot">The slot.</param>
        internal DiagramItem(DiagramItemDefinition definition, DiagramItem parentItem, SlotCanvas slot)
        {
            ContainingDiagramCanvas = slot;
            Definition = definition;
            ParentItem = parentItem;
            ParentItem._children.Add(this);
            DiagramContext = parentItem.DiagramContext;

            initialize();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private void initialize()
        {
            if (Definition.GlobalPosition.HasValue)
                GlobalPosition = Definition.GlobalPosition.Value;

            if (IsRootItem)
            {
                DiagramCanvasBase.SetPosition(this, GlobalPosition);
            }

            InitializeComponent();

            setEdits();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Set initial positions of given children
        /// </summary>
        /// <param name="parent">Parent of children</param>
        /// <param name="container">Container where children are displayed</param>
        /// <param name="children">Children which positions will be initialized</param>
        private void setInitialPositions(DiagramItem parent, DiagramCanvasBase container, IEnumerable <DiagramItem> children)
        {
            var isRoot     = parent == null;
            var lastCursor = isRoot ? _rootCursor : parent.PositionCursor;

            var needsInitialPositions = lastCursor == null;

            if (needsInitialPositions)
            {
                var  cursor = new PositionCursor();
                Size lastLayoutSize;

                if (isRoot)
                {
                    //root has no owner, because of that has special cursor
                    _rootCursor = cursor;
                    //we dont want to limit size of root canvas
                    lastLayoutSize = new Size();
                }
                else
                {
                    //owner should keep their cursors
                    parent.PositionCursor = cursor;
                    lastLayoutSize        = container.DesiredSize;
                }

                //inform cursor about items
                foreach (var child in children)
                {
                    setInitialPosition(cursor, child);
                }

                //update positions of children
                cursor.UpdatePositions(lastLayoutSize);
            }

            foreach (var child in children)
            {
                child.GlobalPosition = checkBounds(child, child.GlobalPosition);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Arrange children of given owner according to Arrange algorithm
        /// </summary>
        /// <param name="owner">Owner which children will be arranged</param>
        /// <param name="container">Container where children are arranged</param>
        internal Size ArrangeChildren(DiagramItem owner, DiagramCanvasBase container)
        {
            var isRoot   = owner == null;
            var children = isRoot ? _rootItems : owner.Children;

            setInitialPositions(owner, container, children);

            if (Output.DiagramContext.Diagram.UseItemAvoidance)
            {
                var collisionRepairer = new ItemCollisionRepairer();
                collisionRepairer.Arrange(children);
            }

            //create navigator after items are positioned
            Navigator = new SceneNavigator(Items);

            var borders = getChildrenBorders(children);

            refreshJoinPaths();

            return(borders);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Get position of given item
 /// </summary>
 /// <param name="item">Item which position is returned</param>
 /// <returns>Item's position</returns>
 internal Point GetPosition(FrameworkElement item)
 {
     return(DiagramCanvasBase.GetPosition(item));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Set position of given item
 /// </summary>
 /// <param name="item">Positioned item</param>
 /// <param name="position">Position of item</param>
 internal void SetPosition(FrameworkElement item, Point position)
 {
     DiagramCanvasBase.SetPosition(item, position);
 }