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


C# ObservableCollection.Union方法代码示例

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


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

示例1: MainWindowModel

        public MainWindowModel()
        {
            Todos = new ObservableCollection<TodoViewModel>(Laden());

            Neu = new Command(() =>
            {
                Ausgewählt = new TodoViewModel()
                {
                    Name = "Neue Aufgabe"
                };
                Todos.Add(Ausgewählt);
            });

            Speichern = new Command(async () =>
            {
                var todosService = new TodoService.TodoServiceClient();
                try
                {
                    await todosService.SpeichernAsync(Todos.Union(new[] { Ausgewählt })
                                .Where(t => t != null && t.Dirty)
                                .Select(t => t.AsDto())
                                .ToArray());

                    Todos = new ObservableCollection<TodoViewModel>(Laden());
                }
                catch (Exception)
                {
                    var fe = FehlerEvent;
                    if (fe != null) fe();
                }
            });
        }
开发者ID:halllo,项目名称:StpNtp,代码行数:32,代码来源:MainWindowModel.cs

示例2: CheckAvailability

        private void CheckAvailability()
        {
            // Execute only if all required fields have been filled and are validated
            if (!IsValid)
            {
                return;
            }
            var booking = new Booking()
            {
                ID = Booking.ID,
                StartDate = StartDateTime,
                EndDate = EndDateTime,
                RoomID = Room.ID,
                AssetBookings = (from asset in AssetList
                                select new AssetBooking() { AssetID = asset.Asset.ID }).ToList()
            };
            

            List<Booking> roomResults = null;
            List<Booking> assetResults = null;

            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += (object sender, DoWorkEventArgs e) =>
            {
                roomResults = new List<Booking>(_bookingService.CheckRoomAvailability(booking));
                assetResults = new List<Booking>(_bookingService.CheckAssetAvailability(booking));
            };
            worker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) =>
            {
                bool hasRoomConflicts = false;
                bool hasAssetConflicts = false;
                
                // Handle room conflicts
                BookingConflicts = new ObservableCollection<Booking>(roomResults);
                if (roomResults.Count > 0)
                {
                    hasRoomConflicts = true;
                }

                // Handle asset conflicts
                // Remove all existing conflics from every asset
                foreach (var asset in AssetList)
                {
                    asset.Conflicts.Clear();
                }
                if (assetResults.Count > 0)
                {
                    if (BookingConflicts.Count > 0)
                    {
                        BookingConflicts.Union(new ObservableCollection<Booking>(assetResults));
                    }
                    else
                    {
                        BookingConflicts = new ObservableCollection<Booking>(assetResults);
                    }

                    foreach (Booking result in assetResults)
                    {
                        foreach (var item in result.AssetBookings)
                        {
                            var assetQuery = from assetListItem in AssetList
                                             where assetListItem.Asset.ID == item.AssetID
                                             select assetListItem;
                            var asset = assetQuery.FirstOrDefault();
                            if (asset != null)
                            {
                                asset.Conflicts.Add(item);
                                if (asset.IsSelected)
                                {
                                    hasAssetConflicts = true;
                                }
                            }
                        }
                    }
                }
                IsConflicting = hasRoomConflicts || hasAssetConflicts;

                RaisePropertyChanged("BookingConflicts");
                RaisePropertyChanged("IsConflicting");
            };
            worker.RunWorkerAsync();
        }
开发者ID:BrettLeeARV,项目名称:Arvato.TestProject.UserManagement,代码行数:82,代码来源:BookingsFormViewModel.cs

