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


C# List.IndexOf方法代码示例

本文整理汇总了C#中Common.List.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# List.IndexOf方法的具体用法?C# List.IndexOf怎么用?C# List.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Common.List的用法示例。


在下文中一共展示了List.IndexOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowChartAction_Execute

        // Acttion, ������������ ������� �� ���������� �������
        private void ShowChartAction_Execute(object sender, EventArgs e)
        {
            Plant CurrentPlant;
              ReportPart CurrentPart;
              DataRow ChartRow;
              BookColumn ChartColumn;
              GetCurrentCellInfo(out CurrentPlant, out CurrentPart, out ChartRow, out ChartColumn);
              if (ChartColumn == null)
              {
            MessageBox.Show("���������� ������� ������� � ������� ��� ��������� ��������", "�������� ��������", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
              }
              if (ChartRow == null || CurrentPart == null)
              {
            MessageBox.Show("���������� ������� ������ � ��������� ��� ��������� ��������", "�������� ��������", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
              }
              string ModuleNorm = FM[CurrentPart.NormRow, ChartColumn.column1];
              string ModuleName = "";

              string CurrentFieldIndex = CurrentPart.FieldName(ChartColumn.column1).Split('*')[1];
              object CurrentLowerNorm = ChartRow["LowerLimit*" + CurrentFieldIndex];
              object CurrentUpperNorm = ChartRow["UpperLimit*" + CurrentFieldIndex];

              List<Plant> PlantsList = new List<Plant>();
              foreach (ReportPart part in Parts)
            if (part.Data != null && part.Data.Rows.Count > 0)
            {
              Plant p = plants.FindPlant(Convert.ToInt32(part.Data[0, "plantid"]));
              if (!PlantsList.Contains(p))
            PlantsList.Add(p);
            }

              QueryResult[] ChartDatas = new QueryResult[PlantsList.Count];
              DataRow ModuleRow;

              int i = 0;
              foreach (ReportPart part in Parts)
              {
            if (part.Data != null && part.Data.Rows.Count > 0)
            {
              string FieldName = part.FieldName(ChartColumn.column1);
              if (FieldName != "")
              {
            string[] values = FieldName.Split('*');
            int ColumnIndex = Functions.ConvertToInt32(values[1]);
            ModuleRow = part.Columns.Rows[ColumnIndex];

            ModuleName = ModuleRow["TextModule"].ToString();
            if (ModuleRow["TestGroup"].ToString().Trim() != "")
              ModuleName = ModuleRow["TestGroup"].ToString() + ", " + ModuleName;

            string DateField = "qaodecisiontime";
            string CertField = "batchno";
            string DataField = "Result*" + ColumnIndex.ToString();
            string MinField = "LowerLimit*" + ColumnIndex.ToString();
            string MaxField = "UpperLimit*" + ColumnIndex.ToString();

            // ���� ����� ���������, ��
            /*if (ModuleNorm.ToLower() != ModuleRow["ModuleNorm"].ToString().ToLower())
              continue;*/
            if (CurrentLowerNorm.ToString().ToLower() != part.Data[0, MinField].ToString().ToLower()
             || CurrentUpperNorm.ToString().ToLower() != part.Data[0, MaxField].ToString().ToLower())
              continue;

            // ��������� ����� �������� �������
            QueryResult dt = new QueryResult(part.Data.DefaultView.ToTable(false, DateField, CertField, DataField, MinField, MaxField));
            // �������������� ��������
            dt.Columns[DateField].ColumnName = "Date";
            dt.Columns[CertField].ColumnName = "Passport";
            dt.Columns[DataField].ColumnName = "Value";
            dt.Columns[MinField].ColumnName = "Min";
            dt.Columns[MaxField].ColumnName = "Max";
            // ���������� ����� ��������
            dt.AddColumn("PlantName", typeof(string), plants.FindPlant(Convert.ToInt32(part.Data[0, "plantid"])).ShortPlantName);
            dt.AddColumn("Module", typeof(string), ModuleName);
            dt.AddColumn("Norm", typeof(string), ModuleRow["ModuleNorm"]);
            if (Functions.IsNumber(FM[part.RowAvg, ChartColumn.column1]))
              dt.AddColumn("Average", typeof(double), FM[part.RowAvg, ChartColumn.column1]);

            i = PlantsList.IndexOf(plants.FindPlant(Convert.ToInt32(part.Data[0, "plantid"])));
            if (ChartDatas[i] == null)
              ChartDatas[i] = new QueryResult(dt);
            else
            {
              // ���� � ������ ������ ���� �������� � ����������� �������, �� �� ����� ����������
              ChartDatas[i].Merge(dt);
              // �������� ����������������� �������� ����� ����������� ������
              if (ChartDatas[i].Columns.Contains("Average"))
              {
                object newavg = ChartDatas[i].Compute("avg(Average)", "");
                foreach (DataRow row in ChartDatas[i].Rows)
                  row["Average"] = newavg;
              }
            }
              }

            }
            if (ChartDatas[i] != null) // ��������� ������ ����� ������������ (����� ����������, ���� ���� ����������� ������ ���������)
//.........这里部分代码省略.........
开发者ID:PavelAlekseyuk,项目名称:Report-2007,代码行数:101,代码来源:CertTankForm.cs

示例2: ResolveType2

        private void ResolveType2(RKResults res, IFunctionExecuter fe, out List<double> divT, out List<double> divZ,
                                  out List<double> divZ2, out List<ResPointViewType2> list)
        {
            var dz1 = new double[res.Count - 1];
            for (int i = 1; i < res.Count; i++)
            {
                dz1[i - 1] = (res[i].Y[0] - res[i - 1].Y[0])/(res[i].X - res[i - 1].X);
            }
            var dz2 = new double[res.Count - 2];
            for (int i = 1; i < dz1.Length; i++)
            {
                dz2[i - 1] = (dz1[i] - dz1[i - 1])/(res[i].X - res[i - 1].X);
            }

            var lambda = new int[res.Count - 2];

            var valInPoint = new List<double>();
            for (int i = 0; i < res.Count - 2; i++)
            {
                valInPoint.Clear();
                for (int j = 0; j < fe.SetCount; j++)
                {
                    valInPoint.Add(Math.Abs(dz2[i] - fe.FunctionSet(res[i].X, res[i].Y, j)));
                }

                lambda[i] = valInPoint.IndexOf(valInPoint.Min()) + 1;
            }
            //int g = 0;

            int mn = lambda[0];
            divZ = new List<double>(); // res[0].Y[0];
            divT = new List<double>(); // res[0].X;
            divZ2 = new List<double>();

            var checkedSet = new List<int>();

            for (int i = 1; i < lambda.Length; i++)
            {
                if (lambda[i] != mn && (checkedSet.Count == 0 || !checkedSet.Contains(lambda[i])))
                {
                    divT.Add((res[i].X + res[i - 1].X)/2f);
                    divZ.Add((res[i].Y[0] + res[i - 1].Y[0])/2f);
                    divZ2.Add((res[i].Y[1] + res[i - 1].Y[1])/2f);
                    checkedSet.Add(mn);
                    mn = lambda[i];
                }
            }

            //fill DataSouce
            list = new List<ResPointViewType2>();
            for (int i = 0; i < lambda.Length; i++)
            {
                list.Add(new ResPointViewType2(res[i].X, res[i].Y[0], res[i].Y[1], lambda[i], -1));
            }
        }
开发者ID:apravdivy,项目名称:MagistrSolution,代码行数:55,代码来源:View.cs

示例3: Execute

        private void Execute()
        {
            List<byte> rxBuff = new List<byte>();

            while(true)
            {
                byte[] read = new byte[1];

                try
                {
                    // Read
                    int rxed = _socket.Receive(read, read.Length, SocketFlags.None);

                    // Add data to buffer
                    rxBuff.AddRange(read.Take(rxed));

                    // process data if it contains a terminating character
                    if (rxBuff.Contains(0x02))
                    {
                        // retreive the string
                        string rxStr = Encoding.UTF8.GetString(rxBuff.Take(rxBuff.IndexOf(0x02)).ToArray());
                        // remove the data that was just converted into a string (plus the 0x02 terminator)
                        rxBuff.RemoveRange(0, rxBuff.IndexOf(0x02) + 1);

                        // Deserialize to the message structure
                        Message msg = JsonConvert.DeserializeObject<Message>(rxStr);

                        // Notify all listeners
                        if (msg != null)
                        {
                            OnMessageRxed(msg);
                        }
                    }
                }
                catch
                {
                    OnDisconnected();
                }
            }
        }
开发者ID:branchjoshua,项目名称:cse3461,代码行数:40,代码来源:MessageXcvr.cs

示例4: SendSolvingResultType1

        public void SendSolvingResultType1(RKResults res, IFunctionExecuter fe)
        {
            var dz = new double[res.Count - 1];
            for (int i = 1; i < res.Count; i++)
            {
                dz[i - 1] = (res[i].Y[0] - res[i - 1].Y[0])/(res[i].X - res[i - 1].X);
            }
            var lambda = new int[res.Count - 1];

            //v[0] = t <= 0 ? -1 : 1
            var valInPoint = new List<double>();
            for (int i = 0; i < res.Count - 1; i++)
            {
                valInPoint.Clear();
                for (int j = 0; j < fe.SetCount; j++)
                {
                    valInPoint.Add(Math.Abs(dz[i] - fe.FunctionSet(res[i].X, res[i].Y, j)));
                }

                lambda[i] = valInPoint.IndexOf(valInPoint.Min()) + 1;
            }
            //int g = 0;

            int mn = lambda[0];
            var divZ = new List<double>(); // res[0].Y[0];
            var divT = new List<double>(); // res[0].X;

            var checkedSet = new List<int>();

            for (int i = 1; i < lambda.Length; i++)
            {
                if (lambda[i] != mn && (checkedSet.Count == 0 || !checkedSet.Contains(lambda[i])))
                {
                    divT.Add((res[i].X + res[i - 1].X)/2f);
                    divZ.Add((res[i].Y[0] + res[i - 1].Y[0])/2f);
                    checkedSet.Add(mn);
                    mn = lambda[i];
                    continue;
                }
            }

            //fill DataSouce
            var list = new List<ResPointViewType1>();
            for (int i = 0; i < lambda.Length; i++)
            {
                list.Add(new ResPointViewType1(res[i].X, res[i].Y[0], lambda[i], -1));
            }

            ShowResultType1(divT, divZ, list, res[0].X, res[res.Count - 1].X);
        }
开发者ID:apravdivy,项目名称:MagistrSolution,代码行数:50,代码来源:View.cs


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