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


C# List.ForEach方法代码示例

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


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

示例1: GetDataGridElement

        public static XElementString GetDataGridElement(List<GridItem> items)
        {
            XElementString gridXCs = new XElementString("data:DataGrid.Columns");
           
            items.ForEach(item =>
            {
                XElementString gridXColumn = new XElementString("data:DataGridTextColumn",
                                     new XAttributeString("Header", item.PropertyDisplayName),
                                     new XAttributeString("Width", item.Width.ToString())
                                     );
                if (! string.IsNullOrEmpty(item.PropertyName))
                {
                   gridXColumn.Add( new XAttributeString("Binding", "{Binding Mode=TwoWay, Path=" + item.PropertyName + "}"));
                }

                //XElement gridXColumn = new XElement(data + "DataGridTextColumn", 
                //    new XAttribute("Header", item.PropertyDisplayName),
                //    new XAttribute("Width", item.Width.ToString()),
                //    new XAttribute("Binding", "{Binding Mode=TwoWay, Path=" + item.PropertyName +"}")
                //    );
                gridXCs.Add(gridXColumn);
            });
             //  
            XElementString gridX = new XElementString("data:DataGrid", new XAttributeString("AutoGenerateColumns", "false"));
            gridX.Add(gridXCs);

            return gridX;
        }
开发者ID:JuRogn,项目名称:OA,代码行数:28,代码来源:DataTempaleHelper.cs

示例2: InitToast

        private void InitToast()
        {
            var list = sp_toasts.Children.OfType<ToastItemControl>();
            ToastItems = list.ToList();

            ToastItems.ForEach(item => item.AnimationHideComplete += item_AnimationHideComplete);
        }
开发者ID:vista3344,项目名称:KcvPlugins,代码行数:7,代码来源:ToastWindow.xaml.cs

示例3: btnGetSongsYouTube_Click

 /// <summary>
 /// Handles the Click event of the btnGetSongsYouTube control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
 private void btnGetSongsYouTube_Click(object sender, RoutedEventArgs e)
 {
     this.HideDgSongs();
     this.YouTubeSongsImportViewModel.SongsCount = 0;
     this.YouTubeSongsImportViewModel.ObservableSongs.Clear();
     if (this.YouTubeSongsImportViewModel.SelectedPlaylist != null)
     {
         this.ShowProgressBar();
         List<YouTubeGroovesharkSong> youTubeGroovesharkSong = new List<YouTubeGroovesharkSong>();
         Task t = Task.Factory.StartNew(() =>
         {
             youTubeGroovesharkSong = this.YouTubeSongsImportViewModel.PopulateYouTubeSongs();
         });
         t.ContinueWith(antecedent =>
         {
             youTubeGroovesharkSong.ForEach(x => this.YouTubeSongsImportViewModel.ObservableSongs.Add(x));
             this.YouTubeSongsImportViewModel.SongsCount = this.YouTubeSongsImportViewModel.ObservableSongs.Count;
             this.HideProgressBar();
             this.ShowDgSongs();
             btnMap.IsEnabled = true;
         }, TaskScheduler.FromCurrentSynchronizationContext());   
     }
     else
     {
         ModernDialog.ShowMessage("Please Select an YouTube Playlist!", "Warning", MessageBoxButton.OK);
     }
 }
开发者ID:kennedykinyanjui,项目名称:Projects,代码行数:32,代码来源:YouTubeSongsImportView.xaml.cs

