Beispiel #1
0
        /// <summary>
        /// Redraws the graph with the specified layout type
        /// </summary>
        /// <param name="layout">Type of graph layout</param>
        /// <param name="isAnimated">Specifies whether or not to animate the graph when it's laid out</param>
        /// <param name="scope">Specifies the default graph scope</param>
        /// <param name="rootNode">Specifies the root node for layouts that require one</param>
        public void LayoutGraph(LayoutBase layout, bool isAnimated, string scope, NodeViewModelBase rootNode)
        {
            LayoutManager flyweight = LayoutManager.Instance;

            // Make sure we have a scope
            if (String.IsNullOrWhiteSpace(scope))
            {
                scope = this.defaultComponentInstanceScope;
            }

            // Get the graph as a GraphMapData object
            GraphMapData graphMapData = GetGraphComponents(scope).ExportGraph();

            // Execute the layout
            DispatcherHelper.UIDispatcher.BeginInvoke(() =>
            {
                if (rootNode != null)
                {
                    layout.CalculateLayout(graphMapData, rootNode.ParentNode);
                }
                else
                {
                    layout.CalculateLayout(graphMapData);
                }

                System.Diagnostics.Debug.WriteLine("");
                foreach (Delegate d in ContextMenuManager.Instance.GetContextMenuOpeningInvocationList())
                {
                    System.Diagnostics.Debug.WriteLine((d.Target as GraphComponents).Scope);
                }

                layout.PositionNodes(isAnimated, graphMapData);
            });
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="layoutName"></param>
        private void LayoutGraph(string layoutName)
        {
            // Get a light weight version of the graph data to be
            // used with the layout
            GraphMapData graphMapData = GraphComponentsUtility.GetGraph(GraphManager.Instance.GetGraphComponents(scope));

            // Get the instance of the LinLog layout
            LayoutBase graphLayout = LayoutManager.Instance.GetLayoutByName(layoutName);

            // Wire up the LayoutFinished event
            graphLayout.LayoutFinished += new EventHandler(LayoutFinishedHandler);

            // Execute the layout on the UI thread
            DispatcherHelper.UIDispatcher.BeginInvoke(() =>
            {
                graphLayout.CalculateLayout(graphMapData);
                graphLayout.PositionNodes(false, graphMapData);
            });
        }