O
Oleg
I have to change fillforegnd property of a grouped shape on a visio control
from c#.
If I do this from main application thread (button1_Click) then changes
appears on visio control almost immedeatelly.
If i do this from secondary thread (button2_Click) then shape fills very
slowly, part by part.
Why does this happen and how I can fix this?
I have to change fillforegnd property from secondary thread.
from c#.
If I do this from main application thread (button1_Click) then changes
appears on visio control almost immedeatelly.
If i do this from secondary thread (button2_Click) then shape fills very
slowly, part by part.
Why does this happen and how I can fix this?
I have to change fillforegnd property from secondary thread.
Code:
public partial class Form1 : Form
{
private Shape wsShape;
public Form1()
{
InitializeComponent();
axDrawingControl1.Src = @"d:\test_schema2.vsd";
Shape vs =
axDrawingControl1.Document.Pages[1].Shapes.ContainingShape;
for (int i = 1; i <= vs.Shapes.Count; i++)
if (getPropValueStr(vs.Shapes[i], "type") == "workstation")
wsShape = vs.Shapes[i];
}
private string getPropValueStr(Shape vs, string prop)
{
string value = "";
if (vs.get_CellExists("Prop." + prop, 0) != 0)
{
value = vs.get_Cells("Prop." +
prop).get_ResultStr(Microsoft.Office.Interop.Visio.VisUnitCodes.visUnitsString);
if (value == "0,0000") value = "";
}
return value;
}
private void button1_Click(object sender, EventArgs e)
{
fill();
}
private void button2_Click(object sender, EventArgs e)
{
Thread newT = new Thread(new ThreadStart(fill));
newT.Start();
}
private void fill()
{
if ((wsShape != null))
if ((wsShape.Type ==
(short)Microsoft.Office.Interop.Visio.VisShapeTypes.visTypeGroup))
for (int i = 1; i <= wsShape.Shapes.Count; i++)
wsShape.Shapes[i].get_Cells("FillForegnd").FormulaU
= "RGB(255,0,0)";
else
wsShape.get_Cells("FillForegnd").FormulaU =
"RGB(255,0,0)";
}
}