Inheritance: NodeXLApplicationSettingsBase
Exemplo n.º 1
0
        CreateNodeXLVisual
        (
            GeneralUserSettings oGeneralUserSettings
        )
        {
            Debug.Assert(oGeneralUserSettings != null);
            AssertValid();

            NodeXLVisual oNodeXLVisual = new NodeXLVisual();

            GraphDrawer oGraphDrawer = oNodeXLVisual.GraphDrawer;

            VertexDrawer oVertexDrawer = oGraphDrawer.VertexDrawer;

            EdgeDrawer oEdgeDrawer = oGraphDrawer.EdgeDrawer;

            oGeneralUserSettings.TransferToGraphDrawer(oGraphDrawer);

            // Override some of the user's settings.

            oVertexDrawer.Shape  = VertexShape.Disk;
            oVertexDrawer.Radius = 2.0;
            oEdgeDrawer.Width    = 1;

            return(oNodeXLVisual);
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        CreateGraphDrawingContext
        (
            Rectangle oSubgraphRectangle,
            GeneralUserSettings oGeneralUserSettings
        )
        {
            Debug.Assert(oGeneralUserSettings != null);
            AssertValid();

            return(new GraphDrawingContext(
                       WpfGraphicsUtil.RectangleToRect(oSubgraphRectangle), Margin,
                       WpfGraphicsUtil.ColorToWpfColor(oGeneralUserSettings.BackColor)
                       ));
        }
Exemplo n.º 4
0
        CreateSubgraphImagesAsync
        (
            IGraph graph,
            ICollection <IVertex> selectedVertices,
            Decimal levels,
            Boolean saveToFolder,
            String folder,
            Size imageSizePx,
            ImageFormat imageFormat,
            Boolean createThumbnails,
            Size thumbnailSizePx,
            Boolean selectedVerticesOnly,
            Boolean selectVertex,
            Boolean selectIncidentEdges,
            GeneralUserSettings generalUserSettings,
            LayoutUserSettings layoutUserSettings
        )
        {
            Debug.Assert(graph != null);
            Debug.Assert(selectedVertices != null);
            Debug.Assert(levels >= 0);
            Debug.Assert(Decimal.Remainder(levels, 0.5M) == 0M);
            Debug.Assert(!saveToFolder || !String.IsNullOrEmpty(folder));
            Debug.Assert(!saveToFolder || imageSizePx.Width > 0);
            Debug.Assert(!saveToFolder || imageSizePx.Height > 0);
            Debug.Assert(!createThumbnails || thumbnailSizePx.Width > 0);
            Debug.Assert(!createThumbnails || thumbnailSizePx.Height > 0);
            Debug.Assert(generalUserSettings != null);
            AssertValid();

            const String MethodName = "CreateSubgraphImagesAsync";

            if (this.IsBusy)
            {
                throw new InvalidOperationException(String.Format(

                                                        "{0}:{1}: An asynchronous operation is already in progress."
                                                        ,
                                                        this.ClassName,
                                                        MethodName
                                                        ));
            }

            // Wrap the arguments in an object that can be passed to
            // BackgroundWorker.RunWorkerAsync().

            CreateSubgraphImagesAsyncArgs oCreateSubgraphImagesAsyncArgs =
                new CreateSubgraphImagesAsyncArgs();

            oCreateSubgraphImagesAsyncArgs.Graph            = graph;
            oCreateSubgraphImagesAsyncArgs.SelectedVertices = selectedVertices;
            oCreateSubgraphImagesAsyncArgs.Levels           = levels;
            oCreateSubgraphImagesAsyncArgs.SaveToFolder     = saveToFolder;
            oCreateSubgraphImagesAsyncArgs.Folder           = folder;
            oCreateSubgraphImagesAsyncArgs.ImageSizePx      = imageSizePx;
            oCreateSubgraphImagesAsyncArgs.ImageFormat      = imageFormat;
            oCreateSubgraphImagesAsyncArgs.CreateThumbnails = createThumbnails;
            oCreateSubgraphImagesAsyncArgs.ThumbnailSizePx  = thumbnailSizePx;

            oCreateSubgraphImagesAsyncArgs.SelectedVerticesOnly =
                selectedVerticesOnly;

            oCreateSubgraphImagesAsyncArgs.SelectVertex = selectVertex;

            oCreateSubgraphImagesAsyncArgs.SelectIncidentEdges =
                selectIncidentEdges;

            oCreateSubgraphImagesAsyncArgs.GeneralUserSettings =
                generalUserSettings;

            oCreateSubgraphImagesAsyncArgs.Layout =
                CreateLayout(layoutUserSettings);

            oCreateSubgraphImagesAsyncArgs.Layout.Margin = Margin;

            // Note: the NodeXLVisual object can't be created yet, because it must
            // be created on the same thread that uses it.  It will get created by
            // BackgroundWorker_DoWork().

            oCreateSubgraphImagesAsyncArgs.NodeXLVisual = null;

            // Create a BackgroundWorker and handle its events.

            m_oBackgroundWorker = new BackgroundWorker();

            m_oBackgroundWorker.WorkerReportsProgress      = true;
            m_oBackgroundWorker.WorkerSupportsCancellation = true;

            m_oBackgroundWorker.DoWork += new DoWorkEventHandler(
                BackgroundWorker_DoWork);

            m_oBackgroundWorker.ProgressChanged +=
                new ProgressChangedEventHandler(BackgroundWorker_ProgressChanged);

            m_oBackgroundWorker.RunWorkerCompleted +=
                new RunWorkerCompletedEventHandler(
                    BackgroundWorker_RunWorkerCompleted);

            m_oBackgroundWorker.RunWorkerAsync(oCreateSubgraphImagesAsyncArgs);
        }
Exemplo n.º 5
0
    ReadWorkbook
    (
        Boolean bLayOutGraph
    )
    {
        AssertValid();

        if (oNodeXLControl.IsLayingOutGraph)
        {
            return;
        }

        RemoveSplashScreen();

        if (
            !this.NonEmptyWorkbookRead
            && this.LayoutIsNull
            && !ShowLayoutTypeIsNullNotification()
            )
        {
            return;
        }

        // This is in case another open workbook has modified the user
        // settings.

        GeneralUserSettings oGeneralUserSettings = new GeneralUserSettings();
        GroupUserSettings oGroupUserSettings = new GroupUserSettings();

        ApplyGeneralUserSettings(oGeneralUserSettings);
        ApplyLayoutUserSettings( new LayoutUserSettings() );

        ReadWorkbookContext oReadWorkbookContext = new ReadWorkbookContext();

        oReadWorkbookContext.IgnoreVertexLocations = false;
        oReadWorkbookContext.GraphRectangle = this.GraphRectangle;
        oReadWorkbookContext.FillIDColumns = true;
        oReadWorkbookContext.ReadGroups = oGroupUserSettings.ReadGroups;
        oReadWorkbookContext.ReadEdgeWeights = true;

        oReadWorkbookContext.ReadVertexColorFromGroups =
            oGroupUserSettings.ReadVertexColorFromGroups;

        oReadWorkbookContext.ReadVertexShapeFromGroups =
            oGroupUserSettings.ReadVertexShapeFromGroups;

        oReadWorkbookContext.ReadVertexLabels = m_oRibbon.ReadVertexLabels;
        oReadWorkbookContext.ReadEdgeLabels = m_oRibbon.ReadEdgeLabels;
        oReadWorkbookContext.ReadGroupLabels = m_oRibbon.ReadGroupLabels;
        oReadWorkbookContext.ReadVertexImages = true;

        oReadWorkbookContext.DefaultVertexImageSize =
            oGeneralUserSettings.VertexImageSize;

        oReadWorkbookContext.DefaultVertexShape =
            oGeneralUserSettings.VertexShape;

        // Populate the vertex worksheet.  This isn't strictly necessary, but
        // it does enable the vertex worksheet to be updated when the user
        // edits vertex attributes in the NodeXL graph.  (If the vertex
        // worksheet is missing, vertex attributes can still be edited in the
        // graph; the edits just won't get saved in the workbook.)

        oReadWorkbookContext.PopulateVertexWorksheet = true;

        WorkbookReader oWorkbookReader = new WorkbookReader();

        m_oEdgeRowIDDictionary = null;
        m_oVertexRowIDDictionary = null;

        EnableGraphControls(false);

        try
        {
            // Read the workbook into a Graph object.

            IGraph oGraph = oWorkbookReader.ReadWorkbook(
                m_oWorkbook, oReadWorkbookContext);

            // Save the edge and vertex dictionaries that were created by
            // WorkbookReader.

            m_oEdgeRowIDDictionary = oReadWorkbookContext.EdgeRowIDDictionary;

            m_oVertexRowIDDictionary =
                oReadWorkbookContext.VertexRowIDDictionary;

            // Load the NodeXLControl with the resulting graph.

            oNodeXLControl.Graph = oGraph;

            // Collapse any groups that are supposed to be collapsed.

            CollapseOrExpandGroups(GetGroupNamesToCollapse(oGraph), true,
                false);

            // Enable tooltips in case tooltips were specified in the workbook.

            oNodeXLControl.ShowVertexToolTips = true;

            // If the dynamic filter dialog is open, read the dynamic filter
            // columns it filled in.

            if (m_oDynamicFilterDialog != null)
            {
                ReadDynamicFilterColumns(false);

                DynamicFilterHandler.ReadFilteredAlpha(m_oDynamicFilterDialog,
                    oNodeXLControl, false);
            }

            oNodeXLControl.DrawGraph(bLayOutGraph);

            PerWorkbookSettings oPerWorkbookSettings =
                this.PerWorkbookSettings;

            UpdateAutoFillResultsLegend(oPerWorkbookSettings);
            UpdateDynamicFiltersLegend();
            UpdateAxes(oPerWorkbookSettings);
            UpdateGraphHistory(oPerWorkbookSettings);
        }
        catch (Exception oException)
        {
            // If exceptions aren't caught here, Excel consumes them without
            // indicating that anything is wrong.  This can result in the graph
            // controls remaining disabled, among other problems.

            ErrorUtil.OnException(oException);
        }
        finally
        {
            EnableGraphControls(true);
        }

        // Change the button text to indicate that if any of the buttons is
        // clicked again, the graph will be read again.

        tsbReadWorkbook.Text = msiContextReadWorkbook.Text =
            m_oRibbon.ReadWorkbookButtonText =
            "Refresh Graph";
    }
Exemplo n.º 6
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();
    }
