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


C# ObservableCollection.Last方法代码示例

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


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

示例1: ParseXml

        /// <summary>
        /// Wybiera stronę na podstawie adresu url i zapisuje wszystkie wiadomości w kolekcji
        /// </summary>
        /// <param name="lineNews">Lista wiadomości</param>
        /// <param name="category">Kategoria źródłowa do odczytu</param>
        public void ParseXml(ObservableCollection<News> lineNews, Category category)
        {
            try
            {
                using (XmlReader reader = XmlReader.Create(category.Url))
                {
                    var formatter = new Rss20FeedFormatter();
                    formatter.ReadFrom(reader);
                    foreach (var item in formatter.Feed.Items)
                    {
                        lineNews.Add(new News
                        {
                            Title = item.Title.Text,
                            Date = item.PublishDate.DateTime.ToString(),
                            UrlNews = item.Links.First().Uri.ToString(),
                            Description = item.Summary.Text,
                            Category = category.Name,
                            Id = item.Id
                        });

                        if (item.Links.Count > 1 && item.Links.Any(n => n.Uri.ToString().Contains(".jpg")))
                            lineNews.Last().UrlImage = item.Links[1].Uri.ToString();

                        ParseId(lineNews.Last());
                        ParseDescription(lineNews.Last());
                    }
                }
            }
            catch (WebException ex)
            {
                MessageBox.Show(ex.Message, "Syndication Reader");
            }
        }
开发者ID:mobile32,项目名称:RSS-Reader,代码行数:38,代码来源:Reader.cs

示例2: MainViewModel

		public MainViewModel(SettingsViewModel settings)
		{
			Settings = settings;
			Documents = new ObservableCollection<Document>();
			OpenCommand = new RelayCommand(() => Open());
			NewCommand = new RelayCommand(New);
			SaveCommand = new RelayCommand(() => _source.Save(SelectedDocument));
			CloseCommand = new RelayCommand(async () =>
				{
					if (SelectedDocument == null)
						return;

					var d = SelectedDocument;
					if (d.IsModified && await ShouldSave())
						_source.Save(d);

					_source.Close(d);
					Documents.Remove(d);

					if (Documents.Count == 0)
						New();
					else
						SelectedDocument = Documents.Last();
				});
			PinCommand = new RelayCommand<Document>(document => PinDocument(document), CanExecute);
			Load();

			DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
			dataTransferManager.DataRequested += ShareRequested;
			SettingsPane.GetForCurrentView().CommandsRequested += CommandsRequested;
		}
开发者ID:modulexcite,项目名称:MarkPadRT,代码行数:31,代码来源:MainViewModel.cs

示例3: ObservableCollectionTest

        public void ObservableCollectionTest()
        {
            var originalCollection = new ObservableCollection<MyModel>() { new MyModel() };
            var synchronizingCollection = new SynchronizingCollection<MyDataModel, MyModel>(originalCollection, m => new MyDataModel(m));
            Assert.IsTrue(originalCollection.SequenceEqual(synchronizingCollection.Select(dm => dm.Model)));

            // Check add operation with collection changed event.
            bool handlerCalled = false;
            NotifyCollectionChangedEventHandler handler = (sender, e) =>
            {
                handlerCalled = true;
                Assert.AreEqual(synchronizingCollection, sender);
                Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action);
                Assert.AreEqual(1, e.NewStartingIndex);
                Assert.AreEqual(originalCollection.Last(), e.NewItems.Cast<MyDataModel>().Single().Model);
            };
            synchronizingCollection.CollectionChanged += handler;
            originalCollection.Add(new MyModel());
            Assert.IsTrue(handlerCalled);

            // After dispose the collection does not synchronize anymore
            handlerCalled = false;
            synchronizingCollection.Dispose();
            originalCollection.Add(new MyModel());
            Assert.IsFalse(handlerCalled);
            synchronizingCollection.CollectionChanged -= handler;
        }
开发者ID:jbe2277,项目名称:waf,代码行数:27,代码来源:SynchronizingCollectionTest.cs

示例4: Chat

 public Chat(string chatName)
 {
     chatLogs = new ObservableCollection<ChatLog>();
     name = chatName;
     if (chatLogs.Count != 0)
     {
         summary = chatLogs.Last().Content;
     }
 }
开发者ID:t103z,项目名称:FZChat,代码行数:9,代码来源:Chat.cs

