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;
            }
        }
        /// <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);
        }
        /// <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;
        }
Beispiel #4
0
        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;
            }
               } finally {
            lock(lstArtist_Jobs)
              lstArtist_Jobs.Remove(c);
               }};
               var cancel = new Cancel();
               Cancel.Set(lstArtist_Jobs, cancel);
               if (navigating)
             populate(cancel, x => x());
               else
             populate.BeginInvoke(cancel, (Action<Action>)(x => Dispatcher.BeginInvoke(x)), populate.EndInvoke, null);
              }
              else
              {
            m_Tracks = null;
            lstTracks.ItemsSource = null;
              }
        }