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


C# ObservableCollection.Contains方法代码示例

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


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

示例1: Init

        private void Init()
        {
            DateTimeClocks = new ObservableCollection<ClockRecord>(Respostory.GetAllClockRecord());

            TestBeer = new RelayCommand(() => BeepVulous.Beep(1000, 1000));
            TestEmail = new RelayCommand(() =>
                {
                    if (null != CurrentDateTimeClock)
                        EmailSend.Send(CurrentDateTimeClock.EmailAdress, "测试邮件");

                });

            AddRecord = new RelayCommand(() =>
                {
                    if (!DateTimeClocks.Contains(CurrentDateTimeClock))
                    {
                        DateTimeClocks.Insert(0, CurrentDateTimeClock);
                        Respostory.InsertRecore(CurrentDateTimeClock);
                    }
                }
                );
            DeleteRecord = new RelayCommand(() =>
                {
                    if (DateTimeClocks.Contains(CurrentDateTimeClock))
                    {
                        DateTimeClocks.Remove(CurrentDateTimeClock);
                        Respostory.DeleteRecore(CurrentDateTimeClock);
                    }
                }
                );
        }
开发者ID:SeptemberWind,项目名称:AlarmClock-WPF,代码行数:31,代码来源:ClockAddViewModel.cs

示例2: HidManager

        public HidManager()
        {
            HidDeviceLoader = new HidDeviceLoader();
            FoundDevices = new ObservableCollection<HidDeviceRepresentation>();

            _hidScanThread = new Thread(() =>
            {
                while (true)
                {
                    var currentDevices = HidDeviceLoader.GetDevices().Select(hidDevice => new HidDeviceRepresentation(hidDevice)).ToList();

                    if (!Thread.CurrentThread.IsAlive) { break; }

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        foreach (var newDevice in currentDevices.Where(device => !FoundDevices.Contains(device)))
                        {
                            FoundDevices.Add(newDevice);
                        }
                    });

                    Thread.Sleep(TimeSpan.FromSeconds(10));
                }
                // ReSharper disable once FunctionNeverReturns
            });
            _hidScanThread.Start();
        }
开发者ID:Axadiw,项目名称:MFIGamepadFeeder,代码行数:27,代码来源:HidManager.cs

