Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Application.Init ();
            //MainWindow win = new MainWindow ();
            //win.Show ();
            MoonlightRuntime.Init ();
            Window w = new Window ("mldsp");
            w.DefaultHeight = 520;
            w.DefaultWidth = 760;
            w.DeleteEvent += delegate { Application.Quit (); };

            var moon = new MoonlightHost ();
            var xappath = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (new Uri (typeof (MainClass).Assembly.CodeBase).LocalPath), "mldsp.clr.xap");
            moon.LoadXap (xappath);
            if (args.Length > 0) {
                int device;
                if (int.TryParse (args [0], out device))
                    ((mldsp.App) moon.Application).OutputDeviceID = device;
                else {
                    Console.WriteLine ("WARNING: wrong device ID speficication. Specify an index.");
                    foreach (var dev in PortMidiSharp.MidiDeviceManager.AllDevices)
                        if (dev.IsOutput)
                            Console.WriteLine ("{0} {1}", dev.ID, dev.Name);
                }
            }

            var vbox = new VBox (false, 0);
            w.Add (vbox);
            var mainmenu = new MenuBar ();
            vbox.PackStart (mainmenu, false, true, 0);
            var optmi = new MenuItem ("_Options");
            mainmenu.Add (optmi);
            var devmi = new MenuItem ("Select Device");
            var optmenu = new Menu ();
            optmi.Submenu = optmenu;
            optmenu.Append (devmi);
            var devlist = new SList (IntPtr.Zero);
            var devmenu = new Menu ();
            devmi.Submenu = devmenu;
            foreach (var dev in PortMidiSharp.MidiDeviceManager.AllDevices) {
                if (dev.IsOutput) {
                    var mi = new RadioMenuItem (devlist, dev.Name);
                    mi.Data ["Device"] = dev.ID;
                    devlist = mi.Group;
                    int id = dev.ID;
                    mi.Activated += delegate {
                        ((mldsp.App) moon.Application).ResetDevice ((int) mi.Data ["Device"]);
                    };
                    devmenu.Append (mi);
                }
            }

            vbox.PackEnd (moon);

            w.ShowAll ();
            Application.Run ();
        }
Exemplo n.º 2
0
#pragma warning disable 219
	public void UpdateBookmarkList(List<string> items)
	{
		Menu bookmarksSub = new Menu();
		Menu addAllSub = new Menu();
		Menu addSelSub = new Menu();
	
		CacheStore store = Engine.getInstance().Store;
		int count = 0;
		GLib.SList grp = new GLib.SList(IntPtr.Zero);
		RadioAction noList = new RadioAction("None", Catalog.GetString("None"), null, null, count);
		noList.Active = true;
		noList.Toggled += HandleNoListToggled;
		bookmarksSub.Append(noList.CreateMenuItem());
		bookmarksSub.Append(new MenuItem());
		foreach (string str in items)
		{
			RadioAction action = new RadioAction(str, str, null, null, count);
			action.Group = noList.Group;
			action.Toggled += HandleActionToggled;
			bookmarksSub.Append(action.CreateMenuItem());
			MenuItem bookmarkAll = new MenuItem(str);
			if (store.BookmarkList == str)
				bookmarkAll.Sensitive = false;
			bookmarkAll.Activated += HandleBookmarkAllActivated;
			addAllSub.Append(bookmarkAll);
			MenuItem bookmarkSel = new MenuItem(str);
			if (store.BookmarkList == str)
				bookmarkSel.Sensitive = false;
			bookmarkSel.Activated += HandleBookmarkSelActivated;
			addSelSub.Append(bookmarkSel);
			if (str == store.BookmarkList)
				action.Active = true;
			count++;
		}
		if (items.Count != 0)
		{
			bmrkLists.Submenu = bookmarksSub;
			bmrkLists.Sensitive = true;
			addVisibleCaches.Submenu = addAllSub;
			addVisibleCaches.Sensitive = true;
			addCacheTo.Submenu = addSelSub;
			addCacheTo.Sensitive = true;
		}
		else
		{
			bmrkLists.Sensitive = false;
			bmrkLists.Submenu = null;
			addVisibleCaches.Submenu = null;
			addVisibleCaches.Sensitive = false;
			addCacheTo.Submenu = null;
			addCacheTo.Sensitive = false;
		}
		bmrkLists.ShowAll();
		addVisibleCaches.ShowAll();
		addCacheTo.ShowAll();		
	}
