|
From: Mark J. <mj...@we...> - 2005-12-13 14:04:11
|
=20
In the past, there were discutions about a Global Font support.
=20
Last March, when I was doing a Praticum where I hoped to get a =
permanent
Job,
I showed this Library ro the owner and the first question was 'can it
Zoom, change the Colours and Font'?
=20
Building in the proper Zooming and Colouring was not a problem, but the
Font was.
=20
Last month Fran=E7ois and I again has a talk about this and came to no
conclusion.
=20
Yesterday, however (still having no Job), while preparing my Shape Demo =
to
work within the MDI-Application,
I realized that the logic I used there would also solve the Problem =
here.
=20
The the main pain there was the commenly used Objects/Methods had to be
passed to each Frame
apon creation.
=20
I then tried creating a Class in the Dll that stored Static Fields =
which
were filled upon
Application start (Main-Form, MainMenu, StatusBar, Colours, Font, =
Project
Paths etc) and
simply read out by the Forms that used the same Dll.
=20
Calling an Application twice from the same /Bin using also the same Dll
(also in the same /Bin)
created an Unique Version of the Static Class for each Application - =
which
meant that the
first copy could change a static Field (in this case the Font) but =
this
would not effect
the Value in the second Application (i.e. the Second Application would =
not
use the Font
set by the first Application).
=20
The problem here is that when a Shape is created it uses the default =
Font
set in Entity.cs.
This could not be changed in a way that after a certin Point another =
Font
should be used.
=20
Since Entity.Font was 'protected', it could also not be changed
afterwards.
=20
My suggestion is the following :
=20
- one small Class in 'Netron.GraphLib' with static Fields
- Font
- and maybe others like CutureInfo for language support.
=20
- When the Application calls the Dll for the first the Default value =
will
be set
- for CutureInfo this would be that of the Machine called on.
The Application could then change the default Values :
- 'NetronBase.Font =3D WinForm.Font; '
=20
With Entity.InitEntity() changed to :=20
=20
// mFont =3D new
Font(mFontFamily,mFontSize,FontStyle.Regular,GraphicsUnit.Point);
Font =3D NetronBase.Font;
=20
all Shapes / Connection etc. would use the desired Font.
=20
If Entity.Font was changed from 'protected' to 'internal'
=20
internal Font Font
{
get{return this.mFont;}
set
{
this.mFont =3D value;
this.mFontFamily =3D value.FontFamily.ToString();
this.mFontSize =3D value.Size; =20
RecalculateSize =3D true;
this.Invalidate();
}
}
- note added 'RecalculateSize =3D true;' !
=20
a Propery in the GraphControl for 'Font' could be written
that could change the Font used at any time (i.e. Object allready
created) :
=20
[Category("Graph"), Browsable(true), Description("Gets or sets the =
Font
for the GraphControl and all Shapes and Connectors.")]
public override Font Font
{
get
{
return base.Font;
}
set
{
if (value !=3D null)
{
base.Font =3D value;
NetronBase.Font =3D base.Font;
foreach(Shape so in mAbstract.Shapes)
{
so.Font =3D base.Font;
foreach(Connector co in so.Connectors)
{
co.Font =3D base.Font;
foreach (Connection con in co.Connections)
{
con.Font =3D base.Font;
} // foreach (Connection con in co.Connections)
} // foreach(Connector co in so.Connectors)
} // foreach(Shape so in mAbstract.Shapes)
// Will force all Controls to Paint with new Font
Invalidate();
} // if (value !=3D null)
} // Set
} // public override Font Font
=20
With these changes, every thing works well with me after insuring that
NetronGraphControl
uses the Parent.Font when recalulating it size.
=20
All Shapes would have to be Font aware, but most are.
And if not, they should be changed.
=20
If there are no objections to this I would like to commit the needed
changes to CVS.
=20
Mark Johnson, Berlin Germany=20
mj...@mj...
=20
PS : I wish Windows would do the same, I allways hate changing to the =
Fornt
that I use 99,9999 % of the time =85=20
=20
=20
|