⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemcontainer.cs

📁 无线网卡接口编程源码
💻 CS
字号:
using System;using Gtk;using Gdk;using Mono.Posix;public class ItemContainer : TreeView{	Pixbuf LightOn, LightOff, Lock, Router;		private enum ItemData {		SSID,		MAC,		Channel,		Rate,		Signal,		Caps,		Pix1,Pix2,Pix3	};	public ItemContainer(Pixbuf lighton, Pixbuf lightoff, Pixbuf lockpad, Pixbuf router){		LightOff = lightoff;		LightOn  = lighton;		Lock     = lockpad;		Router   = router;		Reorderable = true; //<--- doesnt work?		HeadersClickable = true;		HeadersVisible = true;				this.Model = new TreeStore( 			typeof (string),			typeof (string),			typeof (string),			//typeof (ProgressBar),  Gtk# 2.5.x allows this...			typeof (string),			typeof (string),			typeof (string),			typeof (Gdk.Pixbuf),			typeof (Gdk.Pixbuf),			typeof (Gdk.Pixbuf)		);		TreeViewColumn column = new TreeViewColumn ();		CellRendererPixbuf rPixbuf1 = new CellRendererPixbuf ();		CellRendererPixbuf rPixbuf2 = new CellRendererPixbuf ();		CellRendererPixbuf rPixbuf3 = new CellRendererPixbuf ();		CellRendererText rText = new CellRendererText(); 		column.PackStart (rPixbuf1, false);		column.PackStart (rPixbuf2, false);		column.PackStart (rPixbuf3, false);		column.PackStart (rText, false);				column.AddAttribute (rPixbuf1, "pixbuf", (int) ItemData.Pix1);		column.AddAttribute (rPixbuf2, "pixbuf", (int) ItemData.Pix2);		column.AddAttribute (rPixbuf3, "pixbuf", (int) ItemData.Pix3);		column.AddAttribute (rText, "text", (int) ItemData.Signal);				column.Reorderable=true;				AppendColumn(column);			//AppendColumn ("Signal", new CellRendererText (), "text", ItemData.Signal);		//AppendColumn ("MAC", new CellRendererText (), "text", ItemData.MAC);							AppendColumn (Catalog.GetString("Network"), new CellRendererText (), "text", ItemData.SSID).Reorderable=true;		AppendColumn (Catalog.GetString("Rate")   , new CellRendererText (), "text", ItemData.Rate).Reorderable=true;					}	public void Clear(){		((TreeStore)Model).Clear();	}	public void SetFrom(Networks nets, bool OnlineOnly){			Clear();		foreach (Network n in nets.list.Values)			if (OnlineOnly){				if (n.IsOnline)					Add(n);			}			else				Add(n);			}		public string SelectionId{		get {			TreeIter iter;			TreeModel model;			if ( this.Selection.GetSelected(out model,out iter) ) {				string id = (string) ((TreeStore)Model).GetValue(iter,(int)ItemData.SSID);				return id;			}			else				return null;		}	}		public void Add(Network o){		TreeIter iter;		TreeStore store = (TreeStore)Model;		store.Append(out iter);		_Update(store,iter,o); 	}		public void Update(Network o){			TreeIter iter;		TreeStore store = (TreeStore) Model;				bool valid = store.GetIterFirst (out iter);		while (valid) {			string ssid = (string) store.GetValue (iter, (int) ItemData.SSID);			if (ssid == o.SSID) {				_Update(store,iter,o);				return;			}			valid = store.IterNext (ref iter);		}			}	public void _Update(TreeStore s, TreeIter i, Network o){		s.SetValue(i,(int) ItemData.SSID,   o.SSID);		s.SetValue(i,(int) ItemData.MAC,    o.MAC);		s.SetValue(i,(int) ItemData.Channel,o.Channel);		s.SetValue(i,(int) ItemData.Rate,o.Rate);		s.SetValue(i,(int) ItemData.Signal, String.Format("{0}%",o.Signal));		s.SetValue(i,(int) ItemData.Caps,   o.Caps);				if (o.IsRouter)			s.SetValue(i,(int) ItemData.Pix2 , Router);		if (o.IsEncripted)			s.SetValue(i,(int) ItemData.Pix1 , Lock);		if (o.IsOnline)			s.SetValue(i,(int) ItemData.Pix3, LightOn);		else			s.SetValue(i,(int) ItemData.Pix3, LightOff);	}		public void Remove(string ssid){		//store.Remove()...	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -