本文整理汇总了C#中System.Int16.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Int16.Select方法的具体用法?C# Int16.Select怎么用?C# Int16.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Int16
的用法示例。
在下文中一共展示了Int16.Select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
}
示例2: Receive_Timer_Tick
private void Receive_Timer_Tick(object state)
{
receiveTimer.Dispose();
bool go = false;
if (_socket != null && _socket.Connected)
{
if (socketEventArg == null)
{
socketEventArg = new SocketAsyncEventArgs();
socketEventArg.RemoteEndPoint = _socket.RemoteEndPoint;
socketEventArg.SetBuffer(new Byte[MAX_BUFFER_SIZE], 0, MAX_BUFFER_SIZE);
socketEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(async delegate (object s, SocketAsyncEventArgs e)
{
if (e.SocketError == SocketError.Success && e.BytesTransferred > 0)
{
//First 2 ints contain the trigger index offset and the sample rate.
var triggerIndex = (Int16)((e.Buffer[1] << 8) | e.Buffer[0]);
var samplerate = (Int16)((e.Buffer[3] << 8) | e.Buffer[2]);
Int16[] data = new Int16[(e.BytesTransferred - 4) / 2];
for (int i = 2; i < e.BytesTransferred / 2; i++)
{
int bi = i * 2;
byte upper = e.Buffer[bi + 1];
byte lower = e.Buffer[bi];
data[i - 2] = (Int16)((upper << 8) | lower);
}
int index = -triggerIndex;
await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
this.Trigger = triggerIndex;
this.SampleTime = samplerate;
this.Status = string.Format("{0} Points Received", data.Length);
this.Points = null;
this.Points = data.Select(d => new ScatterDataPoint()
{
XValue = samplerate * index++,
YValue = d,
});
});
}
else
{
await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
this.Status = e.BytesTransferred > 0 ? e.SocketError.ToString() : "No data received";
});
}
_clientDone.Set();
});
}
_clientDone.Reset();
_socket.ReceiveAsync(socketEventArg);
go = _clientDone.WaitOne(TIMEOUT_MILLISECONDS);
if (!go)
{
this.Disconnect.Execute(null);
}
}
if (go && _socket != null && _socket.Connected)
{
receiveTimer = new Timer(this.Receive_Timer_Tick, null, 0, System.Threading.Timeout.Infinite);
}
}