Beispiel #1
0
        //*************************************************************************
        //  Constructor: ReadabilityMetricsDialog()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="ReadabilityMetricsDialog" /> class.
        /// </summary>
        ///
        /// <param name="nodeXLControl">
        /// NodeXLControl containing the graph.
        /// </param>
        ///
        /// <param name="workbook">
        /// Workbook containing the graph data.
        /// </param>
        //*************************************************************************

        public ReadabilityMetricsDialog
        (
            NodeXLControl nodeXLControl,
            Microsoft.Office.Interop.Excel.Workbook workbook
        )
        {
            InitializeComponent();

            m_oNodeXLControl = nodeXLControl;
            m_oWorkbook      = workbook;
            m_oReadabilityMetricUserSettings = new ReadabilityMetricUserSettings();

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

            m_oReadabilityMetricsDialogUserSettings =
                new ReadabilityMetricsDialogUserSettings(this);

            DoDataExchange(false);

            m_oNodeXLControl.VerticesMoved +=
                new VerticesMovedEventHandler(this.OnVerticesMoved);

            m_oNodeXLControl.GraphLaidOut +=
                new AsyncCompletedEventHandler(this.OnGraphLaidOut);

            AssertValid();
        }
Beispiel #2
0
        GetSelectedVertexRowIDs
        (
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(nodeXLControl != null);

            LinkedList <Int32> oSelectedVertexIDs = new LinkedList <Int32>();

            foreach (IVertex oSelectedVertex in nodeXLControl.SelectedVertices)
            {
                // The IDs from the worksheet are stored in the vertex Tags.

                if (!(oSelectedVertex.Tag is Int32))
                {
                    // The ID column is optional, so vertices may not have their
                    // Tag set.

                    continue;
                }

                oSelectedVertexIDs.AddLast((Int32)oSelectedVertex.Tag);
            }

            return(oSelectedVertexIDs);
        }
        GetImages
        (
            NodeXLControl oNodeXLControl,
            Boolean bUseFixedAspectRatio,
            out Byte [] abtFullSizeImage,
            out Byte [] abtThumbnail
        )
        {
            Debug.Assert(oNodeXLControl != null);
            Debug.Assert(oNodeXLControl.ActualWidth >= MinimumNodeXLControlWidth);
            Debug.Assert(oNodeXLControl.ActualHeight >= MinimumNodeXLControlHeight);

            Size oFullSizeImageSizePx = GetFullSizeImageSizePx(oNodeXLControl,
                                                               bUseFixedAspectRatio);

            Image oFullSizeImage = oNodeXLControl.CopyGraphToBitmap(
                oFullSizeImageSizePx.Width, oFullSizeImageSizePx.Height);

            Size oThumbnailImageSizePx = GetThumbnailImageSizePx(
                oFullSizeImageSizePx);

            Image oThumbnail = oFullSizeImage.GetThumbnailImage(
                oThumbnailImageSizePx.Width, oThumbnailImageSizePx.Height,
                () => { return(false); }, IntPtr.Zero);

            abtFullSizeImage = ImageToBytes(oFullSizeImage);
            abtThumbnail     = ImageToBytes(oThumbnail);

            oFullSizeImage.Dispose();
            oThumbnail.Dispose();
        }
        SelectSubgraphs
        (
            NodeXLControl oNodeXLControl,
            IVertex oClickedVertex,
            Boolean bUseAllSelectedVertices,
            Decimal decLevels,
            Boolean bSelectConnectingEdges
        )
        {
            Debug.Assert(oNodeXLControl != null);
            Debug.Assert(bUseAllSelectedVertices || oClickedVertex != null);
            Debug.Assert(decLevels > 0);
            AssertValid();

            // Determine which vertices need to have their subgraphs selected.

            IVertex [] aoVertices;

            if (bUseAllSelectedVertices)
            {
                aoVertices = m_aoInitiallySelectedVertices;
            }
            else
            {
                Debug.Assert(oClickedVertex != null);

                aoVertices = new IVertex [] { oClickedVertex };
            }

            // Select the vertices' subgraphs.

            NodeXLControlUtil.SelectSubgraphs(oNodeXLControl, aoVertices,
                                              decLevels, bSelectConnectingEdges);
        }
        ShowDialogAndSaveGraphImage
        (
            NodeXLControl nodeXLControl,
            Int32 width,
            Int32 height,
            String headerText,
            String footerText,
            System.Drawing.Font headerFooterFont,
            IEnumerable <LegendControlBase> legendControls
        )
        {
            Debug.Assert(nodeXLControl != null);
            Debug.Assert(width > 0);
            Debug.Assert(height > 0);
            Debug.Assert(headerFooterFont != null);
            Debug.Assert(legendControls != null);
            AssertValid();

            // Let the base class do most of the work.  The actual saving will be
            // done by SaveObject() in this class.  Wrap the information required
            // by SaveObject().

            GraphImageInfo oGraphImageInfo = new GraphImageInfo();

            oGraphImageInfo.NodeXLControl    = nodeXLControl;
            oGraphImageInfo.Width            = width;
            oGraphImageInfo.Height           = height;
            oGraphImageInfo.HeaderText       = headerText;
            oGraphImageInfo.FooterText       = footerText;
            oGraphImageInfo.HeaderFooterFont = headerFooterFont;
            oGraphImageInfo.LegendControls   = legendControls;

            return(ShowDialogAndSaveObject(oGraphImageInfo));
        }