Exemplo n.º 3
0
    private SharpMusique( string [] args )
    {
        int i;
        string strPath;
        TreeViewColumn tvc;
        CellRenderer rendr;

        string [] strColumns = new string[]
        {
            "Title", "Artist", "Album", "Time", "Price"
        };

        string [] strCWidths = new string[]
        {
            "260", "190", "180", "70", "70"
        };

        if( Environment.OSVersion.ToString().IndexOf( "Unix" ) != -1 )
        {
            strHomeDir = Environment.GetEnvironmentVariable( "HOME" );
            strSongDir = Path.Combine( strHomeDir, "Music" );
            strDataDir = Path.Combine( strHomeDir, ".SharpMusique" );
        }
        else
        {
            strHomeDir = Environment.GetFolderPath(
                Environment.SpecialFolder.ApplicationData );
            strSongDir = Environment.GetFolderPath(
                Environment.SpecialFolder.MyMusic );
            strDataDir = Path.Combine( strHomeDir, "SharpMusique" );
        }

        Utility.CreateDirectory( strDataDir );

        strPath = Path.Combine( strDataDir, "songdir" );
        if( File.Exists( strPath ) )
        {
            StreamReader sr = new StreamReader( strPath );
            strSongDir = sr.ReadToEnd().Trim();
            sr.Close();
        }

        Utility.CreateDirectory( strSongDir );

        strPath = Path.Combine( strDataDir, "cwidths" );
        if( File.Exists( strPath ) )
        {
            StreamReader sr = new StreamReader( strPath );
            string [] strTmp = sr.ReadToEnd().Split( ',' );
            sr.Close();

            if( strTmp.Length == strCWidths.Length )
                strCWidths = strTmp;
        }

        Application.Init();

        Glade.XML gxml = new Glade.XML( null, "SharpMusique.glade",
                                        "MainWindow", null );
        gxml.Autoconnect( this );

        MainWindow.Icon = new Gdk.Pixbuf( null, "sharpmusique.png" );

        songls = new ListStore( GType.String, GType.String, GType.String,
                                GType.String, GType.String, GType.Int );

        songtv.Model = songls;
        songtv.HeadersClickable = true;
        songtv.Selection.Changed += new EventHandler( OnTreeViewSelection );

        for( i = 0; i < strColumns.Length; i++ )
        {
            tvc = new TreeViewColumn();
            rendr = new CellRendererText();
            tvc.Title = strColumns[ i ];
            tvc.PackStart( rendr, true );
            tvc.AddAttribute( rendr, "text", i );
            tvc.Sizing = TreeViewColumnSizing.Fixed;
            tvc.FixedWidth = Convert.ToInt32( strCWidths[ i ] );
            tvc.Resizable = true;
            tvc.SortColumnId = i;
            songtv.AppendColumn( tvc );
        }

        strPath = Path.Combine( strDataDir, "country" );
        if( File.Exists( strPath ) )
        {
            StreamReader sr = new StreamReader( strPath );
            strCountry = sr.ReadToEnd().Trim();
            sr.Close();
        }

        SList group = new SList( IntPtr.Zero );
        Menu cmenu = new Menu();
        micountry.Submenu = cmenu;
        string [] countries = FairStore.Countries.AllKeys;
        for( i = 0; i < countries.Length; i++ )
        {
            RadioMenuItem rmi = new RadioMenuItem( group, countries[ i ] );
            rmi.Toggled += new EventHandler( OnCountrySelect );
            rmi.Name = countries[ i ];
            if( (((i + 1) == countries.Length) && (strCountry == null)) ||
                countries[ i ].Equals( strCountry ) )
            {
                rmi.Active = true;
            }
            group = rmi.Group;
            cmenu.Append( rmi );
            rmi.Show();
        }

        mipending.Sensitive = false;
        mipepsicap.Sensitive = false;
        migiftcert.Sensitive = false;
        mipreview.Sensitive = false;
        mipurchase.Sensitive = false;
        mipurchasealbum.Sensitive = false;
        miviewalbum.Sensitive = false;

        cidStatus = sbar.GetContextId( "Status" );
        cidProgress = sbar.GetContextId( "Progress" );

        sbar.Push( cidStatus, "Not Logged In" );

        mutex = new Mutex();

        Application.Run();
    }