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


C# List.FindIndex方法代码示例

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


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

示例1: RefrenshList

        public void RefrenshList()
        {
            testManagerBLL = new BLL.TB_TestManager();
            testItmesListBox.ItemsSource = testList = testManagerBLL.GetModelList("");

            //如果设置了测试项目,则选中设置的测试项目
            int index = -1;

            if (testItem != null)
            {
                index = testList.FindIndex(x => x.ID == testItem.ID);
            }
            else if (testList.Count>0)
            {
                index = 0;
            }

            if (selectedTestItemIndex >= 0 && testItem == null)
            {
                testItmesListBox.SelectedIndex = selectedTestItemIndex;
            }
            else
            {
                testItmesListBox.SelectedIndex = index;
            }
        }
开发者ID:dewade2003,项目名称:DSJL,代码行数:26,代码来源:TestManager.xaml.cs

示例2: getIndex

 public static int getIndex(List<string> list, string name)
 {
     int index = list.FindIndex(r => r == name);
     return index;
 }
开发者ID:mukeshdepani,项目名称:ParaRD,代码行数:5,代码来源:Common.cs

示例3: crawler_ProcessPageCrawlCompleted

        static void crawler_ProcessPageCrawlCompleted(object sender, PageCrawlCompletedArgs e)
        {
            CrawledPage crawledPage = e.CrawledPage;

            if (crawledPage.WebException != null || crawledPage.HttpWebResponse.StatusCode != HttpStatusCode.OK)
                Debug.WriteLine(string.Format("页面:{0}抓取失败,原因:{1}", crawledPage.Uri.AbsoluteUri, crawledPage.WebException.Message));

            string text = crawledPage.Content.Text;

            if (string.IsNullOrEmpty(text))
                Console.WriteLine("Page had no content {0}", crawledPage.Uri.AbsoluteUri);
            else if (text.Contains("活动八"))
            {

            }
            else
            {

                var c = Regex.Matches(text, "活动(一|二|三|四|五|六|七|八|九|十)(.|\n)*?活动时间(.|\n)*?<br");
                if (c.Count == 0)
                {
                    var a = Regex.Match(text, "thread_subject(.|\n)*?活动(.|\n){1,50}?</a");
                    if (a.Value != "")
                    {
                        var b = Regex.Match(text, "活动时间(.|\n)*?<br");
                        var time = Regex.Match(b.Value, "\\d{1,2}月\\d{1,2}(-|日)").Value;
                        Debug.Write(DateTime.Parse(time) + "   ");
                        Debug.WriteLine(Regex.Match(a.Value, "活动(.|\n)*?</a").Value.Replace("】", ":").Replace("<br", "").Replace("</a", ""));
                    }
                }

                List<string> list = new List<string>() { "古城探宝", "天降神剑" };

                foreach (Match item in c)
                {
                    string date = Regex.Match(item.Value, "\\d{1,2}月\\d{1,2}(-|日)").Value;
                    if (date != "" && !date.Contains("日"))
                    {
                        date = date.Replace("-", "日");
                    }
                    Debug.Write(DateTime.Parse(date) + "   ");
                    Debug.WriteLine(Regex.Match(item.Value, "活动(一|二|三|四|五|六|七|八|九|十)(.|\n)*?<br").Value.Replace("】", ":").Replace("<br", "").Replace("</a", ""));
                    var index = list.FindIndex(x => item.Value.Contains(x));
                    if (index != -1)
                    {
                        Activity activity = new Activity();
                        activity.Name = list[index];
                        activity.Date = DateTime.Parse(date);

                    }
                }

            }
        }
开发者ID:rhjv55,项目名称:Utilities,代码行数:54,代码来源:MainWindow.xaml.cs