Beispiel #6
0
        GetVisibleVertices
        (
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(nodeXLControl != null);

            List <IVertex> oVisibleVertices = new List <IVertex>();

            foreach (IVertex oVertex in nodeXLControl.Graph.Vertices)
            {
                Object oVisibilityKeyValue;

                if (
                    !oVertex.TryGetValue(ReservedMetadataKeys.Visibility,
                                         typeof(VisibilityKeyValue), out oVisibilityKeyValue)
                    ||
                    (VisibilityKeyValue)oVisibilityKeyValue ==
                    VisibilityKeyValue.Visible
                    )
                {
                    oVisibleVertices.Add(oVertex);
                }
            }

            return(oVisibleVertices);
        }
Beispiel #7
0
        GetSelectedEdgeRowIDs
        (
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(nodeXLControl != null);

            LinkedList <Int32> oSelectedEdgeRowIDs = new LinkedList <Int32>();

            foreach (IEdge oSelectedEdge in nodeXLControl.SelectedEdges)
            {
                // The IDs from the worksheet are stored in the edge Tags.

                if (!(oSelectedEdge.Tag is Int32))
                {
                    // The ID column is optional, so edges may not have their Tag
                    // set.

                    continue;
                }

                oSelectedEdgeRowIDs.AddLast((Int32)oSelectedEdge.Tag);
            }

            return(oSelectedEdgeRowIDs);
        }
        //*************************************************************************
        //  Constructor: ExportToEmailDialog()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportToEmailDialog" />
        /// class.
        /// </summary>
        ///
        /// <param name="mode">
        /// Indicates the mode in which the dialog is being used.
        /// </param>
        ///
        /// <param name="workbook">
        /// Workbook containing the graph data.
        /// </param>
        ///
        /// <param name="nodeXLControl">
        /// NodeXLControl containing the graph.  This can be null if <paramref
        /// name="mode" /> is <see cref="DialogMode.EditOnly" />.
        /// </param>
        //*************************************************************************

        public ExportToEmailDialog
        (
            DialogMode mode,
            Microsoft.Office.Interop.Excel.Workbook workbook,
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(nodeXLControl != null || mode == DialogMode.EditOnly);

            m_eMode                      = mode;
            m_oWorkbook                  = workbook;
            m_oNodeXLControl             = nodeXLControl;
            m_oExportToEmailUserSettings = new ExportToEmailUserSettings();
            m_oPasswordUserSettings      = new PasswordUserSettings();

            InitializeComponent();

            if (m_eMode == DialogMode.EditOnly)
            {
                InitializeForEditOnly();
            }

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

            m_oExportToEmailDialogUserSettings =
                new ExportToEmailDialogUserSettings(this);

            DoDataExchange(false);

            AssertValid();
        }