示例4: UpdateFunctionalChoices

        public void UpdateFunctionalChoices(String listguid, List<string> choices, Action<bool> reply)
        {
                //string listname = "{C6DE93CD-0076-4B62-B794-3729BADB7242}";

                String choicexml = "<CHOICES>";
                choices.ForEach(choice => { choicexml += "<CHOICE>" + choice.Replace("&","&amp;") + "</CHOICE>"; });
                choicexml += "</CHOICES>";

                string updatequery = "<Method ID='3'>" +
                                     "<Field Type='Choice' Name='Functional' DisplayName='Functional'>" +
                                     choicexml +
                                     "</Field>" +
                                     "</Method>";
                XElement xquery = XElement.Parse(updatequery);
                XElement updatefields = new XElement("Fields", xquery);
                proxy_update.UpdateListCompleted += (s, e) =>
                                                 {
                                                     if(e.Error == null)
                                                     {
                                                         reply(true);
                                                     }
                                                     else
                                                     {
                                                        reply(false);
                                                     }
                                                 };
                proxy_update.UpdateListAsync(listguid, null, null, updatefields, null, null);
            }
开发者ID:nilavghosh,项目名称:VChk,代码行数:28,代码来源:FucntionalChoicesServicesAgent.cs

示例5: ResourceHistoryView

        public ResourceHistoryView()
        {
            var listPages = new List<TabViewItem>() {
                new HistogramTabViewItem("油", new Func<IEnumerable<KeyValuePair<long,double>>>(() => BasicInfoLog?.Fuel.Select(x => new KeyValuePair<long, double>(x.Key, x.Value)))),
                new HistogramTabViewItem("弹", new Func<IEnumerable<KeyValuePair<long,double>>>(() => BasicInfoLog?.Ammo.Select(x => new KeyValuePair<long, double>(x.Key, x.Value)))),
                new HistogramTabViewItem("钢", new Func<IEnumerable<KeyValuePair<long,double>>>(() => BasicInfoLog?.Steel.Select(x => new KeyValuePair<long, double>(x.Key, x.Value)))),
                new HistogramTabViewItem("铝", new Func<IEnumerable<KeyValuePair<long,double>>>(() => BasicInfoLog?.Bauxite.Select(x => new KeyValuePair<long, double>(x.Key, x.Value)))),
                new HistogramTabViewItem("桶", new Func<IEnumerable<KeyValuePair<long,double>>>(() => BasicInfoLog?.HsRepair.Select(x => new KeyValuePair<long, double>(x.Key, x.Value)))),
                new HistogramTabViewItem("喷火器", new Func<IEnumerable<KeyValuePair<long,double>>>(() => BasicInfoLog?.HsBuild.Select(x => new KeyValuePair<long, double>(x.Key, x.Value)))),
                new HistogramTabViewItem("开发", new Func<IEnumerable<KeyValuePair<long,double>>>(() => BasicInfoLog?.DevMaterial.Select(x => new KeyValuePair<long, double>(x.Key, x.Value)))),
                new HistogramTabViewItem("改修", new Func<IEnumerable<KeyValuePair<long,double>>>(() => BasicInfoLog?.ModMaterial.Select(x => new KeyValuePair<long, double>(x.Key, x.Value)))),
            };
            listPages.ForEach(x => {
                x.IsSelected = false;
                x.PropertyChanged += (s, e) => {
                    if ((s as HistogramTabViewItem)?.IsSelected == true) {
                        _histogramFactory = (s as HistogramTabViewItem).Factory;
                    }
                };
            });
            Pages = listPages;
            SelectedPage = Pages.First();
            DataStore.Store.OnDataStoreCreate += ds => ds.OnBasicInfoChange += x => {
                RaisePropertyChanged();
            };

            InitializeComponent();
        }
开发者ID:c933103,项目名称:KanColleViewer,代码行数:28,代码来源:ResourceHistoryView.xaml.cs

示例6: RemoveAllEntitiesCommand_Executed

        private void RemoveAllEntitiesCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            EntityViewModel evm = GetCurrentEntity(e.Parameter);

             List<IEntity> entities = new List<IEntity>(evm.Entity.SubEntities);

             entities.ForEach((en) => evm.Entity.RemoveEntity(en));
        }
开发者ID:VivekRagunathan,项目名称:EI,代码行数:8,代码来源:CommandHandlers.cs

