Exemple #1
0
        private void btnTest_Click()
        {
            textbox.CloseIntellisense();

            ExpressionTree et = new ExpressionTree(ExpressionTree.CleanExpression(textbox.ToString()));

            ExpressionTree.ValidationError ve = et.Compile();

            if (ve == ExpressionTree.ValidationError.Valid)
            {
                bool sorted;
                var  v = et.Filter(Database.LibrarySnapshot, out sorted);

                string message;

                if (v.Count == 1)
                {
                    message = String.Format("Playlist returns {0} track.", v.Count.ToString());
                }
                else
                {
                    message = String.Format("Playlist returns {0} tracks.", v.Count.ToString());
                }

                QMessageBox.Show(this, message, "Auto Playlist Test", QMessageBoxIcon.Information);
            }
            else
            {
                QMessageBox.Show(this, getValidationErrorText(ve), "Auto Playlist Test Failed", QMessageBoxIcon.Information);
            }
        }
Exemple #2
0
        private void mnuPlaylistsDeletePlaylist_DropDownOpening(object sender, EventArgs e)
        {
            List <string> playlists = Database.GetPlaylists();

            mnuPlaylistsDeletePlaylist.DropDownItems.Clear();
            foreach (string s in playlists)
            {
                switch (Database.GetPlaylistType(s))
                {
                case PlaylistType.Standard:
                case PlaylistType.Auto:

                    ToolStripItem tsi = mnuPlaylistsDeletePlaylist.DropDownItems.Add(s);
                    tsi.Tag    = s;
                    tsi.Click += delegate(object sender1, EventArgs e1)
                    {
                        string ss = tsi.Tag.ToString();
                        if (QMessageBox.Show(this,
                                             Localization.Get(UI_Key.Dialog_Remove_Playlist, ss),
                                             Localization.Get(UI_Key.Dialog_Remove_Playlist_Title),
                                             QMessageBoxButtons.OKCancel,
                                             QMessageBoxIcon.Question,
                                             QMessageBoxButton.NoCancel)
                            == DialogResult.OK)
                        {
                            controller.DeletePlaylist(ss);
                        }
                    };
                    break;
                }
            }
        }
