Ejemplo n.º 1
0
        private void MyToolWindow_Loaded(object sender, RoutedEventArgs e)
        {
            lvm = ListViewMode.kPlayList;
            UpdateUIColors();

            if (!Command1Package.isAuthenticated())
            {
                Command1Package.AuthenticateSpotifyWeb();
            }


            if (Command1Package.spotWeb != null)
            {
                RetreivePlayListsFromWeb();
                ShowPlayListsInView();
            }
            else
            {
                MessageBox.Show("Sorry, authentication failed, its needed for this feature.");
            }



            listView.Height = this.ActualHeight;// - WindowTitle.ActualHeight;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Command2"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private Command2(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.MenuItemCallback, menuCommandID);
                //commandService.AddCommand(menuItem);

                OleMenuCommand myOleCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID);
                buttonMenuCommand = myOleCommand;
                if (!Command1Package.CommandShouldShowText())
                {
                    myOleCommand.Text = " ";
                }
                commandService.AddCommand(myOleCommand);
            }
        }
Ejemplo n.º 3
0
 private void TimerAnimateOriginal(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (myOleCommand.Text.Length <= kSpotifyOpenString.Length)
     {
         timer.Stop();
         timer.Elapsed -= TimerAnimateOriginal;
         timer          = null;
         if (Command1Package.SpotifyCommandShouldShowText())
         {
             myOleCommand.Text = kSpotifyOpenString;
         }
         else
         {
             myOleCommand.Text = " ";
         }
     }
     else
     {
         if (myOleCommand.Text.Length > kSpotifyOpenString.Length)
         {
             myOleCommand.Text = myOleCommand.Text.Remove(myOleCommand.Text.Length - 1);
         }
         else
         {
             myOleCommand.Text += " ";
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Command3"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private Command3(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                // var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
                // commandService.AddCommand(menuItem);

                myOleCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID);
                if (!Command1Package.CommandShouldShowText())
                {
                    myOleCommand.Text = " ";
                }

                //Microsoft.VisualStudio.Shell.ServiceProvider serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(((EnvDTE.DTE)Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE))) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
                //IVsUIShell uiShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;
                //uiShell.UpdateCommandUI(0);

                commandService.AddCommand(myOleCommand);
            }
        }
Ejemplo n.º 5
0
        private void TrackChangeTimerTick(object sender, System.Timers.ElapsedEventArgs e)
        {
            Console.WriteLine("Set Command4 back to original String.");
            timer.Stop();
            timer.Elapsed -= TrackChangeTimerTick;

            // set timer to null, and set string back to original spotify string.
            // done if user disabled animation otherwise execute animation if it is not disabled with define NO_ANIM
            if (!UserPreferences.Default.EnableInteractiveAnimation)
            {
                timer = null;
                if (Command1Package.SpotifyCommandShouldShowText())
                {
                    myOleCommand.Text = kSpotifyOpenString;
                }
                else
                {
                    myOleCommand.Text = " ";
                }
                return;
            }

#if NO_ANIM
            timer             = null;
            myOleCommand.Text = kSpotifyOpenString;
#else
            timer.Elapsed += TimerAnimateOriginal;
            timer.Interval = kANIMATE_SPOT_STRING;
            timer.Start();
#endif
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
            string title   = "Command4";

            // Show a message box to prove we were here
            //VsShellUtilities.ShowMessageBox(
            //    this.ServiceProvider,
            //    message,
            //    title,
            //    OLEMSGICON.OLEMSGICON_INFO,
            //    OLEMSGBUTTON.OLEMSGBUTTON_OK,
            //    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);

            //Process process = Process.Start("Spotify.exe");
            //int id = process.Id;
            //Process tempProc = Process.GetProcessById(id);
            //this.Visible = false;
            //tempProc.WaitForExit();
            //this.Visible = true;

            //myOleCommand.Text = "Test.";

            Process[] retrevedProc = Process.GetProcessesByName("Spotify");
            Process   spotMain     = null;

            foreach (Process item in retrevedProc)
            {
                if (item.MainWindowTitle != "")
                {
                    spotMain = item;
                    break;
                }
            }

            if (spotMain != null)
            {
                WindowHelper.BringProcessToFront(spotMain);
            }
            else
            {
                Console.WriteLine("Spotify not running.");
                if (!SpotifyAPI.Local.SpotifyLocalAPI.IsSpotifyRunning())
                {
                    SpotifyAPI.Local.SpotifyLocalAPI.RunSpotify();
                    System.Threading.Thread.Sleep(300);
                    Command1Package.SpotifyConnect();
                    SpotClientRegisterTrackChange();
                    Command1Package.UpdateCommandsHiddenState();
                }
                else
                {
                    Console.WriteLine("Something went wrong..\n "
                                      + "Spotify seems to be running but cant focus.");
                }
            }
        }
