Beispiel #1
0
    static void RunGui()
    {
        Container a = new Container(0, 0, Application.Cols, Application.Lines);

        Frame ftorrents = new Frame(0, 0, 0, 0, "Torrents");

        a.Add(ftorrents);

        // Add
        Button badd = new Button(1, 1, "Add");

        badd.Clicked += delegate { AddDialog(); };
        ftorrents.Add(badd);

        // Options
        Button boptions = new Button(9, 1, "Options");

        boptions.Clicked += delegate { OptionsDialog(); };
        ftorrents.Add(boptions);

        // Quit
        Button bquit = new Button(21, 1, "Quit");

        bquit.Clicked += delegate {
            // FIXME: shut down torrent here
            a.Running = false;
        };
        ftorrents.Add(bquit);

        // Random widget tests
        //f.Add (new Label (7,  3, "Name:"));
        //f.Add (new Entry (13, 3, 20, "First"));

        //f.Add (new Label (4,  5, "Address:"));
        //f.Add (new Entry (13, 5, 20, "Second"));

        ListView ltorrents = new ListView(1, 5, 0, 0, torrent_list);

        ltorrents.Fill = Fill.Horizontal | Fill.Vertical;
        ftorrents.Add(ltorrents);

        Frame fprogress = new Frame("Messages");

        fprogress.Add(log_widget = new LogWidget(0, 0));
        a.Add(fprogress);

        // For testing focus, not ready
        //f.Add (new Label (0, 0, "->0<-"));
        //f.Add (new Entry  (7, 0, 20, "Another"));


        // Details
        Frame fdetails = new Frame("Details");

        fdetails.Add(new Label(1, 1, "Files for: "));
        torrent_name      = new TrimLabel(12, 1, 10, "");
        torrent_name.Fill = Fill.Horizontal;
        fdetails.Add(torrent_name);

        details_list      = new TorrentDetailsList();
        list_details      = new ListView(1, 3, 0, 0, details_list);
        list_details.Fill = Fill.Horizontal | Fill.Vertical;
        fdetails.Add(list_details);

        a.Add(fdetails);

        // Status
        Frame fstatus = SetupStatus();

        a.Add(fstatus);

        iteration = new Label(35, 0, "0");
        fstatus.Add(iteration);

        Application.Timeout = 1000;

        Application.Iteration += delegate {
            iteration.Text = (it++).ToString();
            UpdateStatus();
            lock (queue){
                if (queue.Count > 0)
                {
                    foreach (string s in queue)
                    {
                        log_widget.AddText(s);
                    }
                    queue.Clear();
                }
            }
            Application.Refresh();
        };

        LayoutDialogs(ftorrents, fstatus, fdetails, fprogress);
        a.SizeChangedEvent += delegate {
            LayoutDialogs(ftorrents, fstatus, fdetails, fprogress);
        };

        UpdateStatus();
        Application.Run(a);
    }
