Exemplo n.º 1
0
        public static string GetUserSelectedFolder(string Caption, string Default, bool ShowNewFolderButton)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.Description         = Caption;
            fbd.ShowNewFolderButton = false;

            Track t = Controller.GetInstance().GetTracklistFirstSelectedOrFirst;

            fbd.RootFolder = Environment.SpecialFolder.Desktop;

            fbd.ShowNewFolderButton = ShowNewFolderButton;

            if (Default.Length > 0)
            {
                fbd.SelectedPath = Default;
            }
            else if (t == null || !File.Exists(t.FilePath))
            {
                fbd.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            }
            else
            {
                fbd.SelectedPath = Path.GetDirectoryName(t.FilePath);
            }

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                return(fbd.SelectedPath);
            }
            else
            {
                return(String.Empty);
            }
        }
Exemplo n.º 2
0
        private static void getLibrary()
        {
            iTunesApp app = new iTunesApp();

            app.ForceToForegroundOnDialog = true;

            IITTrackCollection tc = app.LibraryPlaylist.Tracks;

            Controller.ShowMessage(tc.Count.ToString() + " tracks found...");

            List <string> tracks = new List <string>();

            foreach (IITTrack t in tc)
            {
                if (Cancel)
                {
                    break;
                }

                if (t.Kind == ITTrackKind.ITTrackKindFile)
                {
                    string l = (t as IITFileOrCDTrack).Location;
                    Controller.ShowMessage(t.Name);
                    tracks.Add(l);
                }
            }
            if (!Cancel)
            {
                FileAdder.AddItemsToLibrary(tracks, String.Empty, true, Controller.GetInstance().RefreshAll);
            }
        }
Exemplo n.º 3
0
        public frmMiniPlayer(ControlPanel ControlPanel, bool Radio)
        {
            this.Cursor  = Cursors.Hand;
            this.Opacity = TRANSPARENT;

            this.radio = Radio;

            Rectangle r = new Rectangle(DefaultLocation, Styles.BitmapMiniPlayer.Size);

            r = Lib.MakeVisible(r);

            this.Bounds = r;

            this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 5, 5));

            controller = Controller.GetInstance();

            controlPanel = ControlPanel;
            controlPanel.Subscribe(this);

            exitRect      = new Rectangle(EXIT, TOP, WIDTH, HEIGHT);
            backRect      = new Rectangle(BACK, TOP, EXTRA_WIDTH, HEIGHT);
            playPauseRect = new Rectangle(PLAY_PAUSE, TOP, HEIGHT, WIDTH);
            nextRect      = new Rectangle(NEXT, TOP, EXTRA_WIDTH, HEIGHT);
            muteRect      = new Rectangle(MUTE, TOP, WIDTH, HEIGHT);
            volUpRect     = new Rectangle(VOL, TOP, WIDTH, HEIGHT / 2);
            volDownRect   = new Rectangle(VOL, TOP + HEIGHT / 2, WIDTH, HEIGHT / 2);

            timeRect = new Rectangle(TIME, 0, this.ClientRectangle.Width - TIME - 4, this.ClientRectangle.Height - 2);

            WinAudioLib.VolumeChanged += volUpdate;

            instance = this;
        }
Exemplo n.º 4
0
        public void InvokeSelectedStation()
        {
            if (SelectedStation != null)
            {
                Controller.GetInstance().RequestAction(QActionType.UpdateRadioStation);
                txtURL.Text = SelectedStation.URL;

                ensureSelectedStationVisible();
            }
        }
Exemplo n.º 5
0
 public static void BrowseTo(string URL)
 {
     try
     {
         Controller.GetInstance().RequestAction(QActionType.ReleaseFullScreenAuto);
         Controller.GetInstance().RequestAction(QActionType.UnlockControls);
         System.Diagnostics.Process.Start(URL);
     }
     catch { }
 }
Exemplo n.º 6
0
        public Gamepad(Form Owner)
        {
            this.Enabled = false;

            owner = Owner;

            controller    = Controller.GetInstance();
            actionHandler = controller;

            GamePadMode = Mode.Normal;
        }