Exemplo n.º 7
0
    ApplyGeneralUserSettings
    (
        GeneralUserSettings oGeneralUserSettings
    )
    {
        Debug.Assert(oGeneralUserSettings != null);
        AssertValid();

        oGeneralUserSettings.TransferToNodeXLWithAxesControl(
            m_oNodeXLWithAxesControl);
    }
Exemplo n.º 8
0
    EditGeneralUserSettings()
    {
        AssertValid();

        if (oNodeXLControl.IsLayingOutGraph)
        {
            return;
        }

        GeneralUserSettings oGeneralUserSettings = new GeneralUserSettings();

        GeneralUserSettingsDialog oGeneralUserSettingsDialog =
            new GeneralUserSettingsDialog(oGeneralUserSettings, m_oWorkbook);

        if (oGeneralUserSettingsDialog.ShowDialog() == DialogResult.OK)
        {
            oGeneralUserSettings.Save();
            ApplyGeneralUserSettings(oGeneralUserSettings);
            oNodeXLControl.DrawGraph();
        }
    }
Exemplo n.º 9
0
    LoadUserSettings()
    {
        AssertValid();

        GeneralUserSettings oGeneralUserSettings = new GeneralUserSettings();

        this.ReadVertexLabels = oGeneralUserSettings.ReadVertexLabels;
        this.ReadEdgeLabels = oGeneralUserSettings.ReadEdgeLabels;
        this.ReadGroupLabels = oGeneralUserSettings.ReadGroupLabels;
        this.ShowGraphLegend = oGeneralUserSettings.ShowGraphLegend;
        this.ShowGraphAxes = oGeneralUserSettings.ShowGraphAxes;
    }
