LQL# HTB control
Now that LQL-Sharp has been released I thought I should put together a quick little demonstration of just how cool it is.
I have created a extremely simple GUI control that can modify the rate and ceiling parameters of a HTB class. This control should really subclass Gtk.Widget but it serves its purpose as is.

using System; using Gtk; using LQL;
class HTBControl { private LQL.ClassHTB klass; private LQL.Con con; private Gtk.SpinButton rateSpin; private Gtk.SpinButton ceilSpin;
public HTBControl(LQL.ClassHTB klass, LQL.Con con) { this.klass = klass; this.con = con;
Gtk.Window myWin = new Gtk.Window("TC GTK+"); myWin.DeleteEvent += new DeleteEventHandler(WindowDelete); Gtk.VBox vbox = new Gtk.VBox(false, 3);
Gtk.HBox hbox1 = new Gtk.HBox(false, 2); hbox1.Add(new Gtk.Label("Rate (bytes/sec): ")); this.rateSpin = new Gtk.SpinButton(0, 10000000, 1); hbox1.Add(this.rateSpin); vbox.Add(hbox1);
Gtk.HBox hbox2 = new Gtk.HBox(false, 2); hbox2.Add(new Gtk.Label("Ceiling (bytes/sec): ")); this.ceilSpin = new Gtk.SpinButton(0, 10000000, 1); hbox2.Add(this.ceilSpin); vbox.Add(hbox2);
Gtk.Button modifyButton = new Gtk.Button("Modify"); modifyButton.Clicked += new EventHandler(Modify); vbox.Add(modifyButton);
rateSpin.Value = this.klass.Rate; ceilSpin.Value = this.klass.Ceiling;
myWin.Add(vbox); myWin.ShowAll(); }
static void WindowDelete(object o, DeleteEventArgs args) { Gtk.Application.Quit(); args.RetVal = true; }
void Modify(object o, EventArgs args) { this.klass.Rate = (uint) this.rateSpin.Value; this.klass.Ceiling = (uint) this.ceilSpin.Value; this.klass.Modify(this.con); } }
using System; using Gtk; using LQL;
class MainClass { public static void Main(string[] args) { Application.Init(); LQL.Con con = new LQL.Con();
LQL.Interface nIf = con.FindInterfaceByName("eth0");
GLib.List classes = con.ListClasses(nIf);
foreach (LQL.Class klass in classes) { if (klass is LQL.ClassHTB) { new HTBControl((LQL.ClassHTB) klass, con); } }
Application.Run(); } }