示例3: DeviceGuardZoneViewModel

		public DeviceGuardZoneViewModel(GKDeviceGuardZone deviceGuardZone, GKDevice device)
		{
			DeviceGuardZone = deviceGuardZone;
			if (device != null)
				IsCodeReader = device.Driver.IsCardReaderOrCodeReader;
			No = deviceGuardZone.GuardZone.No;
			Name = deviceGuardZone.GuardZone.Name;
			Description = deviceGuardZone.GuardZone.Description;
			ActionTypes = new ObservableCollection<GKGuardZoneDeviceActionType>();
			if (device != null)
			switch (device.DriverType)
			{
				case GKDriverType.RSR2_GuardDetector:
				case GKDriverType.RSR2_GuardDetectorSound:
				case GKDriverType.RSR2_HandGuardDetector:
					ActionTypes.Add(GKGuardZoneDeviceActionType.SetAlarm);
					break;

				case GKDriverType.RSR2_AM_1:
				case GKDriverType.RSR2_MAP4:
					ActionTypes.Add(GKGuardZoneDeviceActionType.SetGuard);
					ActionTypes.Add(GKGuardZoneDeviceActionType.ResetGuard);
					ActionTypes.Add(GKGuardZoneDeviceActionType.ChangeGuard);
					ActionTypes.Add(GKGuardZoneDeviceActionType.SetAlarm);
					break;
			}
			if (deviceGuardZone.ActionType == null || !ActionTypes.Contains(deviceGuardZone.ActionType.Value))
				SelectedActionType = ActionTypes.FirstOrDefault();
			ShowPropertiesCommand = new RelayCommand(OnShowProperties);
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:30,代码来源:DeviceGuardZoneViewModel.cs

示例4: GroupHistoryViewModel

        public GroupHistoryViewModel(IStockProvider dataService)
        {
            _dataService = dataService;

            StockGroups = new ObservableCollection<StockQuoteGroup>();

            var groupingsStream = from quote in _dataService.StockQuoteStream.ObserveOnDispatcher()
                                  group quote by quote.Symbol into company
                                  let grp = new StockQuoteGroup(company.Key)
                                  from quote in company
                                  select new
                                  {
                                      Group = grp,
                                      Quote = quote
                                  };

            var res =  groupingsStream.Select(item =>
            {
                //Add it to the list of all groups if it doesn't exist
                if (!StockGroups.Contains(item.Group))
                {
                    StockGroups.Insert(0, item.Group);
                }
                item.Group.Quotes.Insert(0, item.Quote);
                item.Group.Latest = item.Quote;

                return item;
            });
            res.Subscribe();
        }
开发者ID:xyicheng,项目名称:Stocks,代码行数:30,代码来源:GroupHistoryViewModel.cs

示例5: Init

        private void Init()
        {
            Musicses = new ObservableCollection<Musics>(Respostory.GetAllMusic());
            InsertMusic = new RelayCommand(() =>
            {
                if (!Musicses.Contains(SelectMusic))
                {
                    Musicses.Insert(0, SelectMusic);
                    Respostory.InsertMusic(SelectMusic);
                }
            });


            LastMusic=new RelayCommand(() =>
                {
                    _incuten = Musicses.IndexOf(SelectMusic);
                    if (-1 != _incuten)
                    {
                        SelectMusic = Musicses[_incuten - 1 >= 0 ? _incuten - 1 : 0];
                    }
                });

            NextMusic = new RelayCommand(() =>
                {
                    _incuten = Musicses.IndexOf(SelectMusic);
                    if (-1 != _incuten)
                    {
                        SelectMusic = Musicses[_incuten + 1 < Musicses.Count ? _incuten + 1 : Musicses.Count-1];
                    }
                });
        }
开发者ID:SeptemberWind,项目名称:AlarmClock-WPF,代码行数:31,代码来源:MusicPlayerViewModel.cs

示例6: UpdateIcons

        private void UpdateIcons() {
            Icons = new ObservableCollection<FilesStorage.ContentEntry>(FilesStorage.Instance.GetContentDirectory(ContentCategory.UpgradeIcons));

            if (Icons.Contains(Selected)) return;
            var previous = ValuesStorage.GetString(_key);
            Selected = (previous != null ? Icons.FirstOrDefault(x => x.Name == previous) : null) ?? (Icons.Count > 0 ? Icons[0] : null);
        }
开发者ID:gro-ove,项目名称:actools,代码行数:7,代码来源:UpgradeIconEditor_Library.xaml.cs

示例7: AppGrabberUI

        public AppGrabberUI(AppGrabber appGrabber)
        {
            this.appGrabber = appGrabber;
            InitializeComponent();

            // Grab the Programs
            List<ApplicationInfo> apps = appGrabber.ProgramList;

            // Now to add them to the list on the AppGrabber
            // Create ObservableCollections to bind to the ListViews

            ObservableCollection<ApplicationInfo> installedAppsCollection = new ObservableCollection<ApplicationInfo>();
            programsMenuAppsCollection = new ObservableCollection<ApplicationInfo>(appGrabber.CategoryList.FlatList.ToList());
            InstalledAppsView.ItemsSource = installedAppsCollection;
            ProgramsMenuAppsView.ItemsSource = programsMenuAppsCollection;
            // Need to use an event handler to remove Apps from categories when moved to the "Installed Applications" listing
            programsMenuAppsCollection.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(programsMenuAppsCollection_CollectionChanged);

            // Iterate thru the apps, creating ApplicationInfoPanels and
            // add them to the installedAppsCollection
            foreach (ApplicationInfo app in apps)
            {
                if (!programsMenuAppsCollection.Contains(app)) {
                    installedAppsCollection.Add(app);
                }
            }
            AppViewSorter.Sort(installedAppsCollection, "Name");
            AppViewSorter.Sort (programsMenuAppsCollection, "Name");
            GC.Collect ();
        }
开发者ID:RevolutionSmythe,项目名称:cairoshell,代码行数:30,代码来源:AppGrabberUI.xaml.cs

示例8: PopupViewModel

        public PopupViewModel()
        {
            Locations = new ObservableCollection<PopupLocationItem>();
            LocationSelectedCommand = new Command<PopupLocationItem>((item) =>
            {
                if (!Locations.Contains(item)) return;

                foreach (PopupLocationItem items in Locations)
                {
                    items.IsSelected = false;
                }

                item.IsSelected = true;

                if (LocationSelected != null)
                {
                    LocationSelected(this, item);
                }
                             
            });

            LocationRemovedCommand = new Command<PopupLocationItem>((item) =>
            {
                Locations.Remove(item);

                if (LocationRemoved != null)
                {
                    LocationRemoved(this, item);
                }
            });
       
        }
开发者ID:iejeecee,项目名称:mediaviewer,代码行数:32,代码来源:PopupViewModel.cs

示例9: CollectionContainsItem

        public static bool CollectionContainsItem(ObservableCollection<string> collection,
            string item)
        {
            bool contains = false;

            if (collection != null)
                GUIDispatcher.Invoke((Action)(() => { contains = collection.Contains(item); }));
            else
                throw new ArgumentNullException("Collection can not be null");

            return contains;
        }
开发者ID:philspain,项目名称:ordoFile,代码行数:12,代码来源:GUIDispatcherUpdates.cs

示例10: WhenGridViewSelectedItemsChange_SelectedItemsCollectionIsUpdated

        public void WhenGridViewSelectedItemsChange_SelectedItemsCollectionIsUpdated()
        {
            // Arrange.
            var item1 = new object();
            var item2 = new object();
            var grid = new RadGridView { SelectionMode = SelectionMode.Multiple, ItemsSource = new[] { item1, item2 } };
            var behavior = new GridViewMultiSelectBehavior();
            var selectedItems = new ObservableCollection<object>();

            behavior.Attach(grid);
            behavior.SelectedItems = selectedItems;

            // Act.
            grid.SelectedItems.Add(item1);

            // Assert
            Assert.AreEqual(1, selectedItems.Count);
            Assert.IsTrue(selectedItems.Contains(item1));

            // Act.
            grid.SelectedItems.Add(item2);

            // Assert.
            Assert.AreEqual(2, selectedItems.Count);
            Assert.IsTrue(selectedItems.Contains(item1));
            Assert.IsTrue(selectedItems.Contains(item2));

            // Act.
            grid.SelectedItems.Remove(item1);

            // Assert.
            Assert.AreEqual(1, selectedItems.Count);
            Assert.IsTrue(selectedItems.Contains(item2));

            // Act.
            grid.SelectedItems.Clear();

            // Assert.
            Assert.AreEqual(0, selectedItems.Count);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:40,代码来源:GridViewMultiSelectBehaviorTests.cs

示例11: SearchAlbums

 public static void SearchAlbums(string tag, ObservableCollection<AlbumItem> results)
 {
     var albums = SearchAlbumItems(tag);
     foreach (var album in albums)
     {
         if (!results.Contains(album)) 
             results.Add(album);
     }
     foreach (var result in results.ToList())
     {
         if (!albums.Contains(result))
             results.Remove(result);
     }
 }
开发者ID:robUx4,项目名称:vlc-winrt,代码行数:14,代码来源:SearchHelpers.cs

示例12: SetBooking

        public void SetBooking(Booking booking, SubmitBookingResponse submitBookingResponse)
        {
            if (booking == null)
                return;
            
            _booking = booking;

            Email3 = Email4 = null;

            CreatorEmails = new ObservableCollection<string>(submitBookingResponse.CreatorEmails);
            if (!string.IsNullOrWhiteSpace(_booking.Creator.Email) && !CreatorEmails.Contains(_booking.Creator.Email))
                CreatorEmails.Insert(0, _booking.Creator.Email);
            OnPropertyChanged(() => CreatorEmails);
        }
开发者ID:felixthehat,项目名称:Limo,代码行数:14,代码来源:ConfirmationViewModel.cs

示例13: AllAvoidAttackMoves

 public static ObservableCollection<Move> AllAvoidAttackMoves()
 {
     ObservableCollection<Piece> attackablePieces = new ObservableCollection<Piece>();
     foreach (Move move in This.Game.OppositePlayer.AllMoves())
     {
         if (move.EndPosition.Piece != null && !attackablePieces.Contains(move.EndPosition.Piece))
             attackablePieces.Add(move.EndPosition.Piece);
     }
     ObservableCollection<Move> possible = new ObservableCollection<Move>();
     foreach (Piece piece in attackablePieces)
     {
         possible.AddRange<Move>(piece.LegalMoves);
     }
     return possible;
 }
开发者ID:Puddler,项目名称:Chess,代码行数:15,代码来源:Defense.cs

示例14: parseTermIntoKGrams

 public ObservableCollection<String> parseTermIntoKGrams(String term)
 {
     var kGrams = new ObservableCollection<String>();
     var kGram = "";
     kGrams.Add(" " + term[0]);
     for (int i = 0; i < term.Length - 1; i++)
     {
         kGram = term.Substring(i, 2);
         if (!kGrams.Contains(kGram))
         {
             kGrams.Add(kGram);
         }
     }
     return kGrams;
 }
开发者ID:Marbulinek,项目名称:NIS,代码行数:15,代码来源:KGramsManager.cs

示例15: DefaultTaskViewModel

        /// <summary>
        /// Constructor of the class
        /// </summary>
        /// <param name="taskModel"></param>
        /// <param name="targetList"></param>
        /// <param name="dataConnector"></param>
        /// <param name="mainPage"></param>
        /// <param name="state"></param>
        public DefaultTaskViewModel(ITaskModel taskModel, ObservableCollection<ITaskViewModel> targetList, IDataConnector dataConnector, MainPage mainPage, TaskState state)
        {
            TaskModel = taskModel;
            _targetList = targetList;
            _dataConnector = dataConnector;
            ItemVisualWidth = mainPage.ActualWidth;

            // Commands
            Break = new ViewModelCommand()
            {
                Command = new RelayCommand(r => BreakTask()),
                Text = "Break"
            };

            PunchOut = new ViewModelCommand
            {
                Command = new RelayCommand(r => FinishTask()),
                Text = "Finished",
                ImagePath = @"Images/finish.png"
            };

            DeleteFromList = new ViewModelCommand
            {
                Command = new RelayCommand(
                    r =>
                    {
                        if (targetList != null && targetList.Contains(this))
                        {
                            targetList.Remove(this);
                            _dataConnector.DeleteTask(taskModel.Id);
                        }
                    }),
                Text = "Delete",
                ImagePath = "Images/delete.png"
            };

            // Timer Init
            _timer = new DispatcherTimer();
            _timer.Tick += timer_Tick;
            _timer.Interval = TimeSpan.FromSeconds(1);
            _timer.Start();

            // Setstate
            State = state;
            _initLoad = false;
        }
开发者ID:nhammerl,项目名称:TaskTimeRecorder,代码行数:54,代码来源:DefaultTaskViewModel.cs


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