本文整理汇总了C#中System.Int32.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Int32.Select方法的具体用法?C# Int32.Select怎么用?C# Int32.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Int32
的用法示例。
在下文中一共展示了Int32.Select方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPageSizes
internal static IEnumerable<SelectListItem> GetPageSizes(Int32[] pageSizes = null, Int32? currentSize = null)
{
if (pageSizes == null)
pageSizes = TableModel.DefaultPageSizes;
if (currentSize.HasValue && !pageSizes.Contains(currentSize.Value))
pageSizes = pageSizes.Union(new[] { currentSize.Value }).OrderBy(p => p).ToArray();
return pageSizes.Select(i => new SelectListItem { Text = i.ToString(), Value = i.ToString(), Selected = i == TableModel.DefaultPageSize });
}
示例2: TargetProjectionsOfElementsAreReturnedWhenSourceIsEmpty
public void TargetProjectionsOfElementsAreReturnedWhenSourceIsEmpty()
{
var source = new Int32[0];
var expected = new Boolean[0];
var result = source.Select(i => i == 0);
Assert.That(result, Is.EqualTo(expected));
}
示例3: LogarithmicCorrection
/// <summary>
/// g = c * log (1 + f)
/// </summary>
/// <param name="pixels"></param>
/// <param name="c">constant</param>
/// <returns></returns>
public static Int32[] LogarithmicCorrection(Int32[] pixels, byte c)
{
return pixels.Select(pixel => Pixel.SetBrightness(pixel, Pixel.GetValidByte(c * Math.Log(1 + Pixel.GetBrightness(pixel))))).ToArray();
}
示例4: ChangeBrightness
/// <summary>
/// g = c + f
/// </summary>
/// <param name="pixels"></param>
/// <param name="c">constant</param>
/// <returns></returns>
public static Int32[] ChangeBrightness(Int32[] pixels, byte c)
{
return pixels.Select(pixel => Pixel.SetBrightness(pixel, Pixel.GetValidByte(c + Pixel.GetBrightness(pixel)))).ToArray();
}
示例5: SetIndices
public void SetIndices(MLOD mlod, MLOD.Mesh mesh, MLOD.GeometryState geometryState, Int32[] indices)
{
SetIndices(mlod, mesh.IndexBufferIndex, mesh.PrimitiveType, geometryState.StartIndex, geometryState.PrimitiveCount,
indices.Select(x => x + geometryState.MinVertexIndex).ToArray());
geometryState.PrimitiveCount = indices.Length / IndexCountFromPrimitiveType(mesh.PrimitiveType);
}
示例6: GetDataBySite
public List<TaskDetail> GetDataBySite(Int64 TaskHeaderID, String TaskSite, Int32[] TaskStatus)
{
String Query = "SELECT * FROM TaskDetail WHERE TaskHeaderID = @TaskHeaderID AND TaskSite = @TaskSite AND TaskStatus IN ({0})";
Query = String.Format(Query, String.Join(",", TaskStatus.Select(x => x.ToString()).ToArray()));
SqlCeDataManager oDm = new SqlCeDataManager(ConnectionString, Query, true);
oDm.AddIntegerBigPara("TaskHeaderID", TaskHeaderID);
oDm.AddVarcharPara("TaskSite", 4000, TaskSite);
return DataParser.ToList<TaskDetail>(oDm.GetTable());
}
示例7: GetDataByStatus
public List<TaskDetail> GetDataByStatus(Int64 TaskHeaderID, Int32[] TaskStatus)
{
String Query = "SELECT * FROM TaskDetail WHERE TaskHeaderID = " + TaskHeaderID.ToString()
+ " AND TaskStatus IN (" + string.Join(",", TaskStatus.Select(x => x.ToString())) + ")";
SqlCeDataManager oDm = new SqlCeDataManager(ConnectionString, Query, true);
return DataParser.ToList<TaskDetail>(oDm.GetTable());
}
示例8: save_button_Click
private void save_button_Click(object sender, EventArgs e)
{
Int32[] new_ingredients;
new_ingredients = new Int32[10];
// get information about the selected ingredient and calibration for each pump
var combo_boxes = settingsPanel.Controls
.OfType<ComboBox>()
.Where(txt => txt.Name.ToLower().StartsWith("seting"));
int pump = 0;
foreach (ComboBox txt in combo_boxes)
{
new_ingredients[pump] = txt.SelectedIndex;
pump++;
}
var calib_textboxes = settingsPanel.Controls
.OfType<TextBox>()
.Where(txt => txt.Name.ToLower().StartsWith("calib"));
pump = 0;
Int16[] calib_value;
calib_value = new Int16[10];
foreach (TextBox txt in calib_textboxes)
{
calib_value[pump] = Convert.ToInt16(txt.Text);
pump++;
}
// start assuming we don't have a duplicate
bool duplicate = false;
for (int i = 0; i < 10; i++)
{
for (int j = i + 1; j < 10; j++)
{
if ((new_ingredients[i] == new_ingredients[j]) && (new_ingredients[i] != 0))
// verify all the ingredients for duplicates
duplicate = true;
}
}
// give error if duplicates
if (!duplicate)
{
try
{
System.IO.File.WriteAllLines(@"available_ing.txt", new_ingredients.Select(x => x.ToString()).ToArray());
System.IO.File.AppendAllLines(@"available_ing.txt", calib_value.Select(x => x.ToString()).ToArray());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
// Reload
LoadAll(this, EventArgs.Empty);
// close seetings panel
settingsPanel.Visible = false;
}
else
{
MessageBox.Show("Duplicates were found. \nPlease make sure that you don't have the same ingredient in two slots");
}
}
示例9: GetQuantizedImage
//Input image and returns a color quantized image (Hardcoded to 31 color - HSB Algorithm!)
//31 color to allow for a transparent BG color
private Image GetQuantizedImage(Image image)
{
// checks whether a source image is valid
if (image == null)
{
const String message = "Cannot quantize a null image.";
throw new ArgumentNullException(message);
}
// locks the source image data
Bitmap bitmap = (Bitmap)image;
Rectangle bounds = Rectangle.FromLTRB(0, 0, bitmap.Width, bitmap.Height);
BitmapData sourceData = bitmap.LockBits(bounds, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
// prepares time statistics variables
TimeSpan duration = new TimeSpan(0);
DateTime before;
try
{
// initalizes the pixel read buffer
Int32[] sourceBuffer = new Int32[image.Width];
// sets the offset to the first pixel in the image
Int64 sourceOffset = sourceData.Scan0.ToInt64();
for (Int32 row = 0; row < image.Height; row++)
{
// copies the whole row of pixels to the buffer
Marshal.Copy(new IntPtr(sourceOffset), sourceBuffer, 0, image.Width);
// scans all the colors in the buffer
foreach (Color color in sourceBuffer.Select(argb => Color.FromArgb(argb)))
{
before = DateTime.Now;
//Ideas to do the transparent color:
// make a mask
// AND the bytes
if(color != System.Drawing.Color.FromArgb(255,255,0,255))
// .the_quantizerthe_quantizer.AddColor(color);
duration += DateTime.Now - before;
}
// increases a source offset by a row
sourceOffset += sourceData.Stride;
}
// editTargetInfo.Text = string.Format("Quantized: {0} colors (duration {1})", 256, duration); // TODO
}
catch
{
bitmap.UnlockBits(sourceData);
throw;
}
Bitmap result = new Bitmap(image.Width, image.Height, PixelFormat.Format8bppIndexed);
// calculates the palette
try
{
before = DateTime.Now;
Int32 colorCount = 31; //GetColorCount();
// List<Color> palette = the_quantizer.GetPalette(colorCount);
// sets our newly calculated palette to the target image
ColorPalette imagePalette = result.Palette;
duration += DateTime.Now - before;
imagePalette.Entries[0] = System.Drawing.Color.FromArgb(255, 255, 0, 255);
/* for (Int32 index = 1; index-1 < palette.Count; index++)
{
imagePalette.Entries[index] = palette[index-1];
}
*/
result.Palette = imagePalette;
}
catch (Exception)
{
bitmap.UnlockBits(sourceData);
throw;
}
// locks the target image data
BitmapData targetData = result.LockBits(bounds, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
try
{
// initializes read/write buffers
Byte[] targetBuffer = new Byte[result.Width];
Int32[] sourceBuffer = new Int32[image.Width];
// sets the offsets on the beginning of both source and target image
Int64 sourceOffset = sourceData.Scan0.ToInt64();
Int64 targetOffset = targetData.Scan0.ToInt64();
//.........这里部分代码省略.........