Beispiel #9
0
        TryExportToNodeXLGraphGallery
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            NodeXLControl oNodeXLControl
        )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oNodeXLControl != null);

            ExportToNodeXLGraphGalleryUserSettings
                oExportToNodeXLGraphGalleryUserSettings =
                new ExportToNodeXLGraphGalleryUserSettings();

            String sAuthor, sPassword;

            GetGraphGalleryAuthorAndPassword(
                oExportToNodeXLGraphGalleryUserSettings, out sAuthor,
                out sPassword);

            // Note that a graph summary is used for the description.

            try
            {
                (new NodeXLGraphGalleryExporter()).ExportToNodeXLGraphGallery(
                    oWorkbook,
                    oNodeXLControl,
                    GraphTitleCreator.CreateGraphTitle(oWorkbook),
                    GraphSummarizer.SummarizeGraph(oWorkbook),
                    oExportToNodeXLGraphGalleryUserSettings.SpaceDelimitedTags,
                    sAuthor,
                    sPassword,

                    oExportToNodeXLGraphGalleryUserSettings
                    .ExportWorkbookAndSettings,

                    oExportToNodeXLGraphGalleryUserSettings.ExportGraphML,
                    oExportToNodeXLGraphGalleryUserSettings.UseFixedAspectRatio
                    );

                return(true);
            }
            catch (Exception oException)
            {
                String sMessage;

                if (NodeXLGraphGalleryExceptionHandler
                    .TryGetMessageForRecognizedException(
                        oException, out sMessage))
                {
                    FormUtil.ShowWarning(sMessage);
                }
                else
                {
                    ErrorUtil.OnException(oException);
                }

                return(false);
            }
        }
Beispiel #10
0
        //*************************************************************************
        //  Constructor: EdgeAttributesDialog()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="EdgeAttributesDialog" />
        /// class.
        /// </summary>
        ///
        /// <param name="nodeXLControl">
        /// NodeXLControl whose edge attributes need to be edited.
        /// </param>
        //*************************************************************************

        public EdgeAttributesDialog
        (
            NodeXLControl nodeXLControl
        )
            : base(nodeXLControl)
        {
            InitializeComponent();

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

            m_oEdgeAttributesDialogUserSettings =
                new EdgeAttributesDialogUserSettings(this);

            m_oEditedEdgeAttributes = GetInitialEdgeAttributes();

            nudWidth.Minimum = (Decimal)EdgeWidthConverter.MinimumWidthWorkbook;
            nudWidth.Maximum = (Decimal)EdgeWidthConverter.MaximumWidthWorkbook;

            (new EdgeStyleConverter()).PopulateComboBox(cbxStyle, true);

            nudAlpha.Minimum = (Decimal)AlphaConverter.MinimumAlphaWorkbook;
            nudAlpha.Maximum = (Decimal)AlphaConverter.MaximumAlphaWorkbook;

            EdgeVisibilityConverter oEdgeVisibilityConverter =
                new EdgeVisibilityConverter();

            String sHide = oEdgeVisibilityConverter.GraphToWorkbook(
                EdgeWorksheetReader.Visibility.Hide);

            cbxVisibility.PopulateWithObjectsAndText(

                NotEditedMarker, String.Empty,

                EdgeWorksheetReader.Visibility.Show,
                oEdgeVisibilityConverter.GraphToWorkbook(
                    EdgeWorksheetReader.Visibility.Show),

                EdgeWorksheetReader.Visibility.Skip,
                oEdgeVisibilityConverter.GraphToWorkbook(
                    EdgeWorksheetReader.Visibility.Skip),

                EdgeWorksheetReader.Visibility.Hide, sHide
                );

            SetVisibilityHelpText(lnkVisibility, sHide);

            nudLabelFontSize.Minimum =
                (Decimal)FontSizeConverter.MinimumFontSizeWorkbook;

            nudLabelFontSize.Maximum =
                (Decimal)FontSizeConverter.MaximumFontSizeWorkbook;

            DoDataExchange(false);

            AssertValid();
        }
