本文整理汇总了C#中PaintDotNet.List.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# List.Clear方法的具体用法?C# List.Clear怎么用?C# List.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaintDotNet.List
的用法示例。
在下文中一共展示了List.Clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SliceRectangles
internal Rectangle[] SliceRectangles(Rectangle[] rois)
{
if (rois.Length == 0 || (this.MaximumRegionHeight == 0 && this.MaximumRegionWidth == 0))
return rois;
// Re-slice regions
List<Rectangle> sizedRegions = new List<Rectangle>();
Rectangle[] rectCopy = rois;
// Resize width
foreach (Rectangle rect in rectCopy)
{
if (this.MaximumRegionWidth > 0 && rect.Width > this.MaximumRegionWidth)
{
int sliceCount = (int)Math.Ceiling((double)rect.Width / (double)this.MaximumRegionWidth);
for (int i = 0; i < sliceCount; i++)
{
if (i < sliceCount - 1)
{
sizedRegions.Add(new Rectangle(rect.X + (this.MaximumRegionWidth * i), rect.Y, this.MaximumRegionWidth, rect.Height));
}
else
{
int remainingWidth = rect.Width - this.MaximumRegionWidth * (sliceCount - 1);
sizedRegions.Add(new Rectangle(rect.Right - remainingWidth, rect.Y, remainingWidth, rect.Height));
}
}
}
else
{
sizedRegions.Add(rect);
}
}
rectCopy = sizedRegions.ToArray();
sizedRegions.Clear();
// Resize height
foreach (Rectangle rect in rectCopy)
{
if (this.MaximumRegionHeight > 0 && rect.Height > this.MaximumRegionHeight)
{
int sliceCount = (int)Math.Ceiling((double)rect.Height / (double)this.MaximumRegionHeight);
for (int i = 0; i < sliceCount; i++)
{
if (i < sliceCount - 1)
{
sizedRegions.Add(new Rectangle(rect.X, rect.Y + (this.MaximumRegionHeight * i), rect.Width, this.MaximumRegionHeight));
}
else
{
int remainingHeight = rect.Height - this.MaximumRegionHeight * (sliceCount - 1);
sizedRegions.Add(new Rectangle(rect.X, rect.Bottom - remainingHeight, rect.Width, remainingHeight));
}
}
}
else
{
sizedRegions.Add(rect);
}
}
return sizedRegions.ToArray();
}
示例2: PolygonSetFromStencil
public unsafe static Point[][] PolygonSetFromStencil(IBitVector2D stencil, Rectangle bounds, int translateX, int translateY)
{
List<Point[]> polygons = new List<Point[]>();
if (!stencil.IsEmpty)
{
Point start = bounds.Location;
List<Point> pts = new List<Point>();
int count = 0;
// find all islands
while (true)
{
bool startFound = false;
while (true)
{
if (stencil[start])
{
startFound = true;
break;
}
++start.X;
if (start.X >= bounds.Right)
{
++start.Y;
start.X = bounds.Left;
if (start.Y >= bounds.Bottom)
{
break;
}
}
}
if (!startFound)
{
break;
}
pts.Clear();
Point last = new Point(start.X, start.Y + 1);
Point curr = new Point(start.X, start.Y);
Point next = curr;
Point left = Point.Empty;
Point right = Point.Empty;
// trace island outline
while (true)
{
left.X = ((curr.X - last.X) + (curr.Y - last.Y) + 2) / 2 + curr.X - 1;
left.Y = ((curr.Y - last.Y) - (curr.X - last.X) + 2) / 2 + curr.Y - 1;
right.X = ((curr.X - last.X) - (curr.Y - last.Y) + 2) / 2 + curr.X - 1;
right.Y = ((curr.Y - last.Y) + (curr.X - last.X) + 2) / 2 + curr.Y - 1;
if (bounds.Contains(left) && stencil[left])
{
// go left
next.X += curr.Y - last.Y;
next.Y -= curr.X - last.X;
}
else if (bounds.Contains(right) && stencil[right])
{
// go straight
next.X += curr.X - last.X;
next.Y += curr.Y - last.Y;
}
else
{
// turn right
next.X -= curr.Y - last.Y;
next.Y += curr.X - last.X;
}
if (Math.Sign(next.X - curr.X) != Math.Sign(curr.X - last.X) ||
Math.Sign(next.Y - curr.Y) != Math.Sign(curr.Y - last.Y))
{
pts.Add(curr);
++count;
}
last = curr;
curr = next;
if (next.X == start.X && next.Y == start.Y)
{
break;
}
}
Point[] points = pts.ToArray();
Scanline[] scans = Utility.GetScans(points);
foreach (Scanline scan in scans)
{
stencil.Invert(scan);
}
//.........这里部分代码省略.........
示例3: foreach
//.........这里部分代码省略.........
if (needLocalCopy.Count > 0)
{
IntPtr hwnd = IntPtr.Zero;
NativeInterfaces.IOleWindow oleWindow = (NativeInterfaces.IOleWindow)pfd;
oleWindow.GetWindow(out hwnd);
Win32Window win32Window = new Win32Window(hwnd, oleWindow);
IFileTransferProgressEvents progressEvents = this.FileDialogUICallbacks.CreateFileTransferProgressEvents();
ThreadStart copyThreadProc =
delegate()
{
try
{
progressEvents.SetItemCount(needLocalCopy.Count);
for (int i = 0; i < needLocalCopy.Count; ++i)
{
NativeInterfaces.IShellItem item = needLocalCopy[i];
string pathName = null;
progressEvents.SetItemOrdinal(i);
CopyResult result = CreateLocalCopy(item, progressEvents, out pathName);
if (result == CopyResult.Success)
{
localPathNames.Add(pathName);
}
else if (result == CopyResult.Skipped)
{
// do nothing
}
else if (result == CopyResult.CancelOperation)
{
hr = NativeConstants.S_FALSE;
break;
}
else
{
throw new InvalidEnumArgumentException();
}
}
}
finally
{
OperationResult result;
if (hr == NativeConstants.S_OK)
{
result = OperationResult.Finished;
}
else
{
result = OperationResult.Canceled;
}
progressEvents.EndOperation(result);
}
};
Thread copyThread = new Thread(copyThreadProc);
copyThread.SetApartmentState(ApartmentState.STA);
EventHandler onUIShown =
delegate(object sender, EventArgs e)
{
copyThread.Start();
};
this.cancelSink = new CancelableTearOff();
progressEvents.BeginOperation(win32Window, onUIShown, cancelSink);
this.cancelSink = null;
copyThread.Join();
Marshal.ReleaseComObject(oleWindow);
oleWindow = null;
}
this.FileNames = localPathNames.ToArray();
// If they selected a bunch of files, and then they all errored or something, then don't proceed.
if (this.FileNames.Length == 0)
{
hr = NativeConstants.S_FALSE;
}
foreach (NativeInterfaces.IShellItem item in items)
{
Marshal.ReleaseComObject(item);
}
items.Clear();
items = null;
GC.KeepAlive(pfd);
return hr;
}