Exemplo n.º 10
0
        protected void ShowGraph(Boolean bLayOutGraph)
        {
            AssertValid();

            if (m_oNodeXLControl.IsLayingOutGraph)
            {
                return;
            }
            GeneralUserSettings oGeneralUserSettings = new GeneralUserSettings();
            oGeneralUserSettings.NotUseWorkbookSettings();
            LayoutUserSettings oLayoutUserSettings = new LayoutUserSettings();
            oLayoutUserSettings.NotUseWorkbookSettings();

            ApplyGeneralUserSettings(oGeneralUserSettings);
            ApplyLayoutUserSettings(oLayoutUserSettings);
            EnableGraphControls(false);

            try
            {
                IGraphAdapter oGraphAdapter = new SimpleGraphAdapter();
                m_oNodeXLControl.Graph = oGraphAdapter.LoadGraphFromFile(
                    "..\\..\\SampleGraph.txt");

                //IGraph oGraph = oWorkbookReader.ReadWorkbook(
                //    m_oWorkbook, oReadWorkbookContext);

                // Load the NodeXLControl with the resulting graph.

                //m_oNodeXLControl.Graph = oGraph;

                // Collapse any groups that are supposed to be collapsed.

                //CollapseOrExpandGroups(GetGroupNamesToCollapse(oGraph), true,
                //    false);

                // Enable tooltips in case tooltips were specified in the workbook.

                m_oNodeXLControl.ShowVertexToolTips = true;

                // If the dynamic filter dialog is open, read the dynamic filter
                // columns it filled in.

                m_oNodeXLControl.DrawGraph(bLayOutGraph);

            }
            catch (Exception oException)
            {
                // If exceptions aren't caught here, Excel consumes them without
                // indicating that anything is wrong.  This can result in the graph
                // controls remaining disabled, among other problems.

                ErrorUtil.OnException(oException);
            }
            finally
            {
                EnableGraphControls(true);
            }

            // Change the button text to indicate that if any of the buttons is
            // clicked again, the graph will be read again.

            tsbShowGraph.Text = "Refresh Graph";

        }