示例4: ProcessWiresharkOutput

        /// <summary>
        /// Process the Wireshark packets and determine the number of datasets
        /// </summary>
        /// <returns>An <c>AnalysisStatus</c> enumeration indicating whether the analysis process completed successfuly.</returns>
        private Enums.AnalysisStatus ProcessWiresharkOutput()
        {
            Enums.AnalysisStatus status = Enums.AnalysisStatus.Success;
            DateTime start_step = new DateTime();
            DateTime end_step = new DateTime();
            TimeSpan time_step = new TimeSpan();
            WiresharkPSMLStructure psml_structure = new WiresharkPSMLStructure();
            WiresharkPSMLPacket psml_packet = new WiresharkPSMLPacket();

            string[] delimiters = {" ",",",":"};
            int num;
            double time;
            EthernetMACAddr mac_src = new EthernetMACAddr();
            EthernetMACAddr mac_dst = new EthernetMACAddr();
            IPv4Addr ip_src = new IPv4Addr();
            IPv4Addr ip_dst = new IPv4Addr();
            int enip_cid = 0;
            int enip_seq = 0;
            string index_name;
            List<string> indices_names = new List<string>();
            int index;
            NetworkPair pair = new NetworkPair();
            JitterDatum datum = new JitterDatum();

            _process_log.Add(DateTime.Now.ToString() + ": Process Wireshark Output: Started.");
            start_step = DateTime.Now;

            _progress.Current = _progress.Minimum;
            _background_worker.ReportProgress(_progress.Current);
            _tshark.Progress = _progress;

            XmlReader reader = XmlReader.Create(_tshark.TemporaryFile.FullName);
            XmlDocument doc = new XmlDocument();
            doc.Load(reader);

            XmlNodeList structure;
            XmlNode root = doc.DocumentElement;
            structure = root.SelectNodes("//structure");
            if (structure.Count == 1)
            {
                XmlNode structure_node = structure.Item(0);
                List<string> sections = new List<string>();
                for (int i = 0; i < structure_node.ChildNodes.Count; i++)
                {
                    sections.Add(structure_node.ChildNodes[i].InnerText);
                }
                int temp = sections.FindIndex(delegate(string title) { return title == psml_structure.NumberTitle; });
                if (temp == -1)
                    status = Enums.AnalysisStatus.Error;
                else
                    psml_structure.NumberIndex = temp;
                temp = sections.FindIndex(delegate(string title) { return title == psml_structure.TimeTitle; });
                if (temp == -1)
                    status = Enums.AnalysisStatus.Error;
                else
                    psml_structure.TimeIndex = temp;
                temp = sections.FindIndex(delegate(string title) { return title == psml_structure.SourceTitle; });
                if (temp == -1)
                    status = Enums.AnalysisStatus.Error;
                else
                    psml_structure.SourceIndex = temp;
                temp = sections.FindIndex(delegate(string title) { return title == psml_structure.DestinationTitle; });
                if (temp == -1)
                    status = Enums.AnalysisStatus.Error;
                else
                    psml_structure.DestinationIndex = temp;
                temp = sections.FindIndex(delegate(string title) { return title == psml_structure.ProtocolTitle; });
                if (temp == -1)
                    status = Enums.AnalysisStatus.Error;
                else
                    psml_structure.ProtocolIndex = temp;
                temp = sections.FindIndex(delegate(string title) { return title == psml_structure.EnipCidTitle; });
                if (temp == -1)
                    status = Enums.AnalysisStatus.Error;
                else
                    psml_structure.EnipCidIndex = temp;
                temp = sections.FindIndex(delegate(string title) { return title == psml_structure.EnipSeqTitle; });
                if (temp == -1)
                    status = Enums.AnalysisStatus.Error;
                else
                    psml_structure.EnipSeqIndex = temp;
                temp = sections.FindIndex(delegate(string title) { return title == psml_structure.InfoTitle; });
                if (temp == -1)
                    status = Enums.AnalysisStatus.Error;
                else
                    psml_structure.InfoIndex = temp;
            }
            else
            {
                status = Enums.AnalysisStatus.Error;
            }

            if (status == Enums.AnalysisStatus.Error)
            {
                _process_log.Add(DateTime.Now.ToString() + ": Process Wireshark Output: Error reading structure of Wireshark PSML output.");
            }
//.........这里部分代码省略.........
开发者ID:paperwork,项目名称:IENetP,代码行数:101,代码来源:MainWindow.xaml.cs

示例5: Window_Loaded

 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     testManagerBLL = new BLL.TB_TestManager();
     athInfoBLL = new BLL.TB_AthleteInfo();
     testList = testManagerBLL.GetModelList("");
     Binding b = new Binding() { Source = testList };
     cbTestItems.SetBinding(ComboBox.ItemsSourceProperty, b);
     if (testItem == null)
     {
         cbTestItems.SelectedIndex = 0;
     }
     else {
         cbTestItems.SelectedIndex = testList.FindIndex(x => x.ID == testItem.ID);
     }
 }
开发者ID:dewade2003,项目名称:DSJL,代码行数:15,代码来源:ImportAthlete.xaml.cs

示例6: _KeyPress

 public void _KeyPress(object sender, KeyEventArgs e)
 {
     List<Key> keys = new List<Key>() { Key.D1, Key.D2, Key.D3, Key.D4, Key.D5, Key.D6, Key.D7, Key.D8 };
     int number;
     try { number = keys.FindIndex(a => a == e.Key); }
     catch (System.ArgumentNullException) { number = -1; }
     if (number >= 0)
         _ButtonPress(Buttons[number], e);
 }
开发者ID:fmin2958,项目名称:Pamya,代码行数:9,代码来源:MCGame.xaml.cs

