本文整理汇总了C#中PaintDotNet.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToArray方法的具体用法?C# List.ToArray怎么用?C# List.ToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaintDotNet.List
的用法示例。
在下文中一共展示了List.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFileTypeFactoriesFromAssemblies
private static Type[] GetFileTypeFactoriesFromAssemblies(ICollection assemblies)
{
List<Type> allFactories = new List<Type>();
foreach (Assembly assembly in assemblies)
{
Type[] factories;
try
{
factories = GetFileTypeFactoriesFromAssembly(assembly);
}
catch (Exception)
{
continue;
}
foreach (Type type in factories)
{
allFactories.Add(type);
}
}
return allFactories.ToArray();
}
示例2: OnCreatePropertyCollection
protected override PropertyCollection OnCreatePropertyCollection()
{
List<Property> propsBuilder = new List<Property>();
propsBuilder.Add(new DoubleProperty("X", 0.3, 0, 1));
propsBuilder.Add(new DoubleProperty("Y", 0.5, 0, 1));
propsBuilder.Add(new DoubleProperty("Z", 0.11, 0, 1));
return new PropertyCollection(propsBuilder.ToArray());
}
示例3: GetFileTypeFactoriesFromAssembly
private static Type[] GetFileTypeFactoriesFromAssembly(Assembly assembly)
{
List<Type> fileTypeFactories = new List<Type>();
foreach (Type type in assembly.GetTypes())
{
if (IsInterfaceImplemented(type, typeof(IFileTypeFactory)) && !type.IsAbstract)
{
fileTypeFactories.Add(type);
}
}
return fileTypeFactories.ToArray();
}
示例4: GetBlendOps
/// <summary>
/// Returns an array of Type objects that lists all of the pixel ops contained
/// within this class. You can then use Utility.GetStaticName to retrieve the
/// value of the StaticName property.
/// </summary>
/// <returns></returns>
public static Type[] GetBlendOps()
{
Type[] allTypes = typeof(UserBlendOps).GetNestedTypes();
List<Type> types = new List<Type>(allTypes.Length);
foreach (Type type in allTypes)
{
if (type.IsSubclassOf(typeof(UserBlendOp)) && !type.IsAbstract)
{
types.Add(type);
}
}
return types.ToArray();
}
示例5: GetLocaleNameChain
public static string[] GetLocaleNameChain()
{
List<string> names = new List<string>();
CultureInfo ci = pdnCulture;
while (ci.Name != string.Empty)
{
names.Add(ci.Name);
ci = ci.Parent;
}
return names.ToArray();
}
示例6: GetInstalledLocales
public static string[] GetInstalledLocales()
{
const string left = "PaintDotNet.Strings.3";
const string right = ".resources";
string ourDir = ResourcesDir;
string fileSpec = left + "*" + right;
string[] pathNames = Directory.GetFiles(ourDir, fileSpec);
List<String> locales = new List<string>();
for (int i = 0; i < pathNames.Length; ++i)
{
string pathName = pathNames[i];
string dirName = Path.GetDirectoryName(pathName);
string fileName = Path.GetFileName(pathName);
string sansRight = fileName.Substring(0, fileName.Length - right.Length);
string sansLeft = sansRight.Substring(left.Length);
string locale;
if (sansLeft.Length > 0 && sansLeft[0] == '.')
{
locale = sansLeft.Substring(1);
}
else if (sansLeft.Length == 0)
{
locale = "en-US";
}
else
{
locale = sansLeft;
}
try
{
// Ensure this locale can create a valid CultureInfo object.
CultureInfo ci = new CultureInfo(locale);
}
catch (Exception)
{
// Skip past invalid locales -- don't let them crash us
continue;
}
locales.Add(locale);
}
return locales.ToArray();
}
示例7: PerformAction
public override void PerformAction(AppWorkspace appWorkspace)
{
DocumentWorkspace originalDW = appWorkspace.ActiveDocumentWorkspace;
int oldLatency = 10;
try
{
oldLatency = appWorkspace.Widgets.DocumentStrip.ThumbnailUpdateLatency;
appWorkspace.Widgets.DocumentStrip.ThumbnailUpdateLatency = 0;
}
catch (NullReferenceException)
{
// See bug #2544
}
List<DocumentWorkspace> unsavedDocs = new List<DocumentWorkspace>();
foreach (DocumentWorkspace dw in appWorkspace.DocumentWorkspaces)
{
if (dw.Document != null && dw.Document.Dirty)
{
unsavedDocs.Add(dw);
}
}
if (unsavedDocs.Count == 1)
{
CloseWorkspaceAction cwa = new CloseWorkspaceAction(unsavedDocs[0]);
cwa.PerformAction(appWorkspace);
this.cancelled = cwa.Cancelled;
}
else if (unsavedDocs.Count > 1)
{
using (UnsavedChangesDialog dialog = new UnsavedChangesDialog())
{
dialog.DocumentClicked += (s, e2) => { appWorkspace.ActiveDocumentWorkspace = e2.Data; };
dialog.Documents = unsavedDocs.ToArray();
if (appWorkspace.ActiveDocumentWorkspace.Document.Dirty)
{
dialog.SelectedDocument = appWorkspace.ActiveDocumentWorkspace;
}
Form mainForm = appWorkspace.FindForm();
if (mainForm != null)
{
PdnBaseForm asPDF = mainForm as PdnBaseForm;
if (asPDF != null)
{
asPDF.RestoreWindow();
}
}
DialogResult dr = Utility.ShowDialog(dialog, appWorkspace);
switch (dr)
{
case DialogResult.Yes:
{
foreach (DocumentWorkspace dw in unsavedDocs)
{
appWorkspace.ActiveDocumentWorkspace = dw;
bool result = dw.DoSave();
if (result)
{
appWorkspace.RemoveDocumentWorkspace(dw);
}
else
{
this.cancelled = true;
break;
}
}
}
break;
case DialogResult.No:
this.cancelled = false;
break;
case DialogResult.Cancel:
this.cancelled = true;
break;
default:
throw new InvalidEnumArgumentException();
}
}
}
try
{
appWorkspace.Widgets.DocumentStrip.ThumbnailUpdateLatency = oldLatency;
}
catch (NullReferenceException)
//.........这里部分代码省略.........
示例8: 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;
}
示例9: ShowFileTransferFailedDialog
private WorkItemFailureAction ShowFileTransferFailedDialog(Exception ex)
{
WorkItemFailureAction result;
Icon formIcon = this.progressDialog.Icon;
string formTitle = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemFailureDialog.Title");
Image taskImage = PdnResources.GetImageResource("Icons.WarningIcon.png").Reference;
string introTextFormat = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemFailureDialog.IntroText.Format");
string introText = string.Format(introTextFormat, ex.Message);
TaskButton retryTB = new TaskButton(
PdnResources.GetImageResource("Icons.MenuImageRotate90CWIcon.png").Reference,
PdnResources.GetString("DocumentWorkspace.ShowFileDialog.RetryTB.ActionText"),
PdnResources.GetString("DocumentWorkspace.ShowFileDialog.RetryTB.ExplanationText"));
TaskButton skipTB = new TaskButton(
PdnResources.GetImageResource("Icons.HistoryFastForwardIcon.png").Reference,
PdnResources.GetString("DocumentWorkspace.ShowFileDialog.SkipTB.ActionText"),
PdnResources.GetString("DocumentWorkspace.ShowFileDialog.SkipTB.ExplanationText"));
TaskButton cancelTB = new TaskButton(
PdnResources.GetImageResource("Icons.CancelIcon.png").Reference,
PdnResources.GetString("DocumentWorkspace.ShowFileDialog.CancelTB.ActionText"),
PdnResources.GetString("DocumentWorkspace.ShowFileDialog.CancelTB.ExplanationText"));
List<TaskButton> taskButtons = new List<TaskButton>();
taskButtons.Add(retryTB);
// Only have the Skip button if there is more than 1 item being transferred.
// If only 1 item is begin transferred, Skip and Cancel are essentially synonymous.
if (this.itemCount > 1)
{
taskButtons.Add(skipTB);
}
taskButtons.Add(cancelTB);
int width96 = (TaskDialog.DefaultPixelWidth96Dpi * 4) / 3; // 33% wider
TaskButton clickedTB = TaskDialog.Show(
this.progressDialog,
formIcon,
formTitle,
taskImage,
true,
introText,
taskButtons.ToArray(),
retryTB,
cancelTB,
width96);
if (clickedTB == retryTB)
{
result = WorkItemFailureAction.RetryItem;
}
else if (clickedTB == skipTB)
{
result = WorkItemFailureAction.SkipItem;
}
else
{
result = WorkItemFailureAction.CancelOperation;
}
return result;
}
示例10: PenDashStyleButton_DropDownOpening
private void PenDashStyleButton_DropDownOpening(object sender, EventArgs e)
{
List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();
foreach (DashStyle dashStyle in this.dashStyles)
{
ToolStripMenuItem mi = new ToolStripMenuItem(
this.dashStyleLocalizer.EnumValueToLocalizedName(dashStyle),
GetDashStyleImage(dashStyle),
delegate(object sender2, EventArgs e2)
{
ToolStripMenuItem tsmi = (ToolStripMenuItem)sender2;
DashStyle newDashStyle = (DashStyle)tsmi.Tag;
PenInfo newPenInfo = PenInfo.Clone();
newPenInfo.DashStyle = newDashStyle;
PenInfo = newPenInfo;
});
mi.ImageScaling = ToolStripItemImageScaling.None;
if (dashStyle == PenInfo.DashStyle)
{
mi.Checked = true;
}
mi.Tag = dashStyle;
menuItems.Add(mi);
}
this.penDashStyleSplitButton.DropDownItems.Clear();
this.penDashStyleSplitButton.DropDownItems.AddRange(menuItems.ToArray());
}
示例11: SwatchControl_ColorClicked
private void SwatchControl_ColorClicked(object sender, EventArgs<Pair<int, MouseButtons>> e)
{
List<ColorBgra> colors = new List<ColorBgra>(this.swatchControl.Colors);
if (this.colorAddButton.Checked)
{
colors[e.Data.First] = GetColorFromUpDowns();
this.swatchControl.Colors = colors.ToArray();
this.colorAddButton.Checked = false;
this.swatchControl.BlinkHighlight = false;
}
else
{
ColorBgra color = colors[e.Data.First];
if (e.Data.Second == MouseButtons.Right)
{
SetUserColors(UserPrimaryColor, color);
}
else
{
switch (this.WhichUserColor)
{
case WhichUserColor.Primary:
this.UserPrimaryColor = color;
break;
case WhichUserColor.Secondary:
this.UserSecondaryColor = color;
break;
default:
throw new InvalidEnumArgumentException();
}
}
}
OnRelinquishFocus();
}
示例12: 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();
}
示例13: OnCreatePropertyCollection
protected override PropertyCollection OnCreatePropertyCollection()
{
List<Property> props = new List<Property>();
props.Add(new StringProperty(PropertyNames.Amount1, "", 255));
props.Add(new Int32Property(PropertyNames.Amount2, 100, 1, 1000));
props.Add(new Int32Property(PropertyNames.Amount3, 12, 6, 250));
FontFamily[] intstalledFontFamilies = new InstalledFontCollection().Families;
List<FontFamily> usableFonts = new List<FontFamily>();
foreach (FontFamily font in intstalledFontFamilies)
{
if (font.IsStyleAvailable(FontStyle.Regular))
usableFonts.Add(font);
}
FontFamily[] Amount4FontFamilies = usableFonts.ToArray();
props.Add(new StaticListChoiceProperty(PropertyNames.Amount4, Amount4FontFamilies, 0, false));
props.Add(new BooleanProperty(PropertyNames.Amount5, false));
props.Add(new BooleanProperty(PropertyNames.Amount6, false));
props.Add(new BooleanProperty(PropertyNames.Amount7, false));
props.Add(new BooleanProperty(PropertyNames.Amount8, false));
props.Add(new DoubleVectorProperty(PropertyNames.Amount9, Pair.Create(0.0, 0.0), Pair.Create(-1.0, -1.0), Pair.Create(+1.0, +1.0)));
props.Add(new Int32Property(PropertyNames.Amount10, ColorBgra.ToOpaqueInt32(ColorBgra.FromBgra(EnvironmentParameters.PrimaryColor.B, EnvironmentParameters.PrimaryColor.G, EnvironmentParameters.PrimaryColor.R, 255)), 0, 0xffffff));
return new PropertyCollection(props);
}
示例14: GetLocaleDirs
private static string[] GetLocaleDirs()
{
const string rootDirName = "Resources";
string appDir = ResourcesDir;
string rootDir = Path.Combine(appDir, rootDirName);
List<string> dirs = new List<string>();
CultureInfo ci = pdnCulture;
while (ci.Name != string.Empty)
{
string localeDir = Path.Combine(rootDir, ci.Name);
if (Directory.Exists(localeDir))
{
dirs.Add(localeDir);
}
ci = ci.Parent;
}
return dirs.ToArray();
}
示例15: PenCapSplitButton_DropDownOpening
private void PenCapSplitButton_DropDownOpening(object sender, EventArgs e)
{
ToolStripSplitButton splitButton = (ToolStripSplitButton)sender;
List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();
LineCap2 currentLineCap = PenInfo.DefaultLineCap;
bool isStartCap;
if (object.ReferenceEquals(splitButton, this.penStartCapSplitButton))
{
isStartCap = true;
currentLineCap = PenInfo.StartCap;
}
else if (object.ReferenceEquals(splitButton, this.penEndCapSplitButton))
{
isStartCap = false;
currentLineCap = PenInfo.EndCap;
}
else
{
throw new InvalidOperationException();
}
foreach (LineCap2 lineCap in this.lineCaps)
{
ToolStripMenuItem mi = new ToolStripMenuItem(
this.lineCapLocalizer.EnumValueToLocalizedName(lineCap),
GetLineCapImage(lineCap, isStartCap).Reference,
delegate(object sender2, EventArgs e2)
{
ToolStripMenuItem tsmi = (ToolStripMenuItem)sender2;
Pair<ToolStripSplitButton, LineCap2> data = (Pair<ToolStripSplitButton, LineCap2>)tsmi.Tag;
PenInfo newPenInfo = PenInfo.Clone();
if (object.ReferenceEquals(data.First, this.penStartCapSplitButton))
{
newPenInfo.StartCap = data.Second;
}
else if (object.ReferenceEquals(data.First, this.penEndCapSplitButton))
{
newPenInfo.EndCap = data.Second;
}
PenInfo = newPenInfo;
});
mi.Tag = Pair.Create(splitButton, lineCap);
if (lineCap == currentLineCap)
{
mi.Checked = true;
}
menuItems.Add(mi);
}
splitButton.DropDownItems.Clear();
splitButton.DropDownItems.AddRange(menuItems.ToArray());
}