Exemple #3
0
        private void save(bool Convert)
        {
            textbox.CloseIntellisense();

            convert = Convert;

            if (!Valid)
            {
                switch (QMessageBox.Show(this,
                                         Localization.Get(UI_Key.Edit_Auto_Playlist_Invalid_Dialog),
                                         Localization.Get(UI_Key.Edit_Auto_Playlist_Invalid_Dialog_Title),
                                         QMessageBoxButtons.OKCancel,
                                         QMessageBoxIcon.Warning,
                                         QMessageBoxButton.NoCancel))
                {
                case DialogResult.OK:
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                    break;

                case DialogResult.Cancel:
                    break;
                }
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Exemple #4
0
        private void btnNewPreset_ButtonPressed(QButton Button)
        {
            QInputBox ib = new QInputBox(this,
                                         Localization.Get(UI_Key.Dialog_Equalizer_New_Preset),
                                         Localization.Get(UI_Key.Dialog_Equalizer_New_Preset_Title),
                                         String.Empty,
                                         24,
                                         1);

            if (ib.DialogResult == DialogResult.OK)
            {
                if (equalizers.ContainsKey(ib.Value))
                {
                    QMessageBox.Show(this,
                                     Localization.Get(UI_Key.Dialog_Equalizer_Duplicate_Preset, ib.Value),
                                     Localization.Get(UI_Key.Dialog_Equalizer_Duplicate_Preset_Title),
                                     QMessageBoxIcon.Error);
                }
                else
                {
                    float[] d = new float[MAX_NUM_BANDS];
                    Array.Copy(CurrentEqualizer.Values, d, MAX_NUM_BANDS);
                    EqualizerSetting es = new EqualizerSetting(ib.Value, d, false);
                    equalizers.Add(ib.Value, es);
                    populateEqualizerList();
                    CurrentEqualizer = es;
                }
            }
        }
Exemple #5
0
        private void changePlaylistName(string OldName, string NewName)
        {
            if (CurrentFilterType == FilterType.Playlist)
            {
                if (Database.PlaylistExists(NewName) && (OldName.ToLowerInvariant() != NewName.ToLowerInvariant()))
                {
                    QMessageBox.Show(mainForm,
                                     Localization.Get(UI_Key.Dialog_Duplicate_Playlist, NewName.Trim()),
                                     Localization.Get(UI_Key.Dialog_Duplicate_Playlist_Title),
                                     QMessageBoxIcon.Warning);
                }
                else if (Database.ChangePlaylistName(OldName, NewName))
                {
                    if (Queue.PlaylistBasis == OldName)
                    {
                        Queue.PlaylistBasis = NewName;
                    }

                    if (controller.TargetPlaylistName == OldName)
                    {
                        controller.TargetPlaylistName = NewName;
                    }

                    CurrentFilterValue = NewName;

                    LoadFilterValues();
                }
            }
        }
Exemple #6
0
        private bool createDir()
        {
            string s = complexify(txtDirectory.Text.Trim());

            if (!Directory.Exists(s))
            {
                try
                {
                    if (QMessageBox.Show(this,
                                         Localization.Get(UI_Key.Organize_Create_Directory),
                                         Localization.Get(UI_Key.Organize_Create_Directory_Title),
                                         QMessageBoxButtons.YesNo,
                                         QMessageBoxIcon.Question,
                                         QMessageBoxButton.YesOK) == DialogResult.OK)
                    {
                        Directory.CreateDirectory(s);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch
                {
                    QMessageBox.Show(this,
                                     Localization.Get(UI_Key.Organize_Create_Directory_Failed),
                                     Localization.Get(UI_Key.Organize_Create_Directory_Failed_Title),
                                     QMessageBoxIcon.Error);
                    return(false);
                }
            }
            return(true);
        }
        public static string ImportPlaylist(Form Parent, out List <Track> Tracks)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.AddExtension       = true;
            ofd.CheckPathExists    = true;
            ofd.DefaultExt         = ".m3u";
            ofd.FileName           = String.Empty;
            ofd.Filter             = Localization.Get(UI_Key.Import_Playlist_Filter);
            ofd.FilterIndex        = 3;
            ofd.InitialDirectory   = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            ofd.RestoreDirectory   = true;
            ofd.Title              = Localization.Get(UI_Key.Import_Playlist_Title);
            ofd.ValidateNames      = true;
            ofd.AutoUpgradeEnabled = true;

            Tracks = new List <Track>();
            string playlistName = String.Empty;

            if (ofd.ShowDialog(Parent) == DialogResult.OK)
            {
                Lib.DoEvents();

                string relativePath = Path.GetDirectoryName(ofd.FileName);

                System.IO.StreamReader sr = new StreamReader(ofd.FileName);

                bool urlsFound = false;

                switch (Path.GetExtension(ofd.FileName).ToLowerInvariant())
                {
                case ".m3u":
                    urlsFound = importM3U(Tracks, relativePath, sr);
                    break;

                case ".pls":
                    urlsFound = importPLS(Tracks, sr, false);
                    break;
                }

                if (Tracks.Count > 0)
                {
                    playlistName = Path.GetFileNameWithoutExtension(ofd.FileName);
                }
                else if (!urlsFound)
                {
                    QMessageBox.Show(Parent,
                                     Localization.Get(UI_Key.Dialog_Import_Playlist_No_Tracks_Found),
                                     Localization.Get(UI_Key.Dialog_Import_Playlist_No_Tracks_Found_Title),
                                     QMessageBoxIcon.Warning);
                }
                sr.Close();
            }
            return(playlistName);
        }
Exemple #8
0
 private void mnuOptionsDetectGamepad_Click(object sender, EventArgs e)
 {
     controller.RequestAction(QActionType.InitializeGamepad);
     if (controller.GamepadEnabled)
     {
         QMessageBox.Show(this,
                          Localization.Get(UI_Key.Dialog_Gamepad_Enabled),
                          Localization.Get(UI_Key.Dialog_Gamepad_Enabled_Title),
                          QMessageBoxIcon.Information);
     }
 }
Exemple #9
0
 public static void ExceptionToClipboard(Exception Exception)
 {
     {
         Clipboard.SetText("Error Starting QuuxPlayer" + Environment.NewLine + Environment.NewLine +
                           "Message:" + Exception.Message + Environment.NewLine + Environment.NewLine +
                           "Source: " + Exception.Source + Environment.NewLine +
                           "Stack Trace: " + Exception.StackTrace +
                           "Target Site: " + Exception.TargetSite +
                           Exception.ToString());
     }
     QMessageBox.Show(null, "Error in QuuxPlayer. Details have been copied to the Windows clipboard.", "QuuxPlayer Error", QMessageBoxIcon.Error);
 }
Exemple #10
0
 protected override void OnShown(EventArgs e)
 {
     base.OnShown(e);
     if (!GamepadEnabled)
     {
         Lib.DoEvents();
         QMessageBox.Show(MainForm,
                          Localization.Get(UI_Key.Gamepad_Help_No_Gamepad),
                          Localization.Get(UI_Key.Gamepad_Help_No_Gamepad_Title),
                          QMessageBoxIcon.Information);
     }
 }
Exemple #11
0
 private void mnuFileRefreshAllTracks_Click(object sender, EventArgs e)
 {
     if (QMessageBox.Show(this,
                          Localization.Get(UI_Key.Dialog_Refresh_Tracks),
                          Localization.Get(UI_Key.Dialog_Refresh_Tracks_Title),
                          QMessageBoxButtons.OKCancel,
                          QMessageBoxIcon.Question,
                          QMessageBoxButton.YesOK)
         == DialogResult.OK)
     {
         controller.RequestAction(QActionType.RefreshLibrary);
     }
 }
Exemple #12
0
 private void mnuFileRemoveGhostTracks_Click(object sender, EventArgs e)
 {
     if (QMessageBox.Show(this,
                          Localization.Get(UI_Key.Dialog_Remove_Ghost_Tracks),
                          Localization.Get(UI_Key.Dialog_Remove_Ghost_Tracks_Title),
                          QMessageBoxButtons.OKCancel,
                          QMessageBoxIcon.Question,
                          QMessageBoxButton.NoCancel)
         == DialogResult.OK)
     {
         controller.RequestAction(QActionType.RemoveNonExistentTracks);
     }
 }
Exemple #13
0
 private void mnuFileClearDatabase_Click(object sender, EventArgs e)
 {
     if (QMessageBox.Show(this,
                          Localization.Get(UI_Key.Dialog_Clear_Database),
                          Localization.Get(UI_Key.Dialog_Clear_Database_Title),
                          QMessageBoxButtons.OKCancel,
                          QMessageBoxIcon.Warning,
                          QMessageBoxButton.NoCancel)
         == DialogResult.OK)
     {
         controller.CreateNewDatabase();
     }
 }
Exemple #14
0
        private void btnFind_Click()
        {
            string mydocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string path   = txtFilePath.Text;

            if (txtFilePath.Text.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
            {
                path = mydocs;
            }
            else if (!Directory.Exists(Path.GetDirectoryName(txtFilePath.Text)))
            {
                path = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
            }
            else
            {
                path = txtFilePath.Text;
            }

            OpenFileDialog ofd = Lib.GetOpenFileDialog(path,
                                                       false,
                                                       Localization.Get(UI_Key.Lib_File_Filter),
                                                       Database.GetSetting(SettingType.FileDialogFilterIndex, 12));

            try
            {
                if (ofd.ShowDialog(this) == DialogResult.OK)
                {
                    if (File.Exists(ofd.FileName))
                    {
                        txtFilePath.Text = ofd.FileName;
                        Database.SaveSetting(SettingType.FileDialogFilterIndex, ofd.FilterIndex);
                    }
                    else
                    {
                        QMessageBox.Show(this,
                                         Localization.Get(UI_Key.Find_File_File_Does_Not_Exist),
                                         Localization.Get(UI_Key.Find_File_File_Does_Not_Exist_Title),
                                         QMessageBoxIcon.Error);
                    }
                }
            }
            catch
            {
                if (txtFilePath.Text != mydocs)
                {
                    txtFilePath.Text = mydocs;
                    btnFind_Click();
                }
            }
        }
Exemple #15
0
        private void btnRemovePreset_ButtonPressed(QButton Button)
        {
            if (cboName.Text != DEFAULT_EQ_NAME)
            {
                if (QMessageBox.Show(this,
                                     Localization.Get(UI_Key.Dialog_Equalizer_Remove_Preset, cboName.Text),
                                     Localization.Get(UI_Key.Dialog_Equalizer_Remove_Preset_Title),
                                     QMessageBoxButtons.OKCancel,
                                     QMessageBoxIcon.Question,
                                     QMessageBoxButton.NoCancel)
                    == DialogResult.OK)
                {
                    string s = cboName.Text;

                    cboName.SelectedItem = DEFAULT_EQ_NAME;
                    cboName.Items.Remove(s);
                    if (equalizers.ContainsKey(s))
                    {
                        equalizers.Remove(s);
                    }
                }
            }
        }
Exemple #16
0
        private void test()
        {
            btnOK.Enabled        = false;
            btnCancel.Enabled    = false;
            btnTest.Enabled      = false;
            btnViewOnWeb.Enabled = false;

            if (Twitter.SendTwitterMessage(Localization.Get(UI_Key.Twitter_Test_Message), txtUserName.Text, txtPassword.Text))
            {
                QMessageBox.Show(this,
                                 Localization.Get(UI_Key.Twitter_Test_Message_Sent),
                                 Localization.Get(UI_Key.Twitter_Test_Message_Sent_Title),
                                 QMessageBoxIcon.Information);
            }
            else
            {
                QMessageBox.Show(this,
                                 Localization.Get(UI_Key.Twitter_Test_Message_Failed),
                                 Localization.Get(UI_Key.Twitter_Test_Message_Failed_Title),
                                 QMessageBoxIcon.Error);
            }

            enableControls();
        }
Exemple #17
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (!Locked)
            {
                if (e.Button == MouseButtons.Right)
                {
                    ContextMenuStrip cms = new ContextMenuStrip();
                    cms.Renderer = new MenuItemRenderer();
                    ToolStripMenuItem  tsi;
                    ToolStripSeparator tss;

                    tsi        = new ToolStripMenuItem(Localization.Get(UI_Key.Filter_Value_List_Play));
                    tsi.Click += (s, ee) => { controller.RequestAction(QActionType.PlayFirstTrack); };
                    cms.Items.Add(tsi);

                    if (filterType == FilterType.Playlist)
                    {
                        tss = new ToolStripSeparator();
                        cms.Items.Add(tss);

                        tsi        = new ToolStripMenuItem(Localization.Get(UI_Key.Filter_Value_List_Add_Playlist));
                        tsi.Click += (s, ee) =>
                        {
                            string[] vals = Values.ToArray();
                            controller.RequestAction(QActionType.CreateNewPlaylist);
                        };
                        cms.Items.Add(tsi);

                        bool editable = Editable;

                        tsi         = new ToolStripMenuItem(Localization.Get(UI_Key.Filter_Value_List_Rename_Playlist));
                        tsi.Click  += (s, ee) => { controller.RequestAction(QActionType.RenameSelectedPlaylist); };
                        tsi.Enabled = editable;
                        cms.Items.Add(tsi);

                        tsi        = new ToolStripMenuItem(Localization.Get(UI_Key.Filter_Value_List_Remove_Playlist));
                        tsi.Click += (s, ee) =>
                        {
                            if (QMessageBox.Show(this,
                                                 Localization.Get(UI_Key.Filter_Value_List_Remove_Playlist_Dialog, Values[SelectedIndex]),
                                                 Localization.Get(UI_Key.Filter_Value_List_Remove_Playlist_Dialog_Title),
                                                 QMessageBoxButtons.OKCancel,
                                                 QMessageBoxIcon.Question,
                                                 QMessageBoxButton.NoCancel)
                                == DialogResult.OK)
                            {
                                controller.RequestAction(QActionType.RemoveSelectedPlaylist);
                            }
                        };
                        tsi.Enabled = editable;
                        cms.Items.Add(tsi);

                        PlaylistType pt = Database.GetPlaylistType(Values[SelectedIndex]);

                        if (editable)
                        {
                            tsi        = new ToolStripMenuItem((pt == PlaylistType.Auto) ? Localization.Get(UI_Key.Filter_Value_List_Edit_Auto_Playlist) : Localization.Get(UI_Key.Filter_Value_List_Convert_To_Auto_Playlist));
                            tsi.Click += (s, ee) => { controller.RequestAction(QActionType.EditAutoPlaylist); };
                            cms.Items.Add(tsi);
                            if (pt == PlaylistType.Auto)
                            {
                                tsi        = new ToolStripMenuItem(Localization.Get(UI_Key.Filter_Value_List_Convert_To_Standard_Playlist));
                                tsi.Click += (s, ee) => { controller.RequestAction(QActionType.ConvertToStandardPlaylist); };
                                cms.Items.Add(tsi);
                            }
                        }

                        tsi        = new ToolStripMenuItem(Localization.Get(UI_Key.Filter_Value_List_Export_Playlist));
                        tsi.Click += (s, ee) =>
                        {
                            controller.RequestAction(QActionType.ExportPlaylist);
                        };
                        cms.Items.Add(tsi);

                        switch (pt)
                        {
                        case PlaylistType.Standard:
                        case PlaylistType.Auto:

                            tss = new ToolStripSeparator();
                            cms.Items.Add(tss);

                            tsi        = new ToolStripMenuItem("Send to iTunes...");
                            tsi.Click += (s, ee) =>
                            {
                                try
                                {
                                    iTunes.CreatePlaylist(Values[SelectedIndex], Database.GetPlaylistTracks(Values[SelectedIndex]));
                                }
                                catch
                                {
                                    iTunes.ShowError();
                                }
                            };
                            tsi.Enabled = !iTunes.Busy;
                            cms.Items.Add(tsi);

                            if (iTunes.Busy)
                            {
                                tsi        = new ToolStripMenuItem("Stop sending to iTunes...");
                                tsi.Click += (s, ee) =>
                                {
                                    iTunes.Cancel = true;
                                };
                                cms.Items.Add(tsi);
                            }

                            break;
                        }
                    }
                    if (SelectedIndex > ANY_INDEX)
                    {
                        tss = new ToolStripSeparator();
                        cms.Items.Add(tss);

                        tsi        = new ToolStripMenuItem(Localization.Get(UI_Key.Filter_Value_List_Release_Filter));
                        tsi.Click += (s, ee) => controller.RequestAction(QActionType.ReleaseCurrentFilter);

                        cms.Items.Add(tsi);
                    }

                    cms.Show(this, e.Location);
                }
            }
        }
Exemple #18
0
        public frmMain()
        {
            instance = this;

            if (SingletonApp.AlreadyExists)
            {
                if (Environment.GetCommandLineArgs().Length < 2)
                {
                    QMessageBox.Show(this,
                                     Localization.Get(UI_Key.Dialog_Already_Running, Application.ProductName),
                                     Localization.Get(UI_Key.Dialog_Already_Running_Title),
                                     QMessageBoxIcon.Information);
                }
                else
                {
                    SingletonApp.NotifyExistingInstance(Environment.GetCommandLineArgs());
                }
                abort = true;
                return;
            }
            else
            {
                string arg = String.Empty;
                if (Environment.GetCommandLineArgs().Length > 1)
                {
                    arg = Environment.GetCommandLineArgs()[1];
                }

                switch (arg.ToLowerInvariant())
                {
                case "/reinstall":
                case "/hideicons":
                case "/showicons":
                    abort = true;
                    return;

                default:
                    SingletonApp.Initialize();
                    SingletonApp.NewInstanceMessage += new NewInstanceMessageEventHandler(SingleInstanceApplication_NewInstanceMessage);
                    break;
                }
            }

            settingView = false;
            locked      = false;

            setupControls();

            init();

            initialized = true;

            initalizeController();

            mnuMain.Renderer = new MenuItemRenderer();

            screenSaverWasActive = Lib.ScreenSaverIsActive;

            if (Setting.DisableScreensaver)
            {
                Lib.ScreenSaverIsActive = false;
            }

            this.KeyPreview = true;

            SetView(ViewType.Normal, false);

            preventPowerEvent();

            QSplitContainer.Initialized = true;
#if DEBUG
            setupTestMenu();

            Started = true;
#endif
        }
Exemple #19
0
 public static void ShowError()
 {
     QMessageBox.Show(frmMain.GetInstance(), "iTunes Error - Is iTunes installed?", "iTunes Error", QMessageBoxIcon.Error);
 }
Exemple #20
0
        private bool updateThisOnly()
        {
            string path;

            try
            {
                path = Path.GetFullPath(txtFilePath.Text);
            }
            catch
            {
                QMessageBox.Show(this,
                                 Localization.Get(UI_Key.Find_File_Illegal_Path),
                                 Localization.Get(UI_Key.Find_File_Illegal_Path_Title),
                                 QMessageBoxIcon.Error);
                return(false);
            }

            if (!File.Exists(txtFilePath.Text))
            {
                QMessageBox.Show(this,
                                 Localization.Get(UI_Key.Find_File_File_Not_Found, txtFilePath.Text),
                                 Localization.Get(UI_Key.Find_File_File_Not_Found_Title),
                                 QMessageBoxIcon.Error);
                return(false);
            }
            else if (Database.TrackExists(t => t.FilePath == path))
            {
                QMessageBox.Show(this,
                                 Localization.Get(UI_Key.Find_File_File_Already_Exists, txtFilePath.Text),
                                 Localization.Get(UI_Key.Find_File_File_Already_Exists_Title),
                                 QMessageBoxIcon.Error);
                return(false);
            }
            else
            {
                Track t = Track.Load(txtFilePath.Text);
                if (t == null)
                {
                    QMessageBox.Show(this,
                                     Localization.Get(UI_Key.Find_File_File_Error),
                                     Localization.Get(UI_Key.Find_File_File_Error_Title),
                                     QMessageBoxIcon.Error);
                    return(false);
                }
                else if (t.Artist != track.Artist || t.Title != track.Title || t.Album != track.Album)
                {
                    if (QMessageBox.Show(this,
                                         Localization.Get(UI_Key.Find_File_Different_Information,
                                                          track.Artist,
                                                          track.Title,
                                                          track.Album,
                                                          t.Artist,
                                                          t.Title,
                                                          t.Album,
                                                          Environment.NewLine),
                                         Localization.Get(UI_Key.Find_File_Different_Information_Title),
                                         QMessageBoxButtons.OKCancel,
                                         QMessageBoxIcon.Question,
                                         QMessageBoxButton.NoCancel)
                        == DialogResult.Cancel)
                    {
                        return(false);
                    }
                }
                track.FilePath      = t.FilePath;
                track.ConfirmExists = true;
                return(true);
            }
        }