示例7: queriesTimer_Tick

        private void queriesTimer_Tick(object sender, EventArgs e)
        {
            List<Query> queries = new List<Query>();
            using (SqlConnection connection = new SqlConnection(String.Format(Configuration.ConnectionString, Configuration.SSISDatabase)))
            {
                try
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand(Properties.Resources.LongQueriesQuery, connection))
                    {
                        command.Parameters.AddWithValue("threshold", Configuration.QueriesThreshold);
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                queries.Add(new Query()
                                {
                                    Id = (Int32)reader["Id"],
                                    User = (String)reader["User"],
                                    Duration = TimeSpan.FromSeconds((Int32)reader["Duration"]),
                                    Command = (String)reader["Query"],
                                    Database = (String)reader["Database"]
                                });
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.NavigationService.GoBack();
                    System.Windows.MessageBox.Show("The SQL Server connection was lost", "SQL Notifier", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

            if (this.lastQueries.Count != queries.Count)
            {
                foreach (Query query in queries)
                {
                    Int32 index = this.lastQueries.FindIndex(obj => obj.Id == query.Id);
                    if (index == -1 && !this.firstRun)
                        this.Window.Notify("New long query is detected");
                }
                foreach (Query query in this.lastQueries)
                {
                    Int32 index = queries.FindIndex(obj => obj.Id == query.Id);
                    if (index == -1 && !this.firstRun)
                        this.Window.Notify("A long query is done");
                }
            }
            this.lastQueries = queries;
            this.dataGridQueries.ItemsSource = queries;
        }
开发者ID:CSharplie,项目名称:SQL-Notifier,代码行数:52,代码来源:ProcessingPage.xaml.cs

示例8: packageTimer_Tick

        private void packageTimer_Tick(object sender, EventArgs e)
        {
            List<Package> packages = new List<Package>();
            using (SqlConnection connection = new SqlConnection(String.Format(Configuration.ConnectionString, Configuration.SSISDatabase)))
            {
                try
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand(Properties.Resources.RunningPackagesQuery, connection))
                    {
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                packages.Add(new Package()
                                {
                                    Id = (Int32)reader["Id"],
                                    Name = (String)reader["Name"],
                                    Duration = TimeSpan.FromSeconds((Int32)reader["Duration"])
                                });
                            }
                        }
                    }
                }
                catch(Exception ex)
                {
                    this.NavigationService.GoBack();
                    System.Windows.MessageBox.Show("The SQL Server connection was lost", "SQL Notifier", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

            if (this.lastPackages.Count != packages.Count)
            {
                foreach (Package package in packages)
                {
                    Int32 index = this.lastPackages.FindIndex(obj => obj.Id == package.Id);
                    if (index == -1 && !this.firstRun)
                        this.Window.Notify(String.Format("The package {0} is running", package.Name));
                }
                foreach (Package package in this.lastPackages)
                {
                    Int32 index = packages.FindIndex(obj => obj.Id == package.Id);
                    if (index == -1 && !this.firstRun)
                        this.Window.Notify(String.Format("The package {0} is finished", package.Name));
                }
            }
            this.lastPackages = packages;
            this.dataGridPackages.ItemsSource = packages;
        }
开发者ID:CSharplie,项目名称:SQL-Notifier,代码行数:49,代码来源:ProcessingPage.xaml.cs

示例9: InitDisk

        private void InitDisk()
        {
            string a=System.IO.Path.GetPathRoot(PathL.path).ToUpper();
            string b=System.IO.Path.GetPathRoot(PathR.path).ToUpper();

            DriveInfo[] allDrivers = DriveInfo.GetDrives();
            List<DiskTemplate> tmp = new List<DiskTemplate>();
            foreach (DriveInfo item in allDrivers)
            {
                if(item.IsReady) tmp.Add(new DiskTemplate(GetIcon.Icon(item.Name, true, true)," [" + WorkPath.GetNameDisk(item.Name) + "] " + item.VolumeLabel, item.Name));
                else tmp.Add(new DiskTemplate(GetIcon.Icon(item.Name, true, true), " [" + WorkPath.GetNameDisk(item.Name) + "]", item.Name));
            }

            tmp.Add(new DiskTemplate(GetIcon.Icon(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), true, true), "My Documents", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)));
            tmp.Add(new DiskTemplate(GetIcon.Icon(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), true, true), "Desktop", Environment.GetFolderPath(Environment.SpecialFolder.Desktop)));
            tmp.Add(new DiskTemplate(GetIcon.Icon(Environment.GetFolderPath(Environment.SpecialFolder.Favorites), true, true), "Favorites", Environment.GetFolderPath(Environment.SpecialFolder.Favorites)));
            tmp.Add(new DiskTemplate(GetIcon.Icon(Environment.GetFolderPath(Environment.SpecialFolder.Startup), true, true), "Startup", Environment.GetFolderPath(Environment.SpecialFolder.Startup)));

            ListDiskL.ItemsSource = tmp;
            ListDiskR.ItemsSource = tmp;
            ListDiskL.SelectedIndex = tmp.FindIndex(s => s.Path == a);
            ListDiskR.SelectedIndex = tmp.FindIndex(s => s.Path == b);
            
            ViewPathL.Content = a;
            ViewPathR.Content = b;
        }
开发者ID:Deswing,项目名称:File-Manager,代码行数:26,代码来源:MainWindow.xaml.cs

示例10: CreateManifest

 private void CreateManifest(List<FileInfo> results, string[] args)
 {
     try
     {
         int toRemove = results.FindIndex(x => x.Name.ToLowerInvariant() == "launcher.cache");
         if (toRemove >= 0)
         {
             results.RemoveAt(toRemove);
         }
         CreateManifest_(results, args);
     }
     catch (System.Exception ex)
     {
         SetStatus("Something went wrong: "+ex.ToString(), 1);
     }
 }
开发者ID:hodgman,项目名称:dayzrp_patcher,代码行数:16,代码来源:Gui.xaml.cs


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