当前位置: 首页>>代码示例>>C#>>正文


C# Int16.Select方法代码示例

本文整理汇总了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");
            }
        }
开发者ID:kyotox,项目名称:Cocktailer,代码行数:66,代码来源:Cocktailer+Form.cs

示例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);
            }
        }
开发者ID:FalafelSoftwareInc,项目名称:ParticalPhotonOscilloscope,代码行数:66,代码来源:MainViewModel.cs


注:本文中的System.Int16.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。