Stores a list of edge attributes that were edited by .
The list of edges whose attributes were edited can be obtained from .
상속: Object
    //*************************************************************************
    //  Constructor: AttributesEditedEventArgs()
    //
    /// <summary>
    /// Initializes a new instance of the <see
    /// cref="AttributesEditedEventArgs" /> class.
    /// </summary>
    ///
    /// <param name="edgeIDs">
    /// Array of IDs of the edges whose attributes were edited in the graph, or
    /// null if edge attributes weren't edited.  The IDs came from the edge
    /// worksheet's ID column.
    /// </param>
    ///
    /// <param name="editedEdgeAttributes">
    /// Edge attributes that were applied to the edges, or null if edge
    /// attributes weren't edited.
    /// </param>
    ///
    /// <param name="vertexIDs">
    /// Array of IDs of the vertices whose attributes were edited in the graph,
    /// or null if vertex attributes weren't edited.  The IDs came from the
    /// vertex worksheet's ID column.
    /// </param>
    ///
    /// <param name="editedVertexAttributes">
    /// Vertex attributes that were applied to the vertices, or null if vertex
    /// attributes weren't edited.
    /// </param>
    ///
    /// <remarks>
    /// If edge attributes were edited, <paramref name="edgeIDs" /> and
    /// <paramref name="editedEdgeAttributes" /> should be non-null.  If vertex
    /// attributes were edited, <paramref name="vertexIDs" /> and <paramref
    /// name="editedVertexAttributes" /> should be non-null.
    /// </remarks>
    //*************************************************************************

    public AttributesEditedEventArgs
    (
        Int32 [] edgeIDs,
        EditedEdgeAttributes editedEdgeAttributes,
        Int32 [] vertexIDs,
        EditedVertexAttributes editedVertexAttributes
    )
    {
        m_aiEdgeIDs = edgeIDs;
        m_oEditedEdgeAttributes = editedEdgeAttributes;
        m_aiVertexIDs = vertexIDs;
        m_oEditedVertexAttributes = editedVertexAttributes;

        AssertValid();
    }
예제 #2
0
        //*************************************************************************
        //  Constructor: AttributesEditedEventArgs()
        //
        /// <summary>
        /// Initializes a new instance of the <see
        /// cref="AttributesEditedEventArgs" /> class.
        /// </summary>
        ///
        /// <param name="edgeIDs">
        /// Array of IDs of the edges whose attributes were edited in the graph, or
        /// null if edge attributes weren't edited.  The IDs came from the edge
        /// worksheet's ID column.
        /// </param>
        ///
        /// <param name="editedEdgeAttributes">
        /// Edge attributes that were applied to the edges, or null if edge
        /// attributes weren't edited.
        /// </param>
        ///
        /// <param name="vertexIDs">
        /// Array of IDs of the vertices whose attributes were edited in the graph,
        /// or null if vertex attributes weren't edited.  The IDs came from the
        /// vertex worksheet's ID column.
        /// </param>
        ///
        /// <param name="editedVertexAttributes">
        /// Vertex attributes that were applied to the vertices, or null if vertex
        /// attributes weren't edited.
        /// </param>
        ///
        /// <remarks>
        /// If edge attributes were edited, <paramref name="edgeIDs" /> and
        /// <paramref name="editedEdgeAttributes" /> should be non-null.  If vertex
        /// attributes were edited, <paramref name="vertexIDs" /> and <paramref
        /// name="editedVertexAttributes" /> should be non-null.
        /// </remarks>
        //*************************************************************************

        public AttributesEditedEventArgs
        (
            Int32 [] edgeIDs,
            EditedEdgeAttributes editedEdgeAttributes,
            Int32 [] vertexIDs,
            EditedVertexAttributes editedVertexAttributes
        )
        {
            m_aiEdgeIDs               = edgeIDs;
            m_oEditedEdgeAttributes   = editedEdgeAttributes;
            m_aiVertexIDs             = vertexIDs;
            m_oEditedVertexAttributes = editedVertexAttributes;

            AssertValid();
        }
예제 #3
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;
        }
예제 #4
0
    FireAttributesEditedInGraph
    (
        EditedEdgeAttributes oEditedEdgeAttributes,
        EditedVertexAttributes oEditedVertexAttributes
    )
    {
        AssertValid();

        EventHandler<AttributesEditedEventArgs> oAttributesEditedInGraph =
            this.AttributesEditedInGraph;

        if (oAttributesEditedInGraph != null)
        {
            oAttributesEditedInGraph( this,

                new AttributesEditedEventArgs(

                    (oEditedEdgeAttributes == null) ? null :

                        NodeXLControlUtil.GetSelectedEdgeRowIDs(
                            oNodeXLControl).ToArray(),

                    oEditedEdgeAttributes,

                    (oEditedVertexAttributes == null) ? null :

                        NodeXLControlUtil.GetSelectedVertexRowIDs(
                            oNodeXLControl).ToArray(),

                    oEditedVertexAttributes
                ) );
        }
    }
예제 #5
0
        GetInitialEdgeAttributes()
        {
            // AssertValid();

            EditedEdgeAttributes oInitialEdgeAttributes =
                new EditedEdgeAttributes();

            ICollection <IMetadataProvider> oSelectedEdges =
                (ICollection <IMetadataProvider>)m_oNodeXLControl.SelectedEdges;

            // Color.

            oInitialEdgeAttributes.Color = GetInitialStructAttributeValue <Color>(
                ReservedMetadataKeys.PerColor);

            // Width.

            oInitialEdgeAttributes.Width = GetInitialSingleAttributeValue(
                oSelectedEdges, ReservedMetadataKeys.PerEdgeWidth,
                new EdgeWidthConverter());

            // Style.

            oInitialEdgeAttributes.Style =
                GetInitialStructAttributeValue <EdgeStyle>(
                    ReservedMetadataKeys.PerEdgeStyle);

            // Alpha.

            oInitialEdgeAttributes.Alpha = GetInitialSingleAttributeValue(
                oSelectedEdges, ReservedMetadataKeys.PerAlpha,
                new AlphaConverter());

            // Visibility.

            oInitialEdgeAttributes.Visibility = null;

            // Label.

            oInitialEdgeAttributes.Label = GetInitialClassAttributeValue <String>(
                oSelectedEdges, ReservedMetadataKeys.PerEdgeLabel);

            // Label text color.

            oInitialEdgeAttributes.LabelTextColor =
                GetInitialStructAttributeValue <Color>(
                    ReservedMetadataKeys.PerEdgeLabelTextColor);

            // Label font size.

            Nullable <Single> oLabelFontSize =
                GetInitialStructAttributeValue <Single>(
                    oSelectedEdges, ReservedMetadataKeys.PerEdgeLabelFontSize);

            if (oLabelFontSize.HasValue)
            {
                oLabelFontSize = (new FontSizeConverter()).GraphToWorkbook(
                    oLabelFontSize.Value);
            }

            oInitialEdgeAttributes.LabelFontSize = oLabelFontSize;

            return(oInitialEdgeAttributes);
        }