Problem programatically changing master's color...

G

Gilgul

Hi!

I'm writing an C# .NET application with a Visio ActiveX component.
One of the features allows the user to create a new master, by filling out a
dialog.
At the end of the dialog, I duplicate an existing master, changing it's name
to the name supplied in the dialog, and it works. Changing the width of the
shape via the "Width" cell also works.However, trying to change the master's
fg color doesn't (although the changes occur in the ShapeSheet).

The code:
// Get a master from the stencil by its universal name.
Visio.Master masterPolicy = VisStencilPolicies.Masters.get_ItemU("Policy");
Visio.Master masterNewPolicyOrig = VisStencilPolicies.Drop(masterPolicy, 0,
0);
Visio.Master masterNewPolicy = masterNewPolicyOrig.Open();

// Set the name of the new policy
masterNewPolicyOrig.NameU = policyDlg.sName;

// Set the color of the new policy
Visio.Cell cellFillForegnd =
masterNewPolicy.Shapes[1].get_CellsU("FillForegnd");
string sColor = "RGB(" +
policyDlg.Color.R.ToString() + "," +
policyDlg.Color.G.ToString() + "," +
policyDlg.Color.B.ToString() + ")";
cellFillForegnd.Formula = sColor;

Visio.Cell cellFillPattern =
masterNewPolicy.Shapes[1].get_CellsU("FillPattern");
cellFillPattern.Formula = "1";

masterNewPolicy.Shapes[1].get_CellsU("Width").set_Result("mm", 100.1);

masterNewPolicy.IconUpdate = (short)Visio.VisMasterProperties.visAutomatic;

masterNewPolicy.Close();

What am I doing wrong? Any ideas?

Thanks,
Gil
 
M

Mark Nelson [MS]

Can you explain what you mean by "fg color doesn't (although the changes
occur in the ShapeSheet)"?

Do you see an RGB formula in the FillForegnd cell of the master shape?

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Gilgul

Hi! Thanks for the quick response.

What I mean is that the actual color of the shape is still white. However,
the formula was updated (I see the shape's sheet and in the cell
"FillForegnd" the value is "RGB(192,0,192)".

Thanks again.

Mark Nelson said:
Can you explain what you mean by "fg color doesn't (although the changes
occur in the ShapeSheet)"?

Do you see an RGB formula in the FillForegnd cell of the master shape?

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

Gilgul said:
Hi!

I'm writing an C# .NET application with a Visio ActiveX component.
One of the features allows the user to create a new master, by filling out
a
dialog.
At the end of the dialog, I duplicate an existing master, changing it's
name
to the name supplied in the dialog, and it works. Changing the width of
the
shape via the "Width" cell also works.However, trying to change the
master's
fg color doesn't (although the changes occur in the ShapeSheet).

The code:
// Get a master from the stencil by its universal name.
Visio.Master masterPolicy =
VisStencilPolicies.Masters.get_ItemU("Policy");
Visio.Master masterNewPolicyOrig = VisStencilPolicies.Drop(masterPolicy,
0,
0);
Visio.Master masterNewPolicy = masterNewPolicyOrig.Open();

// Set the name of the new policy
masterNewPolicyOrig.NameU = policyDlg.sName;

// Set the color of the new policy
Visio.Cell cellFillForegnd =
masterNewPolicy.Shapes[1].get_CellsU("FillForegnd");
string sColor = "RGB(" +
policyDlg.Color.R.ToString() + "," +
policyDlg.Color.G.ToString() + "," +
policyDlg.Color.B.ToString() + ")";
cellFillForegnd.Formula = sColor;

Visio.Cell cellFillPattern =
masterNewPolicy.Shapes[1].get_CellsU("FillPattern");
cellFillPattern.Formula = "1";

masterNewPolicy.Shapes[1].get_CellsU("Width").set_Result("mm", 100.1);

masterNewPolicy.IconUpdate =
(short)Visio.VisMasterProperties.visAutomatic;

masterNewPolicy.Close();

What am I doing wrong? Any ideas?

Thanks,
Gil
 
M

Mark Nelson [MS]

Is the master shape's fill color white or do you mean that a shape instance
of the master in the drawing is white? If you mean the shape instance, then
that shape may have a locally overriden FillForegnd cell with that color.
Or it may be placed on a layer with Color = White.

If you mean the master shape, do you see color when you manually set it?
Maybe there is no fillable region of geometry on the shape.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

Gilgul said:
Hi! Thanks for the quick response.

