Helper class for managing graph layouts.
This class is meant for use in applications that allow the user to select a graph layout via a ToolStripSplitButton that has one item per available layout. It provides methods for populating the ToolStripSplitButton and for creating a layout of the selected type.

Call AddItems during application initialization. When the user clicks one of the items added by this method, the event fires. In the event handler, call LayoutManager.CreateLayout to create a layout of the selected type.

The ToolStripSplitButton object used with this class ends up behaving like a ToolStripComboBox with a DropDownStyle of DropDownList. It improves on the ToolStripComboBox, however, in that its drop-down list can contain other clickable items, whereas the ToolStripComboBox can contain nothing but items that display text. If the caller has added drop-down items to the ToolStripSplitButton object before calling AddItems, this class will preserve those items.

Inheritance: LayoutManager
コード例 #1
0
        public LayoutControl()
        {
            InitializeComponent();

            GeneralUserSettings oGeneralUserSettings = new GeneralUserSettings();
            oGeneralUserSettings.NotUseWorkbookSettings();
            LayoutUserSettings oLayoutUserSettings = new LayoutUserSettings();
            oLayoutUserSettings.NotUseWorkbookSettings();

            LayoutType eInitialLayout = oLayoutUserSettings.Layout;
//            LayoutType eInitialLayout = LayoutType.FruchtermanReingold;

            // Instantiate an object that populates the tssbLayout
            // ToolStripSplitButton and handles its LayoutChanged event.

            m_oLayoutManagerForToolStripSplitButton =
                new LayoutManagerForToolStripSplitButton();

            m_oLayoutManagerForToolStripSplitButton.AddItems(this.tssbLayout);
            m_oLayoutManagerForToolStripSplitButton.Layout = eInitialLayout;
            m_oLayoutManagerForToolStripSplitButton.LayoutChanged +=
                new EventHandler(
                    this.LayoutManagerForToolStripSplitButton_LayoutChanged);

            CreateNodeXLControl();
            CreateGraphZoomAndScaleControl();

//            ApplyGeneralUserSettings(oGeneralUserSettings);
            ApplyLayoutUserSettings(oLayoutUserSettings);

            AssertValid();
        }
コード例 #2
0
    //*************************************************************************
    //  Constructor: TaskPane()
    //
    /// <summary>
    /// Initializes a new instance of the <see cref="TaskPane" /> class.
    /// </summary>
    ///
    /// <param name="thisWorkbook">
    /// The workbook.
    /// </param>
    ///
    /// <param name="ribbon">
    /// The application's ribbon.
    /// </param>
    //*************************************************************************

    public TaskPane
    (
        ThisWorkbook thisWorkbook,
        Ribbon ribbon
    )
    {
        Debug.Assert(thisWorkbook != null);
        Debug.Assert(ribbon != null);

        InitializeComponent();
        InitializeSplashScreen();

        m_oThisWorkbook = thisWorkbook;
        m_oWorkbook = thisWorkbook.InnerObject;
        m_oRibbon = ribbon;

        // The WpfImageUtil uses the screen DPI in its image handling.

        Graphics oGraphics = this.CreateGraphics();
        WpfImageUtil.ScreenDpi = oGraphics.DpiX;
        oGraphics.Dispose();

        // Get the template version from the per-workbook settings.

        PerWorkbookSettings oPerWorkbookSettings =
            this.PerWorkbookSettings;

        m_iTemplateVersion = oPerWorkbookSettings.TemplateVersion;

        m_bHandlingLayoutChanged = false;
        m_iEnableGraphControlsCount = 0;
        m_oEdgeRowIDDictionary = null;
        m_oVertexRowIDDictionary = null;
        m_oSaveGraphImageFileDialog = null;
        m_oDynamicFilterDialog = null;
        m_oReadabilityMetricsDialog = null;

        GeneralUserSettings oGeneralUserSettings = new GeneralUserSettings();
        LayoutUserSettings oLayoutUserSettings = new LayoutUserSettings();

        LayoutType eInitialLayout = oLayoutUserSettings.Layout;

        // Instantiate an object that populates the tssbLayout
        // ToolStripSplitButton and handles its LayoutChanged event.

        m_oLayoutManagerForToolStripSplitButton =
            new LayoutManagerForToolStripSplitButton();

        m_oLayoutManagerForToolStripSplitButton.AddItems(this.tssbLayout);
        m_oLayoutManagerForToolStripSplitButton.Layout = eInitialLayout;

        // Instantiate an object that populates the msiContextLayout
        // context menu and handles the Clicked events on the child menu items.

        m_oLayoutManagerForContextMenu = new LayoutManagerForMenu();
        m_oLayoutManagerForContextMenu.AddMenuItems(this.msiContextLayout);
        m_oLayoutManagerForContextMenu.Layout = eInitialLayout;

        m_oLayoutManagerForToolStripSplitButton.LayoutChanged +=
            new EventHandler(
                this.LayoutManagerForToolStripSplitButton_LayoutChanged);

        m_oLayoutManagerForContextMenu.LayoutChanged +=
            new EventHandler(this.LayoutManagerForContextMenu_LayoutChanged);

        // The context menu for groups should be enabled only if the template
        // supports groups.

        MenuUtil.EnableToolStripMenuItems(
            m_iTemplateVersion > GroupManager.MinimumTemplateVersionForGroups,
            msiContextGroups);

        thisWorkbook.VisualAttributeSetInWorkbook +=
            new EventHandler(ThisWorkbook_VisualAttributeSetInWorkbook);

        thisWorkbook.WorksheetContextMenuManager.RequestVertexCommandEnable +=
            new RequestVertexCommandEnableEventHandler(
                WorksheetContextMenuManager_RequestVertexCommandEnable);

        thisWorkbook.WorksheetContextMenuManager.RequestEdgeCommandEnable +=
            new RequestEdgeCommandEnableEventHandler(
                WorksheetContextMenuManager_RequestEdgeCommandEnable);

        m_oRibbon.Layout = eInitialLayout;

        CreateNodeXLControl();
        CreateGraphZoomAndScaleControl();

        ApplyGeneralUserSettings(oGeneralUserSettings);
        ApplyLayoutUserSettings(oLayoutUserSettings);

        // Don't show the legend now.  If it is supposed to be shown, the
        // Ribbon, which is responsible for maintaining the visibility of the
        // legend, will send a NoParamCommand.ShowGraphLegend command to the
        // TaskPane later.

        this.ShowGraphLegend = false;

        UpdateAutoFillResultsLegend(oPerWorkbookSettings);
        UpdateDynamicFiltersLegend();
        UpdateAxes(oPerWorkbookSettings);

        CommandDispatcher.CommandSent +=
            new RunCommandEventHandler(this.CommandDispatcher_CommandSent);

        AssertValid();
    }