示例5: LoadAlbumsFromMediaLibraryAsync

 public async Task LoadAlbumsFromMediaLibraryAsync(PictureAlbum album, CancellationToken token)
 {
     ObservableCollection<CollectionControlModel> newItems = new ObservableCollection<CollectionControlModel>();
     foreach (var photo in album.Pictures)
     {
         Log(photo.Name);
        // await Task.Delay(new TimeSpan(0,0,0,0,10));
         token.ThrowIfCancellationRequested();
         Log(photo.Name + "50");
         newItems.Add(new CollectionControlModel()
         {
             FileName = Path.GetFileNameWithoutExtension(photo.Name),
             Data = photo
         });
         Log(photo.Name);
         token.ThrowIfCancellationRequested();
         using (Stream str = photo.GetThumbnail())
         {
            
             Log(photo.Name + "60");
             byte[] buffer = new byte[str.Length];
             await str.ReadAsync(buffer, 0, buffer.Length);
             Log(photo.Name + "63");
             token.ThrowIfCancellationRequested();
             using (MemoryStream ms = new MemoryStream())
             {
                 Log(photo.Name + "67");
                 await ms.WriteAsync(buffer, 0, buffer.Length);
                 token.ThrowIfCancellationRequested();
                 newItems.Last().Thumbnail = new BitmapImage();
                 newItems.Last().Thumbnail.SetSource(ms);
                 Log(photo.Name + "72");
             }
             //await Task.Delay(new TimeSpan(0, 0, 0, 0, 10));
             //Thread.Sleep(1000);
         }
     }
     foreach (var item in newItems)
     {
         Items.Add(item);
     }
 }
开发者ID:narekhay,项目名称:Diplomayin,代码行数:42,代码来源:PhotosViewModel.cs

示例6: ApplyNext

        internal ImageSource ApplyNext(ObservableCollection<Image> removeCarsGroup, List<BitmapImage> removeCarsMasks)
        {
            string imageFilePath0 = GetFilePath(removeCarsGroup.Last());
            IList<string> files = Directory.GetFiles(GetDirectory(removeCarsGroup.Last()));
            string imageFilePath1 = files.ElementAt(files.IndexOf(imageFilePath0) + 1);

            Image image1 = dataContext.Images.Where(i => i.Name == Path.GetFileNameWithoutExtension(imageFilePath1)).FirstOrDefault();
            removeCarsGroup.Add(image1);

            removeCarsMasks.Add(openCVHelper.CalculateAbsoluteDifference(imageFilePath0, imageFilePath1));

            BitmapImage intersectedMask = new BitmapImage();

            if (removeCarsMasks.Count > 1)
            {
                int lastMask = removeCarsMasks.Count - 1;
                intersectedMask = openCVHelper.IntersectMasks(removeCarsMasks[lastMask], removeCarsMasks[lastMask - 1]);
                removeCarsMasks.Add(intersectedMask);
            }

            return removeCarsMasks.Last();
        }
开发者ID:uzapy,项目名称:ch.bfh.bti7302.w2015.schneedetektion,代码行数:22,代码来源:ImageHelper.cs

示例7: ModManager

        public ModManager(string rootPath)
        {
            SafeMode = true;
            CheckRoot(rootPath);
            _rootPath = rootPath;
            _worklog = new Worklog();

            Cars = new ObservableCollection<CarEntity>();
            var playerCarsConfig = XElement.Load(_rootPath + PlayerCarsPath);

            if (playerCarsConfig.HasElements)
            {
                var playerCars = playerCarsConfig.Elements().ToList();
                foreach (var carXml in playerCars)
                {
                    Cars.Add(CarEntity.FromXml(carXml));
                    TrackCarChanges(Cars.Last());
                }
            }
        }
开发者ID:vlad-zapp,项目名称:3diModManager,代码行数:20,代码来源:ModManager.cs

示例8: FolderReactionManagePageViewModel

		public FolderReactionManagePageViewModel(PageManager pageManager, IFolderReactionMonitorModel monitor, IEventAggregator ea, IAppPolicyManager appPolicyManager, IHistoryManager historyManager, IReactiveFolderSettings settings)
			: base(pageManager)
		{
			Monitor = monitor;
			_EventAggregator = ea;
			AppPolicyManager = appPolicyManager;
			HistoryManager = historyManager;
			Settings = settings;



			CurrentFolder = new ReactiveProperty<ReactionManageFolderViewModel>();
			FolderStack = new ObservableCollection<ReactionManageFolderViewModel>();

			FolderStack.CollectionChangedAsObservable()
				.Subscribe(x => 
				{
					CurrentFolder.Value = FolderStack.Last();
				});

			FolderStack.Add(new ReactionManageFolderViewModel(this, Monitor.RootFolder));
		}
开发者ID:tor4kichi,项目名称:ReactiveFolder,代码行数:22,代码来源:FolderReactionManagePageViewModel.cs

