本文整理汇总了C#中System.Windows.Documents.List.ToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToDictionary方法的具体用法?C# List.ToDictionary怎么用?C# List.ToDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.ToDictionary方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPluginConfig
public void SetPluginConfig(string plugin, List<PluginConfigItem> configuration)
{
mPlugin = plugin;
mConfiguration = configuration.ToDictionary(x => x.Name, x => x);
mControls = new List<Control>();
ConfigurationItems.Children.Clear();
int rowHeight = 10;
foreach (PluginConfigItem item in configuration)
{
Label text = new Label();
text.Margin = new Thickness(10, rowHeight - 2, 0, 0);
text.VerticalAlignment = VerticalAlignment.Top;
text.HorizontalAlignment = HorizontalAlignment.Left;
text.Content = item.DisplayName;
text.FontWeight = FontWeights.Bold;
ConfigurationItems.Children.Add(text);
switch (item.Type)
{
case ConfigType.File:
CreateFileChooser(rowHeight, item);
break;
case ConfigType.Folder:
CreateFolderSelect(rowHeight, item);
break;
case ConfigType.Number:
case ConfigType.Text:
CreateTextBox(rowHeight, item);
break;
case ConfigType.Boolean:
CreateBoolean(rowHeight, item);
break;
}
rowHeight += 30;
}
}
示例2: InitializeComponents
/// <summary>
/// Initializes the contents of the components dictionary.
/// </summary>
private void InitializeComponents()
{
List<ComponentInformation> componentList = new List<ComponentInformation>(new[] {
new ComponentInformation { Name = "ATT",
TilePinned = false },
new ComponentInformation { Name = "Designer",
TilePinned = false },
new ComponentInformation { Name = "Model",
TilePinned = false },
new ComponentInformation { Name = "Import",
TilePinned = false },
new ComponentInformation { Name = "Language",
TilePinned = false }
});
Components = componentList.ToDictionary(l => l.Name);
}
示例3: InitializeTestData
/// <summary>
/// Initializes the Test data.
/// </summary>
private Dictionary<string, TestData> InitializeTestData()
{
Dictionary<string, TestData> Datas;
List<TestData> testDataList = new List<TestData>(new[] {
new TestData { Name = "ATT",
ImageName = "In_Progress", PassRate = 0, TestProgress = 0, TestCoverage = 100, CodeCoverage = 100},
new TestData { Name = "Designer",
ImageName = "In_Progress", PassRate = 0, TestProgress = 0, TestCoverage = 100, CodeCoverage = 95},
new TestData { Name = "Import",
ImageName = "In_Progress", PassRate = 0, TestProgress = 0, TestCoverage = 100, CodeCoverage = 96},
new TestData { Name = "Language",
ImageName = "In_Progress", PassRate = 0, TestProgress = 0, TestCoverage = 100, CodeCoverage = 94},
new TestData { Name = "Model",
ImageName = "In_Progress", PassRate = 0, TestProgress = 0, TestCoverage = 100, CodeCoverage = 98}});
Datas = testDataList.ToDictionary(l => l.Name);
return Datas;
}
示例4: lstAlbums_SelectionChanged
private void lstAlbums_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (m_Mpc == null || !m_Mpc.Connected)
return;
ListBox list = sender as ListBox;
if (list.SelectedItem != null) {
Dictionary<ScopeSpecifier, string> search = new Dictionary<ScopeSpecifier, string>();
ListBox listBox = null;
if (tabBrowse.SelectedIndex == 0 && lstArtist.SelectedItem != null) {
string artist = lstArtist.Selected().Artist();
search[ScopeSpecifier.Artist] = artist;
listBox = lstAlbums;
} else if (tabBrowse.SelectedIndex == 1 && lstGenres.SelectedItem != null) {
string genre = lstGenres.SelectedItem.ToString();
if (genre == Mpc.NoGenre)
genre = string.Empty;
search[ScopeSpecifier.Genre] = genre;
listBox = lstGenresAlbums;
}
var album = listBox.Selected();
search[ScopeSpecifier.Album] = album.Album();
Action<Cancel, Action<Action>> populate = (c, call) => {
try {
if (c.cancel)
return;
if (album != null) {
album.Related.Do(r => r.Selected = true);
if (e != null) {
var old = e.RemovedItems.OfType<ListboxEntry>().FirstOrDefault();
if (old != null && !(album.Related != null && album.Related.Contains(old)))
old.Related.Do(r => r.Selected = false);
}
if (c.cancel)
return;
call(() => {
listBox.ScrollIntoView(album);
});
}
try {
m_Tracks = m_Mpc.Find(search);
if (c.cancel)
return;
if (album != null) {
Albums[album.Artist + ":" + album.Album] = album;
album.Tracks = () => m_Tracks;
if (album.Info == null)
album.Info = new ObservableCollection<object>();
m_ArtDownloader.Now(album);
}
m_Tracks.Do(m => m.AlbumEntry = album);
var selection = m_Tracks.ToDictionary(m => m.File);
var all = m_Tracks
.OrderBy(m => m.Disc).ThenBy(m => m.TrackNo).ThenBy(m => m.Title, Utilities.VersionComparer.Instance)
.GroupBy(m => dir.Replace(m.File, "$1"))
.Where(g => {
if (album != null && album.Album != "Misc")
FindInfo(album.Info, g.Key, 20, Dispatcher);
return true;
})
.SelectMany(Utilities.Try<IGrouping<string, MpdFile>, IEnumerable<MpdFile>>(g =>
m_Mpc.ListAllInfo(g.Key)
.OrderBy(m => m.Disc).ThenBy(m => m.TrackNo).ThenBy(m => m.Title, Utilities.VersionComparer.Instance)
.Where(m => (m.Supplement = !selection.Remove(m.File)) || true)
))
.ToList();
if (c.cancel)
return;
all.GroupBy(m => m.Artist).Do(a =>
a.GroupBy(m => m.Album).Do(b => {
var i = new ListboxEntry() {
Type = ListboxEntry.EntryType.Album,
Artist = a.Key,
Album = b.Key,
Tracks = () => b,
};
b.Do(m => m.AlbumEntry = i);
m_ArtDownloader.Soon(i);
}));
all.AddRange(selection.Values);
if (c.cancel)
return;
call(() => {
if (album != null)
lstInfo.ItemsSource = album.Info;
lstTracks.ItemsSource = all;
ScrollTracksToLeft();
});
}
catch (Exception ex)
{
ShowException(ex);
return;
}
//.........这里部分代码省略.........