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


C# List.Exists方法代码示例

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


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

示例1: DownloaderWorker_DoWork

        private void DownloaderWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (e.Argument == null)
                    return;

                basePath = Environment.CurrentDirectory;
                dhtNodeFile = System.IO.Path.Combine(basePath, "DhtNodes");
                downloadsPath = System.IO.Path.Combine(basePath, "Downloads");
                torrentsPath = System.IO.Path.Combine(basePath, "Torrents");
                fastResumeFile = System.IO.Path.Combine(torrentsPath, "fastresume.data");
                torrents = new List<TorrentManager>();     // The list where all the torrentManagers will be stored that the engine gives us
                listener = new Top10Listener(10);

                string torrentpath = e.Argument.ToString();

                int port = 6969;
                Torrent torrent = null;

                // Create the settings which the engine will use
                // downloadsPath - this is the path where we will save all the files to
                // port - this is the port we listen for connections on
                EngineSettings engineSettings = new EngineSettings(downloadsPath, port);
                engineSettings.PreferEncryption = false;
                engineSettings.AllowedEncryption = EncryptionTypes.All;

                //engineSettings.GlobalMaxUploadSpeed = 30 * 1024;
                //engineSettings.GlobalMaxDownloadSpeed = 100 * 1024;
                //engineSettings.MaxReadRate = 1 * 1024 * 1024;

                // Create the default settings which a torrent will have.
                // 4 Upload slots - a good ratio is one slot per 5kB of upload speed
                // 50 open connections - should never really need to be changed
                // Unlimited download speed - valid range from 0 -> int.Max
                // Unlimited upload speed - valid range from 0 -> int.Max
                TorrentSettings torrentDefaults = new TorrentSettings(4, 150, 0, 0);

                // Create an instance of the engine.
                engine = new ClientEngine(engineSettings);
                engine.ChangeListenEndpoint(new IPEndPoint(IPAddress.Any, port));
                byte[] nodes = null;
                try
                {
                    nodes = File.ReadAllBytes(dhtNodeFile);
                }
                catch
                {
                    Console.WriteLine("No existing dht nodes could be loaded");
                }

                DhtListener dhtListner = new DhtListener(new IPEndPoint(IPAddress.Any, port));
                DhtEngine dht = new DhtEngine(dhtListner);
                engine.RegisterDht(dht);
                dhtListner.Start();
                engine.DhtEngine.Start(nodes);

                // If the SavePath does not exist, we want to create it.
                if (!Directory.Exists(engine.Settings.SavePath))
                    Directory.CreateDirectory(engine.Settings.SavePath);

                // If the torrentsPath does not exist, we want to create it
                if (!Directory.Exists(torrentsPath))
                    Directory.CreateDirectory(torrentsPath);

                BEncodedDictionary fastResume;
                try
                {
                    fastResume = BEncodedValue.Decode<BEncodedDictionary>(File.ReadAllBytes(fastResumeFile));
                }
                catch
                {
                    fastResume = new BEncodedDictionary();
                }

                // Load the .torrent from the file into a Torrent instance
                // You can use this to do preprocessing should you need to
                torrent = Torrent.Load(torrentpath);

                // When any preprocessing has been completed, you create a TorrentManager
                // which you then register with the engine.
                TorrentManager manager = new TorrentManager(torrent, downloadsPath, torrentDefaults);
                //if (fastResume.ContainsKey(torrent.InfoHash.ToHex()))
                //    manager.LoadFastResume(new FastResume((BEncodedDictionary)fastResume[torrent.infoHash.ToHex()]));
                engine.Register(manager);

                // Store the torrent manager in our list so we can access it later
                torrents.Add(manager);
                manager.PeersFound += new EventHandler<PeersAddedEventArgs>(manager_PeersFound);

                // Every time a piece is hashed, this is fired.
                manager.PieceHashed += delegate (object o, PieceHashedEventArgs ec)
                {
                    lock (listener)
                        listener.WriteLine(string.Format("Piece Hashed: {0} - {1}", ec.PieceIndex, ec.HashPassed ? "Pass" : "Fail"));
                };

                // Every time the state changes (Stopped -> Seeding -> Downloading -> Hashing) this is fired
                manager.TorrentStateChanged += delegate (object o, TorrentStateChangedEventArgs ev)
                {
//.........这里部分代码省略.........
开发者ID:silvermcd123,项目名称:WoWPrivateServerLauncher,代码行数:101,代码来源:MainWindow.xaml.cs

示例2: GetUnconfirmedReportNumbers

 private string GetUnconfirmedReportNumbers(List<string> reportNumbersProcessed)
 {
     StringBuilder result = new StringBuilder();
     foreach (string reportNumber in this.m_ReportNumbersToProcess)
     {
         if (reportNumbersProcessed.Exists(x => x == reportNumber) == false)
         {
             result.Append(reportNumber + " ");
         }
     }
     return result.ToString();
 }
开发者ID:ericramses,项目名称:YPILIS,代码行数:12,代码来源:PSATransferDialog.xaml.cs

示例3: removeTimelineEntry

        //removes an entry from the time table
        public void removeTimelineEntry(TimeSpan startTime, TimeSpan endTime, string text)
        {
            if (startTime.Days != endTime.Days)
            {
                TimeSpan endTimeSplit = new TimeSpan(startTime.Days, 23, 59, 0);
                removeTimelineEntry(startTime, endTimeSplit, text);

                TimeSpan startTimeSplit = new TimeSpan(endTime.Days, 0, 0, 0);
                removeTimelineEntry(startTimeSplit, endTime, text);
            }

            var entries = new List<TimelineEntry>();

            entries.AddRange(this.TuesdayEntries);
            entries.AddRange(this.MondayEntries);
            entries.AddRange(this.WednesdayEntries);
            entries.AddRange(this.ThursdayEntries);
            entries.AddRange(this.FridayEntries);
            entries.AddRange(this.SaturdayEntries);
            entries.AddRange(this.SundayEntries);

            if (entries.Exists(e => e.StartTime == startTime && e.EndTime == endTime && e.Text == text))
            {
                if (startTime.Days == 2)
                    this.TuesdayEntries.Remove(this.TuesdayEntries.First(e => e.StartTime == startTime && e.EndTime == endTime && e.Text == text));

                if (startTime.Days == 3)
                    this.WednesdayEntries.Remove(this.WednesdayEntries.First(e => e.StartTime == startTime && e.EndTime == endTime && e.Text == text));

                if (startTime.Days == 4)
                    this.ThursdayEntries.Remove(this.ThursdayEntries.First(e => e.StartTime == startTime && e.EndTime == endTime && e.Text == text));

                if (startTime.Days == 5)
                    this.FridayEntries.Remove(this.FridayEntries.First(e => e.StartTime == startTime && e.EndTime == endTime && e.Text == text));

                if (startTime.Days == 6)
                    this.SaturdayEntries.Remove(this.SaturdayEntries.First(e => e.StartTime == startTime && e.EndTime == endTime && e.Text == text));

                if (startTime.Days == 0 || startTime.Days == 7)
                    this.SundayEntries.Remove(this.SundayEntries.First(e => e.StartTime == startTime && e.EndTime == endTime && e.Text == text));

                if (startTime.Days == 1)
                    this.MondayEntries.Remove(this.MondayEntries.First(e => e.StartTime == startTime && e.EndTime == endTime && e.Text == text));
            }
        }
开发者ID:tehknox,项目名称:tap-desktop,代码行数:46,代码来源:ucTimeTable.xaml.cs

示例4: GetCoordinates

        private CustomCoordinateList GetCoordinates(DashboardHelper dashboardHelper, string latVar, string longVar, string timeVar)
        {
            List<string> columnNames = new List<string>();
            if (dashboardHelper.IsUsingEpiProject)
                columnNames.Add("UniqueKey");
            columnNames.Add(latVar);
            if (!columnNames.Exists(delegate(string s) { return s.Equals(longVar); }))
                columnNames.Add(longVar);
            if (!string.IsNullOrEmpty(timeVar))
            {
                if (!columnNames.Exists(delegate(string s) { return s.Equals(timeVar); }))
                    columnNames.Add(timeVar);
            }
            DataTable data = dashboardHelper.GenerateTable(columnNames);

            minTime = DateTime.MaxValue;
            maxTime = DateTime.MinValue;
            minX = double.MaxValue;
            maxX = double.MinValue;
            minY = double.MaxValue;
            maxY = double.MinValue;

            CustomCoordinateList coordinateList = new CustomCoordinateList();
            if (data != null)
            {
                foreach (DataRow row in data.Rows)
                {
                    if (row[latVar] != DBNull.Value && row[longVar] != DBNull.Value)
                    {
                        double latitude = double.Parse(row[latVar].ToString());
                        double longitude = double.Parse(row[longVar].ToString());
                        if (latitude <= 90 && latitude >= -90 && longitude <= 180 && longitude >= -180)
                        {
                            int uniqueKey = 0;
                            if (dashboardHelper.IsUsingEpiProject)
                                uniqueKey = (int)row["UniqueKey"];
                            if (string.IsNullOrEmpty(timeVar))
                            {
                                coordinateList.Coordinates.Add(new CustomCoordinate(uniqueKey, latitude, longitude, null));
                            }
                            else if (!data.Columns.Contains(timeVar))
                            {
                                coordinateList.Coordinates.Add(new CustomCoordinate(uniqueKey, latitude, longitude, null));
                            }
                            else
                            {
                                if (row[timeVar] != DBNull.Value)
                                {
                                    DateTime time = (DateTime)row[timeVar];
                                    minTime = minTime < time ? minTime : time;
                                    maxTime = maxTime > time ? maxTime : time;

                                    coordinateList.Coordinates.Add(new CustomCoordinate(uniqueKey, latitude, longitude, time));
                                }
                                else
                                {
                                    coordinateList.Coordinates.Add(new CustomCoordinate(uniqueKey, latitude, longitude, null));
                                }
                            }
                            minY = Math.Min(minY, latitude);
                            maxY = Math.Max(maxY, latitude);
                            minX = Math.Min(minX, longitude);
                            maxX = Math.Max(maxX, longitude);
                        }
                    }
                }
            }
            return coordinateList;
        }
开发者ID:NALSS,项目名称:epiinfo-82474,代码行数:69,代码来源:PointLayerProvider.cs

示例5: scanMedia_Click

        //Scan Media Button
        private void scanMedia_Click(object sender, RoutedEventArgs e)
        {
            //string filter = string.Empty;
            //if (Path.Contains("Wheel"))
            //    filter = "*.png";

            //di = new DirectoryInfo(Path);
            //fi = di.GetFiles(filter);
            //foreach (var item in fi)
            //{
            //    List<string> FilesList = new List<string>();
            //}

            try
            {
                string filter = string.Empty;
                DirectoryInfo di = new DirectoryInfo("Media\\" + systemName + "\\Wheel Images");
                if (di.FullName.Contains("Wheel"))
                    filter = "*.png";

                FileInfo[] fi = di.GetFiles(filter);
                listWheels = new List<MediaFiles>();

                List<Table> tab = new List<Table>(tables);
                foreach (FileInfo file in fi)
                {
                    bool exist = tab.Exists(x => x.Description == System.IO.Path.GetFileNameWithoutExtension(file.Name));
                    if (!exist)
                    {
                        listWheels.Add(new MediaFiles(file, "", false, "Wheels"));
                    }
                    else
                    { }

                }

                CollectionViewSource ItemCollectionViewSourceWheelFiles;
                ItemCollectionViewSourceWheelFiles = (CollectionViewSource)(FindResource("ItemCollectionViewSourceWheelFiles"));
                ItemCollectionViewSourceWheelFiles.Source = listWheels;

                di = new DirectoryInfo("Media\\" + systemName + "\\Table Images");
                fi = di.GetFiles("*.png");
                listTImgs = new List<MediaFiles>();
                foreach (var file in fi)
                {
                    bool exist = tab.Exists(x => x.Description == System.IO.Path.GetFileNameWithoutExtension(file.Name));
                    if (!exist)
                    {
                        listTImgs.Add(new MediaFiles(file, "", false, "Table Image"));
                    }
                    else
                    { }

                }

                di = new DirectoryInfo("Media\\" + systemName + "\\Table Videos");
                fi = di.GetFiles("*.mp4");
                listTVids = new List<MediaFiles>();
                foreach (var file in fi)
                {
                    bool exist = tab.Exists(x => x.Description == System.IO.Path.GetFileNameWithoutExtension(file.Name));
                    if (!exist)
                    {
                        listTImgs.Add(new MediaFiles(file, "", false, "Table Vids"));
                    }
                    else
                    { }

                }

                if (DataGridMedia.Items.Count > 0)
                {
                    foreach (var item in DataGridMedia.Items)
                    {
                        var t = item as Table;

                        if (File.Exists("Media\\" + systemName + "\\Wheel Images\\" + t.Description + ".png"))
                        {
                            t.HaveWheels = true;
                        }

                        if (File.Exists("Media\\" + systemName + "\\Backglass Images\\" + t.Description + ".png"))
                        {
                            t.HaveBGImage = true;
                        }

                        if (File.Exists("Media\\" + systemName + "\\Backglass Videos\\" + t.Description + ".f4v"))
                        {
                            t.HaveBGVids = true;
                        }

                        if (File.Exists("Media\\" + systemName + "\\Backglass Videos\\" + t.Description + ".mp4"))
                        {
                            t.HaveBGVids = true;
                        }

                        if (File.Exists("Media\\" + systemName + "\\DMD Images\\" + t.Description + ".png"))
                        {
                            t.HaveDmdImg = true;
//.........这里部分代码省略.........
开发者ID:horseyhorsey,项目名称:PinXCheck,代码行数:101,代码来源:MainWindow.xaml.cs

示例6: ScanTablePath

        public void ScanTablePath(string path)
        {
            string ext = string.Empty;
            string ext2 = string.Empty;
            DirectoryInfo di = new DirectoryInfo(path);
            if (systemName == "Visual Pinball")
            {
                ext = ".vpt";
                ext2 = ".vpx";
            }
            else if (systemName == "Future Pinball")
                ext = ".fpt";
            else if (systemName == "P-ROC")
            {
                ext = ".vpt";
                ext2 = ".vpx";
            }

            FileInfo[] fi;
            DirectoryInfo[] dia;
            List<Table> tab = new List<Table>(tables);
            oddTables = new ObservableCollection<OddTables>();

            fi = di.GetFiles("*.*");

            string tableExt = string.Empty;
            foreach (FileInfo file in fi)
            {
                tableExt = System.IO.Path.GetExtension(file.Name);
                if (ext == tableExt || ext2 == tableExt)
                {
                    bool exist = tab.Exists(x => x.Name == System.IO.Path.GetFileNameWithoutExtension(file.Name));
                    if (!exist)
                    {
                        oddTables.Add(new OddTables(file.Name, file.LastWriteTime));
                    }
                }
            }

            populateOddTables();
        }
开发者ID:horseyhorsey,项目名称:PinXCheck,代码行数:41,代码来源:MainWindow.xaml.cs

示例7: CardSearchFilterText

        /// <summary>
        /// Filter by Card text content
        /// </summary>
        /// <param name="searchStr">The search STR.</param>
        /// <param name="actualStr">The actual STR.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev08, 2009-07-16</remarks>
        private bool CardSearchFilterText(string searchStr, List<string> actualStrings)
        {
            if (string.IsNullOrEmpty(searchStr))        //nothing typed --> show all
                return true;

            return actualStrings.Exists(s => s.ToLower().Contains(searchStr.ToLower()));
        }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:14,代码来源:FilterAndSortControl.xaml.cs

示例8: MediaPathButton_Click

        //Event Handler: Click on Browse button
        private void MediaPathButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Media files (image, video, audio)|*.jpg;*.gif;*.png;*.aac;*.wma;*.m4a;*.ogg;*.flac;*.wav;*.mp3;*.avi;*.mpg;*.mov|All Files (*.*)|*.*";
            ofd.FilterIndex = 1;
            if (ofd.ShowDialog() == true)
            {
                
                FileInfo info = new FileInfo(ofd.FileName);
                Boolean valid = false;
                List<String> validVideoExt = new List<String> {".avi", ".mpg", ".mov"};
                List<String> validAudioExt = new List<String> {".aac", ".wma", ".m4a", ".ogg", ".flac", ".wav", ".mp3"};
                List<String> validImageExt = new List<String> {".jpg", ".gif", ".png"};

                //Clearing previous fields
                ClearFields();

                //Is it a video file?
                if (validVideoExt.Exists(delegate(String ext) { return (ext == info.Extension); }))
                {
                    MediaVideoQualityLabel.IsEnabled    = true;
                    MediaVideoQuality.IsEnabled         = true;
                    MediaVideoQuality.Visibility        = System.Windows.Visibility.Visible;
                    MediaVideoQualityLabel.Visibility   = System.Windows.Visibility.Visible;
                    MediaVideoQuality.IsChecked         = false;
                    valid = true;
                    _mediaType = MediaType.Video;
                }
                //Is it an audio file?
                if (validAudioExt.Exists(delegate(String ext) { return (ext == info.Extension); }))
                {
                    MediaAudioType.Text                 = info.Extension;
                    MediaAudioTypeLabel.Visibility      = System.Windows.Visibility.Visible;
                    MediaAudioType.Visibility           = System.Windows.Visibility.Visible;
                    valid = true;
                    _mediaType = MediaType.Audio;
                }
                //Is it an image file?
                if (validImageExt.Exists(delegate(String ext) { return (ext == info.Extension); }))
                {
                    valid = true;
                    _mediaType = MediaType.Image;
                }
                
                //If we have a valid file, we can fill both path and size.
                if (valid)
                {
                    MediaPath.Text = ofd.FileName;
                    MediaSize.Text = info.Length.ToFileSize();
                    Submit.IsEnabled = true;
                }
                
            }
            ofd = null;
        }
开发者ID:adrienrouquet,项目名称:cpe-tpcsharp,代码行数:56,代码来源:MediaWindow.xaml.cs


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