Exemplo n.º 11
0
        //*************************************************************************
        //  Constructor: GeneralUserSettingsDialog()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="GeneralUserSettingsDialog" /> class.
        /// </summary>
        ///
        /// <param name="generalUserSettings">
        /// The object being edited.
        /// </param>
        ///
        /// <param name="workbook">
        /// Workbook containing the graph data.
        /// </param>
        //*************************************************************************

        public GeneralUserSettingsDialog
        (
            GeneralUserSettings generalUserSettings,
            Microsoft.Office.Interop.Excel.Workbook workbook
        )
        {
            Debug.Assert(generalUserSettings != null);
            Debug.Assert(workbook != null);
            generalUserSettings.AssertValid();

            m_oGeneralUserSettings = generalUserSettings;
            m_oWorkbook            = workbook;
            m_oAxisFont            = m_oGeneralUserSettings.AxisFont;
            m_oLabelUserSettings   = m_oGeneralUserSettings.LabelUserSettings;

            m_oOpenFileDialog = new OpenFileDialog();

            m_oOpenFileDialog.Filter =
                "All files (*.*)|*.*|" + SaveableImageFormats.Filter
            ;

            m_oOpenFileDialog.Title = "Browse for Background Image";

            // Instantiate an object that saves and retrieves the position of this
            // dialog.  Note that the object automatically saves the settings when
            // the form closes.

            m_oGeneralUserSettingsDialogUserSettings =
                new GeneralUserSettingsDialogUserSettings(this);

            InitializeComponent();

            nudEdgeWidth.Minimum =
                (Decimal)EdgeWidthConverter.MinimumWidthWorkbook;

            nudEdgeWidth.Maximum =
                (Decimal)EdgeWidthConverter.MaximumWidthWorkbook;

            nudRelativeArrowSize.Minimum =
                (Decimal)EdgeDrawer.MinimumRelativeArrowSize;

            nudRelativeArrowSize.Maximum =
                (Decimal)EdgeDrawer.MaximumRelativeArrowSize;

            cbxEdgeBezierDisplacementFactor.PopulateWithObjectsAndText(
                0.1, "Low",
                0.2, "Medium",
                0.6, "High",
                1.2, "Very High"
                );

            cbxEdgeBundlerStraightening.PopulateWithObjectsAndText(
                0.15F, "Tight",
                0.40F, "Medium",
                0.60F, "Loose"
                );

            nudVertexRadius.Minimum = nudVertexImageSize.Minimum =
                (Decimal)VertexRadiusConverter.MinimumRadiusWorkbook;

            nudVertexRadius.Maximum = nudVertexImageSize.Maximum =
                (Decimal)VertexRadiusConverter.MaximumRadiusWorkbook;

            (new VertexShapeConverter()).PopulateComboBox(cbxVertexShape, false);

            nudVertexAlpha.Minimum = nudEdgeAlpha.Minimum =
                (Decimal)AlphaConverter.MinimumAlphaWorkbook;

            nudVertexAlpha.Maximum = nudEdgeAlpha.Maximum =
                (Decimal)AlphaConverter.MaximumAlphaWorkbook;

            nudVertexRelativeOuterGlowSize.Minimum =
                (Decimal)VertexDrawer.MinimumRelativeOuterGlowSize;

            nudVertexRelativeOuterGlowSize.Maximum =
                (Decimal)VertexDrawer.MaximumRelativeOuterGlowSize;

            DoDataExchange(false);

            AssertValid();
        }
    CreateGraphDrawingContext
    (
        Rectangle oSubgraphRectangle,
        GeneralUserSettings oGeneralUserSettings
    )
    {
        Debug.Assert(oGeneralUserSettings != null);
        AssertValid();

        return ( new GraphDrawingContext(
            WpfGraphicsUtil.RectangleToRect(oSubgraphRectangle), Margin,
            WpfGraphicsUtil.ColorToWpfColor(oGeneralUserSettings.BackColor) 
            ) );
    }
    CreateNodeXLVisual
    (
        GeneralUserSettings oGeneralUserSettings
    )
    {
        Debug.Assert(oGeneralUserSettings != null);
        AssertValid();

        NodeXLVisual oNodeXLVisual = new NodeXLVisual();

        GraphDrawer oGraphDrawer = oNodeXLVisual.GraphDrawer;

        VertexDrawer oVertexDrawer = oGraphDrawer.VertexDrawer;

        EdgeDrawer oEdgeDrawer = oGraphDrawer.EdgeDrawer;

        oGeneralUserSettings.TransferToGraphDrawer(oGraphDrawer);

        // Override some of the user's settings.

        oVertexDrawer.Shape = VertexShape.Disk;
        oVertexDrawer.Radius = 2.0;
        oEdgeDrawer.Width = 1;

        return (oNodeXLVisual);
    }
    CreateSubgraphImagesAsync
    (
        IGraph graph,
        ICollection<IVertex> selectedVertices,
        Decimal levels,
        Boolean saveToFolder,
        String folder,
        Size imageSizePx,
        ImageFormat imageFormat,
        Boolean createThumbnails,
        Size thumbnailSizePx,
        Boolean selectedVerticesOnly,
        Boolean selectVertex,
        Boolean selectIncidentEdges,
        GeneralUserSettings generalUserSettings,
        LayoutUserSettings layoutUserSettings
    )
    {
        Debug.Assert(graph != null);
        Debug.Assert(selectedVertices != null);
        Debug.Assert(levels >= 0);
        Debug.Assert(Decimal.Remainder(levels, 0.5M) == 0M);
        Debug.Assert( !saveToFolder || !String.IsNullOrEmpty(folder) );
        Debug.Assert( !saveToFolder || imageSizePx.Width > 0);
        Debug.Assert( !saveToFolder || imageSizePx.Height > 0);
        Debug.Assert( !createThumbnails || thumbnailSizePx.Width > 0);
        Debug.Assert( !createThumbnails || thumbnailSizePx.Height > 0);
        Debug.Assert(generalUserSettings != null);
        AssertValid();

        const String MethodName = "CreateSubgraphImagesAsync";

        if (this.IsBusy)
        {
            throw new InvalidOperationException( String.Format(

                "{0}:{1}: An asynchronous operation is already in progress."
                ,
                this.ClassName,
                MethodName
                ) );
        }

        // Wrap the arguments in an object that can be passed to
        // BackgroundWorker.RunWorkerAsync().

        CreateSubgraphImagesAsyncArgs oCreateSubgraphImagesAsyncArgs =
            new CreateSubgraphImagesAsyncArgs();

        oCreateSubgraphImagesAsyncArgs.Graph = graph;
        oCreateSubgraphImagesAsyncArgs.SelectedVertices = selectedVertices;
        oCreateSubgraphImagesAsyncArgs.Levels = levels;
        oCreateSubgraphImagesAsyncArgs.SaveToFolder = saveToFolder;
        oCreateSubgraphImagesAsyncArgs.Folder = folder;
        oCreateSubgraphImagesAsyncArgs.ImageSizePx = imageSizePx;
        oCreateSubgraphImagesAsyncArgs.ImageFormat = imageFormat;
        oCreateSubgraphImagesAsyncArgs.CreateThumbnails = createThumbnails;
        oCreateSubgraphImagesAsyncArgs.ThumbnailSizePx = thumbnailSizePx;

        oCreateSubgraphImagesAsyncArgs.SelectedVerticesOnly =
            selectedVerticesOnly;

        oCreateSubgraphImagesAsyncArgs.SelectVertex = selectVertex;

        oCreateSubgraphImagesAsyncArgs.SelectIncidentEdges =
            selectIncidentEdges;

        oCreateSubgraphImagesAsyncArgs.GeneralUserSettings =
            generalUserSettings;

        oCreateSubgraphImagesAsyncArgs.Layout =
            CreateLayout(layoutUserSettings);

        oCreateSubgraphImagesAsyncArgs.Layout.Margin = Margin;

        // Note: the NodeXLVisual object can't be created yet, because it must
        // be created on the same thread that uses it.  It will get created by
        // BackgroundWorker_DoWork().

        oCreateSubgraphImagesAsyncArgs.NodeXLVisual = null;

        // Create a BackgroundWorker and handle its events.

        m_oBackgroundWorker = new BackgroundWorker();

        m_oBackgroundWorker.WorkerReportsProgress = true;
        m_oBackgroundWorker.WorkerSupportsCancellation = true;

        m_oBackgroundWorker.DoWork += new DoWorkEventHandler(
            BackgroundWorker_DoWork);

        m_oBackgroundWorker.ProgressChanged +=
            new ProgressChangedEventHandler(BackgroundWorker_ProgressChanged);

        m_oBackgroundWorker.RunWorkerCompleted +=
            new RunWorkerCompletedEventHandler(
                BackgroundWorker_RunWorkerCompleted);

        m_oBackgroundWorker.RunWorkerAsync(oCreateSubgraphImagesAsyncArgs);
    }
