本文整理汇总了C#中IGraphicsContext.PushGraphicsState方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphicsContext.PushGraphicsState方法的具体用法?C# IGraphicsContext.PushGraphicsState怎么用?C# IGraphicsContext.PushGraphicsState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphicsContext
的用法示例。
在下文中一共展示了IGraphicsContext.PushGraphicsState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(IGraphicsContext GC)
{
using (GC.PushGraphicsState ())
{
string name = Name;
if (IsNotEmptyString (name))
{
GC.Color = Color.Orange;
}
else
{
name = "NoName";
GC.Color = Color.Red;
}
base.Draw (GC);
using (Brush brush = new SolidBrush (GC.Color))
{
Rectangle bounds = Bounds;
Point centre = new Point (bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
GC.DrawString (name, brush, 10, centre, true);
}
}
}
示例2: Draw
public override void Draw(IGraphicsContext GC)
{
using (GC.PushGraphicsState ())
{
bool isOk;
bool usePrimary;
Color primary;
DashStyle dashStyle;
usePrimary = PrimaryInformation (out isOk, out primary, out dashStyle);
GC.Color = primary;
int thickness = 2;
if (Selected)
{
thickness = 5;
}
Color fromColor;
Color toColor;
DrawContactPoints (GC, isOk, usePrimary, primary, out fromColor, out toColor);
GC.Thickness = thickness;
GC.DrawLine (_From, _To, fromColor, toColor, dashStyle);
ArrayList contextList = GetDisplayTextAsContextList (GC);
int startX = (_To.X + _From.X) / 2;
int startY = (_To.Y + _From.Y) / 2;
bool isMoreHorizontal = Math.Abs (_To.X - _From.X) > Math.Abs (_To.Y - _From.Y);
bool positiveWidthAdjust;
bool positiveHeightAdjust;
if (isMoreHorizontal)
{
positiveWidthAdjust = false;
positiveHeightAdjust = true;
}
else
{
positiveWidthAdjust = false;
positiveHeightAdjust = false;
}
GC.DrawString (contextList, new Point (startX, startY), positiveWidthAdjust, positiveHeightAdjust, true);
}
}
示例3: Draw
public override void Draw(IGraphicsContext gc)
{
using (gc.PushGraphicsState ())
{
int depth = CountParentDepth ();
Color color = _Colors [depth]; // CountParentDepth is expensive - so don't call StateColor here...
Color contactColor = color;
if (Name == null || Name.Trim () == "")
{
color = Color.Red;
}
gc.Color = color;
DrawState (gc, _Bounds.Left, _Bounds.Top, _Bounds.Width, _Bounds.Height, 20, 2+depth, color, false);
gc.Color = contactColor;
gc.Thickness = 2 + depth;
if (Selected)
{
foreach (IGlyph contact in ContactPoints)
{
contact.Draw (gc);
}
}
}
}