public override bool Initialize() { System.Reflection.Assembly exec = System.Reflection.Assembly. GetExecutingAssembly (); Stream stream = exec. GetManifestResourceStream ("eco.pgn"); EcoDbLoader loader = new EcoDbLoader (stream); db = loader.Openings; GameViewer.EcoDb = this; CsBoardApp.Instance. AddApp (new OpeningBrowserUI (db)); return true; }
public OpeningBrowserUI(OpeningsDb db) : base() { menubar = new AppMenuBar (); title = Catalog.GetString ("Opening Browser"); accel = new AccelGroup (); menubar.quitMenuItem. AddAccelerator ("activate", accel, new AccelKey (Gdk.Key. q, Gdk. ModifierType. ControlMask, AccelFlags. Visible)); toolbutton = new ToolButton (Stock.Info); toolbutton.Label = Catalog.GetString ("Openings"); toolbutton.ShowAll (); this.db = db; store = new TreeStore (typeof (string), typeof (int), typeof (string)); this.db.PopulateTree (store); view = new TreeView (); view.Model = store; view.AppendColumn (Catalog. GetString ("Moves"), new CellRendererText (), "text", 0); view.AppendColumn (Catalog. GetString ("Variations"), new CellRendererText (), "text", 1); view.AppendColumn (Catalog. GetString ("Name"), new CellRendererText (), "markup", 2); ScrolledWindow win = new ScrolledWindow (); win.SetPolicy (PolicyType.Automatic, PolicyType.Automatic); win.Add (view); boardWidget = new GameViewerBoard (); HPaned split = new HPaned (); VBox box = new VBox (); box.PackStart (boardWidget, true, true, 2); split.Pack1 (box, false, true); // resize, shrink split.Pack2 (win, true, true); split.ShowAll (); //split.Position = 400; int width, height; CsBoardApp.Instance.Window.GetSize (out width, out height); split.Position = (int) Math.Round (width * 0.5f); split.PositionSet = true; PackStart (split, true, true, 2); view.CursorChanged += OnCursorChanged; ShowAll (); }
public EcoDbLoader(Stream filestream) { TextReader reader = new StreamReader (filestream); PGNParser parser = new PGNParser (reader); PGNGameLoader loader = new PGNGameLoader (); db = new OpeningsDb (); loader.GameLoaded += OnGameLoaded; parser.Parse (loader); reader.Close (); }