Beispiel #11
0
    //*************************************************************************
    //  Constructor: AttributesDialogBase()
    //
    /// <overloads>
    /// Initializes a new instance of the <see cref="AttributesDialogBase" />
    /// class.
    /// </overloads>
    ///
    /// <summary>
    /// Initializes a new instance of the <see cref="AttributesDialogBase" />
    /// class.
    /// </summary>
    ///
    /// <param name="nodeXLControl">
    /// NodeXLControl whose edge or vertex attributes need to be edited.
    /// </param>
    //*************************************************************************

    public AttributesDialogBase
    (
        NodeXLControl nodeXLControl
    )
    {
        m_oNodeXLControl = nodeXLControl;

        // AssertValid();
    }
Beispiel #12
0
        AutomateOneWorkbook
        (
            ThisWorkbook thisWorkbook,
            NodeXLControl nodeXLControl,
            AutomationTasks tasksToRun,
            String folderToSaveWorkbookTo
        )
        {
            Debug.Assert(thisWorkbook != null);
            Debug.Assert(nodeXLControl != null);

            CheckTasksToRunArgument(ref tasksToRun);

            Microsoft.Office.Interop.Excel.Workbook oWorkbook =
                thisWorkbook.InnerObject;

            if
            (
                (
                    ShouldRunTask(tasksToRun, AutomationTasks.MergeDuplicateEdges)
                    &&
                    !TryMergeDuplicateEdges(thisWorkbook)
                )
                ||
                (
                    ShouldRunTask(tasksToRun, AutomationTasks.CalculateClusters)
                    &&
                    !TryCalculateClusters(thisWorkbook)
                )
                ||
                (
                    ShouldRunTask(tasksToRun,
                                  AutomationTasks.CalculateGraphMetrics)
                    &&
                    !TryCalculateGraphMetrics(oWorkbook)
                )
                ||
                (
                    ShouldRunTask(tasksToRun, AutomationTasks.AutoFillWorkbook)
                    &&
                    !TryAutoFillWorkbook(thisWorkbook)
                )
                ||
                (
                    ShouldRunTask(tasksToRun, AutomationTasks.CreateSubgraphImages)
                    &&
                    !TryCreateSubgraphImages(thisWorkbook)
                )
            )
            {
                return;
            }

            RunReadWorkbookTasks(thisWorkbook, nodeXLControl, tasksToRun,
                                 folderToSaveWorkbookTo);
        }
Beispiel #13
0
        //*************************************************************************
        //  Constructor: GraphRectangleEventArgs()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="GraphRectangleEventArgs" /> class.
        /// </summary>
        ///
        /// <param name="graphRectangle">
        /// The rectangle the graph was drawn within.
        /// </param>
        ///
        /// <param name="nodeXLControl">
        /// The control in which the graph was drawn.
        /// </param>
        //*************************************************************************

        public GraphRectangleEventArgs
        (
            Rectangle graphRectangle,
            NodeXLControl nodeXLControl
        )
        {
            m_oGraphRectangle = graphRectangle;
            m_oNodeXLControl  = nodeXLControl;

            // AssertValid();
        }
Beispiel #14
0
        TransferToNodeXLControl
        (
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(nodeXLControl != null);
            AssertValid();

            TransferToGraphDrawer(nodeXLControl.GraphDrawer);

            nodeXLControl.MouseAlsoSelectsIncidentEdges = this.AutoSelect;
        }
Beispiel #15
0
        //*************************************************************************
        //  Constructor: VerticesMovedEventArgs2()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="VerticesMovedEventArgs2" /> class.
        /// </summary>
        ///
        /// <param name="verticesAndRowIDs">
        /// Collection of <see cref="VertexAndRowID" /> objects, one for each
        /// vertex that was moved.
        /// </param>
        ///
        /// <param name="graphRectangle">
        /// The rectangle the graph was drawn within.
        /// </param>
        ///
        /// <param name="nodeXLControl">
        /// The control in which the graph was drawn.
        /// </param>
        //*************************************************************************

        public VerticesMovedEventArgs2
        (
            ICollection <VertexAndRowID> verticesAndRowIDs,
            Rectangle graphRectangle,
            NodeXLControl nodeXLControl
        )
            :
            base(graphRectangle, nodeXLControl)
        {
            m_oVerticesAndRowIDs = verticesAndRowIDs;

            AssertValid();
        }