Exemplo n.º 7
0
 private void lvwEpisodes_DoubleClickCallback(PodcastEpisode SelectedItem)
 {
     if (!Locked)
     {
         if (SelectedItem.Playable)
         {
             Controller.GetInstance().Play(SelectedItem);
         }
         else
         {
             PodcastSubscription.Download(SelectedItem);
             lvwEpisodes.Invalidate();
         }
     }
 }
Exemplo n.º 8
0
        private void doBulkUpdate()
        {
            int i       = newPath.Length - 1;
            int lenDiff = newPath.Length - oldPath.Length;

            while (i >= lenDiff && newPath[i] == oldPath[i - lenDiff])
            {
                i--;
            }
            i++;
            string oldStart       = oldPath.Substring(0, i - lenDiff);
            string newStart       = newPath.Substring(0, i);
            int    oldStartLength = oldStart.Length;

            int count    = 0;
            int badCount = 0;

            List <Track> tracks = Database.LibrarySnapshot;

            for (int j = 0; j < tracks.Count; j++)
            {
                Track tt = tracks[j];

                if (tt.Exists != true && tt.FilePath.StartsWith(oldStart, StringComparison.OrdinalIgnoreCase) && !tt.ConfirmExists)
                {
                    string s = newStart + tt.FilePath.Substring(oldStartLength);
                    if (File.Exists(s))
                    {
                        tt.FilePath      = s;
                        tt.ConfirmExists = true;
                        count++;
                        Controller.ShowMessage(Localization.Get(UI_Key.Find_File_Message_Updating, count.ToString(), tt.ToShortString()));
                        Controller.GetInstance().Invalidate();
                    }
                    else
                    {
                        badCount++;
                    }
                }
                else
                {
                    badCount++;
                }
            }
            Database.IncrementDatabaseVersion(true);
        }
Exemplo n.º 9
0
        protected override void OnVisibleChanged(EventArgs e)
        {
            if (this.Visible)
            {
                this.SplitterDistance = Setting.SplitterDistance;
            }

            base.OnVisibleChanged(e);
            Controller c = Controller.GetInstance();

            if (c != null)
            {
                c.RequestAction(QActionType.KeyPreviewChange);
            }

            if (this.Visible)
            {
                stationPanel.Focus();
            }
        }
Exemplo n.º 10
0
        public Player(System.Windows.Forms.Form OwnerForm, string OutputDeviceName, SpectrumMode SpectrumMode)
        {
            Stream        = AudioStream.NullStream;
            PreloadStream = AudioStream.NullStream;

            outputDeviceName = OutputDeviceName;
            parentForm       = OwnerForm;

            PlayingTrack = null;
            NextTrack    = null;

            spectrumMode = SpectrumMode;
            createSpectrum();

            System.Diagnostics.Debug.Assert(READ_BUFFER_SIZE / spectrumSampleSize >= 4);

            controller = Controller.GetInstance();

            Clock.DoOnMainThread(createOutput, 1000);
        }
Exemplo n.º 11
0
        public AudioStreamRadio(RadioStation Station,
                                int PresumedFrequency,
                                Callback FrequencyMismatch,
                                float GainDB,
                                float[] Equalizer,
                                int NumEqBands,
                                bool EqualizerOn,
                                ReplayGainMode ReplayGain) : base(null, GainDB, Equalizer, NumEqBands, EqualizerOn, ReplayGain)
        {
            this.replayGainDB = -6.0f; // Radio is loud, clips a bunch

            controller = Controller.GetInstance();
            Controller.ShowMessageUntilReplaced(Localization.Get(UI_Key.Radio_Connecting));

            this.station = Station;

            presumedFreq = PresumedFrequency;
            frequencyMismatchDelegate = FrequencyMismatch;

            Clock.DoOnNewThread(setup);
        }
Exemplo n.º 12
0
 private static void refreshFiles()
 {
     try
     {
         IEnumerable <Track> all = Database.LibrarySnapshot;
         foreach (Track t in all)
         {
             if (t.ConfirmExists && File.GetLastWriteTime(t.FilePath) > t.FileDate)
             {
                 t.ForceLoad();
             }
             if (++count == 200)
             {
                 Controller.GetInstance().Invalidate();
             }
         }
         Controller.GetInstance().Invalidate();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.ToString());
     }
 }