示例3: Start

        public static BackgroundWorker Start(string fileName, long currentOperatorId, IEnumerable<SheetRulePair> ruleToSheets)
        {
            BackgroundWorker result = new BackgroundWorker();
            result.DoWork += (s, e) =>
                {
                    StringBuilder errors = new StringBuilder();

                    bool showLogAnytime = false;

                    BackgroundWorker current = s as BackgroundWorker;
                    PercentageProgress fullProgress = new PercentageProgress();

                    var readRulesProgress = fullProgress.GetChild();
                    var getLinksProgress = fullProgress.GetChild();
                    var writeExcelFileProgress = fullProgress.GetChild();

                    fullProgress.Change += (s2, args) => { current.ReportProgress((int)args.Value); };

                    ObservableCollection<OutputRow> rowsToExport = new ObservableCollection<OutputRow>();

                    bool wasException = false;
                    var logSession = Helpers.Old.Log.SessionStart("ReExport.ReExport()", true);
                    try
                    {
                        #region Read Rules

                        Helpers.Old.Log.Add(logSession, string.Format("total sheets count: '{0}'", ruleToSheets.Count()));
                        int rulesToSheets = ruleToSheets.Count();

                        int ind = 0;
                        foreach (var item in ruleToSheets)
                        {
                            var mappingRule = item.Rule;
                            var ds = item.Sheet;
                            if (mappingRule != null && ds != null)
                            {
                                if (ds.MainHeader == null)
                                {
                                    Helpers.Old.Log.Add(logSession, string.Format("should update main header row..."));

                                    ds.UpdateMainHeaderRow(mappingRule.MainHeaderSearchTags
                                        .Select(h => h.Tag)
                                        .Union(SettingsProvider.CurrentSettings.HeaderSearchTags.Split(new char[] { ',' }))
                                        .Select(i => i.Trim())
                                        .Where(i => !string.IsNullOrEmpty(i))
                                        .Distinct()
                                        .ToArray());

                                    ds.UpdateHeaders(mappingRule.SheetHeadersSearchTags
                                        .Select(h => h.Tag.Trim())
                                        .Where(i => !string.IsNullOrEmpty(i))
                                        .Distinct()
                                        .ToArray());
                                }

                                var oc = new ObservableCollection<OutputRow>(mappingRule.Convert(ds, new string[] { "Code" }));
                                Helpers.Old.Log.Add(logSession, string.Format("row count on sheet '{0}' : '{1}'", ds.Name, oc.Count));
                                rowsToExport = new ObservableCollection<OutputRow>(rowsToExport.Union(oc));
                                Helpers.Old.Log.Add(logSession, string.Format("subtotal row count on sheets: '{0}'", rowsToExport.Count));
                            }

                            ind++;
                            readRulesProgress.Value = ((decimal)ind / (decimal)rulesToSheets) * 100m;
                        }
                        Helpers.Old.Log.Add(logSession, string.Format("total row count to export: '{0}'", rowsToExport.Count));

                        #endregion
                        #region Get Links
                        Helpers.Old.Log.Add(logSession, string.Format("Try to get links..."));

                        var idsToGet =
                            rowsToExport
                            .Select(i => new ReExportData(i.Code.Trim(), i.OriginalIndex, i.OriginalSheet))
                            .Cast<ReExportData>()
                            .ToList();

                        string outerMap;
                        string outerPdf;

                        try
                        {
                            HttpDataClient.Default.GetResourcesList(currentOperatorId, idsToGet, out outerMap, out outerPdf);
                        }
                        catch(Exception ex)
                        {
                            throw new Exception(string.Format("Ошибка при получении ссылок для кодов (кол-во: {0})", idsToGet.Count), ex);
                        }
                        //Log.Add(logSession, string.Format("Get CODES from server..."));
                        //foreach (var i in idsToGet)
                        //    Log.Add(logSession, string.Format("[Code:'{0}',Location:'{1}',Map:'{2}',Photo:'{3}']", i.Code, i.LinkLocation, i.LinkMap, i.LinkPhoto));
                        //Log.Add(logSession, string.Format("Get CODES done"));

                        //HttpDataAccess.GetResourcesList(currentOperatorId, idsToGet, out outerMap, out outerPdf);
                        Helpers.Old.Log.Add(logSession, string.Format("Links getted"));
                        getLinksProgress.Value = 100;
                        #endregion
                        #region Write Excel File

                        Workbook wb = new Workbook(fileName);
                        foreach (var r in ruleToSheets.Where(r => r.Sheet != null))
//.........这里部分代码省略.........
开发者ID:kblc,项目名称:ExcelConverter,代码行数:101,代码来源:ReExport.cs

示例4: UpdateMessageTileAsync

        /// <summary>
        /// Get all message from Repository to display in first Live Tile.
        /// </summary>
        private async void UpdateMessageTileAsync(object messages)
        {
            ClearTileAndBadge();
            _dictionary.Clear();
            IEnumerable<TaskModel> tasks = new ObservableCollection<TaskModel>(await TaskRepository.Instance.GetTaskListFor(DateTime.Now));

            tasks = tasks.Any() ? tasks.Union(await TaskRepository.Instance.GetTaskListFor(DateTime.Now.AddDays(1))) : new ObservableCollection<TaskModel>(await TaskRepository.Instance.GetTaskListFor(DateTime.Now.AddDays(1)));

            tasks = tasks.Any() ? tasks.Union(await TaskRepository.Instance.GetTaskListFor(DateTime.Now.AddDays(2))) : new ObservableCollection<TaskModel>(await TaskRepository.Instance.GetTaskListFor(DateTime.Now.AddDays(2)));
            _wideImagePath = WIDE_NORMAL_IMAGE;
            _squareImagePath = SQUARE_NORMAL_IMAGE;


            if (tasks != null)
            {
                _numberOfNew = tasks.Count();
                foreach (var item in tasks)
                {
                    if (_dictionary.Count < MAX_MESSAGE)
                    {
                        var fullDate =
                            Convert.ToDateTime(item.StartDate).ToString(
                                CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern);

                        fullDate = fullDate.Substring(0, fullDate.Length - 5);
                        var key = intToTimeConverter.Convert(item.StartTime, null, null, null) + " " + fullDate
                                  ;
                        if (!_dictionary.ContainsKey(key))
                        {
                            _dictionary.Add(key, item.Name + "\r\n" + item.Description
                                                            );
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                //if (_dictionary.Count > 0)
                //{
                //    _dictionary.Reverse();
                try
                {
                    CreateTileQueue(_dictionary);
                }
                catch (Exception)
                {
                    
                }
               
                //}

                //DisplayFirstTile(taskCount, _wideImagePath, _squareImagePath);
            }
        }
开发者ID:nghia2080,项目名称:CProject,代码行数:59,代码来源:LiveTileManager.cs

示例5: SelectCollectProducts

 /// <summary>
 /// 获取收藏产品
 /// </summary>
 /// <param name="count"></param>
 /// <returns></returns>
 public ObservableCollection<Product> SelectCollectProducts(int count)
 {
     ObservableCollection<Product> ObservableCollection = new ObservableCollection<Product>();
     var temp = (from Product product in b_data.T_Product
                 where product.Collect == true
                 select product).Take(count);
     ObservableCollection.Union(new ObservableCollection<Product>(temp));
     return ObservableCollection;
 }
开发者ID:Letractively,项目名称:newspublish-web,代码行数:14,代码来源:BllFun.cs

示例6: SelectProducts

 /// <summary>
 /// 获取所有产品
 /// </summary>
 /// <returns></returns>
 //public ObservableCollection<Product> SelectProducts()
 //{
 //    var productObservableCollection = from Product product in b_data.T_Product
 //                      select product;
 //    return new ObservableCollection<Product>(productObservableCollection);
 //}
 /// <summary>
 /// 获取最新的产品
 /// </summary>
 /// <param name="count">条数</param>
 /// <returns></returns>
 //public ObservableCollection<Product> SelectProducts(int count)
 //{
 //    var productObservableCollection = (from Product product in b_data.T_Product
 //                       orderby product.Time
 //                       select product).Take(count);
 //    return new ObservableCollection<Product>(productObservableCollection);
 //}
 /// <summary>
 /// 获取某一个产品
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 //public Product SelectProduct(string id)
 //{ 
 //    int productId=int.Parse(id);
 //    var productTemp = from Product product in b_data.T_Product
 //                  where product.Id == productId
 //                  select product;
 //    ObservableCollection<Product> ObservableCollection = new ObservableCollection<Product>(productTemp);
 //    return ObservableCollection.Count>0?ObservableCollection[0]:null;
 //}
 /// <summary>
 /// 获取某一大类的某一个小类产品
 /// </summary>
 /// <param name="type">category、city、site</param>
 /// <param name="typeid">小类</param>
 /// <param name="count">数量</param>
 /// <returns></returns>
 public ObservableCollection<Product> SelectProducts(bool isCity, int cityId, bool isSite, int siteId, int categoryId, int count)
 {
     ObservableCollection<Product> ObservableCollection = new ObservableCollection<Product>();
     if (isCity && !isSite)
     {
         var temp = (from Product product in b_data.T_Product
                     where product._cityId == cityId && product._categoryId == categoryId
                     orderby product.Time descending
                     select product).Take(count);
         ObservableCollection.Union(new ObservableCollection<Product>(temp));
     }
     else if (!isCity && isSite)
     {
         var temp = (from Product product in b_data.T_Product
                     where product._webSiteId == siteId && product._categoryId == categoryId
                     orderby product.Time descending
                     select product).Take(count);
         ObservableCollection.Union(new ObservableCollection<Product>(temp));
     }
     else if (isCity && isSite)
     {
         var temp = (from Product product in b_data.T_Product
                     where product._webSiteId == siteId && product._cityId == cityId && product._categoryId == categoryId
                     orderby product.Time descending
                     select product).Take(count);
         ObservableCollection.Union(new ObservableCollection<Product>(temp));
     }
     else
     {
         var temp = (from Product product in b_data.T_Product
                     where product._categoryId == categoryId
                     orderby product.Time descending
                     select product).Take(count);
         ObservableCollection.Union(new ObservableCollection<Product>(temp));
     }
     return ObservableCollection;
 }
开发者ID:Letractively,项目名称:newspublish-web,代码行数:80,代码来源:BllFun.cs

示例7: Initialize

        public void Initialize()
        {
            InitializeError = string.Empty;
            if (Export2CsvCommand == null)
                Export2CsvCommand = new RelayCommand(() => Export2Csv());
            if (Export2DbCommand == null)
                Export2DbCommand = new RelayCommand(Export2Db);
            if (UpdateErrorsCommand == null)
                UpdateErrorsCommand = new RelayCommand(UpdateErrors);
            if (UpdateSelectedErrorCommand == null)
                UpdateSelectedErrorCommand = new RelayCommand(UpdateSelectedError);
            if (UpdateSelectedWarningCommand == null)
                UpdateSelectedWarningCommand = new RelayCommand(UpdateSelectedWarning);

            loadWorker = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true };
            loadWorker.DoWork += (s, prm) =>
            {
                var Disp = prm.Argument as System.Windows.Threading.Dispatcher;

                ObservableCollection<OutputRow> rowsToExport = new ObservableCollection<OutputRow>();
                Guid logSession = Helpers.Old.Log.SessionStart("ExportViewModel.Initialize()");
                try
                {
                    Log.Add(string.Format("total sheets count: '{0}'", App.Locator.Import.Document.DocumentSheets.Count));
                    var addErr = new List<Error>();
                    var addGErr = new List<GlobalError>();

                    var progress = new PercentageProgress();

                    foreach (var item in App.Locator.Import
                        .ExportRules
                        .Where(r => r.Rule != App.Locator.Import.NullRule)
                        .Select(r => new { Rule = r, Progress = progress.GetChild() })
                        .ToArray()
                        )
                    {
                        if (((BackgroundWorker)s).CancellationPending || s != loadWorker)
                            break;

                        var mappingRule = item.Rule.Rule;
                        var ds = item.Rule.Sheet;

                        if (mappingRule == null || ds == null)
                        {
                            if (!string.IsNullOrWhiteSpace(item.Rule.Status))
                                addGErr.Add(new GlobalError() { Description = item.Rule.Status });
                            item.Progress.Value = 100;
                            continue;
                        }
                        else
                        {
                            if (ds.MainHeader == null)
                            {
                                Log.Add(string.Format("should update main header row..."));

                                ds.UpdateMainHeaderRow(mappingRule.MainHeaderSearchTags
                                        .Select(h => h.Tag)
                                        .Union(SettingsProvider.CurrentSettings.HeaderSearchTags.Split(new char[] { ',' }))
                                        .Select(i => i.Trim())
                                        .Where(i => !string.IsNullOrEmpty(i))
                                        .Distinct()
                                        .ToArray());

                                ds.UpdateHeaders(mappingRule.SheetHeadersSearchTags
                                        .Select(h => h.Tag.Trim())
                                        .Where(i => !string.IsNullOrEmpty(i))
                                        .Distinct()
                                        .ToArray());
                            }

                            var oc = new ObservableCollection<OutputRow>(mappingRule.Convert(ds,
                                progressAction: (i) =>
                                {
                                    item.Progress.Value = i;
                                    ((BackgroundWorker)s).ReportProgress((int)progress.Value);
                                },
                                isCanceled: () => { return ((BackgroundWorker)s).CancellationPending; },
                                additionalErrorAction: (e, r) =>
                                {
                                    addErr.Add(new Error() { Description = e.GetExceptionText(includeStackTrace: false, clearText: true).Trim(), RowNumber = r });
                                }));
                            Log.Add(string.Format("row count on sheet '{0}' : '{1}'", ds.Name, oc.Count));
                            rowsToExport = new ObservableCollection<OutputRow>(rowsToExport.Union(oc));
                            Log.Add(string.Format("subtotal row count on sheets: '{0}'", rowsToExport.Count));
                        }
                    }

                    ExelConvertionRule.RemoveRepeatingId(rowsToExport.ToList());

                    var UrlsPhoto = new UrlCollection();
                    var UrlsSchema = new UrlCollection();
                    var UrlsAll = new UrlCollection();

                    var photos = rowsToExport.Select(r => r.Photo_img).Where(r => Helper.IsWellFormedUriString(r, UriKind.Absolute)).Distinct();
                    var schemas = rowsToExport.Select(r => r.Location_img).Where(r => Helper.IsWellFormedUriString(r, UriKind.Absolute)).Distinct();
                    var all = photos.Union(schemas).Distinct();

                    foreach (var p in photos)
                        UrlsPhoto.Add(new StringUrlWithResultWrapper(p));
                    foreach (var p in schemas)
//.........这里部分代码省略.........
开发者ID:kblc,项目名称:ExcelConverter,代码行数:101,代码来源:ExportViewModel.cs


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