Beispiel #16
0
        //*************************************************************************
        //  Constructor: GraphImageScaler()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphImageScaler" />
        /// class.
        /// </summary>
        ///
        /// <param name="nodeXLControl">
        /// The control for which a graph image will be created.
        /// </param>
        //*************************************************************************

        public GraphImageScaler
        (
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(nodeXLControl != null);

            m_oNodeXLControl           = nodeXLControl;
            m_dOriginalGraphScale      = 0;
            m_dOriginalGroupLabelScale = 0;

            AssertValid();
        }
        //*************************************************************************
        //  Constructor: GroupsCollapsedOrExpandedEventArgs()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="GroupsCollapsedOrExpandedEventArgs" /> class.
        /// </summary>
        ///
        /// <param name="graphRectangle">
        /// The rectangle the graph was drawn within.
        /// </param>
        ///
        /// <param name="nodeXLControl">
        /// The control in which the graph was drawn.
        /// </param>
        ///
        /// <param name="groupsRedrawnImmediately">
        /// true if the groups were redrawn immediately after they were collapsed
        /// or expanded, false if they won't be redrawn until the graph is redrawn.
        /// </param>
        //*************************************************************************

        public GroupsCollapsedOrExpandedEventArgs
        (
            Rectangle graphRectangle,
            NodeXLControl nodeXLControl,
            Boolean groupsRedrawnImmediately
        )
            :
            base(graphRectangle, nodeXLControl)
        {
            m_bGroupsRedrawnImmediately = groupsRedrawnImmediately;

            AssertValid();
        }
Beispiel #18
0
        SelectSubgraphs
        (
            NodeXLControl nodeXLControl,
            IEnumerable <IVertex> verticesToSelectSubgraphsFor,
            Decimal levels,
            Boolean selectConnectingEdges
        )
        {
            Debug.Assert(nodeXLControl != null);
            Debug.Assert(verticesToSelectSubgraphsFor != null);
            Debug.Assert(levels >= 0);
            Debug.Assert(Decimal.Remainder(levels, 0.5M) == 0M);

            // Create HashSets for all of the vertices and edges that will be
            // selected.  The key is the IVertex or IEdge.  HashSets are used to
            // prevent the same vertex or edge from being selected twice.

            HashSet <IVertex> oAllSelectedVertices = new HashSet <IVertex>();
            HashSet <IEdge>   oAllSelectedEdges    = new HashSet <IEdge>();

            foreach (IVertex oVertexToSelectSubgraphFor in
                     verticesToSelectSubgraphsFor)
            {
                // These are similar collections for the vertices and edges that
                // will be selected for this subgraph only.

                Dictionary <IVertex, Int32> oThisSubgraphSelectedVertices;
                HashSet <IEdge>             oThisSubgraphSelectedEdges;

                SubgraphCalculator.GetSubgraph(oVertexToSelectSubgraphFor, levels,
                                               selectConnectingEdges, out oThisSubgraphSelectedVertices,
                                               out oThisSubgraphSelectedEdges);

                // Consolidate the subgraph's selected vertices and edges into the
                // "all" dictionaries.

                foreach (IVertex oVertex in oThisSubgraphSelectedVertices.Keys)
                {
                    oAllSelectedVertices.Add(oVertex);
                }

                foreach (IEdge oEdge in oThisSubgraphSelectedEdges)
                {
                    oAllSelectedEdges.Add(oEdge);
                }
            }

            // Replace the selection.

            nodeXLControl.SetSelected(oAllSelectedVertices, oAllSelectedEdges);
        }
