Пример #1
0
        private void StartSearch(Object sender, DoWorkEventArgs e)
        {
            List <string> extensions = new List <string>();

            foreach (_Media media in m_IMediaManager.GetAllMedia())
            {
                extensions.Add(media.Extension);
            }
            Search.SearchResults searchResults;
            Search.SearchFilesInPath(m_RootPath, (string)e.Argument, extensions.ToArray(), out searchResults);
            e.Result = searchResults;
        }
Пример #2
0
        internal SelectForm(IMediaManager iMediaManager)
        {
            InitializeComponent();
            m_IMediaManager = iMediaManager;
#if FULL
            this.WindowState     = FormWindowState.Maximized;
            this.FormBorderStyle = FormBorderStyle.None;
            this.AutoScroll      = false;
#endif

            m_SelectedMedia  = new SelectedMedia(this);
            m_SelectingMedia = new SelectingMedia(this);
            m_Artist         = new Artist(this);

            headerCtrl1.StyleItems =
                new List <DirectoryInfo>(new DirectoryInfo(Properties.Settings.Default.RootPath).GetDirectories()).ConvertAll <String>(
                    delegate(DirectoryInfo di)
            {
                return(di.Name);
            }).ToArray();
            headerCtrl1.Mode       = HeaderCtrl.Modes.Styles;
            headerCtrl1.ItemClick += delegate(Object sender, EventArgs e)
            {
                HeaderCtrl hc = (HeaderCtrl)sender;
                HeaderCtrl.ItemClickEventArgs itemClickEventArgs = e as HeaderCtrl.ItemClickEventArgs;
                m_Artist.ClearItems();
                if (hc.Mode == HeaderCtrl.Modes.Styles)
                {
                    foreach (DirectoryInfo tempDirectoryInfo in
                             new DirectoryInfo(Path.Combine(Properties.Settings.Default.RootPath, itemClickEventArgs.Item)).GetDirectories())
                    {
                        m_Artist.AddItem(tempDirectoryInfo.FullName);
                    }
                }
                else if (hc.Mode == HeaderCtrl.Modes.AYa || hc.Mode == HeaderCtrl.Modes.AZ ||
                         hc.Mode == HeaderCtrl.Modes.ZeroNine)
                {
                    List <DirectoryInfo> diList = new List <DirectoryInfo>();
                    new List <DirectoryInfo>(new DirectoryInfo(Properties.Settings.Default.RootPath).GetDirectories()).ForEach(
                        delegate(DirectoryInfo di)
                    {
                        diList.AddRange(di.GetDirectories(itemClickEventArgs.Item + "*"));
                    });
                    foreach (DirectoryInfo tempDirInfo in
                             FiltrateDirs(diList.ToArray(), true, itemClickEventArgs.Item))
                    {
                        m_Artist.AddItem(tempDirInfo.FullName);
                    }
                }
            };
            headerCtrl1.SearchClick += delegate
            {
                using (Search.SearchForm search = new musicbox.Search.SearchForm(m_IMediaManager))
                {
                    DialogResult dlgResult = search.ShowDialog(this);
                    if (dlgResult == DialogResult.OK)
                    {
                        m_Artist.ClearItems();
                        m_SelectingMedia.ClearItems();
                        foreach (DirectoryInfo directoryInfo in search.Results.Directories)
                        {
                            m_Artist.AddItem(directoryInfo.FullName);
                        }
                        foreach (FileInfo fileInfo in search.Results.Files)
                        {
                            string fileExtension = Path.GetExtension(fileInfo.FullName);
                            _Media media;
                            if (m_IMediaManager.TryGetMedia(fileExtension, out media))
                            {
                                m_SelectingMedia.AddItem(new FileNameAndMedia(fileInfo.FullName, media));
                            }
                        }
                    }
                }
            };
            // new EventHandler(stylesCtrl1_SearchClick);

            m_Artist.ItemClick += delegate(Object sender, Artist.ArtistClickEventArgs e)
            {
                Artist ai = (Artist)sender;
                if (e.Item.Length > 0)
                {
                    m_SelectingMedia.ClearItems();

                    foreach (_Media media in m_IMediaManager.GetAllMedia())
                    {
                        foreach (FileInfo fileInfo in new DirectoryInfo(e.Item).GetFiles("*" + media.Extension))
                        {
                            m_SelectingMedia.AddItem(new FileNameAndMedia(fileInfo.FullName, media));
                        }
                    }
                }
            };
            m_SelectingMedia.ItemClick += new EventHandler <SelectingMedia.SelectingMediaEventArgs>(m_SelectingMedia_ItemClick);
            //{

            /* if (!m_SelectedMedia.Items.IsNameExist(e.Item.FileName))
             * {
             *   String[] lastOrdered = LastOrdered.Instance.GetItems();
             *   if (!Array.Exists<String>(lastOrdered,
             *       delegate(String value)
             *       {
             *           return value == e.Item.FileName;
             *       }))
             *   {
             *       if (!Properties.Settings.Default.MoneylessModeEnabled)
             *       {
             *           if (m_SelectedMedia.RestSum >= e.Item.IMedia.Price)
             *           {
             *               m_SelectedMedia.Items.Add(new FileNameAndIMediaWithIsMoneyless(e.Item.IMedia, false));
             *           }
             *       }
             *       else
             *       {
             *           m_SelectedMedia.Items.Add(new FileNameAndIMediaWithIsMoneyless(e.Item.IMedia, true));
             *       }
             *   }
             *   else
             *       ApplicationMessage.Show(this, m_MediaExistInPlaylist);
             *
             * }
             * else
             *   ApplicationMessage.Show(this, m_MediaYetOrder);*/
            /* }
             * else
             *   ApplicationMessage.Show(this,m_strMoneyNotEnough);*/
            //-------------------------------------
            //};
            m_SelectedMedia.GoClicked += new EventHandler(m_SelectedMedia_GoClicked);
        }