Exemplo n.º 13
0
        private static void sendTracks()
        {
            try
            {
                lock (@lock)
                {
                    int numTracks = newTracks.Count;

                    List <Track> tracks = newTracks.Take(numTracks).ToList();
                    newTracks.RemoveRange(0, numTracks);

                    Controller c = Controller.GetInstance();

                    c.AddToLibrarySilent(tracks, false);
                    c.RequestAction(QActionType.UpdateTrackCount);

                    addTracksAlarm = Clock.NULL_ALARM;
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
            }
        }
Exemplo n.º 14
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);

            Item i;

            lock (@lock)
            {
                i = Item.ItemAt(e.Location);
            }
            Controller c = Controller.GetInstance();

            if (i == null)
            {
                c.RequestAction(QActionType.AdvanceScreen);
            }
            else
            {
                switch (this.ViewMode)
                {
                case ViewModeEnum.Artist:

                    if ((e.Button == MouseButtons.Right) || (i.Count < 2) || (Database.FindAllTracks(t => t.MainGroup == i.Text && t.Album.Length > 0).GroupBy(t => t.Album).Count() < 2))
                    {
                        c.RequestAction(new QAction(QActionType.ShowAllOfArtist, i.Text));
                    }
                    else
                    {
                        this.ViewMode = ViewModeEnum.Album;
                        currentArtist = i.Text;
                        setupItems();
                    }
                    break;

                case ViewModeEnum.Album:
                    c.RequestAction(new QAction(QActionType.ShowAllOfAlbum, i.Text, currentArtist));
                    break;

                case ViewModeEnum.Genre:

                    if (e.Button == MouseButtons.Right)
                    {
                        c.RequestAction(new QAction(QActionType.ShowAllOfGenre, i.Text));
                    }
                    else
                    {
                        this.ViewMode = ViewModeEnum.Artist;

                        currentGrouping = String.Empty;
                        currentGenre    = i.Text;

                        setupItems();
                    }
                    break;

                case ViewModeEnum.Grouping:

                    if (e.Button == MouseButtons.Right)
                    {
                        c.RequestAction(new QAction(QActionType.ShowAllOfGrouping, i.Text));
                    }
                    else
                    {
                        this.ViewMode = ViewModeEnum.Artist;

                        currentGrouping = i.Text;
                        currentGenre    = String.Empty;

                        setupItems();
                    }
                    break;
                }
            }
        }
Exemplo n.º 15
0
 static Equalizer()
 {
     controller = Controller.GetInstance();
 }
Exemplo n.º 16
0
 public static void Stop()
 {
     Controller.GetInstance().RequestAction(QActionType.Exit);
 }
Exemplo n.º 17
0
        private static void start()
        {
            running = true;
            cancel  = false;

            try
            {
                if (directories.Count > 0)
                {
                    Random r = new Random();

                    IOrderedEnumerable <string> dirs = directories.OrderBy(d => r.Next());

                    Stack <string> paths = new Stack <string>(dirs);

                    while (paths.Count > 0 && paths.Peek() != null && !cancel)
                    {
                        string s = paths.Pop();
                        if (Directory.Exists(s))
                        {
                            foreach (string ss in (Directory.GetDirectories(s)).OrderBy(x => r.Next()))
                            {
                                paths.Push(ss);
                            }
                            foreach (string ss in (Directory.GetFiles(s).Reverse()))
                            {
                                paths.Push(ss);
                            }
                        }
                        else if (File.Exists(s))
                        {
                            Track t = Track.Load(s);
                            if (t != null)
                            {
                                lock (@lock)
                                {
                                    newTracks.Add(t);
                                }

                                Thread.Sleep(100);
                                if (addIfNeeded(30))
                                {
                                    Thread.Sleep(200);
                                }
                            }
                            Thread.Sleep(50);
                        }
                    }
                    while (!cancel && !addIfNeeded(0))
                    {
                        Thread.Sleep(200);
                    }
                    ;
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
            }

            running = false;

            if (cancel)
            {
                newTracks.Clear();
            }
            else
            {
                cancel = true;
                Clock.DoOnMainThread(sendTracks, 50);

                // get back to UI thread
                Clock.DoOnMainThread(Controller.GetInstance().RefreshAll, 500);
            }

            resetRestartAlarm();
        }