当前位置: 首页>>代码示例>>C#>>正文


C# Dialog.Add方法代码示例

本文整理汇总了C#中Dialog.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Dialog.Add方法的具体用法?C# Dialog.Add怎么用?C# Dialog.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dialog的用法示例。


在下文中一共展示了Dialog.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddDialog

	static void AddDialog ()
	{
		int cols = (int) (Application.Cols * 0.7);
		Dialog d = new Dialog (cols, 8, "Add");
		Entry e;
		string name = null;
		
		
		d.Add (new Label (1, 0, "Torrent file:"));
		e = new Entry (1, 1, cols - 6, Environment.CurrentDirectory);
		d.Add (e);

		// buttons
		Button b = new Button ("Ok", true);
		b.Clicked += delegate {
			b.Container.Running = false;
			name = e.Text;
		};
		d.AddButton (b);
		b = new Button ("Cancel");
		b.Clicked += delegate {
			b.Container.Running = false;
		};
		d.AddButton (b);
		
		Application.Run (d);

		if (name != null){
			if (!File.Exists (name)){
				Application.Error ("Missing File", "Torrent file:\n" + name + "\ndoes not exist");
				return;
			}
			torrent_list.Add (name);
		}
	}
开发者ID:Cyarix,项目名称:monotorrent,代码行数:35,代码来源:monotorrent.cs

示例2: OptionsDialog

	static void OptionsDialog ()
	{
		Dialog d = new Dialog (62, 15, "Options");

		d.Add (new Label (1, 1, "  Download Directory:"));
		d.Add (new Label (1, 3, "         Listen Port:"));
		d.Add (new Label (1, 5, "  Upload Speed Limit:"));
		d.Add (new Label (35,5, "kB/s"));
		d.Add (new Label (1, 7, "Download Speed Limit:"));
		d.Add (new Label (35,7, "kB/s"));

		Entry download_dir = new Entry (24, 1, 30, config.DownloadDir);
		d.Add (download_dir);

		Entry listen_port = new Entry (24, 3, 6, config.ListenPort.ToString ());
		d.Add (listen_port);

		Entry upload_limit = new Entry (24, 5, 10, RenderSpeed (config.UploadSpeed / 1024));
		d.Add (upload_limit);

		Entry download_limit = new Entry (24, 7, 10, RenderSpeed (config.DownloadSpeed / 1024));
		d.Add (download_limit);
		
		bool ok = false;
		
		Button b = new Button ("Ok", true);
		b.Clicked += delegate { ok = true; b.Container.Running = false; };
		d.AddButton (b);

		b = new Button ("Cancel");
		b.Clicked += delegate { b.Container.Running = false; };
		d.AddButton (b);
		
		Application.Run (d);

		if (ok){
			int v;
			
			if (!Int32.TryParse (listen_port.Text, out v)){
				Application.Error ("Error", "The value `{0}' is not a valid port number", listen_port.Text);
				return;
			}

			if (!Directory.Exists (download_dir.Text)){
				Application.Error ("Error", "The directory\n{0}\ndoes not exist", download_dir.Text);
				return;
			}

			if (!ValidateSpeed (upload_limit, out config.UploadSpeed))
				return;

			if (!ValidateSpeed (download_limit, out config.DownloadSpeed))
				return;

			config.DownloadDir = download_dir.Text;
			config.ListenPort = v;

			// The user enters in kB/sec, the engine expects bytes/sec
			config.UploadSpeed *= 1024;
			config.DownloadSpeed *= 1024;
			TorrentCurses.engine.Settings.GlobalMaxUploadSpeed = config.UploadSpeed;
			TorrentCurses.engine.Settings.GlobalMaxDownloadSpeed = config.DownloadSpeed;
		}
	}
开发者ID:Cyarix,项目名称:monotorrent,代码行数:64,代码来源:monotorrent.cs

示例3: TorrentControl

		public void TorrentControl (int selected)
		{
			Dialog d = new Dialog (60, 8, "Torrent Control");

			TorrentManager item = items [selected];
			
			d.Add (new TrimLabel (1, 1, 60-6, item.Torrent.Name));

			bool stopped = item.State == TorrentState.Stopped;
			Button bstartstop = new Button (stopped ? "Start" : "Stop");
			bstartstop.Clicked += delegate {
				if (stopped)
					item.Start();
				else
					item.Stop();
				d.Running = false;
				
			};
			d.AddButton (bstartstop);
			
			// Later, when we hook it up, look up the state
			
			bool paused = item.State == TorrentState.Paused;
			Button br = new Button (paused ? "Resume" : "Pause");
			br.Clicked += delegate {
				if (paused)
					item.Start();
				else
					item.Pause();
				d.Running = false;
			};
			d.AddButton (br);

			Button bd = new Button ("Delete");
			bd.Clicked += delegate {
				Application.Error ("Not Implemented",
						   "I have not implemented delete yet");
				d.Running = false;
			};
			d.AddButton (bd);
			
			Button bmap = new Button ("Map");
			bmap.Clicked += delegate {
				Application.Error ("Not Implemented",
						   "I have not implemented map yet");
				d.Running = false;
			};
			d.AddButton (bmap);

			Button bcancel = new Button ("Cancel");
			bcancel.Clicked += delegate {
				d.Running = false;
			};
			Application.Run (d);
			UpdateStatus ();
		}
开发者ID:Cyarix,项目名称:monotorrent,代码行数:56,代码来源:monotorrent.cs


注:本文中的Dialog.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。