/// <summary> /// This method is drawing core connections diagram for given cables /// </summary> /// <param name="aCables">list of cables for which diagram should be drawn</param> public void DrawSchema(ArrayList aCables) { // check if drawing control for schema is set and correct if (mDwgCtrl == null || mDwgCtrl.IsDisposed) { return; } try { mDwgCtrl.Document.Application.QueueMarkerEvent("E_OFF"); // prepare first page for drawing SetPageProperties(mDwgCtrl.Document.Pages[1].PageSheet); // draw diagram header double _posY = DrawDiagramHeader(mDwgCtrl.Document.Pages[1]); // draw header of connections table _posY = DrawTableHeader(mDwgCtrl.Document.Pages[1], _posY - mMargin); // set current page Visio.Page _currPage = mDwgCtrl.Document.Pages[1]; // draw connections diagram for all cables in list foreach (Database.DbElement _dbCable in aCables) { // get info for current cable CableInfo _cableInfo = new CableInfo(_dbCable); // check if new page is needed and if so create it if (GetCableHeight(_cableInfo) > _posY - mMargin * 2) { Visio.Page _newPage = mDwgCtrl.Document.Pages.Add(); SetPageProperties(_newPage.PageSheet); _posY = DrawTableHeader(_newPage, _newPage.PageSheet.get_Cells(CELL_PAGE_HEIGHT).ResultIU - mMargin); _currPage = _newPage; } // draw schema for current cable _posY = DrawCable(_currPage, _cableInfo, _posY - mMargin); } // clear selection mDwgCtrl.Window.DeselectAll(); // at the end set first page as active mDwgCtrl.Window.Page = mDwgCtrl.Document.Pages[1]; // mark document as saved mDwgCtrl.Document.Saved = true; } finally { mDwgCtrl.Document.Application.QueueMarkerEvent("E_ON"); } }
/// <summary> /// public constructor /// </summary> /// <param name="aCore">database core element to get information from</param> public CoreInfo(Database.DbElement aCore, CableInfo aCableInfo) { mStartElconn = aCableInfo.StartElconn; mStartEqui = aCableInfo.StartEqui; mEndElconn = aCableInfo.EndElconn; mEndEqui = aCableInfo.EndEqui; if (aCore.IsValid) { // get core name mCoreName = aCore.GetAsString(Database.DbAttributeInstance.NAMN); // get information about elements connected to core head Database.DbElement _elconn = aCore.GetElement(Database.DbAttributeInstance.STAREF); if (_elconn.IsValid) { mStartElconn = MiscUtilities.GetElemPresName(_elconn); mStartEqui = MiscUtilities.GetElemPresName(_elconn.Owner); } int _point = aCore.GetInteger(Database.DbAttributeInstance.STAPOI); if (_point == 0) { mStartPin = UNSET_TEXT; } else { mStartPin = string.Format(PIN_TEMPLATE, _point.ToString()); } // get information about elements connected to core tail _elconn = aCore.GetElement(Database.DbAttributeInstance.ENDREF); if (_elconn.IsValid) { mEndElconn = MiscUtilities.GetElemPresName(_elconn); mEndEqui = MiscUtilities.GetElemPresName(_elconn.Owner); } _point = aCore.GetInteger(Database.DbAttributeInstance.ENDPOI); if (_point == 0) { mEndPin = UNSET_TEXT; } else { mEndPin = string.Format(PIN_TEMPLATE, _point.ToString()); } } }
/// <summary> /// This method is calculating height of schema for single cable /// </summary> /// <param name="aCableInfo">information about cable to calculate height</param> /// <returns>height of schema for given cable</returns> private double GetCableHeight(CableInfo aCableInfo) { double _height = 0.0; if (aCableInfo.CoreNo == 0) { _height = mCoreHeight; } else { _height = aCableInfo.CoreNo * mCoreHeight; } return(_height); }
/// <summary> /// public constructor /// </summary> /// <param name="aCore">database core element to get information from</param> public CoreInfo( Database.DbElement aCore, CableInfo aCableInfo ) { mStartElconn = aCableInfo.StartElconn; mStartEqui = aCableInfo.StartEqui; mEndElconn = aCableInfo.EndElconn; mEndEqui = aCableInfo.EndEqui; if( aCore.IsValid ) { // get core name mCoreName = aCore.GetAsString( Database.DbAttributeInstance.NAMN ); // get information about elements connected to core head Database.DbElement _elconn = aCore.GetElement( Database.DbAttributeInstance.STAREF ); if( _elconn.IsValid ) { mStartElconn = MiscUtilities.GetElemPresName( _elconn ); mStartEqui = MiscUtilities.GetElemPresName( _elconn.Owner ); } int _point = aCore.GetInteger( Database.DbAttributeInstance.STAPOI ); if( _point == 0 ) mStartPin = UNSET_TEXT; else mStartPin = string.Format( PIN_TEMPLATE, _point.ToString() ); // get information about elements connected to core tail _elconn = aCore.GetElement( Database.DbAttributeInstance.ENDREF ); if( _elconn.IsValid ) { mEndElconn = MiscUtilities.GetElemPresName( _elconn ); mEndEqui = MiscUtilities.GetElemPresName( _elconn.Owner ); } _point = aCore.GetInteger( Database.DbAttributeInstance.ENDPOI ); if( _point == 0 ) mEndPin = UNSET_TEXT; else mEndPin = string.Format( PIN_TEMPLATE, _point.ToString() ); } }
/// <summary> /// This method is drawing schema for single cable /// </summary> /// <param name="aPage">page to draw on</param> /// <param name="aCableInfo">information about cable to draw</param> /// <param name="aPosY">vertical position in which schema should start</param> /// <returns>ertical position after drawing</returns> private double DrawCable(Visio.Page aPage, CableInfo aCableInfo, double aPosY) { if (aCableInfo.CoreNo == 0) { aCableInfo.CoreInfo.Add(new CoreInfo(Database.DbElement.GetElement(), aCableInfo)); } double _cableHeight = aCableInfo.CoreNo * mCoreHeight; Visio.Shape _newShape = aPage.DrawLine(mCablePosX, aPosY - _cableHeight / 2.0, mCablePosX + mCableWidth, aPosY - _cableHeight / 2.0); SetTextProperties(_newShape, aCableInfo.CableName + Environment.NewLine + aCableInfo.ComponentName, FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter); _newShape = aPage.DrawLine(mCablePosX, aPosY, mCablePosX, aPosY - _cableHeight); _newShape = aPage.DrawLine(mCablePosX + mCableWidth, aPosY, mCablePosX + mCableWidth, aPosY - _cableHeight); int _lastBeginEqui = 0, _lastEndEqui = 0, _lastBeginElconn = 0, _lastEndElconn = 0, _current = 0; string _lastBeginEquiName = string.Empty, _lastEndEquiName = string.Empty, _lastBeginElconnName = string.Empty, _lastEndElconnName = string.Empty; foreach (CoreInfo _core in aCableInfo.CoreInfo) { //draw core boxes _newShape = aPage.DrawRectangle(mCablePosX - mCoreWidth - mSpaceBetween, aPosY - _current * mCoreHeight, mCablePosX - mSpaceBetween, aPosY - (_current + 1) * mCoreHeight); SetTextProperties(_newShape, _core.CoreName, "6pt", (int)Visio.VisCellVals.visHorzCenter); _newShape = aPage.DrawRectangle(mCablePosX + mCableWidth + mSpaceBetween, aPosY - _current * mCoreHeight, mCablePosX + mCableWidth + mSpaceBetween + mCoreWidth, aPosY - (_current + 1) * mCoreHeight); SetTextProperties(_newShape, _core.CoreName, "6pt", (int)Visio.VisCellVals.visHorzCenter); //draw pin boxes _newShape = aPage.DrawRectangle(mCablePosX - (mCoreWidth + mSpaceBetween) * 2, aPosY - _current * mCoreHeight, mCablePosX - mCoreWidth - mSpaceBetween * 2, aPosY - (_current + 1) * mCoreHeight); SetTextProperties(_newShape, _core.StartPin, "6pt", (int)Visio.VisCellVals.visHorzCenter); _newShape = aPage.DrawRectangle(mCablePosX + mCableWidth + mSpaceBetween * 2 + mCoreWidth, aPosY - _current * mCoreHeight, mCablePosX + mCableWidth + (mSpaceBetween + mCoreWidth) * 2, aPosY - (_current + 1) * mCoreHeight); SetTextProperties(_newShape, _core.EndPin, "6pt", (int)Visio.VisCellVals.visHorzCenter); //check/draw elconns if (_core.StartElconn == string.Empty || _lastBeginElconnName != _core.StartElconn) { if (_current > 0) { double _posX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2; double _posY = aPosY - _lastBeginElconn * mCoreHeight; //draw elconn _newShape = aPage.DrawRectangle(_posX - mElconnWidth, _posY, _posX, _posY - (_current - _lastBeginElconn) * mCoreHeight); SetTextProperties(_newShape, _lastBeginElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter); _lastBeginElconn = _current; } _lastBeginElconnName = _core.StartElconn; } if (_core.EndElconn == string.Empty || _lastEndElconnName != _core.EndElconn) { if (_current > 0) { //draw elconn double _posX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth; double _posY = aPosY - _lastEndElconn * mCoreHeight; //draw elconn _newShape = aPage.DrawRectangle(_posX, _posY, _posX + mElconnWidth, _posY - (_current - _lastEndElconn) * mCoreHeight); SetTextProperties(_newShape, _lastEndElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter); _lastEndElconn = _current; } _lastEndElconnName = _core.EndElconn; } //check/draw equips if (_core.StartEqui == string.Empty || _lastBeginEquiName != _core.StartEqui) { if (_current > 0) { //draw equi double _posX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2 - mElconnWidth; double _posY = aPosY - _lastBeginEqui * mCoreHeight; _newShape = aPage.DrawRectangle(_posX - mEquiWidth, _posY, _posX, _posY - (_current - _lastBeginEqui) * mCoreHeight); SetTextProperties(_newShape, _lastBeginEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter); _lastBeginEqui = _current; } _lastBeginEquiName = _core.StartEqui; } if (_core.EndEqui == string.Empty || _lastEndEquiName != _core.EndEqui) { if (_current > 0) { //draw equi double _posX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth + mElconnWidth; double _posY = aPosY - _lastEndEqui * mCoreHeight; _newShape = aPage.DrawRectangle(_posX, _posY, _posX + mEquiWidth, _posY - (_current - _lastEndEqui) * mCoreHeight); SetTextProperties(_newShape, _lastEndEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter); _lastEndEqui = _current; } _lastEndEquiName = _core.EndEqui; } _current++; } //draw last elconns double _pX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2; double _pY = aPosY - _lastBeginElconn * mCoreHeight; _newShape = aPage.DrawRectangle(_pX - mElconnWidth, _pY, _pX, _pY - (_current - _lastBeginElconn) * mCoreHeight); SetTextProperties(_newShape, _lastBeginElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter); _pX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth; _pY = aPosY - _lastEndElconn * mCoreHeight; _newShape = aPage.DrawRectangle(_pX, _pY, _pX + mElconnWidth, _pY - (_current - _lastEndElconn) * mCoreHeight); SetTextProperties(_newShape, _lastEndElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter); //draw last equips _pX = mCablePosX - (mSpaceBetween + mCoreWidth) * 2 - mElconnWidth; _pY = aPosY - _lastBeginEqui * mCoreHeight; _newShape = aPage.DrawRectangle(_pX - mEquiWidth, _pY, _pX, _pY - (_current - _lastBeginEqui) * mCoreHeight); SetTextProperties(_newShape, _lastBeginEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter); _pX = mCablePosX + (mSpaceBetween + mCoreWidth) * 2 + mCableWidth + mElconnWidth; _pY = aPosY - _lastEndEqui * mCoreHeight; _newShape = aPage.DrawRectangle(_pX, _pY, _pX + mEquiWidth, _pY - (_current - _lastEndEqui) * mCoreHeight); SetTextProperties(_newShape, _lastEndEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter); return(aPosY - _cableHeight); }
/// <summary> /// This method is calculating height of schema for single cable /// </summary> /// <param name="aCableInfo">information about cable to calculate height</param> /// <returns>height of schema for given cable</returns> private double GetCableHeight( CableInfo aCableInfo ) { double _height = 0.0; if( aCableInfo.CoreNo == 0 ) _height = mCoreHeight; else _height = aCableInfo.CoreNo * mCoreHeight; return _height; }
/// <summary> /// This method is drawing schema for single cable /// </summary> /// <param name="aPage">page to draw on</param> /// <param name="aCableInfo">information about cable to draw</param> /// <param name="aPosY">vertical position in which schema should start</param> /// <returns>ertical position after drawing</returns> private double DrawCable( Visio.Page aPage, CableInfo aCableInfo, double aPosY ) { if( aCableInfo.CoreNo == 0 ) aCableInfo.CoreInfo.Add( new CoreInfo( Database.DbElement.GetElement(), aCableInfo ) ); double _cableHeight = aCableInfo.CoreNo * mCoreHeight; Visio.Shape _newShape = aPage.DrawLine( mCablePosX, aPosY - _cableHeight / 2.0, mCablePosX + mCableWidth, aPosY - _cableHeight / 2.0 ); SetTextProperties( _newShape, aCableInfo.CableName + Environment.NewLine + aCableInfo.ComponentName, FONT_SIZE, (int)Visio.VisCellVals.visHorzCenter ); _newShape = aPage.DrawLine( mCablePosX, aPosY, mCablePosX, aPosY - _cableHeight ); _newShape = aPage.DrawLine( mCablePosX + mCableWidth, aPosY, mCablePosX + mCableWidth, aPosY - _cableHeight ); int _lastBeginEqui = 0, _lastEndEqui = 0, _lastBeginElconn = 0, _lastEndElconn = 0, _current = 0; string _lastBeginEquiName = string.Empty, _lastEndEquiName = string.Empty, _lastBeginElconnName = string.Empty, _lastEndElconnName = string.Empty; foreach( CoreInfo _core in aCableInfo.CoreInfo ) { //draw core boxes _newShape = aPage.DrawRectangle( mCablePosX - mCoreWidth - mSpaceBetween, aPosY - _current * mCoreHeight, mCablePosX - mSpaceBetween, aPosY - ( _current + 1 ) * mCoreHeight ); SetTextProperties( _newShape, _core.CoreName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); _newShape = aPage.DrawRectangle( mCablePosX + mCableWidth + mSpaceBetween, aPosY - _current * mCoreHeight, mCablePosX + mCableWidth + mSpaceBetween + mCoreWidth, aPosY - ( _current + 1 ) * mCoreHeight ); SetTextProperties( _newShape, _core.CoreName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); //draw pin boxes _newShape = aPage.DrawRectangle( mCablePosX - ( mCoreWidth + mSpaceBetween ) * 2, aPosY - _current * mCoreHeight, mCablePosX - mCoreWidth - mSpaceBetween * 2, aPosY - ( _current + 1 ) * mCoreHeight ); SetTextProperties( _newShape, _core.StartPin, "6pt", (int)Visio.VisCellVals.visHorzCenter ); _newShape = aPage.DrawRectangle( mCablePosX + mCableWidth + mSpaceBetween * 2 + mCoreWidth, aPosY - _current * mCoreHeight, mCablePosX + mCableWidth + ( mSpaceBetween + mCoreWidth ) * 2, aPosY - ( _current + 1 ) * mCoreHeight ); SetTextProperties( _newShape, _core.EndPin, "6pt", (int)Visio.VisCellVals.visHorzCenter ); //check/draw elconns if( _core.StartElconn == string.Empty || _lastBeginElconnName != _core.StartElconn ) { if( _current > 0 ) { double _posX = mCablePosX - ( mSpaceBetween + mCoreWidth ) * 2; double _posY = aPosY - _lastBeginElconn * mCoreHeight; //draw elconn _newShape = aPage.DrawRectangle( _posX - mElconnWidth, _posY, _posX, _posY - ( _current - _lastBeginElconn ) * mCoreHeight ); SetTextProperties( _newShape, _lastBeginElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); _lastBeginElconn = _current; } _lastBeginElconnName = _core.StartElconn; } if( _core.EndElconn == string.Empty || _lastEndElconnName != _core.EndElconn ) { if( _current > 0 ) { //draw elconn double _posX = mCablePosX + ( mSpaceBetween + mCoreWidth ) * 2 + mCableWidth; double _posY = aPosY - _lastEndElconn * mCoreHeight; //draw elconn _newShape = aPage.DrawRectangle( _posX, _posY, _posX + mElconnWidth, _posY - ( _current - _lastEndElconn ) * mCoreHeight ); SetTextProperties( _newShape, _lastEndElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); _lastEndElconn = _current; } _lastEndElconnName = _core.EndElconn; } //check/draw equips if( _core.StartEqui == string.Empty || _lastBeginEquiName != _core.StartEqui ) { if( _current > 0 ) { //draw equi double _posX = mCablePosX - ( mSpaceBetween + mCoreWidth ) * 2 - mElconnWidth; double _posY = aPosY - _lastBeginEqui * mCoreHeight; _newShape = aPage.DrawRectangle( _posX - mEquiWidth, _posY, _posX, _posY - ( _current - _lastBeginEqui ) * mCoreHeight ); SetTextProperties( _newShape, _lastBeginEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); _lastBeginEqui = _current; } _lastBeginEquiName = _core.StartEqui; } if( _core.EndEqui == string.Empty || _lastEndEquiName != _core.EndEqui ) { if( _current > 0 ) { //draw equi double _posX = mCablePosX + ( mSpaceBetween + mCoreWidth ) * 2 + mCableWidth + mElconnWidth; double _posY = aPosY - _lastEndEqui * mCoreHeight; _newShape = aPage.DrawRectangle( _posX, _posY, _posX + mEquiWidth, _posY - ( _current - _lastEndEqui ) * mCoreHeight ); SetTextProperties( _newShape, _lastEndEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); _lastEndEqui = _current; } _lastEndEquiName = _core.EndEqui; } _current++; } //draw last elconns double _pX = mCablePosX - ( mSpaceBetween + mCoreWidth ) * 2; double _pY = aPosY - _lastBeginElconn * mCoreHeight; _newShape = aPage.DrawRectangle( _pX - mElconnWidth, _pY, _pX, _pY - ( _current - _lastBeginElconn ) * mCoreHeight ); SetTextProperties( _newShape, _lastBeginElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); _pX = mCablePosX + ( mSpaceBetween + mCoreWidth ) * 2 + mCableWidth; _pY = aPosY - _lastEndElconn * mCoreHeight; _newShape = aPage.DrawRectangle( _pX, _pY, _pX + mElconnWidth, _pY - ( _current - _lastEndElconn ) * mCoreHeight ); SetTextProperties( _newShape, _lastEndElconnName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); //draw last equips _pX = mCablePosX - ( mSpaceBetween + mCoreWidth ) * 2 - mElconnWidth; _pY = aPosY - _lastBeginEqui * mCoreHeight; _newShape = aPage.DrawRectangle( _pX - mEquiWidth, _pY, _pX, _pY - ( _current - _lastBeginEqui ) * mCoreHeight ); SetTextProperties( _newShape, _lastBeginEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); _pX = mCablePosX + ( mSpaceBetween + mCoreWidth ) * 2 + mCableWidth + mElconnWidth; _pY = aPosY - _lastEndEqui * mCoreHeight; _newShape = aPage.DrawRectangle( _pX, _pY, _pX + mEquiWidth, _pY - ( _current - _lastEndEqui ) * mCoreHeight ); SetTextProperties( _newShape, _lastEndEquiName, "6pt", (int)Visio.VisCellVals.visHorzCenter ); return ( aPosY - _cableHeight ); }
/// <summary> /// This method is drawing core connections diagram for given cables /// </summary> /// <param name="aCables">list of cables for which diagram should be drawn</param> public void DrawSchema( ArrayList aCables ) { // check if drawing control for schema is set and correct if( mDwgCtrl == null || mDwgCtrl.IsDisposed ) return; try { mDwgCtrl.Document.Application.QueueMarkerEvent( "E_OFF" ); // prepare first page for drawing SetPageProperties( mDwgCtrl.Document.Pages[ 1 ].PageSheet ); // draw diagram header double _posY = DrawDiagramHeader( mDwgCtrl.Document.Pages[ 1 ] ); // draw header of connections table _posY = DrawTableHeader( mDwgCtrl.Document.Pages[ 1 ], _posY - mMargin ); // set current page Visio.Page _currPage = mDwgCtrl.Document.Pages[ 1 ]; // draw connections diagram for all cables in list foreach( Database.DbElement _dbCable in aCables ) { // get info for current cable CableInfo _cableInfo = new CableInfo( _dbCable ); // check if new page is needed and if so create it if( GetCableHeight( _cableInfo ) > _posY - mMargin * 2 ) { Visio.Page _newPage = mDwgCtrl.Document.Pages.Add(); SetPageProperties( _newPage.PageSheet ); _posY = DrawTableHeader( _newPage, _newPage.PageSheet.get_Cells( CELL_PAGE_HEIGHT ).ResultIU - mMargin ); _currPage = _newPage; } // draw schema for current cable _posY = DrawCable( _currPage, _cableInfo, _posY - mMargin ); } // clear selection mDwgCtrl.Window.DeselectAll(); // at the end set first page as active mDwgCtrl.Window.Page = mDwgCtrl.Document.Pages[ 1 ]; // mark document as saved mDwgCtrl.Document.Saved = true; } finally { mDwgCtrl.Document.Application.QueueMarkerEvent( "E_ON" ); } }