示例9: GetAdapters

        public ObservableCollection<NetworkAdapters> GetAdapters()
        {
            int id_count = 1;
            ObservableCollection<NetworkAdapters> ListAdapters = new ObservableCollection<NetworkAdapters>();
            NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
            if(adapters!=null)
            {

                foreach (NetworkInterface adapter in adapters)
                {
                    // OperationalStatus adapterStatus = adapter.OperationalStatus; // текущее состояние адаптера
                    string[] descrToParts;
                    string descr;
                    descr = adapter.Description;
                    if (descr.Contains(" - "))
                    {
                        descrToParts = descr.Split('-'); //расщепляет на 2 части (чтобы откинуть часть с "минипорт планировщика бла бла")
                        //descrToParts[1] = descr; // забираем только первую часть
                        foreach (string s in descrToParts)
                        {
                            descr = s;   // забираем только первую часть
                            break;
                        }
                    }
                    // descr = descrToParts.Skip(1).ToString();     
                    ListAdapters.Add(new NetworkAdapters { DescrForUser = descr + "  (" + adapter.Name + ")", ConnectionName = adapter.Name, AdapterDescription = descr, AdapterDescriptionFull = adapter.Description, GUID = adapter.Id, Id = id_count });

                    id_count++;


                    //MessageBox.Show(""+adapter.Name);
                }
                ListAdapters.Remove(ListAdapters.Last());

            return ListAdapters;
            }
            return null;
        }
开发者ID:CoffeeNova,项目名称:ventenergy,代码行数:38,代码来源:Network+adapters.cs

示例10: PopulateData

        void PopulateData (IEnumerable<Tweet> entries)
        {
            _dispatcher.BeginInvoke (delegate {
                //
                // Set all the tweets
                //
                Items = new ObservableCollection<TweetViewModel> (
                    from e in entries
                    select new TweetViewModel (e));

                //
                // Add some margin to the last item to get it out of the
                // way of the AppBar
                //
                if (Items.Count > 0) {
                    var last = Items.Last();
                    if (last != null) {
                        var m = last.Margin;
                        m.Bottom = 12 * 6;
                        last.Margin = m;
                    }
                }
                //
                // Update the properties
                //
                OnPropertyChanged ("Items");

                ListVisibility = Items.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
                NoDataVisibility = Items.Count == 0 ? Visibility.Visible : Visibility.Collapsed;

                OnPropertyChanged ("ListVisibility");
                OnPropertyChanged ("NoDataVisibility");
                OnPropertyChanged ("IsUpdating");
                OnPropertyChanged ("UpdatingVisibility");
            });
        }
开发者ID:Adameg,项目名称:mobile-samples,代码行数:36,代码来源:TwitterViewModel.cs

示例11: PopulateData

        void PopulateData (IEnumerable<RSSEntry> entries)
        {
            InvokeOnMainThread (delegate {
                //
                // Set all the news items
                //
                Items = new ObservableCollection<NewsItemViewModel> (
                    from e in entries
                    select new NewsItemViewModel (e));

                //
                // Add some margin to the last item to get it out of the
                // way of the AppBar
                //
                if (Items.Count > 0) {
                    var last = Items.Last();
                    if (last != null) {
                        var m = last.Margin;
                        m.Bottom = 12 * 6;
                        last.Margin = m;
                    }
                }
                //
                // Update the properties
                //
                FirePropertyChanged ("Items");

                ListVisibility = Items.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
                NoDataVisibility = Items.Count == 0 ? Visibility.Visible : Visibility.Collapsed;

                FirePropertyChanged ("ListVisibility");
                FirePropertyChanged ("NoDataVisibility");
                FirePropertyChanged ("IsUpdating");
                FirePropertyChanged ("UpdatingVisibility");
            });
        }
开发者ID:slodge,项目名称:mobile-samples,代码行数:36,代码来源:NewsListViewModel.cs