Beispiel #2
0
	static void RunGui ()
	{
		Container a = new Container (0, 0, Application.Cols, Application.Lines);

		Frame ftorrents = new Frame (0,  0, 0, 0, "Torrents");
		a.Add (ftorrents);

		// Add
		Button badd = new Button (1, 1, "Add");
		badd.Clicked += delegate { AddDialog (); };
		ftorrents.Add (badd);

		// Options
		Button boptions = new Button (9, 1, "Options");
		boptions.Clicked += delegate { OptionsDialog (); };
		ftorrents.Add (boptions);

		// Quit
		Button bquit = new Button (21, 1, "Quit");
		bquit.Clicked += delegate {
			// FIXME: shut down torrent here
			a.Running = false;
		};
		ftorrents.Add (bquit);
		
		// Random widget tests
		//f.Add (new Label (7,  3, "Name:"));
		//f.Add (new Entry (13, 3, 20, "First"));
		
		//f.Add (new Label (4,  5, "Address:"));
		//f.Add (new Entry (13, 5, 20, "Second"));

		ListView ltorrents = new ListView (1, 5, 0, 0, torrent_list);
		ltorrents.Fill = Fill.Horizontal | Fill.Vertical;
		ftorrents.Add (ltorrents);
		
		Frame fprogress = new Frame ("Messages");
		fprogress.Add (log_widget = new LogWidget (0, 0));
		a.Add (fprogress);

		// For testing focus, not ready
		//f.Add (new Label (0, 0, "->0<-"));
		//f.Add (new Entry  (7, 0, 20, "Another"));


		// Details
		Frame fdetails = new Frame ("Details");
		fdetails.Add (new Label (1, 1, "Files for: "));
		torrent_name = new TrimLabel (12, 1, 10, "");
		torrent_name.Fill = Fill.Horizontal;
		fdetails.Add (torrent_name);
			      
		details_list = new TorrentDetailsList ();
		list_details = new ListView (1, 3, 0, 0, details_list);
		list_details.Fill = Fill.Horizontal | Fill.Vertical;
		fdetails.Add (list_details);
		
		a.Add (fdetails);

		// Status
		Frame fstatus = SetupStatus ();
		a.Add (fstatus);

		iteration = new Label (35, 0, "0");
		fstatus.Add (iteration);
		
		Application.Timeout = 1000;

		Application.Iteration += delegate {
			iteration.Text = (it++).ToString ();
			UpdateStatus ();
			lock (queue){
				if (queue.Count > 0){
					foreach (string s in queue){
						log_widget.AddText (s);
					}
					queue.Clear ();
				}
			}
			Application.Refresh ();
		};
		
		LayoutDialogs (ftorrents, fstatus, fdetails, fprogress);
		a.SizeChangedEvent += delegate {
			LayoutDialogs (ftorrents, fstatus, fdetails, fprogress);
		};

		UpdateStatus ();
		Application.Run (a);
	}
Beispiel #3
0
    static void Main()
    {
        Application.Init(false);

        var frame = new Frame(0, 0, Application.Cols, Application.Lines, "List");
        var top   = new Container(0, 0, Application.Cols, Application.Lines)
        {
            frame
        };
        // Add
        Button badd = new Button(1, 1, "Add");

        badd.Clicked += delegate { AddDialog(); };
        frame.Add(badd);

        // Options
        Button boptions = new Button(9, 1, "Options");

        boptions.Clicked += delegate { OptionsDialog(); };
        frame.Add(boptions);

        // Quit
        Button bquit = new Button(21, 1, "Quit");

        bquit.Clicked += delegate {
            // FIXME: shut down torrent here
            top.Running = false;
        };
        frame.Add(bquit);

        ListView list = new ListView(1, 5, 0, 0, new TorrentDetailsList());

        list.Fill = Fill.Horizontal | Fill.Vertical;
        frame.Add(list);

        Frame     fprogress  = new Frame("Messages");
        LogWidget log_widget = new LogWidget(0, 0);

        fprogress.Add(log_widget);
        top.Add(fprogress);

        // For testing focus, not ready
        //f.Add (new Label (0, 0, "->0<-"));
        //f.Add (new Entry  (7, 0, 20, "Another"));


        // Details
        Frame fdetails = new Frame("Details");

        fdetails.Add(new Label(1, 1, "Files for: "));
        var torrent_name = new TrimLabel(12, 1, 10, "");

        torrent_name.Fill = Fill.Horizontal;
        fdetails.Add(torrent_name);

        var details_list = new TorrentDetailsList();
        var list_details = new ListView(1, 3, 0, 0, details_list);

        list_details.Fill = Fill.Horizontal | Fill.Vertical;
        fdetails.Add(list_details);

        top.Add(fdetails);

        // Status
        Frame fstatus = SetupStatus();

        top.Add(fstatus);

        iteration = new Label(35, 0, "0");
        fstatus.Add(iteration);

        int it = 0;

        Application.MainLoop.AddTimeout(TimeSpan.FromSeconds(1), (mainloop) => {
            iteration.Text = (it++).ToString();
            UpdateStatus();
            log_widget.AddText("Iteration " + it);
            Application.Refresh();
            return(true);
        });

        LayoutDialogs(frame, fstatus, fdetails, fprogress);
        top.SizeChangedEvent += delegate {
            LayoutDialogs(frame, fstatus, fdetails, fprogress);
        };

        UpdateStatus();

        Application.Run(top);
    }