예제 #1
0
 /// <summary>
 /// Handles the DataLoaded event
 /// </summary>
 /// <param name="args">The arguments for the event</param>
 public void DataLoadedEventHandler(DataLoadedEventArgs args)
 {
     if (args.SourceMechanism == CreationType.Live)
     {
         LayoutGraph(LayoutManager.Instance.ActiveLayout, false, args.Scope);
     }
     else if (AllNodesHaveSamePosition(args.Scope))
     {
         // Layout the graph
         LayoutGraph(LayoutManager.Instance.DefaultLayout, true, args.Scope);
     }
     else
     {
         // Just resize the graph to fit
         UI.GraphViewModel graphVM = UI.ViewModelLocator.GraphDataStatic;
         graphVM.ResizeToFit();
     }
 }
예제 #2
0
        /// <summary>
        /// Handles the ToolbarItemClicked event
        /// </summary>
        /// <param name="args">The arguments for the event</param>
        public void ToolbarItemClickedEventHandler(ToolBarItemEventArgs args)
        {
            NodeViewModelBase rootNode = GetGraphComponents(args.Scope).NodeSelector.SelectedNode;

            // TODO: USE CONSTANT FOR ITEM NAME
            // TODO: Controls should control their own behavior
            if (args.ToolBarItem.Name == "GENERATOR")
            {
                CreateRandomGraph(args.Scope);
            }
            else if (args.ToolBarItem.Name.EndsWith("_LAYOUT"))
            {
                LayoutBase layout = InitializeLayout(args.ToolBarItem.Name, args.Scope);

                // Perform the layout
                LayoutGraph(layout, false, args.Scope, rootNode);
            }
            else if (args.ToolBarItem.Name == "IMPORT")
            {
                PerformImport(args.Scope, new GraphMLGraphDataFormat());     // TODO: Determine which type at runtime
            }
            else if (args.ToolBarItem.Name == "EXPORT")
            {
                PerformExport(args.Scope);
            }
            else if (args.ToolBarItem.Name == "GRAPH_TO_IMAGE")
            {
                SaveGraphAsImage();
            }
            else if (args.ToolBarItem.Name == "PRINT_GRAPH")
            {
                PrintGraph();
            }
            else if (args.ToolBarItem.Name == "RESIZE")
            {
                UI.GraphViewModel graphVM = UI.ViewModelLocator.GraphDataStatic;
                graphVM.ResizeToFit();

                //TODO:  THIS SHOULD BE DECOUPLED
            }
        }