コード例 #1
0
        public TorrentContextMenu(TorrentController torrentController)
        {
            this.torrentController = torrentController;

            ImageMenuItem startItem   = new ImageMenuItem("Start/Pause");
            ImageMenuItem stopItem    = new ImageMenuItem("Stop");
            ImageMenuItem removeItem  = new ImageMenuItem("Remove");
            ImageMenuItem deleteItem  = new ImageMenuItem("Delete");
            ImageMenuItem recheckItem = new ImageMenuItem("Force Re-_check");
            //ImageMenuItem hashItem  = new ImageMenuItem("Force Re-_hash");
            ImageMenuItem announceItem = new ImageMenuItem("Force _announce");

            startItem.Image   = new Image(Stock.MediaPlay, IconSize.Menu);
            stopItem.Image    = new Image(Stock.MediaStop, IconSize.Menu);
            removeItem.Image  = new Image(Stock.Remove, IconSize.Menu);
            deleteItem.Image  = new Image(Stock.Delete, IconSize.Menu);
            recheckItem.Image = new Image(Stock.Refresh, IconSize.Menu);
            //hashItem.Image = new Image(Stock.Convert, IconSize.Menu);
            announceItem.Image = new Image(Stock.Network, IconSize.Menu);

            startItem.Activated   += OnStartItemActivated;
            stopItem.Activated    += OnStopItemActivated;
            removeItem.Activated  += OnRemoveItemActivated;
            deleteItem.Activated  += OnDeleteItemActivated;
            recheckItem.Activated += OnRecheckItemActivated;
            //hashItem.Activated += OnHashItemActivated;
            announceItem.Activated += OnAnnounceItemActivated;

            Append(startItem);
            Append(stopItem);
            Append(removeItem);
            Append(deleteItem);
            Append(new SeparatorMenuItem());
            Append(recheckItem);
            //Append(hashItem);
            Append(announceItem);

            selectedTorrent = torrentController.GetSelectedTorrent();

            switch (selectedTorrent.State)
            {
            case TorrentState.Downloading:
                startItem.Image = new Image(Stock.MediaPause, IconSize.Menu);
                break;

            case TorrentState.Seeding:
                startItem.Image = new Image(Stock.MediaPause, IconSize.Menu);
                break;

            case TorrentState.Stopped:
                stopItem.Sensitive = false;
                break;

            default:
                break;
            }
        }
コード例 #2
0
		public TorrentContextMenu(TorrentController torrentController)
		{
			this.torrentController = torrentController;
			
			ImageMenuItem startItem = new ImageMenuItem("Start/Pause");
			ImageMenuItem stopItem  = new ImageMenuItem("Stop");
			ImageMenuItem removeItem  = new ImageMenuItem("Remove");
			ImageMenuItem deleteItem  = new ImageMenuItem("Delete");
			ImageMenuItem recheckItem  = new ImageMenuItem("Force Re-_check");
			//ImageMenuItem hashItem  = new ImageMenuItem("Force Re-_hash");
			ImageMenuItem announceItem  = new ImageMenuItem("Force _announce");
			
			startItem.Image = new Image(Stock.MediaPlay, IconSize.Menu);
			stopItem.Image = new Image(Stock.MediaStop, IconSize.Menu);
			removeItem.Image = new Image(Stock.Remove, IconSize.Menu);
			deleteItem.Image = new Image(Stock.Delete, IconSize.Menu);
			recheckItem.Image = new Image(Stock.Refresh, IconSize.Menu);
			//hashItem.Image = new Image(Stock.Convert, IconSize.Menu);
			announceItem.Image = new Image(Stock.Network, IconSize.Menu);
			
			startItem.Activated += OnStartItemActivated;
			stopItem.Activated += OnStopItemActivated;
			removeItem.Activated += OnRemoveItemActivated;
			deleteItem.Activated += OnDeleteItemActivated;
			recheckItem.Activated += OnRecheckItemActivated;
			//hashItem.Activated += OnHashItemActivated;
			announceItem.Activated += OnAnnounceItemActivated;
			
			Append(startItem);
			Append(stopItem);
			Append(removeItem);
			Append(deleteItem);
			Append(new SeparatorMenuItem());
			Append(recheckItem);
			//Append(hashItem);
			Append(announceItem);
			
			selectedTorrent = torrentController.GetSelectedTorrent();
			
			switch(selectedTorrent.State)
			{
				case TorrentState.Downloading:
					startItem.Image = new Image(Stock.MediaPause, IconSize.Menu);
					break;
				case TorrentState.Seeding:
					startItem.Image = new Image(Stock.MediaPause, IconSize.Menu);
					break;
				case TorrentState.Stopped:
					stopItem.Sensitive = false;
					break;
				default:
					break;
			}
		}
コード例 #3
0
        private void OnTorrentDragDataGet(object o, DragDataGetArgs args)
        {
            // TODO: Support dragging multiple torrents to a label
            TorrentManager manager;

            manager = torrentController.GetSelectedTorrent();
            if (manager == null)
            {
                return;
            }

            args.SelectionData.Set(Gdk.Atom.Intern("application/x-monotorrent-torrentmanager-objects", false), 8, Encoding.UTF8.GetBytes(manager.GetHashCode().ToString()));
        }