SetVisualAttribute ( SetVisualAttributeEventArgs e, Range selectedRange, String colorColumnName, String alphaColumnName ) { Debug.Assert(e != null); Debug.Assert(selectedRange != null); Debug.Assert(ExcelUtil.WorksheetIsActive(m_oWorksheet.InnerObject)); AssertValid(); if (e.VisualAttribute == VisualAttributes.Color && colorColumnName != null) { String sColor; // Get a color from the user. if (NodeXLWorkbookUtil.TryGetColor(out sColor)) { ExcelUtil.SetVisibleSelectedTableColumnData( m_oTable.InnerObject, selectedRange, colorColumnName, sColor); e.VisualAttributeSet = true; } } }
ThisWorkbook_SetVisualAttribute2 ( Object sender, SetVisualAttributeEventArgs e ) { Debug.Assert(e != null); AssertValid(); Microsoft.Office.Interop.Excel.Range oSelectedRange; if (e.VisualAttributeSet || !m_oSheets1And2Helper.TryGetSelectedRange(out oSelectedRange)) { return; } // See if the specified attribute is set by the helper class. m_oSheets1And2Helper.SetVisualAttribute(e, oSelectedRange, EdgeTableColumnNames.Color, CommonTableColumnNames.Alpha); if (e.VisualAttributeSet) { return; } if (e.VisualAttribute == VisualAttributes.EdgeWidth) { EdgeWidthDialog oEdgeWidthDialog = new EdgeWidthDialog(); if (oEdgeWidthDialog.ShowDialog() == DialogResult.OK) { ExcelUtil.SetVisibleSelectedTableColumnData( this.Edges.InnerObject, oSelectedRange, EdgeTableColumnNames.Width, oEdgeWidthDialog.EdgeWidth); e.VisualAttributeSet = true; } } else if (e.VisualAttribute == VisualAttributes.EdgeVisibility) { Debug.Assert(e.AttributeValue is EdgeWorksheetReader.Visibility); ExcelUtil.SetVisibleSelectedTableColumnData( this.Edges.InnerObject, oSelectedRange, CommonTableColumnNames.Visibility, (new EdgeVisibilityConverter()).GraphToWorkbook( (EdgeWorksheetReader.Visibility)e.AttributeValue) ); e.VisualAttributeSet = true; } }
ThisWorkbook_SetVisualAttribute2 ( Object sender, SetVisualAttributeEventArgs e ) { Debug.Assert(e != null); AssertValid(); Microsoft.Office.Interop.Excel.Range oSelectedRange; if (e.VisualAttributeSet || !m_oSheetHelper.TryGetSelectedRange(out oSelectedRange)) { return; } // See if the specified attribute is set by the helper class. m_oSheetHelper.SetVisualAttribute(e, oSelectedRange, GroupTableColumnNames.VertexColor, null); if (e.VisualAttributeSet) { return; } if (e.VisualAttribute == VisualAttributes.VertexShape) { Debug.Assert(e.AttributeValue is VertexShape); ExcelUtil.SetVisibleSelectedTableColumnData( this.Groups.InnerObject, oSelectedRange, GroupTableColumnNames.VertexShape, (new VertexShapeConverter()).GraphToWorkbook( (VertexShape)e.AttributeValue) ); e.VisualAttributeSet = true; } }
SetVisualAttribute ( SetVisualAttributeEventArgs e, Range selectedRange, String colorColumnName, String alphaColumnName ) { Debug.Assert(e != null); Debug.Assert(selectedRange != null); Debug.Assert(ExcelUtil.WorksheetIsActive(m_oWorksheet.InnerObject)); AssertValid(); base.SetVisualAttribute(e, selectedRange, colorColumnName, alphaColumnName); if (e.VisualAttributeSet) { return; } if (e.VisualAttribute == VisualAttributes.Alpha && alphaColumnName != null) { AlphaDialog oAlphaDialog = new AlphaDialog(); if (oAlphaDialog.ShowDialog() == DialogResult.OK) { ExcelUtil.SetVisibleSelectedTableColumnData( m_oTable.InnerObject, selectedRange, alphaColumnName, oAlphaDialog.Alpha); e.VisualAttributeSet = true; } } }
//************************************************************************* // Method: ThisWorkbook_SetVisualAttribute2() // /// <summary> /// Handles the SetVisualAttribute2 event on ThisWorkbook. /// </summary> /// /// <param name="sender"> /// Standard event argument. /// </param> /// /// <param name="e"> /// Standard event argument. /// </param> //************************************************************************* private void ThisWorkbook_SetVisualAttribute2( Object sender, SetVisualAttributeEventArgs e ) { Debug.Assert(e != null); AssertValid(); Microsoft.Office.Interop.Excel.Range oSelectedRange; if ( e.VisualAttributeSet || !m_oSheetHelper.TryGetSelectedRange(out oSelectedRange) ) { return; } // See if the specified attribute is set by the helper class. m_oSheetHelper.SetVisualAttribute(e, oSelectedRange, GroupTableColumnNames.VertexColor, null); if (e.VisualAttributeSet) { return; } if (e.VisualAttribute == VisualAttributes.VertexShape) { Debug.Assert(e.AttributeValue is VertexShape); ExcelUtil.SetVisibleSelectedTableColumnData( this.Groups.InnerObject, oSelectedRange, GroupTableColumnNames.VertexShape, ( new VertexShapeConverter() ).GraphToWorkbook( (VertexShape)e.AttributeValue) ); e.VisualAttributeSet = true; } }
//************************************************************************* // Method: ThisWorkbook_SetVisualAttribute2() // /// <summary> /// Handles the SetVisualAttribute2 event on ThisWorkbook. /// </summary> /// /// <param name="sender"> /// Standard event argument. /// </param> /// /// <param name="e"> /// Standard event argument. /// </param> //************************************************************************* private void ThisWorkbook_SetVisualAttribute2( Object sender, SetVisualAttributeEventArgs e ) { Debug.Assert(e != null); AssertValid(); Microsoft.Office.Interop.Excel.Range oSelectedRange; if ( e.VisualAttributeSet || !m_oSheets1And2Helper.TryGetSelectedRange(out oSelectedRange) ) { return; } // See if the specified attribute is set by the helper class. m_oSheets1And2Helper.SetVisualAttribute(e, oSelectedRange, EdgeTableColumnNames.Color, CommonTableColumnNames.Alpha); if (e.VisualAttributeSet) { return; } if (e.VisualAttribute == VisualAttributes.EdgeWidth) { EdgeWidthDialog oEdgeWidthDialog = new EdgeWidthDialog(); if (oEdgeWidthDialog.ShowDialog() == DialogResult.OK) { ExcelUtil.SetVisibleSelectedTableColumnData( this.Edges.InnerObject, oSelectedRange, EdgeTableColumnNames.Width, oEdgeWidthDialog.EdgeWidth); e.VisualAttributeSet = true; } } else if (e.VisualAttribute == VisualAttributes.EdgeVisibility) { Debug.Assert(e.AttributeValue is EdgeWorksheetReader.Visibility); ExcelUtil.SetVisibleSelectedTableColumnData( this.Edges.InnerObject, oSelectedRange, CommonTableColumnNames.Visibility, ( new EdgeVisibilityConverter() ).GraphToWorkbook( (EdgeWorksheetReader.Visibility)e.AttributeValue) ); e.VisualAttributeSet = true; } }
//************************************************************************* // Method: SetVisualAttribute() // /// <summary> /// Sets one visual attribute that gets stored in the workbook. /// </summary> /// /// <param name="visualAttribute"> /// Specifies the visual attribute to set. Must be only one of the flags /// in the <see cref="VisualAttributes" /> enumeration; it cannot be an /// ORed combination. /// </param> /// /// <param name="attributeValue"> /// The visual attribute value, or null if the value isn't known yet and /// must be obtained from the user. /// </param> /// /// <remarks> /// If the specified visual attribute is a graph-level attribute (such as /// VisualAttribute.GraphBackground), the visual attribute value gets /// stored in the workbook's per-workbook settings. Otherwise, the visual /// attribute value gets stored in the selected rows of the active /// worksheet. /// </remarks> //************************************************************************* public void SetVisualAttribute( VisualAttributes visualAttribute, Object attributeValue ) { AssertValid(); if ( !this.ExcelApplicationIsReady(true) ) { return; } if (visualAttribute == VisualAttributes.GraphBackground) { BackgroundDialog oBackgroundDialog = new BackgroundDialog( this.PerWorkbookSettings); if (oBackgroundDialog.ShowDialog() == DialogResult.OK) { FireVisualAttributeSetInWorkbook(); } } else { SetVisualAttributeEventHandler oSetVisualAttributeEventHandler = this.SetVisualAttribute2; if (oSetVisualAttributeEventHandler != null) { SetVisualAttributeEventArgs oSetVisualAttributeEventArgs = new SetVisualAttributeEventArgs(visualAttribute, attributeValue); oSetVisualAttributeEventHandler(this, oSetVisualAttributeEventArgs); if (oSetVisualAttributeEventArgs.VisualAttributeSet) { FireVisualAttributeSetInWorkbook(); } } } }