Ejemplo n.º 7
0
 public void SetStartupCommandTextState()
 {
     if (!Command1Package.CommandShouldShowText())
     {
         buttonMenuCommand.Text = " ";
     }
     else
     {
         buttonMenuCommand.Text = commandText;
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            //string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
            //string title = "Command1";

            string message = string.Format(CultureInfo.CurrentCulture, "Spotify is not running");
            string title   = "SpotifyRemote";

            if (!SpotifyAPI.Local.SpotifyLocalAPI.IsSpotifyRunning())
            {
#if SPOT_WARN_NOT_RUNNING
                VsShellUtilities.ShowMessageBox(
                    this.ServiceProvider,
                    message,
                    title,
                    OLEMSGICON.OLEMSGICON_INFO,
                    OLEMSGBUTTON.OLEMSGBUTTON_OK,
                    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
#endif
                SpotifyAPI.Local.SpotifyLocalAPI.RunSpotify();
                System.Threading.Thread.Sleep(300);
                Command1Package.SpotifyConnect();
                Command4.gCommand4Instance.SpotClientRegisterTrackChange();
                Command1Package.UpdateCommandsHiddenState();
                return;
            }

            if (Command1Package.spotClient == null)
            {
#if DEBUG
                MessageBox.Show("spotClient is null.");
                System.Diagnostics.Debug.Assert(false);

                return;
#endif
            }

            //Play/Pause
            SpotifyAPI.Local.Models.StatusResponse sr;
            sr = Command1Package.spotClient.GetStatus();
            if (!sr.Playing)
            {
                Console.WriteLine("Spotify Play.");
                Command1Package.spotClient.Play();
            }
            else
            {
                Console.WriteLine("Spotify Pause.");
                Command1Package.spotClient.Pause();
            }
        }
Ejemplo n.º 9
0
        public void UpdateTextHiddenState()
        {
            if (!Command1Package.SpotifyCommandShouldShowText() && !UserPreferences.Default.HideButtonTextOnInactive)
            {
                return;
            }

            if (!Command1Package.IsSpotifyProcessRunning())
            {
                buttonMenuCommand.Text = " ";
            }
            else
            {
                buttonMenuCommand.Text = commandText;
            }
        }
Ejemplo n.º 10
0
 public void SetStartupCommandTextState()
 {
     if (!Command1Package.SpotifyCommandShouldShowText())
     {
         myOleCommand.Text = " ";
     }
     else
     {
         if (IsSpotifyProcessRunning())
         {
             myOleCommand.Text = kSpotifyOpenString;
         }
         else
         {
             myOleCommand.Text = kSpotifyStartString;
         }
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Command4"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private Command4(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);

                // var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);

                myOleCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID);

                //if (null != myOleCommand)
                //{
                //    myOleCommand.Text = "New Text";
                //
                //}
                if (IsSpotifyProcessRunning())
                {
                    if (Command1Package.SpotifyCommandShouldShowText())
                    {
                        myOleCommand.Text = kSpotifyOpenString;
                    }
                    else
                    {
                        myOleCommand.Text = " ";
                    }
                }
                else
                {
                    if (UserPreferences.Default.HideButtonTextOnInactive)
                    {
                        myOleCommand.Text = " ";
                    }
                    else
                    {
                        myOleCommand.Text = kSpotifyStartString;
                    }
                }

                Microsoft.VisualStudio.Shell.ServiceProvider serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(((EnvDTE.DTE)Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE))) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
                IVsUIShell uiShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;
                uiShell.UpdateCommandUI(0);

                if (IsSpotifyProcessRunning())
                {
                    SpotClientRegisterTrackChange();
                }

                commandService.AddCommand(myOleCommand);

                gCommand4Instance = this;
            }
        }