private void OnViewModeChanged(object o, ChangedArgs args)
 {
     if (args.Current.Value == 0)
     {
         LayoutLeft();
         BrowserPosition.Set("left");
     }
     else
     {
         LayoutTop();
         BrowserPosition.Set("top");
     }
 }
 private void OnViewModeChanged(object o, ChangedArgs args)
 {
     //Hyena.Log.InformationFormat ("ListBrowser mode toggled, val = {0}", args.Current.Value);
     if (args.Current.Value == 0)
     {
         LayoutLeft();
         BrowserPosition.Set("left");
     }
     else
     {
         LayoutTop();
         BrowserPosition.Set("top");
     }
 }
        protected string Layout()
        {
            string position = ForcePosition == null?BrowserPosition.Get() : ForcePosition;

            if (position == "top")
            {
                LayoutTop();
            }
            else
            {
                LayoutLeft();
            }
            return(position);
        }
        public FilteredListSourceContents(string name)
        {
            this.name = name;
            InitializeViews();

            string position = ForcePosition == null?BrowserPosition.Get() : ForcePosition;

            if (position == "top")
            {
                LayoutTop();
            }
            else
            {
                LayoutLeft();
            }

            if (ForcePosition != null)
            {
                return;
            }

            if (ServiceManager.Contains("InterfaceActionService"))
            {
                action_service = ServiceManager.Get <InterfaceActionService> ();

                if (action_service.FindActionGroup("BrowserView") == null)
                {
                    browser_view_actions = new ActionGroup("BrowserView");

                    browser_view_actions.Add(new RadioActionEntry [] {
                        new RadioActionEntry("BrowserLeftAction", null,
                                             Catalog.GetString("Browser on Left"), null,
                                             Catalog.GetString("Show the artist/album browser to the left of the track list"), 0),

                        new RadioActionEntry("BrowserTopAction", null,
                                             Catalog.GetString("Browser on Top"), null,
                                             Catalog.GetString("Show the artist/album browser above the track list"), 1),
                    }, position == "top" ? 1 : 0, null);

                    browser_view_actions.Add(new ToggleActionEntry [] {
                        new ToggleActionEntry("BrowserVisibleAction", null,
                                              Catalog.GetString("Show Browser"), "<control>B",
                                              Catalog.GetString("Show or hide the artist/album browser"),
                                              null, BrowserVisible.Get())
                    });

                    action_service.AddActionGroup(browser_view_actions);
                    //action_merge_id = action_service.UIManager.NewMergeId ();
                    action_service.UIManager.AddUiFromString(menu_xml);
                }

                (action_service.FindAction("BrowserView.BrowserLeftAction") as RadioAction).Changed += OnViewModeChanged;
                (action_service.FindAction("BrowserView.BrowserTopAction") as RadioAction).Changed  += OnViewModeChanged;
                action_service.FindAction("BrowserView.BrowserVisibleAction").Activated             += OnToggleBrowser;
            }

            ServiceManager.SourceManager.ActiveSourceChanged += delegate {
                Banshee.Base.ThreadAssist.ProxyToMain(delegate {
                    browser_container.Visible = ActiveSourceCanHasBrowser ? BrowserVisible.Get() : false;
                });
            };

            NoShowAll = true;
        }
        /// <summary>
        /// Constructor -- creates the source contents for a plugin and sets up the event handlers for the view
        /// and the plugin refresh events.
        /// </summary>
        /// <param name="plugin">
        /// A <see cref="ILiveRadioPlugin"/> -- the plugin to set up the source contents for.
        /// </param>
        public LiveRadioPluginSourceContents(ILiveRadioPlugin plugin)
        {
            base.Name   = plugin.Name;
            this.plugin = plugin;

            InitializeViews();

            string position = ForcePosition == null?BrowserPosition.Get() : ForcePosition;

            if (position == "top")
            {
                LayoutTop();
            }
            else
            {
                LayoutLeft();
            }

            plugin.GenreListLoaded        += OnPluginGenreListLoaded;
            plugin.RequestResultRetrieved += OnPluginRequestResultRetrieved;

            if (ForcePosition != null)
            {
                return;
            }

            if (ServiceManager.Contains("InterfaceActionService"))
            {
                action_service = ServiceManager.Get <InterfaceActionService> ();

                if (action_service.FindActionGroup("BrowserView") == null)
                {
                    browser_view_actions = new ActionGroup("BrowserView");

                    browser_view_actions.Add(new RadioActionEntry [] {
                        new RadioActionEntry("BrowserLeftAction", null,
                                             AddinManager.CurrentLocalizer.GetString("Browser on Left"), null,
                                             AddinManager.CurrentLocalizer.GetString("Show the artist/album browser to the left of the track list"), 0),

                        new RadioActionEntry("BrowserTopAction", null,
                                             AddinManager.CurrentLocalizer.GetString("Browser on Top"), null,
                                             AddinManager.CurrentLocalizer.GetString("Show the artist/album browser above the track list"), 1),
                    }, position == "top" ? 1 : 0, null);

                    browser_view_actions.Add(new ToggleActionEntry [] {
                        new ToggleActionEntry("BrowserVisibleAction", null,
                                              AddinManager.CurrentLocalizer.GetString("Show Browser"), "<control>B",
                                              AddinManager.CurrentLocalizer.GetString("Show or hide the artist/album browser"),
                                              null, BrowserVisible.Get())
                    });


                    action_service.AddActionGroup(browser_view_actions);
                    action_service.UIManager.AddUiFromString(menu_xml);
                }

                (action_service.FindAction("BrowserView.BrowserLeftAction") as RadioAction).Changed += OnViewModeChanged;
                (action_service.FindAction("BrowserView.BrowserTopAction") as RadioAction).Changed  += OnViewModeChanged;
                action_service.FindAction("BrowserView.BrowserVisibleAction").Activated             += OnToggleBrowser;
            }

            ServiceManager.SourceManager.ActiveSourceChanged += delegate {
                ThreadAssist.ProxyToMain(delegate {
                    browser_container.Visible = ActiveSourceCanHasBrowser ? BrowserVisible.Get() : false;
                });
            };

            NoShowAll = true;
        }