本文整理汇总了C#中System.Windows.Documents.List.ConvertAll方法的典型用法代码示例。如果您正苦于以下问题:C# List.ConvertAll方法的具体用法?C# List.ConvertAll怎么用?C# List.ConvertAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.ConvertAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SiteCompare
public SiteCompare(Window owner, User user, SiteExplorerNodeViewModel dest, List<SiteExplorerNodeViewModel> otherSites)
{
this.Owner = owner;
this.User = user;
InitializeComponent();
Destination = dest;
_compareModel = new ObservableCollection<SiteExplorerNodeViewModel>(otherSites.ConvertAll((vm) => {
vm.IsSelected = true;
return vm;
}));
txtMergeInto.Text = dest.Name;
lstRemove.ItemsSource = _compareModel;
grpDiff.DataContextChanged += new DependencyPropertyChangedEventHandler(grpDiff_DataContextChanged);
if (_compareModel.Count > 0) {
lstRemove.SelectedItem = _compareModel[0];
}
}
示例2: LoadCitiesBase
void LoadCitiesBase() {
var path = AppDomain.CurrentDomain.BaseDirectory;
var root = Path.GetPathRoot(path);
bool fileExists = false;
if (File.Exists(Path.Combine(path, JsonFileName))) {
fileExists = true;
}
else {
while (path != "" && path != root) {
path = Directory.GetParent(path).ToString();
if (File.Exists(Path.Combine(path, JsonFileName))) {
fileExists = true;
break;
}
}
}
if (fileExists) {
var resultList = new List<string>();
using (var reader = new StreamReader(Path.Combine(path, JsonFileName))) {
string line = "";
JavaScriptSerializer js = new JavaScriptSerializer();
while (( line = reader.ReadLine() ) != null) {
var dict = js.Deserialize<Dictionary<string, string>>(line);
if (dict.ContainsKey("city")) {
resultList.Add(dict["city"]);
}
}
}
resultList = resultList.ConvertAll(x => x.ToLower());
_locations = resultList.OrderBy(x => x).ToArray();
}
else {
MessageBox.Show(JsonFileName + " not found");
}
}
示例3: DisplaySearchResultItems
private void DisplaySearchResultItems(string title, List<SearchResultItem> result)
{
if (result != null && result.Count > 0)
{
if (result[0] is VideoInfo)
{
SelectedCategory = new Category() { Name = title };
List<VideoInfo> videoList = result.ConvertAll(i => i as VideoInfo);
listViewMain.ItemsSource = ViewModels.VideoList.GetVideosView(this, videoList, SelectedSite.HasNextPage);
SelectAndFocusItem();
ImageDownloader.GetImages<VideoInfo>(videoList);
}
else
{
SelectedCategory = new Category()
{
Name = title,
HasSubCategories = true,
SubCategoriesDiscovered = true,
};
SelectedCategory.SubCategories = result.ConvertAll(i => { (i as Category).ParentCategory = SelectedCategory; return i as Category; });
listViewMain.ItemsSource = ViewModels.CategoryList.GetCategoriesView(this, SelectedCategory.SubCategories);
SelectAndFocusItem();
ImageDownloader.GetImages<Category>(SelectedCategory.SubCategories);
}
}
}
示例4: SiteDetails
public SiteDetails(User user, int siteID, bool readOnly)
: base(user, "Site:" + siteID)
{
InitializeComponent();
this.SiteID = siteID;
this.IsReadOnly = readOnly;
var list = new List<Ellipsoid>(GeoUtils.ELLIPSOIDS);
cmbDatum.ItemsSource = new ObservableCollection<string>(list.ConvertAll((ellipsoid) => { return ellipsoid.Name; }));
if (GoogleEarth.IsInstalled()) {
coordGrid.ColumnDefinitions[7].Width = new GridLength(23);
} else {
coordGrid.ColumnDefinitions[7].Width = new GridLength(0);
}
// Radio button checked event handlers
optNearestPlace.Checked += new RoutedEventHandler((s, e) => {
txtLocality.IsEnabled = false;
txtDirectionFrom.IsEnabled = true;
txtDistanceFrom.IsEnabled = true;
txtFrom.IsEnabled = true;
});
optLocality.Checked += new RoutedEventHandler((s, e) => {
txtLocality.IsEnabled = true;
txtDirectionFrom.IsEnabled = false;
txtDistanceFrom.IsEnabled = false;
txtFrom.IsEnabled = false;
});
var service = new MaterialService(User);
var model = service.GetSite(SiteID);
_viewModel = new SiteViewModel(model);
this.DataContext = _viewModel;
tabSite.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Site, _viewModel) { IsReadOnly = readOnly });
tabSite.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Site, _viewModel) { IsReadOnly = readOnly });
tabSite.AddTabItem("Multimedia", new MultimediaControl(User, TraitCategoryType.Site, _viewModel) { IsReadOnly = readOnly });
tabSite.AddTabItem("Ownership", new OwnershipDetails(_viewModel.Model));
txtPosSource.BindUser(User, PickListType.Phrase, "Source", TraitCategoryType.Site);
txtPosWho.BindUser(User, "tblSite", "vchrPosWho");
txtPosOriginal.BindUser(User, PickListType.Phrase, "OriginalDetermination", TraitCategoryType.Site);
txtElevUnits.BindUser(User, PickListType.Phrase, "Units", TraitCategoryType.Site);
txtElevSource.BindUser(User, PickListType.Phrase, "Source", TraitCategoryType.Site);
txtGeoEra.BindUser(User, PickListType.Phrase, "Geological Era", TraitCategoryType.Site);
txtGeoPlate.BindUser(User, PickListType.Phrase, "Geological Plate", TraitCategoryType.Site);
txtGeoStage.BindUser(User, PickListType.Phrase, "Geological State", TraitCategoryType.Site);
txtGeoFormation.BindUser(User, PickListType.Phrase, "Geological Formation", TraitCategoryType.Site);
txtGeoMember.BindUser(User, PickListType.Phrase, "Geological Member", TraitCategoryType.Site);
txtGeoBed.BindUser(User, PickListType.Phrase, "Geological Bed", TraitCategoryType.Site);
this.ctlX1.CoordinateValueChanged += new CoordinateValueChangedHandler((s, v) => { UpdateMiniMap(ctlY1.Value, ctlX1.Value); });
this.ctlY1.CoordinateValueChanged += new CoordinateValueChangedHandler((s, v) => { UpdateMiniMap(ctlY1.Value, ctlX1.Value); });
this.ctlX2.Visibility = System.Windows.Visibility.Hidden;
this.ctlY2.Visibility = System.Windows.Visibility.Hidden;
txtPoliticalRegion.BindUser(User, LookupType.Region);
string llmode = Config.GetUser(User, "SiteDetails.LatLongFormat", LatLongMode.DegreesMinutesSeconds.ToString());
if (!String.IsNullOrEmpty(llmode)) {
LatLongMode mode = (LatLongMode)Enum.Parse(typeof(LatLongMode), llmode);
SwitchLatLongFormat(mode);
}
optPoint.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
optLine.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
optBoundingBox.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
optCoordsNotSpecified.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
optEastingsNorthings.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
optLatLong.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); });
optElevDepth.Checked += new RoutedEventHandler(UpdateElevation);
optElevElevation.Checked += new RoutedEventHandler(UpdateElevation);
optElevNotSpecified.Checked += new RoutedEventHandler(UpdateElevation);
if (model.PosY1.HasValue && model.PosX1.HasValue) {
UpdateMiniMap(model.PosY1.Value, model.PosX1.Value);
}
this.PreviewDragOver += new DragEventHandler(site_PreviewDragEnter);
this.PreviewDragEnter += new DragEventHandler(site_PreviewDragEnter);
//this.Drop += new DragEventHandler(site_Drop);
HookLatLongControl(ctlX1);
HookLatLongControl(ctlY1);
HookLatLongControl(ctlX2);
HookLatLongControl(ctlY2);
this.Loaded += new RoutedEventHandler(SiteDetails_Loaded);
}
示例5: ReloadMultimediaPanel
private void ReloadMultimediaPanel(List<MultimediaLink> data)
{
JobExecutor.QueueJob(() => {
_model = new ObservableCollection<MultimediaLinkViewModel>(data.ConvertAll((item) => {
MultimediaLinkViewModel viewmodel = null;
this.InvokeIfRequired(() => {
viewmodel = new MultimediaLinkViewModel(item);
viewmodel.DataChanged += new DataChangedHandler((m) => {
RegisterUniquePendingChange(new UpdateMultimediaLinkCommand(viewmodel.Model, CategoryType));
});
});
return viewmodel;
}));
this.InvokeIfRequired(() => {
this.thumbList.ItemsSource = _model;
});
foreach (MultimediaLinkViewModel item in _model) {
this.BackgroundInvoke(() => {
GenerateThumbnail(item, THUMB_SIZE);
});
}
});
}
示例6: BuildExplorerModel
private ObservableCollection<HierarchicalViewModelBase> BuildExplorerModel(List<SiteExplorerNode> list, bool isFindModel)
{
list.Sort((item1, item2) => {
int compare = item1.ElemType.CompareTo(item2.ElemType);
if (compare == 0) {
return item1.Name.CompareTo(item2.Name);
}
return compare;
});
var regionsModel = new ObservableCollection<HierarchicalViewModelBase>(list.ConvertAll((model) => {
var viewModel = new SiteExplorerNodeViewModel(model, isFindModel);
if (model.NumChildren > 0) {
viewModel.Children.Add(new ViewModelPlaceholder("Loading..."));
viewModel.LazyLoadChildren += new HierarchicalViewModelAction(viewModel_LazyLoadChildren);
}
return viewModel;
}));
return regionsModel;
}
示例7: ChooseTemplate
public int? ChooseTemplate(SiteExplorerNodeType templateType)
{
var picklist = new PickListWindow(User, "Select Template", () => {
var service = new MaterialService(User);
List<SiteExplorerNode> list = new List<SiteExplorerNode>();
switch (templateType) {
case SiteExplorerNodeType.Site:
list.AddRange(service.GetSiteTemplates());
break;
case SiteExplorerNodeType.SiteVisit:
list.AddRange(service.GetSiteVisitTemplates());
break;
case SiteExplorerNodeType.Material:
list.AddRange(service.GetMaterialTemplates());
break;
}
return list.ConvertAll((node) => {
return new SiteExplorerNodeViewModel(node);
});
}, null);
if (picklist.ShowDialog().GetValueOrDefault(false)) {
var selected = picklist.SelectedValue as SiteExplorerNodeViewModel;
if (selected != null) {
return selected.ElemID;
}
}
return null;
}
示例8: bDistribute_Click
private void bDistribute_Click(object sender, RoutedEventArgs e)
{
Decimal sumForDistribution = Convert.ToDecimal(tbsum.Text);
String stringOfsum = tbSumForDistribution.Text;
List<String> ListOfSumStr = new List<String>(Regex.Split(stringOfsum, @";"));
List<Decimal> ListOfSumDec = ListOfSumStr.ConvertAll(new Converter<String, Decimal>(ConvertToDecimal));
tbkRezult.Text = operations[cbTypeOfDistribution.Text](ListOfSumDec, sumForDistribution);
}
示例9: RenderAbilities
/// <summary>
/// Render the <paramref name="GammaWorldCharacter"/>'s name, class, level and so on.
/// </summary>
/// <param name="GammaWorldCharacter">
/// The <see cref="Character"/> to render. This cannot be null.
/// </param>
/// <param name="resourceDictionary">
/// A <see cref="ResourceDictionary"/> containing styles. This cannot be null.
/// </param>
/// <exception cref="ArgumentNullException">
/// No arguments can be null.
/// </exception>
private Block RenderAbilities(Character GammaWorldCharacter, ResourceDictionary resourceDictionary)
{
if (GammaWorldCharacter == null)
{
throw new ArgumentNullException("GammaWorldCharacter");
}
if (resourceDictionary == null)
{
throw new ArgumentNullException("resourceDictionary");
}
DictionaryHelper.Expect<Style>(resourceDictionary, StyleHelper.TraitHeaderRowStyleName);
List<Score> skills;
Table table;
TableRowGroup tableRowGroup;
TableRow tableRow;
TableCell leftCell; // Reused
TableCell middleCell; // Reused
TableCell rightCell; // Reused
Paragraph paragraph; // Reused
table = new Table();
table.Style = (Style)resourceDictionary[StyleHelper.TraitHeaderRowStyleName];
table.Columns.Add(new TableColumn());
table.Columns.Add(new TableColumn());
table.Columns.Add(new TableColumn());
tableRowGroup = new TableRowGroup();
// The skills row
skills = new List<Score>();
foreach (ScoreType skill in ScoreTypeHelper.Skills)
{
skills.Add(GammaWorldCharacter[skill]);
}
skills.Sort((x, y) => x.Name.CompareTo(y.Name));
paragraph = new Paragraph();
paragraph.Inlines.Add(new Bold(new Run("Skills ")));
paragraph.Inlines.Add(new Run(string.Join(", ",
skills.ConvertAll(x => string.Format("{0} {1}", x.Name, x.ToString(
CharacterRendererHelper.GetFormatString(ScoreDisplayType.Modifier, ShowModifiers)))).ToArray())));
leftCell = new TableCell();
leftCell.ColumnSpan = 3;
leftCell.Blocks.Add(paragraph);
// Contruct the third row
tableRow = new TableRow();
tableRow.Cells.Add(leftCell);
tableRowGroup.Rows.Add(tableRow);
// TODO: Convert these to loops
// The first row of ability scores
paragraph = new Paragraph();
paragraph.Inlines.Add(new Bold(new Run("Str ")));
paragraph.Inlines.Add(new Run(string.Format(" {0} ({1})",
GammaWorldCharacter[ScoreType.Strength].ToString(
CharacterRendererHelper.GetFormatString(ScoreDisplayType.Score, ShowModifiers)),
ModifierHelper.FormatModifier(((AbilityScore) GammaWorldCharacter[ScoreType.Strength]).Modifier, false))));
leftCell = new TableCell();
leftCell.Blocks.Add(paragraph);
paragraph = new Paragraph();
paragraph.Inlines.Add(new Bold(new Run("Dex ")));
paragraph.Inlines.Add(new Run(string.Format(" {0} ({1})",
GammaWorldCharacter[ScoreType.Dexterity].ToString(
CharacterRendererHelper.GetFormatString(ScoreDisplayType.Score, ShowModifiers)),
ModifierHelper.FormatModifier(((AbilityScore)GammaWorldCharacter[ScoreType.Dexterity]).Modifier, false))));
middleCell = new TableCell();
middleCell.Blocks.Add(paragraph);
paragraph = new Paragraph();
paragraph.Inlines.Add(new Bold(new Run("Wis ")));
paragraph.Inlines.Add(new Run(string.Format(" {0} ({1})",
GammaWorldCharacter[ScoreType.Wisdom].ToString(
CharacterRendererHelper.GetFormatString(ScoreDisplayType.Score, ShowModifiers)),
ModifierHelper.FormatModifier(((AbilityScore) GammaWorldCharacter[ScoreType.Wisdom]).Modifier, false))));
rightCell = new TableCell();
rightCell.Blocks.Add(paragraph);
// Contruct the first row of ability scores
tableRow = new TableRow();
tableRow.Cells.Add(leftCell);
tableRow.Cells.Add(middleCell);
tableRow.Cells.Add(rightCell);
tableRowGroup.Rows.Add(tableRow);
// The second row of ability scores
//.........这里部分代码省略.........