Exemplo n.º 15
0
    SaveUserSettings()
    {
        AssertValid();

        GeneralUserSettings oGeneralUserSettings = new GeneralUserSettings();

        oGeneralUserSettings.ReadVertexLabels = this.ReadVertexLabels;
        oGeneralUserSettings.ReadEdgeLabels = this.ReadEdgeLabels;
        oGeneralUserSettings.ReadGroupLabels = this.ReadGroupLabels;
        oGeneralUserSettings.ShowGraphLegend = this.ShowGraphLegend;
        oGeneralUserSettings.ShowGraphAxes = this.ShowGraphAxes;

        oGeneralUserSettings.Save();
    }
    btnOptions_Click
    (
        object sender,
        EventArgs e
    )
    {
        AssertValid();

        // These are shared by several cases below.

        Form oUserSettingsDialog = null;
        NodeXLApplicationSettingsBase oUserSettings = null;

        switch ( (AutomationTasks)clbTasksToRun.SelectedValue )
        {
            case AutomationTasks.MergeDuplicateEdges:

                oUserSettings = new MergeDuplicateEdgesUserSettings();

                oUserSettingsDialog =
                    new MergeDuplicateEdgesUserSettingsDialog(
                    MergeDuplicateEdgesUserSettingsDialog.DialogMode.EditOnly,
                    (MergeDuplicateEdgesUserSettings)oUserSettings,
                    m_oThisWorkbook.InnerObject);

                break;

            case AutomationTasks.CalculateClusters:

                oUserSettings = new ClusterUserSettings();

                oUserSettingsDialog = new ClusterUserSettingsDialog(
                    ClusterUserSettingsDialog.DialogMode.EditOnly,
                    (ClusterUserSettings)oUserSettings);

                break;

            case AutomationTasks.CalculateGraphMetrics:

                ( new GraphMetricsDialog(
                    GraphMetricsDialog.DialogMode.EditOnly,
                    m_oThisWorkbook.InnerObject) ).ShowDialog();

                break;

            case AutomationTasks.AutoFillWorkbook:

                // ThisWorkbook manages the modeless AutoFillWorkbookDialog, so
                // tell ThisWorkbook to open the dialog.

                m_oThisWorkbook.AutoFillWorkbook(
                    AutoFillWorkbookDialog.DialogMode.EditOnly);

                break;

            case AutomationTasks.CreateSubgraphImages:

                ( new CreateSubgraphImagesDialog(
                    CreateSubgraphImagesDialog.DialogMode.EditOnly, null,
                    null) ).ShowDialog();

                break;

            case AutomationTasks.ReadWorkbook:

                oUserSettings = new GeneralUserSettings();

                oUserSettingsDialog = new GeneralUserSettingsDialog(
                    (GeneralUserSettings)oUserSettings,
                    m_oThisWorkbook.InnerObject);

                break;

            case AutomationTasks.SaveWorkbookIfNeverSaved:

                EditFolderToSaveWorkbookTo();

                break;

            case AutomationTasks.SaveGraphImageFile:

                oUserSettings = new AutomatedGraphImageUserSettings();

                oUserSettingsDialog =
                    new AutomatedGraphImageUserSettingsDialog(
                    (AutomatedGraphImageUserSettings)oUserSettings);

                break;

            case AutomationTasks.ExportToNodeXLGraphGallery:

                ( new ExportToNodeXLGraphGalleryDialog(
                    ExportToNodeXLGraphGalleryDialog.DialogMode.EditOnly,
                    m_oThisWorkbook.InnerObject, null) ).ShowDialog();

                break;

            case AutomationTasks.ExportToEmail:

                ( new ExportToEmailDialog(
                    ExportToEmailDialog.DialogMode.EditOnly,
                    m_oThisWorkbook.InnerObject, null) ).ShowDialog();

                break;

            default:

                Debug.Assert(false);
                break;
        }

        if (oUserSettingsDialog != null)
        {
            Debug.Assert(oUserSettings != null);

            if (oUserSettingsDialog.ShowDialog() == DialogResult.OK)
            {
                oUserSettings.Save();
            }
        }
    }
    //*************************************************************************
    //  Constructor: GeneralUserSettingsDialog()
    //
    /// <summary>
    /// Initializes a new instance of the <see
    /// cref="GeneralUserSettingsDialog" /> class.
    /// </summary>
    ///
    /// <param name="generalUserSettings">
    /// The object being edited.
    /// </param>
    ///
    /// <param name="workbook">
    /// Workbook containing the graph data.
    /// </param>
    //*************************************************************************

    public GeneralUserSettingsDialog
    (
        GeneralUserSettings generalUserSettings,
        Microsoft.Office.Interop.Excel.Workbook workbook
    )
    {
        Debug.Assert(generalUserSettings != null);
        Debug.Assert(workbook != null);
        generalUserSettings.AssertValid();

        m_oGeneralUserSettings = generalUserSettings;
        m_oWorkbook = workbook;
        m_oAxisFont = m_oGeneralUserSettings.AxisFont;
        m_oLabelUserSettings = m_oGeneralUserSettings.LabelUserSettings;

        m_oOpenFileDialog = new OpenFileDialog();

        m_oOpenFileDialog.Filter =
            "All files (*.*)|*.*|" + SaveableImageFormats.Filter
            ;

        m_oOpenFileDialog.Title = "Browse for Background Image";

        // Instantiate an object that saves and retrieves the position of this
        // dialog.  Note that the object automatically saves the settings when
        // the form closes.

        m_oGeneralUserSettingsDialogUserSettings =
            new GeneralUserSettingsDialogUserSettings(this);

        InitializeComponent();

        nudEdgeWidth.Minimum =
            (Decimal)EdgeWidthConverter.MinimumWidthWorkbook;

        nudEdgeWidth.Maximum =
            (Decimal)EdgeWidthConverter.MaximumWidthWorkbook;

        nudRelativeArrowSize.Minimum =
            (Decimal)EdgeDrawer.MinimumRelativeArrowSize;

        nudRelativeArrowSize.Maximum =
            (Decimal)EdgeDrawer.MaximumRelativeArrowSize;

        cbxEdgeBezierDisplacementFactor.PopulateWithObjectsAndText(
            0.1, "Low",
            0.2, "Medium",
            0.6, "High",
            1.2, "Very High"
            );

        cbxEdgeBundlerStraightening.PopulateWithObjectsAndText(
            0.15F, "Tight",
            0.40F, "Medium",
            0.60F, "Loose"
            );

        nudVertexRadius.Minimum = nudVertexImageSize.Minimum =
            (Decimal)VertexRadiusConverter.MinimumRadiusWorkbook;

        nudVertexRadius.Maximum = nudVertexImageSize.Maximum =
            (Decimal)VertexRadiusConverter.MaximumRadiusWorkbook;

        ( new VertexShapeConverter() ).PopulateComboBox(cbxVertexShape, false);

        nudVertexAlpha.Minimum = nudEdgeAlpha.Minimum =
            (Decimal)AlphaConverter.MinimumAlphaWorkbook;

        nudVertexAlpha.Maximum = nudEdgeAlpha.Maximum =
            (Decimal)AlphaConverter.MaximumAlphaWorkbook;

        nudVertexRelativeOuterGlowSize.Minimum =
            (Decimal)VertexDrawer.MinimumRelativeOuterGlowSize;

        nudVertexRelativeOuterGlowSize.Maximum =
            (Decimal)VertexDrawer.MaximumRelativeOuterGlowSize;

        DoDataExchange(false);

        AssertValid();
    }