示例7: OnLoaded

 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     Ok.Focus();
     _links = this.FindDescendants<RichTextBox>().SelectMany(b => b.Document.GetElementsOfType<Hyperlink>()).ToList();
     _links.ForEach(l =>
     {
         l.RequestNavigate += OnHyperlinkRequestNavigate;
     });
 }
开发者ID:mousetwentytwo,项目名称:test,代码行数:9,代码来源:AboutDialog.xaml.cs

示例8: ResultWindow

        //private double moveX, moveY;
        public ResultWindow(List<Result> ResultData)
        {
            InitializeComponent();
            dataGrid.ItemsSource = ResultData;

            minX = 0; maxX = 0; minY = 0; maxY = 0; minZ = 0; maxZ = 0;
            XYcanvas.Children.Clear();
            YZcanvas.Children.Clear();
            ResultData.ForEach(x => SetMinMax(x));

            //Get smallest dimension of canvas
            var cMin = Math.Min(this.Width, this.Height);
            //get largest dimension of model bounds
            var modelXYMax = Math.Max(maxX,maxY)-Math.Min(minX, minY);
            var modelYZMax = Math.Max(maxZ, maxY) - Math.Min(minZ, minY);
            var scaleXY = cMin / modelXYMax;
            var scaleYZ = cMin / modelYZMax;
            //scale *= 0.9; //reduce to 90% to fit in some margins

            //draw the rectangles
            ResultData.ForEach(x => DrawItem(x, scaleXY, scaleYZ));
        }
开发者ID:LloydPickering,项目名称:FederationCoordChecker,代码行数:23,代码来源:Resultwindow.xaml.cs

示例9: BranchEntry

 public BranchEntry()
 {
     List<int> managerIds = new List<int>();
     DataTable dt = DatabaseService.GetDataTable("GetManagerIds");
     foreach (DataRow row in dt.Rows)
     {
         managerIds.Add(int.Parse(row["managerId"].ToString()));
     }
     InitializeComponent();
     if (managerIds.Count > 0)
     {
         managerIds.ForEach(x => cbManagerIds.Items.Add(x));
     }
 }
开发者ID:RupertTheSlim,项目名称:Programming,代码行数:14,代码来源:BranchEntry.xaml.cs

示例10: SetNonOverflowButton

 public void SetNonOverflowButton(ToolboxButton button)
 {
     ToolboxButton currentNonOverflowButton = this.Children.OfType<ToolboxButton>().First();
     if (currentNonOverflowButton != button)
     {
         List<ToolboxButton> allButtons = new List<ToolboxButton>();
         allButtons.Add(currentNonOverflowButton);
         foreach (ToolboxButton item in Overflow.Items)
             allButtons.Add(item);
         allButtons.Remove(button);
         allButtons.Sort(delegate(ToolboxButton one, ToolboxButton two) { return one.DisplayIndex.CompareTo(two.DisplayIndex); });
         Overflow.Items.Clear();
         allButtons.ForEach(delegate(ToolboxButton item) { Overflow.Items.Add(item); });
     }
 }
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:15,代码来源:ToolboxItemContainer.xaml.cs

示例11: CommentAPI_LoadCommentDataComplated

 void CommentAPI_LoadCommentDataComplated(List<CommentInfo> commentList, Exception se)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         if (commentList != null && se == null)
         {
             if (commentList.Count > 0)
             {
                 this.commentInfoCol.Clear();
                 commentList.ForEach(x => { this.commentInfoCol.Add(x); }); //看不懂
             }
         }
         else
             MessageBox.Show(se.Message, "Exception MEssage", MessageBoxButton.OK);
     });
 }
开发者ID:joooohnli,项目名称:workspace_vs,代码行数:16,代码来源:MainPage_ViewModel.cs