Beispiel #19
0
        SaveGraphImageFile
        (
            NodeXLControl oNodeXLControl,
            String sWorkbookFilePath
        )
        {
            Debug.Assert(oNodeXLControl != null);
            Debug.Assert(!String.IsNullOrEmpty(sWorkbookFilePath));

            AutomatedGraphImageUserSettings oAutomatedGraphImageUserSettings =
                new AutomatedGraphImageUserSettings();

            Size oImageSizePx = oAutomatedGraphImageUserSettings.ImageSizePx;

            Bitmap oBitmapCopy = oNodeXLControl.CopyGraphToBitmap(
                oImageSizePx.Width, oImageSizePx.Height);

            ImageFormat eImageFormat =
                oAutomatedGraphImageUserSettings.ImageFormat;

            String sImageFilePath = Path.ChangeExtension(sWorkbookFilePath,
                                                         SaveableImageFormats.GetFileExtension(eImageFormat));

            try
            {
                oBitmapCopy.Save(sImageFilePath, eImageFormat);
            }
            catch (System.Runtime.InteropServices.ExternalException)
            {
                // When an image file already exists and is read-only, an
                // ExternalException is thrown.
                //
                // Note that this method is called from the
                // ThisWorkbook.GraphLaidOut event handler, so this exception can't
                // be handled by a TaskAutomator.AutomateThisWorkbook() exception
                // handler.

                FormUtil.ShowWarning(String.Format(
                                         "The image file \"{0}\" couldn't be saved.  Does a read-only"
                                         + " file with the same name already exist?"
                                         ,
                                         sImageFilePath
                                         ));
            }
            finally
            {
                oBitmapCopy.Dispose();
            }
        }
        //*************************************************************************
        //  Constructor: GraphImageCompositor()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphImageCompositor" />
        /// class.
        /// </summary>
        ///
        /// <param name="nodeXLControl">
        /// The NodeXLControl that will be composited by <see cref="Composite" />.
        /// This is assumed to be hosted in a Panel.
        /// </param>
        //*************************************************************************

        public GraphImageCompositor
        (
            NodeXLControl nodeXLControl
        )
        {
            m_oNodeXLControl      = nodeXLControl;
            m_oLayoutSaver        = null;
            m_oGraphImageScaler   = null;
            m_oGraphImageCenterer = null;
            m_oParentPanel        = null;
            m_iChildIndex         = Int32.MinValue;
            m_oGrid = null;

            AssertValid();
        }
Beispiel #21
0
        //*************************************************************************
        //  Constructor: GraphLaidOutEventArgs()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphLaidOutEventArgs" />
        /// class.
        /// </summary>
        ///
        /// <param name="graphRectangle">
        /// The rectange the graph was drawn within.
        /// </param>
        ///
        /// <param name="edgeIDDictionary">
        /// Dictionary that maps edge IDs stored in the edge worksheet to edge
        /// objects in the graph.
        /// </param>
        ///
        /// <param name="vertexIDDictionary">
        /// Dictionary that maps vertex IDs stored in the vertex worksheet to
        /// vertex objects in the graph.
        /// </param>
        ///
        /// <param name="nodeXLControl">
        /// The control in which the graph was laid out.
        /// </param>
        //*************************************************************************

        public GraphLaidOutEventArgs
        (
            Rectangle graphRectangle,
            Dictionary <Int32, IIdentityProvider> edgeIDDictionary,
            Dictionary <Int32, IIdentityProvider> vertexIDDictionary,
            NodeXLControl nodeXLControl
        )
        {
            m_oGraphRectangle     = graphRectangle;
            m_oEdgeIDDictionary   = edgeIDDictionary;
            m_oVertexIDDictionary = vertexIDDictionary;
            m_oNodeXLControl      = nodeXLControl;

            AssertValid();
        }
Beispiel #22
0
        GetSelectedEdgesAsHashSet
        (
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(nodeXLControl != null);

            HashSet <IEdge> oSelectedEdges = new HashSet <IEdge>();

            foreach (IEdge oSelectedEdge in nodeXLControl.SelectedEdges)
            {
                oSelectedEdges.Add(oSelectedEdge);
            }

            return(oSelectedEdges);
        }
Beispiel #23
0
        GetSelectedVerticesAsHashSet
        (
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(nodeXLControl != null);

            HashSet <IVertex> oSelectedVertices = new HashSet <IVertex>();

            foreach (IVertex oSelectedVertex in nodeXLControl.SelectedVertices)
            {
                oSelectedVertices.Add(oSelectedVertex);
            }

            return(oSelectedVertices);
        }