What I mean is that the actual color of the shape is still white. However,
the formula was updated (I see the shape's sheet and in the cell
"FillForegnd" the value is "RGB(192,0,192)".

Thanks again.

Mark Nelson said:
Can you explain what you mean by "fg color doesn't (although the changes
occur in the ShapeSheet)"?

Do you see an RGB formula in the FillForegnd cell of the master shape?

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no
rights.

Gilgul said:
Hi!

I'm writing an C# .NET application with a Visio ActiveX component.
One of the features allows the user to create a new master, by filling
out
a
dialog.
At the end of the dialog, I duplicate an existing master, changing it's
name
to the name supplied in the dialog, and it works. Changing the width of
the
shape via the "Width" cell also works.However, trying to change the
master's
fg color doesn't (although the changes occur in the ShapeSheet).

The code:
// Get a master from the stencil by its universal name.
Visio.Master masterPolicy =
VisStencilPolicies.Masters.get_ItemU("Policy");
Visio.Master masterNewPolicyOrig =
VisStencilPolicies.Drop(masterPolicy,
0,
0);
Visio.Master masterNewPolicy = masterNewPolicyOrig.Open();

// Set the name of the new policy
masterNewPolicyOrig.NameU = policyDlg.sName;

// Set the color of the new policy
Visio.Cell cellFillForegnd =
masterNewPolicy.Shapes[1].get_CellsU("FillForegnd");
string sColor = "RGB(" +
policyDlg.Color.R.ToString() + "," +
policyDlg.Color.G.ToString() + "," +
policyDlg.Color.B.ToString() + ")";
cellFillForegnd.Formula = sColor;

Visio.Cell cellFillPattern =
masterNewPolicy.Shapes[1].get_CellsU("FillPattern");
cellFillPattern.Formula = "1";

masterNewPolicy.Shapes[1].get_CellsU("Width").set_Result("mm", 100.1);

masterNewPolicy.IconUpdate =
(short)Visio.VisMasterProperties.visAutomatic;

masterNewPolicy.Close();

What am I doing wrong? Any ideas?

Thanks,
Gil
 
G

Gilgul

Hi!

Both the master and every instance of it (shapes) are filled white. As for
layering, I did not make any change nor define any layer, so it's using the
default ("Normal" I think).

When I right-click an instance (a shape) created from the master, and choose
"Format->Fill..." the fill dialog opens with the right color (purple), as if
the shape is colored purple, and the fields in the ShapeSheet are correct as
well, however, the shape itself is not colored! If I change the color in the
above fill dialog and choose "OK" or "Apply" the shape does get colored.
Looks like a matter of refresh missing somewhere after programmatically
changing the FillForegnd and FillPattern formulas. I failed to mention that
my shape is made of subshapes (a hexagon & a circle), if it is at all
relevant.

Appreciate your help,
Gil

Mark Nelson said:
Is the master shape's fill color white or do you mean that a shape instance
of the master in the drawing is white? If you mean the shape instance, then
that shape may have a locally overriden FillForegnd cell with that color.
Or it may be placed on a layer with Color = White.

If you mean the master shape, do you see color when you manually set it?
Maybe there is no fillable region of geometry on the shape.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

Gilgul said:
Hi! Thanks for the quick response.

What I mean is that the actual color of the shape is still white. However,
the formula was updated (I see the shape's sheet and in the cell
"FillForegnd" the value is "RGB(192,0,192)".

Thanks again.

Mark Nelson said:
Can you explain what you mean by "fg color doesn't (although the changes
occur in the ShapeSheet)"?

Do you see an RGB formula in the FillForegnd cell of the master shape?

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no
rights.

Hi!

I'm writing an C# .NET application with a Visio ActiveX component.
One of the features allows the user to create a new master, by filling
out
a
dialog.
At the end of the dialog, I duplicate an existing master, changing it's
name
to the name supplied in the dialog, and it works. Changing the width of
the
shape via the "Width" cell also works.However, trying to change the
master's
fg color doesn't (although the changes occur in the ShapeSheet).

The code:
// Get a master from the stencil by its universal name.
Visio.Master masterPolicy =
VisStencilPolicies.Masters.get_ItemU("Policy");
Visio.Master masterNewPolicyOrig =
VisStencilPolicies.Drop(masterPolicy,
0,
0);
Visio.Master masterNewPolicy = masterNewPolicyOrig.Open();

// Set the name of the new policy
masterNewPolicyOrig.NameU = policyDlg.sName;