Exemplo n.º 18
0
        btnOptions_Click
        (
            object sender,
            EventArgs e
        )
        {
            AssertValid();

            // These are shared by several cases below.

            Form oUserSettingsDialog = null;
            NodeXLApplicationSettingsBase oUserSettings = null;

            switch ((AutomationTasks)clbTasksToRun.SelectedValue)
            {
            case AutomationTasks.MergeDuplicateEdges:

                oUserSettings = new MergeDuplicateEdgesUserSettings();

                oUserSettingsDialog =
                    new MergeDuplicateEdgesUserSettingsDialog(
                        MergeDuplicateEdgesUserSettingsDialog.DialogMode.EditOnly,
                        (MergeDuplicateEdgesUserSettings)oUserSettings,
                        m_oThisWorkbook.InnerObject);

                break;

            case AutomationTasks.CalculateClusters:

                oUserSettings = new ClusterUserSettings();

                oUserSettingsDialog = new ClusterUserSettingsDialog(
                    ClusterUserSettingsDialog.DialogMode.EditOnly,
                    (ClusterUserSettings)oUserSettings);

                break;

            case AutomationTasks.CalculateGraphMetrics:

                (new GraphMetricsDialog(
                     GraphMetricsDialog.DialogMode.EditOnly,
                     m_oThisWorkbook.InnerObject)).ShowDialog();

                break;

            case AutomationTasks.AutoFillWorkbook:

                // ThisWorkbook manages the modeless AutoFillWorkbookDialog, so
                // tell ThisWorkbook to open the dialog.

                m_oThisWorkbook.AutoFillWorkbook(
                    AutoFillWorkbookDialog.DialogMode.EditOnly);

                break;

            case AutomationTasks.CreateSubgraphImages:

                (new CreateSubgraphImagesDialog(
                     CreateSubgraphImagesDialog.DialogMode.EditOnly, null,
                     null)).ShowDialog();

                break;

            case AutomationTasks.ReadWorkbook:

                oUserSettings = new GeneralUserSettings();

                oUserSettingsDialog = new GeneralUserSettingsDialog(
                    (GeneralUserSettings)oUserSettings,
                    m_oThisWorkbook.InnerObject);

                break;

            case AutomationTasks.SaveWorkbookIfNeverSaved:

                EditFolderToSaveWorkbookTo();

                break;

            case AutomationTasks.SaveGraphImageFile:

                oUserSettings = new AutomatedGraphImageUserSettings();

                oUserSettingsDialog =
                    new AutomatedGraphImageUserSettingsDialog(
                        (AutomatedGraphImageUserSettings)oUserSettings);

                break;

            case AutomationTasks.ExportToNodeXLGraphGallery:

                (new ExportToNodeXLGraphGalleryDialog(
                     ExportToNodeXLGraphGalleryDialog.DialogMode.EditOnly,
                     m_oThisWorkbook.InnerObject, null)).ShowDialog();

                break;

            case AutomationTasks.ExportToEmail:

                (new ExportToEmailDialog(
                     ExportToEmailDialog.DialogMode.EditOnly,
                     m_oThisWorkbook.InnerObject, null)).ShowDialog();

                break;

            default:

                Debug.Assert(false);
                break;
            }

            if (oUserSettingsDialog != null)
            {
                Debug.Assert(oUserSettings != null);

                if (oUserSettingsDialog.ShowDialog() == DialogResult.OK)
                {
                    oUserSettings.Save();
                }
            }
        }