Beispiel #24
0
        AddAttachmentsAndAlternateHtml
        (
            MailMessage oMailMessage,
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            NodeXLControl oNodeXLControl,
            Boolean bExportWorkbookAndSettings,
            Boolean bExportGraphML,
            Boolean bUseFixedAspectRatio
        )
        {
            Debug.Assert(oMailMessage != null);
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oNodeXLControl != null);

            Debug.Assert(oNodeXLControl.ActualWidth >=
                         GraphExporterUtil.MinimumNodeXLControlWidth);

            Debug.Assert(oNodeXLControl.ActualHeight >=
                         GraphExporterUtil.MinimumNodeXLControlHeight);

            AssertValid();

            String sSuggestedFileNameNoExtension =
                GetSuggestedFileNameNoExtension(oWorkbook);

            String sGraphMLFileNameNoExtension =
                sSuggestedFileNameNoExtension + "-GraphML";

            Byte [] abtFullSizeImage, abtThumbnail, abtWorkbookContents,
            abtGraphMLZipped;

            String sWorkbookSettings;

            GraphExporterUtil.GetDataToExport(oWorkbook, oNodeXLControl,
                                              bExportWorkbookAndSettings, bExportGraphML,
                                              Path.ChangeExtension(sGraphMLFileNameNoExtension, "xml"),
                                              bUseFixedAspectRatio, out abtFullSizeImage, out abtThumbnail,
                                              out abtWorkbookContents, out sWorkbookSettings,
                                              out abtGraphMLZipped);

            AddAttachments(oMailMessage, sSuggestedFileNameNoExtension,
                           sGraphMLFileNameNoExtension, abtFullSizeImage, abtWorkbookContents,
                           sWorkbookSettings, abtGraphMLZipped);

            AddAlternateHtml(oMailMessage, abtFullSizeImage);
        }
Beispiel #25
0
        ExportToEmail
        (
            Microsoft.Office.Interop.Excel.Workbook workbook,
            NodeXLControl nodeXLControl,
            String [] toAddresses,
            String fromAddress,
            String subject,
            String messageBody,
            String smtpHost,
            Int32 smtpPort,
            Boolean useSslForSmtp,
            String smtpUserName,
            String smtpPassword,
            Boolean exportWorkbookAndSettings,
            Boolean exportGraphML,
            Boolean useFixedAspectRatio
        )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(nodeXLControl != null);

            Debug.Assert(nodeXLControl.ActualWidth >=
                         GraphExporterUtil.MinimumNodeXLControlWidth);

            Debug.Assert(nodeXLControl.ActualHeight >=
                         GraphExporterUtil.MinimumNodeXLControlHeight);

            Debug.Assert(toAddresses != null);
            Debug.Assert(toAddresses.Length > 0);
            Debug.Assert(!String.IsNullOrEmpty(fromAddress));
            Debug.Assert(!String.IsNullOrEmpty(subject));
            Debug.Assert(!String.IsNullOrEmpty(smtpHost));
            Debug.Assert(smtpPort > 0);
            Debug.Assert(!String.IsNullOrEmpty(smtpUserName));
            Debug.Assert(!String.IsNullOrEmpty(smtpPassword));
            AssertValid();

            SmtpClient oSmtpClient = GetSmtpClient(smtpHost, smtpPort,
                                                   useSslForSmtp, smtpUserName, smtpPassword);

            MailMessage oMailMessage = GetMailMessage(workbook, nodeXLControl,
                                                      toAddresses, fromAddress, subject, messageBody,
                                                      exportWorkbookAndSettings, exportGraphML, useFixedAspectRatio);

            oSmtpClient.Send(oMailMessage);
        }
            //*************************************************************************
            //  Constructor: GraphImageCenterer()
            //
            /// <summary>
            /// Initializes a new instance of the <see cref="GraphImageCenterer" />
            /// class.
            /// </summary>
            ///
            /// <param name="nodeXLControl">
            /// The control for which a graph image will be created.
            /// </param>
            //*************************************************************************

            public GraphImageCenterer
            (
                NodeXLControl nodeXLControl
            )
            {
                Debug.Assert(nodeXLControl != null);

                m_oNodeXLControl = nodeXLControl;

                m_dOriginalTranslateTransformForRenderX               =
                    m_dOriginalTranslateTransformForRenderY           =
                        m_dOriginalScaleTransformForRenderCenterX     =
                            m_dOriginalScaleTransformForRenderCenterY =
                                Double.MinValue;

                AssertValid();
            }
