Example #1
0
        ThisWorkbook_VerticesMoved
        (
            Object sender,
            VerticesMovedEventArgs2 e
        )
        {
            Debug.Assert(e != null);
            AssertValid();

            if (m_oSheets1And2Helper.TableExists)
            {
                OnVerticesMoved(e);
            }
        }
Example #2
0
        //*************************************************************************
        //  Method: ThisWorkbook_VerticesMoved()
        //
        /// <summary>
        /// Handles the VerticesMoved event on ThisWorkbook.
        /// </summary>
        ///
        /// <param name="sender">
        /// Standard event argument.
        /// </param>
        ///
        /// <param name="e">
        /// Standard event argument.
        /// </param>
        //*************************************************************************
        private void ThisWorkbook_VerticesMoved(
            Object sender,
            VerticesMovedEventArgs2 e
            )
        {
            Debug.Assert(e != null);
            AssertValid();

            if (m_oSheets1And2Helper.TableExists)
            {
            OnVerticesMoved(e);
            }
        }
Example #3
0
        //*************************************************************************
        //  Method: OnVerticesMoved()
        //
        /// <summary>
        /// Handles the VerticesMoved event on ThisWorkbook.
        /// </summary>
        ///
        /// <param name="e">
        /// Standard event argument.
        /// </param>
        //*************************************************************************
        private void OnVerticesMoved(
            VerticesMovedEventArgs2 e
            )
        {
            Debug.Assert(e != null);
            AssertValid();

            Microsoft.Office.Interop.Excel.ListObject oVertexTable =
            Vertices.InnerObject;

            // Get a dictionary that maps IDs to row numbers, and get the location
            // columns from the vertex table.  These are the entire table columns,
            // including the headers.

            Dictionary<Int32, Int32> oRowIDDictionary;
            Microsoft.Office.Interop.Excel.ListColumn oXColumn, oYColumn;

            if (
            !m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary)
            ||
            !ExcelUtil.TryGetTableColumn(oVertexTable,
                VertexTableColumnNames.X, out oXColumn)
            ||
            !ExcelUtil.TryGetTableColumn(oVertexTable,
                VertexTableColumnNames.Y, out oYColumn)
            )
            {
            return;
            }

            // Create an object that converts a vertex location between coordinates
            // used in the NodeXL graph and coordinates used in the worksheet.

            VertexLocationConverter oVertexLocationConverter =
            new VertexLocationConverter(e.GraphRectangle);

            foreach (VertexAndRowID oVertexAndRowID in e.VerticesAndRowIDs)
            {
            // Look for the cell in the ID column that contains the specified
            // ID.

            Int32 iRowOneBased;

            if ( !oRowIDDictionary.TryGetValue(oVertexAndRowID.VertexRowID,
                out iRowOneBased) )
            {
                continue;
            }

            // Convert the vertex location to workbook coordinates.

            Single fWorkbookX, fWorkbookY;

            oVertexLocationConverter.GraphToWorkbook(
                oVertexAndRowID.Vertex.Location, out fWorkbookX,
                out fWorkbookY);

            // Update the X and Y cells.

            this.Cells[iRowOneBased, oXColumn.Range.Column] = fWorkbookX;
            this.Cells[iRowOneBased, oYColumn.Range.Column] = fWorkbookY;
            }
        }
Example #4
0
        OnVerticesMoved
        (
            VerticesMovedEventArgs2 e
        )
        {
            Debug.Assert(e != null);
            AssertValid();

            Microsoft.Office.Interop.Excel.ListObject oVertexTable =
                Vertices.InnerObject;

            // Get a dictionary that maps IDs to row numbers, and get the location
            // columns from the vertex table.  These are the entire table columns,
            // including the headers.

            Dictionary <Int32, Int32> oRowIDDictionary;

            Microsoft.Office.Interop.Excel.ListColumn oXColumn, oYColumn;

            if (
                !m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary)
                ||
                !ExcelUtil.TryGetTableColumn(oVertexTable,
                                             VertexTableColumnNames.X, out oXColumn)
                ||
                !ExcelUtil.TryGetTableColumn(oVertexTable,
                                             VertexTableColumnNames.Y, out oYColumn)
                )
            {
                return;
            }

            // Create an object that converts a vertex location between coordinates
            // used in the NodeXL graph and coordinates used in the worksheet.

            VertexLocationConverter oVertexLocationConverter =
                new VertexLocationConverter(e.GraphRectangle);

            foreach (VertexAndRowID oVertexAndRowID in e.VerticesAndRowIDs)
            {
                // Look for the cell in the ID column that contains the specified
                // ID.

                Int32 iRowOneBased;

                if (!oRowIDDictionary.TryGetValue(oVertexAndRowID.VertexRowID,
                                                  out iRowOneBased))
                {
                    continue;
                }

                // Convert the vertex location to workbook coordinates.

                Single fWorkbookX, fWorkbookY;

                oVertexLocationConverter.GraphToWorkbook(
                    oVertexAndRowID.Vertex.Location, out fWorkbookX,
                    out fWorkbookY);

                // Update the X and Y cells.

                this.Cells[iRowOneBased, oXColumn.Range.Column] = fWorkbookX;
                this.Cells[iRowOneBased, oYColumn.Range.Column] = fWorkbookY;
            }
        }
Example #5
0
        //*************************************************************************
        //  Method: TaskPane_VerticesMoved()
        //
        /// <summary>
        /// Handles the VerticesMoved event on the TaskPane.
        /// </summary>
        ///
        /// <param name="sender">
        /// Standard event argument.
        /// </param>
        ///
        /// <param name="e">
        /// Standard event argument.
        /// </param>
        //*************************************************************************
        private void TaskPane_VerticesMoved(
            Object sender,
            VerticesMovedEventArgs2 e
            )
        {
            Debug.Assert(e != null);
            AssertValid();

            if ( !this.ExcelApplicationIsReady(false) )
            {
            return;
            }

            // Forward the event.

            VerticesMovedEventHandler2 oVerticesMoved = this.VerticesMoved;

            if (oVerticesMoved != null)
            {
            try
            {
                oVerticesMoved(this, e);
            }
            catch (Exception oException)
            {
                ErrorUtil.OnException(oException);
            }
            }
        }