示例12: SolveClick

        private void SolveClick(object sender, RoutedEventArgs e)
        {
            try
            {
                ResListV.ItemsSource = null;
                ResListV.Items.Clear();
                gridV.Columns.Clear();
                IntLinearEquationSolve.SetMin(stationMin);
                resultList = IntLinearEquationSolve.Solve();

                if (resultList.Count == 0)
                {
                    ErrorViewer.ShowInfo("Отсутствуют решения. Попробуйте увеличить количество используемых станций");
                    return;
                }

                var results = new ObservableCollection<PointCoverW>();
                ResListV.ItemsSource = results;
                bool chk = false;
                foreach (int[] t in resultList)
                {
                    results.Add(new PointCoverW(fStep.GetStationCount(), fStep.GetPointCount()));
                    var str = string.Empty;
                    var pointCover = new int[fStep.GetPointCount()];
                    for (int j = 0; j < t.Length; j++)
                    {
                        if (!chk)
                        {
                            gridV.Columns.Add(new GridViewColumn()
                            {
                                Header = fStep.GetStationName(j),
                                DisplayMemberBinding = new Binding("StationCount[" + j.ToString() + "]")
                            });
                        }

                        results.Last().StationCount[j] = t[j];

                        for (int i = 0; i < fStep.GetPointCount(); i++)
                        {
                            results.Last().PointCover[i] += fStep.GetPointNumber(j, i) * t[j];
                        }
                    }
                    for (int i = 0; i < fStep.GetPointCount(); i++)
                    {
                        results.Last().PointCount[i] = fStep.GetPointTask(i);

                        if (!chk)
                        {
                            gridV.Columns.Add(new GridViewColumn()
                            {
                                Header = fStep.GetPointName(i),
                                DisplayMemberBinding = new Binding("PointView[" + i.ToString() + "]")
                            });
                        }
                    }
                    results.Last().SetPtView();
                    chk = true;
                }
            }
            catch (Exception ex)
            {
                ErrorViewer.ShowError(ex);
            }
        }
开发者ID:megadrow,项目名称:Study,代码行数:64,代码来源:ChooseInitTask.xaml.cs

示例13: ViewModel


//.........这里部分代码省略.........
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Buhne 4",
                    Location = new Location(53.50468, 8.15343)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Buhne 6",
                    Location = new Location(53.50092, 8.15267)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Buhne 8",
                    Location = new Location(53.49871, 8.15321)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Buhne 10",
                    Location = new Location(53.49350, 8.15563)
                });
            Points.Add(
                new VmPoint
                {
                    Name = "Moving",
                    Location = new Location(53.5, 8.25)
                });

            Pushpins = new ObservableCollection<VmPoint>();
            Pushpins.Add(
                new VmPoint
                {
                    Name = "WHV - Eckwarderhörne",
                    Location = new Location(53.5495, 8.1877)
                });
            Pushpins.Add(
                new VmPoint
                {
                    Name = "JadeWeserPort",
                    Location = new Location(53.5914, 8.14)
                });
            Pushpins.Add(
                new VmPoint
                {
                    Name = "Kurhaus Dangast",
                    Location = new Location(53.447, 8.1114)
                });
            Pushpins.Add(
                new VmPoint
                {
                    Name = "Eckwarderhörne",
                    Location = new Location(53.5207, 8.2323)
                });

            //for (double lon = -720; lon <= 720; lon += 15)
            //{
            //    var lat = lon / 10;
            //    Pushpins.Add(
            //        new VmPoint
            //        {
            //            Name = string.Format("{0:00.0}°, {1:000}°", lat, lon),
            //            Location = new Location(lat, lon)
            //        });
            //}

            Polylines = new ObservableCollection<VmPolyline>();
            Polylines.Add(
                new VmPolyline
                {
                    Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387")
                });
            Polylines.Add(
                new VmPolyline
                {
                    Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212")
                });

            var timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(0.1)
            };

            timer.Tick += (s, e) =>
            {
                var p = Points.Last();
                p.Location = new Location(p.Location.Latitude + 0.001, p.Location.Longitude + 0.002);

                if (p.Location.Latitude > 54d)
                {
                    p.Name = "Stopped";
                    ((DispatcherTimer)s).Stop();
                }
            };

            timer.Start();
        }
开发者ID:bhanu475,项目名称:XamlMapControl,代码行数:101,代码来源:ViewModel.cs

示例14: AngleFromSegments

 static double AngleFromSegments(ObservableCollection<DiagramConnectionSegment> segments) => Math.Atan2(segments.Last().EndPoint.X - segments.First().StartPoint.X, segments.Last().EndPoint.Y - segments.First().StartPoint.Y);
开发者ID:Particular,项目名称:ServiceInsight,代码行数:1,代码来源:EndSegmentValueConverter.cs

示例15: AddLineToList

 public void AddLineToList(ObservableCollection<CLineVM> list, DblPoint3 DstPoint)
 {
     if (list.Count > 0)
     PlannedLines.Add(new CLineVM(list.Last().P2, DstPoint, mWorldToCuttingPlaneTransform));
       else
     PlannedLines.Add(new CLineVM(new DblPoint3(0, 0, 0), DstPoint, mWorldToCuttingPlaneTransform));
 }
开发者ID:BitLabProjects,项目名称:LaserCat-Software,代码行数:7,代码来源:CCuttingPlaneVM.cs


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