// Set the color of the new policy
Visio.Cell cellFillForegnd =
masterNewPolicy.Shapes[1].get_CellsU("FillForegnd");
string sColor = "RGB(" +
policyDlg.Color.R.ToString() + "," +
policyDlg.Color.G.ToString() + "," +
policyDlg.Color.B.ToString() + ")";
cellFillForegnd.Formula = sColor;

Visio.Cell cellFillPattern =
masterNewPolicy.Shapes[1].get_CellsU("FillPattern");
cellFillPattern.Formula = "1";

masterNewPolicy.Shapes[1].get_CellsU("Width").set_Result("mm", 100.1);

masterNewPolicy.IconUpdate =
(short)Visio.VisMasterProperties.visAutomatic;

masterNewPolicy.Close();

What am I doing wrong? Any ideas?

Thanks,
Gil
 
M

Mark Nelson [MS]

My guess is that you are applying the changes to a shape which has no
geometry. There is a difference between formatting group shapes through the
dialogs and formatting them programmatically. When applying formatting to
groups from the user interface, the formatting properties are automatically
pushed down to every subshape of the group. When applying formatting
programmatically, only the actual cells you assign are changed. Formatting
is not pushed to subshapes.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

Gilgul said:
Hi!

Both the master and every instance of it (shapes) are filled white. As for
layering, I did not make any change nor define any layer, so it's using
the
default ("Normal" I think).

When I right-click an instance (a shape) created from the master, and
choose
"Format->Fill..." the fill dialog opens with the right color (purple), as
if
the shape is colored purple, and the fields in the ShapeSheet are correct
as
well, however, the shape itself is not colored! If I change the color in
the
above fill dialog and choose "OK" or "Apply" the shape does get colored.
Looks like a matter of refresh missing somewhere after programmatically
changing the FillForegnd and FillPattern formulas. I failed to mention
that
my shape is made of subshapes (a hexagon & a circle), if it is at all
relevant.

Appreciate your help,
Gil

Mark Nelson said:
Is the master shape's fill color white or do you mean that a shape
instance
of the master in the drawing is white? If you mean the shape instance,
then
that shape may have a locally overriden FillForegnd cell with that color.
Or it may be placed on a layer with Color = White.

If you mean the master shape, do you see color when you manually set it?
Maybe there is no fillable region of geometry on the shape.

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no
rights.

Gilgul said:
Hi! Thanks for the quick response.

What I mean is that the actual color of the shape is still white.
However,
the formula was updated (I see the shape's sheet and in the cell
"FillForegnd" the value is "RGB(192,0,192)".

Thanks again.

:

Can you explain what you mean by "fg color doesn't (although the
changes
occur in the ShapeSheet)"?

Do you see an RGB formula in the FillForegnd cell of the master shape?

--
Mark Nelson
Office Graphics - Visio
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no
rights.

Hi!

I'm writing an C# .NET application with a Visio ActiveX component.
One of the features allows the user to create a new master, by
filling
out
a
dialog.
At the end of the dialog, I duplicate an existing master, changing
it's
name
to the name supplied in the dialog, and it works. Changing the width
of
the
shape via the "Width" cell also works.However, trying to change the
master's
fg color doesn't (although the changes occur in the ShapeSheet).

The code:
// Get a master from the stencil by its universal name.
Visio.Master masterPolicy =
VisStencilPolicies.Masters.get_ItemU("Policy");
Visio.Master masterNewPolicyOrig =
VisStencilPolicies.Drop(masterPolicy,
0,
0);
Visio.Master masterNewPolicy = masterNewPolicyOrig.Open();

// Set the name of the new policy
masterNewPolicyOrig.NameU = policyDlg.sName;

// Set the color of the new policy
Visio.Cell cellFillForegnd =
masterNewPolicy.Shapes[1].get_CellsU("FillForegnd");
string sColor = "RGB(" +
policyDlg.Color.R.ToString() + "," +
policyDlg.Color.G.ToString() + "," +
policyDlg.Color.B.ToString() + ")";
cellFillForegnd.Formula = sColor;

Visio.Cell cellFillPattern =
masterNewPolicy.Shapes[1].get_CellsU("FillPattern");
cellFillPattern.Formula = "1";

masterNewPolicy.Shapes[1].get_CellsU("Width").set_Result("mm",
100.1);

masterNewPolicy.IconUpdate =
(short)Visio.VisMasterProperties.visAutomatic;

masterNewPolicy.Close();

What am I doing wrong? Any ideas?

Thanks,
Gil
 
Top