Poor performance when dropping objects -- How to use DropMany in C#???

  • Thread starter Nicolas De Irisarri
  • Start date
N

Nicolas De Irisarri

Hi. I'm building a COM add-in in c# and my client found out that the
application's prefromance degrades critically as my "paint" button has more
and more shapes to paint (I take the MasterID from a database and draw new
shapes on a page.) The thing is that each call to Page.Drop takes around 3
secs to complete.

I was trying to use DropMany instad (one call, multiple shapes) but the
application raises a Type MismatchException.
Does anyone have a code snippet using DroipMany?
I'd appreciate it grately....

Thanks,

Nicolas De Irisarri
 
M

Markus Breugst

Hello Nicolas,

at first thanks for the great idea to use DropMany. I don't know why I did
not get this idea for the application I am developing. I tried it, and it
speeds up the shape creation enormously.

Please find the code below.

Best regards,
Markus

------------------
Array _masterShapes = new object[_numberOfShapes];
Array _xyPositions = new double[_numberOfShapes * 2];
Array _idArray;

for (int _index = 0; _index < numberOfShapes; _index++)
{
_masterShape = ...; // initialize with the master shape you need.
// Instead of the master's referecne, you can
// also use its name or id.

// Set drop position
_xPos = ...;
_yPos = ...;

_masterShapes.SetValue( _masterShape, _index );
_xyPositions.SetValue( _xPos, _index * 2 );
_xyPositions.SetValue( _yPos, _index * 2 + 1 );
}

int _numberOfDroppedShapes = this.vDoc.Pages[1].DropMany( ref _masterShapes,
ref _xyPositions, out _idArray );
 
N

Nicolas De Irisarri

Thanks Markus!!
Big performance improvement!

By the way, I saw a message you posted giving other performance 'tips', but
the links weren't available.
Could you give me the information regarding these tips?

Thanks for your help,
Nicolas.

Markus Breugst said:
Hello Nicolas,

at first thanks for the great idea to use DropMany. I don't know why I did
not get this idea for the application I am developing. I tried it, and it
speeds up the shape creation enormously.

Please find the code below.

Best regards,
Markus

------------------
Array _masterShapes = new object[_numberOfShapes];
Array _xyPositions = new double[_numberOfShapes * 2];
Array _idArray;

for (int _index = 0; _index < numberOfShapes; _index++)
{
_masterShape = ...; // initialize with the master shape you need.
// Instead of the master's referecne, you can
// also use its name or id.

// Set drop position
_xPos = ...;
_yPos = ...;

_masterShapes.SetValue( _masterShape, _index );
_xyPositions.SetValue( _xPos, _index * 2 );
_xyPositions.SetValue( _yPos, _index * 2 + 1 );
}

int _numberOfDroppedShapes = this.vDoc.Pages[1].DropMany( ref _masterShapes,
ref _xyPositions, out _idArray );
------------------


Nicolas De Irisarri said:
Hi. I'm building a COM add-in in c# and my client found out that the
application's prefromance degrades critically as my "paint" button has more
and more shapes to paint (I take the MasterID from a database and draw new
shapes on a page.) The thing is that each call to Page.Drop takes
around
3
secs to complete.

I was trying to use DropMany instad (one call, multiple shapes) but the
application raises a Type MismatchException.
Does anyone have a code snippet using DroipMany?
I'd appreciate it grately....

Thanks,

Nicolas De Irisarri
 
M

Markus Breugst

Hi Nicolas,

in the news message, the links are divided into several lines. If you
combine them to a single line, they should still work.

Best regards,
Markus
 
Top