Beispiel #1
0
        ThisWorkbook_VertexAttributesEditedInGraph
        (
            Object sender,
            VertexAttributesEditedEventArgs e
        )
        {
            Debug.Assert(e != null);
            AssertValid();

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

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

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

            // Get a dictionary containing the ID of each row in the table.

            Dictionary<Int32, Int32> oRowIDDictionary;

            if ( !m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary) )
            {
            // Nothing can be done without the IDs.

            return;
            }

            Globals.ThisWorkbook.ShowWaitCursor = true;

            // Get the columns that might need to be updated.  These columns are
            // not required.

            Microsoft.Office.Interop.Excel.Range oColorColumnData,
            oShapeColumnData, oRadiusColumnData, oAlphaColumnData,
            oVisibilityColumnData, oLabelPositionColumnData, oLockedColumnData,
            oMarkedColumnData;

            Object [,] aoColorValues = null;
            Object [,] aoShapeValues = null;
            Object [,] aoRadiusValues = null;
            Object [,] aoAlphaValues = null;
            Object [,] aoVisibilityValues = null;
            Object [,] aoLabelPositionValues = null;
            Object [,] aoLockedValues = null;
            Object [,] aoMarkedValues = null;

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Color, out oColorColumnData,
            out aoColorValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Shape, out oShapeColumnData,
            out aoShapeValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Radius, out oRadiusColumnData,
            out aoRadiusValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            CommonTableColumnNames.Alpha, out oAlphaColumnData,
            out aoAlphaValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            CommonTableColumnNames.Visibility, out oVisibilityColumnData,
            out aoVisibilityValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.LabelPosition, out oLabelPositionColumnData,
            out aoLabelPositionValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Locked, out oLockedColumnData,
            out aoLockedValues);

            if ( TryGetMarkedColumnData(out oMarkedColumnData) )
            {
            aoMarkedValues = ExcelUtil.GetRangeValues(oMarkedColumnData);
            }

            ColorConverter2 oColorConverter2 = new ColorConverter2();

            VertexShapeConverter oVertexShapeConverter =
            new VertexShapeConverter();

            VertexVisibilityConverter oVertexVisibilityConverter =
            new VertexVisibilityConverter();

            VertexLabelPositionConverter oVertexLabelPositionConverter =
            new VertexLabelPositionConverter();

            BooleanConverter oBooleanConverter = new BooleanConverter();

            // Loop through the IDs of the vertices whose attributes were edited
            // in the graph.

            EditedVertexAttributes oEditedVertexAttributes =
            e.EditedVertexAttributes;

            foreach (Int32 iID in e.VertexIDs)
            {
            // Look for the row that contains the ID.

            Int32 iRowOneBased;

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

            iRowOneBased -= oVertexTable.Range.Row;

            if (oEditedVertexAttributes.Color.HasValue &&
                aoColorValues != null)
            {
                aoColorValues[iRowOneBased, 1] =
                    oColorConverter2.GraphToWorkbook(
                        oEditedVertexAttributes.Color.Value);
            }

            if (oEditedVertexAttributes.Shape.HasValue &&
                aoShapeValues != null)
            {
                aoShapeValues[iRowOneBased, 1] =
                    oVertexShapeConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Shape.Value);
            }

            if (oEditedVertexAttributes.Radius.HasValue &&
                aoRadiusValues != null)
            {
                aoRadiusValues[iRowOneBased, 1] =
                    oEditedVertexAttributes.Radius.Value.ToString();
            }

            if (oEditedVertexAttributes.Alpha.HasValue &&
                aoAlphaValues != null)
            {
                aoAlphaValues[iRowOneBased, 1] =
                    oEditedVertexAttributes.Alpha.Value.ToString();
            }

            if (oEditedVertexAttributes.Visibility.HasValue &&
                aoVisibilityValues != null)
            {
                aoVisibilityValues[iRowOneBased, 1] =
                    oVertexVisibilityConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Visibility.Value);
            }

            if (oEditedVertexAttributes.LabelPosition.HasValue &&
                aoLabelPositionValues != null)
            {
                aoLabelPositionValues[iRowOneBased, 1] =
                    oVertexLabelPositionConverter.GraphToWorkbook(
                        oEditedVertexAttributes.LabelPosition.Value);
            }

            if (oEditedVertexAttributes.Locked.HasValue &&
                aoLockedValues != null)
            {
                aoLockedValues[iRowOneBased, 1] =
                    oBooleanConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Locked.Value);
            }

            if (oEditedVertexAttributes.Marked.HasValue &&
                aoMarkedValues != null)
            {
                aoMarkedValues[iRowOneBased, 1] =
                    oBooleanConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Marked.Value);
            }
            }

            // Activate this worksheet first, because writing to an inactive
            // worksheet causes problems with the selection in Excel.

            ExcelActiveWorksheetRestorer oExcelActiveWorksheetRestorer =
            GetExcelActiveWorksheetRestorer();

            ExcelActiveWorksheetState oExcelActiveWorksheetState =
            oExcelActiveWorksheetRestorer.ActivateWorksheet(this.InnerObject);

            try
            {
            if (aoColorValues != null)
            {
                oColorColumnData.set_Value(Missing.Value, aoColorValues);
            }

            if (aoShapeValues != null)
            {
                oShapeColumnData.set_Value(Missing.Value, aoShapeValues);
            }

            if (aoRadiusValues != null)
            {
                oRadiusColumnData.set_Value(Missing.Value, aoRadiusValues);
            }

            if (aoAlphaValues != null)
            {
                oAlphaColumnData.set_Value(Missing.Value, aoAlphaValues);
            }

            if (aoVisibilityValues != null)
            {
                oVisibilityColumnData.set_Value(Missing.Value,
                    aoVisibilityValues);
            }

            if (aoLabelPositionValues != null)
            {
                oLabelPositionColumnData.set_Value(Missing.Value,
                    aoLabelPositionValues);
            }

            if (aoLockedValues != null)
            {
                oLockedColumnData.set_Value(Missing.Value, aoLockedValues);
            }

            if (aoMarkedValues != null)
            {
                oMarkedColumnData.set_Value(Missing.Value, aoMarkedValues);
            }
            }
            finally
            {
            oExcelActiveWorksheetRestorer.Restore(oExcelActiveWorksheetState);
            }

            Globals.ThisWorkbook.ShowWaitCursor = false;
        }