示例12: LoadFromDatabase

        public void LoadFromDatabase(List<string> kanjiList)
        {
            kanjiDictionary = new Dictionary<string, Kanji>();

            using (KanjiDataContext context = new KanjiDataContext(connectionString)) {

                var data = from k in context.Kanji where kanjiList.Contains(k.Literal) select k;

                kanjiList.ForEach(k => kanjiDictionary.Add(k, data.First(d => d.Literal == k)));

                if (App.AppSettings.IsRandomReviewList)
                    GenerateRandomSequence();
                else
                    GenerateSequence();
            }
          
        }
开发者ID:stejin,项目名称:Kanji-Flashcards-for-Windows-Phone,代码行数:17,代码来源:KanjiDictionary.cs

示例13: btnDraw_Click

        private void btnDraw_Click(object sender, RoutedEventArgs e)
        {
            int drawNum = 0;
            List<int> lottoRivi = new List<int>();

            if (Int32.TryParse(txtDrawNum.Text, out drawNum))
            {
                for (int i = 0; i < drawNum; i++)
                {
                    lottoRivi = lottoKone.ArvoRivi(cmbType.Text);
                    lottoRivi.Sort();
                    lottoRivi.ForEach(Tulosta);
                    lottoRivi.Clear();
                    txtResult.Text += Environment.NewLine;
                }
            }
        }
开发者ID:mikkoleppanen,项目名称:IIO13200_NET_15S,代码行数:17,代码来源:MainWindow.xaml.cs

示例14: SynchronizeLists

        private void SynchronizeLists()
        {
            if (_adMessage == null || _paperMessage == null)
                return;
            var paperList = _paperMessage.NewspaperList.ToList();
            var adList = _adMessage.AdvertisementList.ToList();

            foreach (var paper in paperList)
            {
                var tempAdList = new List<AdvertisementItemViewModel> ();

                foreach (var adModel in paper.Model.Advertisements)
                {
                    try
                    {
                        if (!paper.Advertisements.Any(a => a.UKey == adModel.UKey))
                            tempAdList.Add(adList.First(a=>a.UKey == adModel.UKey));
                    }
                    catch (Exception e)
                    {
                        string msg = e.Message;
                    }
                }

                tempAdList.ForEach(paper.Advertisements.Add);
            }

            foreach (var ad in adList)
            {
                var tempPaperList = new List<NewspaperItemViewModel>();
                foreach(var paperModel in ad.Model.Newspapers)
                {
                    try
                    {
                        if (!ad.Newspapers.Any(n => n.UKey == paperModel.UKey))
                            tempPaperList.Add(paperList.First(p => p.UKey == paperModel.UKey));
                    }
                    catch (Exception e)
                    {
                        string msg = e.Message;
                    }
                }
                tempPaperList.ForEach(ad.Newspapers.Add);
            }
        }
开发者ID:jgartee,项目名称:PillarKata,代码行数:45,代码来源:NewspaperAndAdvertisementListSynchronizer.cs

示例15: Init

		public void Init(Model model) {
			inputsList = new List<InputReceiverPair>();

			OnCompleted += () => {
				disposables.Dispose();
			};
			this.model = model;

			InitializeComponent();

			int count = 0;
			if (model.inputs != null)
				count = model.inputs.Count();

			for (int i = 0; i < count; i++) {
				Receiver rec = null;
				AnalyticsEngineInput inp = null;

				if (model.receivers != null && model.receivers.Count() > i)
					rec = model.receivers[i];

				if (model.inputs != null && model.inputs.Count() > i)
					inp = model.inputs[i];

				inputsList.Add(new InputReceiverPair(rec, inp));
			}

			inputsList.ForEach(inp => {
				CreateInputUI(inp);
			});

			FinishCommand = new DelegateCommand(
				() => Success(new Result.Finish(model)),
				() => true
			);
			btnFinish.Command = FinishCommand;

			AbortCommand = new DelegateCommand(
				() => Success(new Result.Abort()),
				() => true
			);
			btnAbort.Command = AbortCommand;
			
			Localization();
		}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:45,代码来源:EngineControlsInputsCreationView.xaml.cs


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