Beispiel #27
0
        GetSelectedEdgesAsDictionary
        (
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(nodeXLControl != null);

            Dictionary <Int32, IEdge> oSelectedEdges =
                new Dictionary <Int32, IEdge>();

            foreach (IEdge oSelectedEdge in nodeXLControl.SelectedEdges)
            {
                oSelectedEdges[oSelectedEdge.ID] = oSelectedEdge;
            }

            return(oSelectedEdges);
        }
Beispiel #28
0
        GetSelectedVerticesAsDictionary
        (
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(nodeXLControl != null);

            Dictionary <Int32, IVertex> oSelectedVertices =
                new Dictionary <Int32, IVertex>();

            foreach (IVertex oSelectedVertex in nodeXLControl.SelectedVertices)
            {
                oSelectedVertices[oSelectedVertex.ID] = oSelectedVertex;
            }

            return(oSelectedVertices);
        }
        //*************************************************************************
        //  Constructor: GraphLaidOutEventArgs()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphLaidOutEventArgs" />
        /// class.
        /// </summary>
        ///
        /// <param name="graphRectangle">
        /// The rectangle the graph was drawn within.
        /// </param>
        ///
        /// <param name="edgeIDDictionary">
        /// Dictionary that maps edge IDs stored in the edge worksheet to edge
        /// objects in the graph.
        /// </param>
        ///
        /// <param name="vertexIDDictionary">
        /// Dictionary that maps vertex IDs stored in the vertex worksheet to
        /// vertex objects in the graph.
        /// </param>
        ///
        /// <param name="nodeXLControl">
        /// The control in which the graph was laid out.
        /// </param>
        ///
        /// <param name="legendControls">
        /// Zero or more legend controls associated with <paramref
        /// name="nodeXLControl" />.  Can't be null.
        /// </param>
        //*************************************************************************

        public GraphLaidOutEventArgs
        (
            Rectangle graphRectangle,
            Dictionary <Int32, IIdentityProvider> edgeIDDictionary,
            Dictionary <Int32, IIdentityProvider> vertexIDDictionary,
            NodeXLControl nodeXLControl,
            IEnumerable <LegendControlBase> legendControls
        )
            :
            base(graphRectangle, nodeXLControl)
        {
            m_oEdgeIDDictionary   = edgeIDDictionary;
            m_oVertexIDDictionary = vertexIDDictionary;
            m_oLegendControls     = legendControls;

            AssertValid();
        }
        GetDataToExport
        (
            Microsoft.Office.Interop.Excel.Workbook workbook,
            NodeXLControl nodeXLControl,
            Boolean exportWorkbookAndSettings,
            Boolean exportGraphML,
            String zippedGraphMLFileName,
            Boolean useFixedAspectRatio,
            out Byte [] fullSizeImage,
            out Byte [] thumbnail,
            out Byte [] workbookContents,
            out String workbookSettings,
            out Byte [] graphMLZipped
        )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(nodeXLControl != null);
            Debug.Assert(nodeXLControl.ActualWidth >= MinimumNodeXLControlWidth);
            Debug.Assert(nodeXLControl.ActualHeight >= MinimumNodeXLControlHeight);
            Debug.Assert(!String.IsNullOrEmpty(zippedGraphMLFileName));

            GetImages(nodeXLControl, useFixedAspectRatio, out fullSizeImage,
                      out thumbnail);

            if (exportWorkbookAndSettings)
            {
                workbookContents = GetWorkbookContents(workbook);
                workbookSettings = GetWorkbookSettings(workbook);
            }
            else
            {
                workbookContents = null;
                workbookSettings = null;
            }

            if (exportGraphML)
            {
                graphMLZipped = ZipGraphML(GetGraphML(workbook),
                                           zippedGraphMLFileName);
            }
            else
            {
                graphMLZipped = null;
            }
        }