Beispiel #4
0
        OnVertexAttributesEditedInGraph
        (
            VertexAttributesEditedEventArgs e
        )
        {
            Debug.Assert(e != null);
            AssertValid();

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

            // Get a dictionary containing the ID of each row in the table.

            Dictionary <Int32, Int32> oRowIDDictionary;

            if (!m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary))
            {
                // Nothing can be done without the IDs.

                return;
            }

            Globals.ThisWorkbook.ShowWaitCursor = true;

            // Get the columns that might need to be updated.  These columns are
            // not required.

            Microsoft.Office.Interop.Excel.Range oColorColumnData,
                                                 oShapeColumnData, oRadiusColumnData, oAlphaColumnData,
                                                 oVisibilityColumnData, oLabelPositionColumnData, oLockedColumnData,
                                                 oMarkedColumnData;

            Object [,] aoColorValues         = null;
            Object [,] aoShapeValues         = null;
            Object [,] aoRadiusValues        = null;
            Object [,] aoAlphaValues         = null;
            Object [,] aoVisibilityValues    = null;
            Object [,] aoLabelPositionValues = null;
            Object [,] aoLockedValues        = null;
            Object [,] aoMarkedValues        = null;

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.Color, out oColorColumnData,
                                                     out aoColorValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.Shape, out oShapeColumnData,
                                                     out aoShapeValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.Radius, out oRadiusColumnData,
                                                     out aoRadiusValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     CommonTableColumnNames.Alpha, out oAlphaColumnData,
                                                     out aoAlphaValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     CommonTableColumnNames.Visibility, out oVisibilityColumnData,
                                                     out aoVisibilityValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.LabelPosition, out oLabelPositionColumnData,
                                                     out aoLabelPositionValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
                                                     VertexTableColumnNames.Locked, out oLockedColumnData,
                                                     out aoLockedValues);

            if (TryGetMarkedColumnData(out oMarkedColumnData))
            {
                aoMarkedValues = ExcelUtil.GetRangeValues(oMarkedColumnData);
            }

            ColorConverter2 oColorConverter2 = new ColorConverter2();

            VertexShapeConverter oVertexShapeConverter =
                new VertexShapeConverter();

            VertexVisibilityConverter oVertexVisibilityConverter =
                new VertexVisibilityConverter();

            VertexLabelPositionConverter oVertexLabelPositionConverter =
                new VertexLabelPositionConverter();

            BooleanConverter oBooleanConverter = new BooleanConverter();

            // Loop through the IDs of the vertices whose attributes were edited
            // in the graph.

            EditedVertexAttributes oEditedVertexAttributes =
                e.EditedVertexAttributes;

            foreach (Int32 iID in e.VertexIDs)
            {
                // Look for the row that contains the ID.

                Int32 iRowOneBased;

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

                iRowOneBased -= oVertexTable.Range.Row;

                if (oEditedVertexAttributes.Color.HasValue &&
                    aoColorValues != null)
                {
                    aoColorValues[iRowOneBased, 1] =
                        oColorConverter2.GraphToWorkbook(
                            oEditedVertexAttributes.Color.Value);
                }

                if (oEditedVertexAttributes.Shape.HasValue &&
                    aoShapeValues != null)
                {
                    aoShapeValues[iRowOneBased, 1] =
                        oVertexShapeConverter.GraphToWorkbook(
                            oEditedVertexAttributes.Shape.Value);
                }

                if (oEditedVertexAttributes.Radius.HasValue &&
                    aoRadiusValues != null)
                {
                    aoRadiusValues[iRowOneBased, 1] =
                        oEditedVertexAttributes.Radius.Value.ToString();
                }

                if (oEditedVertexAttributes.Alpha.HasValue &&
                    aoAlphaValues != null)
                {
                    aoAlphaValues[iRowOneBased, 1] =
                        oEditedVertexAttributes.Alpha.Value.ToString();
                }

                if (oEditedVertexAttributes.Visibility.HasValue &&
                    aoVisibilityValues != null)
                {
                    aoVisibilityValues[iRowOneBased, 1] =
                        oVertexVisibilityConverter.GraphToWorkbook(
                            oEditedVertexAttributes.Visibility.Value);
                }

                if (oEditedVertexAttributes.LabelPosition.HasValue &&
                    aoLabelPositionValues != null)
                {
                    aoLabelPositionValues[iRowOneBased, 1] =
                        oVertexLabelPositionConverter.GraphToWorkbook(
                            oEditedVertexAttributes.LabelPosition.Value);
                }

                if (oEditedVertexAttributes.Locked.HasValue &&
                    aoLockedValues != null)
                {
                    aoLockedValues[iRowOneBased, 1] =
                        oBooleanConverter.GraphToWorkbook(
                            oEditedVertexAttributes.Locked.Value);
                }

                if (oEditedVertexAttributes.Marked.HasValue &&
                    aoMarkedValues != null)
                {
                    aoMarkedValues[iRowOneBased, 1] =
                        oBooleanConverter.GraphToWorkbook(
                            oEditedVertexAttributes.Marked.Value);
                }
            }

            // Activate this worksheet first, because writing to an inactive
            // worksheet causes problems with the selection in Excel.

            ExcelActiveWorksheetRestorer oExcelActiveWorksheetRestorer =
                GetExcelActiveWorksheetRestorer();

            ExcelActiveWorksheetState oExcelActiveWorksheetState =
                oExcelActiveWorksheetRestorer.ActivateWorksheet(this.InnerObject);

            try
            {
                if (aoColorValues != null)
                {
                    oColorColumnData.set_Value(Missing.Value, aoColorValues);
                }

                if (aoShapeValues != null)
                {
                    oShapeColumnData.set_Value(Missing.Value, aoShapeValues);
                }

                if (aoRadiusValues != null)
                {
                    oRadiusColumnData.set_Value(Missing.Value, aoRadiusValues);
                }

                if (aoAlphaValues != null)
                {
                    oAlphaColumnData.set_Value(Missing.Value, aoAlphaValues);
                }

                if (aoVisibilityValues != null)
                {
                    oVisibilityColumnData.set_Value(Missing.Value,
                                                    aoVisibilityValues);
                }

                if (aoLabelPositionValues != null)
                {
                    oLabelPositionColumnData.set_Value(Missing.Value,
                                                       aoLabelPositionValues);
                }

                if (aoLockedValues != null)
                {
                    oLockedColumnData.set_Value(Missing.Value, aoLockedValues);
                }

                if (aoMarkedValues != null)
                {
                    oMarkedColumnData.set_Value(Missing.Value, aoMarkedValues);
                }
            }
            finally
            {
                oExcelActiveWorksheetRestorer.Restore(oExcelActiveWorksheetState);
            }

            Globals.ThisWorkbook.ShowWaitCursor = false;
        }
Beispiel #5
0
        //*************************************************************************
        //  Method: TaskPane_VertexAttributesEditedInGraph()
        //
        /// <summary>
        /// Handles the VertexAttributesEditedInGraph event on the TaskPane.
        /// </summary>
        ///
        /// <param name="sender">
        /// Standard event argument.
        /// </param>
        ///
        /// <param name="e">
        /// Standard event argument.
        /// </param>
        ///
        /// <remarks>
        /// This event is fired when the user edits vertex attributes in the NodeXL
        /// graph.
        /// </remarks>
        //*************************************************************************
        private void TaskPane_VertexAttributesEditedInGraph(
            Object sender,
            VertexAttributesEditedEventArgs e
            )
        {
            Debug.Assert(e != null);
            AssertValid();

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

            // Forward the event.

            VertexAttributesEditedEventHandler oVertexAttributesEditedInGraph =
            this.VertexAttributesEditedInGraph;

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