Provides event information for the and events.
Наследование: System.EventArgs
Пример #1
0
        ThisWorkbook_AttributesEditedInGraph
        (
            Object sender,
            AttributesEditedEventArgs e
        )
        {
            Debug.Assert(e != null);
            AssertValid();

            // The key is the row ID stored in the table's ID column and the value
            // is the one-based row number relative to the worksheet.

            Dictionary <Int32, Int32> oRowIDDictionary;

            if (
                e.EditedEdgeAttributes == null
                ||
                !m_oSheets1And2Helper.TableExists
                ||
                !m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary)
                )
            {
                return;
            }

            Microsoft.Office.Interop.Excel.ListObject oEdgeTable =
                Edges.InnerObject;

            Globals.ThisWorkbook.ShowWaitCursor = true;

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

            Microsoft.Office.Interop.Excel.Range oColorColumnData,
                                                 oWidthColumnData, oStyleColumnData, oAlphaColumnData,
                                                 oVisibilityColumnData, oLabelColumnData,
                                                 oLabelTextColorColumnData, oLabelFontSizeColumnData;

            Object [,] aoColorValues          = null;
            Object [,] aoWidthValues          = null;
            Object [,] aoStyleValues          = null;
            Object [,] aoAlphaValues          = null;
            Object [,] aoVisibilityValues     = null;
            Object [,] aoLabelValues          = null;
            Object [,] aoLabelTextColorValues = null;
            Object [,] aoLabelFontSizeValues  = null;

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.Color, out oColorColumnData,
                                                          out aoColorValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.Width, out oWidthColumnData,
                                                          out aoWidthValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.Style, out oStyleColumnData,
                                                          out aoStyleValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          CommonTableColumnNames.Alpha, out oAlphaColumnData,
                                                          out aoAlphaValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          CommonTableColumnNames.Visibility, out oVisibilityColumnData,
                                                          out aoVisibilityValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.Label, out oLabelColumnData,
                                                          out aoLabelValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.LabelTextColor, out oLabelTextColorColumnData,
                                                          out aoLabelTextColorValues);

            ExcelTableUtil.TryGetTableColumnDataAndValues(oEdgeTable,
                                                          EdgeTableColumnNames.LabelFontSize, out oLabelFontSizeColumnData,
                                                          out aoLabelFontSizeValues);

            ColorConverter2    oColorConverter2    = new ColorConverter2();
            EdgeStyleConverter oEdgeStyleConverter = new EdgeStyleConverter();

            EdgeVisibilityConverter oEdgeVisibilityConverter =
                new EdgeVisibilityConverter();

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

            EditedEdgeAttributes oEditedEdgeAttributes = e.EditedEdgeAttributes;

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

                Int32 iRowOneBased;

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

                iRowOneBased -= oEdgeTable.Range.Row;

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

                if (oEditedEdgeAttributes.Width.HasValue && aoWidthValues != null)
                {
                    aoWidthValues[iRowOneBased, 1] =
                        oEditedEdgeAttributes.Width.Value.ToString();
                }

                if (oEditedEdgeAttributes.Style.HasValue && aoStyleValues != null)
                {
                    aoStyleValues[iRowOneBased, 1] =
                        oEdgeStyleConverter.GraphToWorkbook(
                            oEditedEdgeAttributes.Style.Value);
                }

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

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

                if (!String.IsNullOrEmpty(oEditedEdgeAttributes.Label))
                {
                    aoLabelValues[iRowOneBased, 1] = oEditedEdgeAttributes.Label;
                }

                if (oEditedEdgeAttributes.LabelTextColor.HasValue &&
                    aoLabelTextColorValues != null)
                {
                    aoLabelTextColorValues[iRowOneBased, 1] =
                        oColorConverter2.GraphToWorkbook(
                            oEditedEdgeAttributes.LabelTextColor.Value);
                }

                if (oEditedEdgeAttributes.LabelFontSize.HasValue &&
                    aoLabelFontSizeValues != null)
                {
                    aoLabelFontSizeValues[iRowOneBased, 1] =
                        oEditedEdgeAttributes.LabelFontSize.Value.ToString();
                }
            }

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

            ExcelActiveWorksheetRestorer oExcelActiveWorksheetRestorer =
                m_oSheets1And2Helper.GetExcelActiveWorksheetRestorer();

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

            try
            {
                m_oSheets1And2Helper.SetColumnDataValues(
                    oColorColumnData, aoColorValues,
                    oWidthColumnData, aoWidthValues,
                    oStyleColumnData, aoStyleValues,
                    oAlphaColumnData, aoAlphaValues,
                    oVisibilityColumnData, aoVisibilityValues,
                    oLabelColumnData, aoLabelValues,
                    oLabelTextColorColumnData, aoLabelTextColorValues,
                    oLabelFontSizeColumnData, aoLabelFontSizeValues
                    );
            }
            finally
            {
                oExcelActiveWorksheetRestorer.Restore(oExcelActiveWorksheetState);
            }

            Globals.ThisWorkbook.ShowWaitCursor = false;
        }
Пример #2
0
    ThisWorkbook_AttributesEditedInGraph
    (
        Object sender,
        AttributesEditedEventArgs e
    )
    {
        Debug.Assert(e != null);
        AssertValid();

        // The key is the row ID stored in the table's ID column and the value
        // is the one-based row number relative to the worksheet.

        Dictionary<Int32, Int32> oRowIDDictionary;

        if (
            e.EditedVertexAttributes == null
            ||
            !m_oSheets1And2Helper.TableExists
            ||
            !m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary)
            )
        {
            return;
        }

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

        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, oLabelColumnData, oLabelFillColorColumnData,
            oLabelPositionColumnData, oToolTipColumnData, oLockedColumnData,
            oMarkedColumnData;

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

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

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

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

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

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

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Label, out oLabelColumnData,
            out aoLabelValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.LabelFillColor,
            out oLabelFillColorColumnData, out aoLabelFillColorValues);

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

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.ToolTip, out oToolTipColumnData,
            out aoToolTipValues);

        ExcelTableUtil.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 ( !String.IsNullOrEmpty(oEditedVertexAttributes.Label) )
            {
                aoLabelValues[iRowOneBased, 1] = oEditedVertexAttributes.Label;
            }

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

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

            if ( !String.IsNullOrEmpty(oEditedVertexAttributes.ToolTip) )
            {
                aoToolTipValues[iRowOneBased, 1] =
                    oEditedVertexAttributes.ToolTip;
            }

            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 =
            m_oSheets1And2Helper.GetExcelActiveWorksheetRestorer();

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

        try
        {
            m_oSheets1And2Helper.SetColumnDataValues(
                oColorColumnData, aoColorValues,
                oShapeColumnData, aoShapeValues,
                oRadiusColumnData, aoRadiusValues,
                oAlphaColumnData, aoAlphaValues,
                oVisibilityColumnData, aoVisibilityValues,
                oLabelColumnData, aoLabelValues,
                oLabelFillColorColumnData, aoLabelFillColorValues,
                oLabelPositionColumnData, aoLabelPositionValues,
                oToolTipColumnData, aoToolTipValues,
                oLockedColumnData, aoLockedValues,
                oMarkedColumnData, aoMarkedValues
                );
        }
        finally
        {
            oExcelActiveWorksheetRestorer.Restore(oExcelActiveWorksheetState);
        }

        Globals.ThisWorkbook.ShowWaitCursor = false;
    }