本文整理汇总了C#中System.Drawing.Region.GetRegionData方法的典型用法代码示例。如果您正苦于以下问题:C# Region.GetRegionData方法的具体用法?C# Region.GetRegionData怎么用?C# Region.GetRegionData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Region
的用法示例。
在下文中一共展示了Region.GetRegionData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Region_Ctor_RegionData
public void Region_Ctor_RegionData ()
{
Region region = new Region (new GraphicsPath ());
RegionData data = region.GetRegionData ();
Region r2 = new Region (data);
CheckEmpty ("RegionData.", region);
}
示例2: Region_Empty
public void Region_Empty ()
{
Region region = new Region ();
CheckEmpty ("Empty.", region);
Region clone = region.Clone ();
CheckEmpty ("Clone.", region);
RegionData data = region.GetRegionData ();
Region r2 = new Region (data);
CheckEmpty ("RegionData.", region);
}
示例3: PdnRegion
public PdnRegion(SerializationInfo info, StreamingContext context)
{
byte[] data = (byte[])info.GetValue("data", typeof(byte[]));
using (Region region = new Region())
{
RegionData regionData = region.GetRegionData();
regionData.Data = data;
this.gdiRegion = new Region(regionData);
}
this.lockObject = new object();
this.cachedArea = -1;
this.cachedBounds = Rectangle.Empty;
this.changed = true;
this.cachedRects = null;
this.cachedRectsF = null;
}
示例4: EmptyRegion
public void EmptyRegion ()
{
// note: an empty region is (for libgdiplus) a rectangular based region
Region empty = new Region ();
RegionData data = empty.GetRegionData ();
Assert.IsNotNull (data.Data, "Data");
Region region = new Region (data);
}
示例5: PathRegion
public void PathRegion ()
{
GraphicsPath path = new GraphicsPath ();
path.AddCurve (new Point[2] { new Point (1, 1), new Point (2, 2) });
Region r = new Region (path);
RegionData data = r.GetRegionData ();
Assert.IsNotNull (data.Data, "Data");
Region region = new Region (data);
Assert.IsTrue (r.GetBounds (graphic).Equals (region.GetBounds (graphic)), "Bounds");
}
示例6: Dispose
/*
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
*/
protected override void OnPaint(PaintEventArgs e)
{
Rectangle r = ClientRectangle;
Graphics g = e.Graphics;
Region originalClip = new Region(g.Clip.GetRegionData());
DrawBackground(g, r);
g.Clip = new Region(originalClip.GetRegionData());
DrawRows(g, r);
g.Clip = new Region(originalClip.GetRegionData());
DrawHeaders(g, r);
g.Clip = new Region(originalClip.GetRegionData());
DrawExtra(g, r);
g.Clip = new Region(originalClip.GetRegionData());
DrawBorder(g, r);
g.Clip = new Region(originalClip.GetRegionData());
}
示例7: CombinedPathRegion
public void CombinedPathRegion ()
{
// note: seems identical to PathRegion but it test another code path inside libgdiplus
Region r = new Region (sp1);
r.Xor (sp2);
RegionData data = r.GetRegionData ();
Assert.IsNotNull (data.Data, "Data");
Region region = new Region (data);
Assert.IsTrue (r.GetBounds (graphic).Equals (region.GetBounds (graphic)), "Bounds");
}
示例8: ctor_RectangleF
public void ctor_RectangleF () {
Region r1 = new Region (rect);
Assert.AreEqual (r.GetRegionData ().Data,
r1.GetRegionData ().Data);
}
示例9: ctor_Rectangle
public void ctor_Rectangle () {
Region r1 = new Region (new Rectangle ((int)rect.X, (int)rect.Y,
(int)rect.Width, (int)rect.Height));
Assert.AreEqual (r.GetRegionData ().Data,
r1.GetRegionData ().Data);
}
示例10: ctor_RegionData
public void ctor_RegionData () {
RegionData rgnData = r.GetRegionData ();
Region r1 = new Region (rgnData);
Assert.AreEqual (rgnData.Data, r1.GetRegionData ().Data);
}
示例11: LoadData
public void LoadData(string path)
{
Console.WriteLine("LoadData >>");
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(path);
XmlNodeList dataNodes = doc.GetElementsByTagName("data");
if (dataNodes.Count > 0)
{
XmlNode dataNode = dataNodes[0];
int x = 0;
int y = 0;
int w = 0;
int h = 0;
if (dataNode.Attributes["x"] != null && dataNode.Attributes["y"] != null)
{
x = Int32.Parse(dataNode.Attributes["x"].Value);
y = Int32.Parse(dataNode.Attributes["y"].Value);
}
if (dataNode.Attributes["width"] != null && dataNode.Attributes["height"] != null)
{
w = Int32.Parse(dataNode.Attributes["width"].Value);
h = Int32.Parse(dataNode.Attributes["height"].Value);
}
x = x < 0 ? 0 : x;
x = (x + w) > Screen.PrimaryScreen.WorkingArea.Width ? Screen.PrimaryScreen.WorkingArea.Width - w : x;
y = y < 0 ? 0 : y;
y = (y + h) > Screen.PrimaryScreen.WorkingArea.Height ? Screen.PrimaryScreen.WorkingArea.Height - h : y;
this.Location = new Point(x, y);
this.Size = new Size(w, h);
if (dataNode.Attributes["bgcolor"] != null)
{
try
{
this.mBgColor = Color.FromArgb(Int32.Parse(dataNode.Attributes["bgcolor"].Value));
}
catch (Exception e)
{
this.mBgColor = Color.Wheat;
}
}
}
XmlNodeList strokeNodes = doc.GetElementsByTagName("stroke");
if (strokeNodes.Count > 0)
{
XmlNode strokeNode = strokeNodes[0];
XmlCDataSection cdata_stroke = (XmlCDataSection)strokeNode.FirstChild;
byte[] decoded = System.Convert.FromBase64String(cdata_stroke.Data);
mInkPicture.Ink.Load(decoded);
mInkPicture.Refresh();
}
XmlNodeList imageNodes = doc.GetElementsByTagName("image");
foreach(XmlNode imageNode in imageNodes)
{
Bitmap bmp = null;
Region rgn = null;
Point loc = new Point();
Point[] ptPolygon = null;
loc.X = Int32.Parse(imageNode.Attributes["x"].Value);
loc.Y = Int32.Parse(imageNode.Attributes["y"].Value);
foreach(XmlNode node in imageNode.ChildNodes)
{
if (node.Name == "region")
{
XmlCDataSection cdata_region = (XmlCDataSection)node.FirstChild;
byte[] decoded = System.Convert.FromBase64String(cdata_region.Data);
Region regionTmp = new Region();
System.Drawing.Drawing2D.RegionData region2Data = regionTmp.GetRegionData();
region2Data.Data = decoded;
rgn = new Region(region2Data);
regionTmp.Dispose();
}
else if (node.Name == "polygon")
{
string[] xdata = null;
string[] ydata = null;
foreach (XmlNode c in node.ChildNodes)
{
if(c.Name == "xdata")
{
xdata = c.InnerText.Split(',');
}
else if (c.Name == "ydata")
{
ydata = c.InnerText.Split(',');
}
}
if (xdata != null && ydata != null)
{
int count = xdata.Length;
ptPolygon = new Point[count];
for (int i = 0; i < count; i++)
{
int x = Convert.ToInt32(xdata[i]);
int y = Convert.ToInt32(ydata[i]);
ptPolygon[i] = new Point(x, y);
}
}
//.........这里部分代码省略.........
示例12: PaintSelection
// Paints the selection.
void PaintSelection( Region rgn )
{
if (null == rgn) return;
Region rgnPaint = new Region( rgn.GetRegionData() );
if (null != _rgnSelLast) {
rgnPaint.Exclude(_rgnSelLast);
}
lock(_mapLock) {
using (var g = picMap.CreateGraphics()) {
Brush br = new SolidBrush(CR_SELECTION);
g.FillRegion(br, rgnPaint);
}
}
_rgnSelLast = new Region(rgn.GetRegionData());
}