Ejemplo n.º 1
0
        public CustomGameDialog(ITranslations translations, GameSession session) : base(translations, "CustomGameDialog.ui", "customgame")
        {
            Game game;

            selection_done = false;
            this.session   = session;
            games          = session.GameManager.AvailableGames;

            drawing_area = new GameDrawingArea();
            drawing_area.UseSolutionArea = false;
            drawing_area.SetSizeRequest(preview_vbox.WidthRequest, preview_vbox.HeightRequest);
            preview_vbox.Add(drawing_area);
            drawing_area.Visible      = true;
            treeview.HeadersClickable = true;

            CreateColumnName();
            CreateColumnType();
            CreateColumnSelected();
            LoadGames();

            treeview.Model    = games_store;
            game              = (Game)Activator.CreateInstance(games [0].TypeOf, true);
            game.Translations = Translations;
            game.Variant      = 0;
            game.Begin();
            drawing_area.Drawable = game;
            drawing_area.Question = game.Question;
            treeview.ColumnsAutosize();
        }
Ejemplo n.º 2
0
        protected void AjustIconCol()
        {
            var col = GetColumn(ColumnNrIcon);

            col.Visible = showIcons;

            if (!showIcons)
            {
                // HACK best solution to reduce row heights so far
                treeView.ColumnsAutosize();
            }
            else
            {
                var iconSizing = this.viewModel.IconSizing;
                cellRendererPixbuf.SetFixedSize(iconSizing.Width, iconSizing.Height);

                // need some more width for PixBuf to be completely visible
                // HACK icon column FixedWidth
                col.FixedWidth = iconSizing.Width + 10;
                col.Sizing     = TreeViewColumnSizing.Fixed;
            }
        }
Ejemplo n.º 3
0
 public void ColumnsAutosize()
 {
     tv.ColumnsAutosize();
 }
Ejemplo n.º 4
0
        public CustomGameDialog(GameManager manager) : base("CustomGameDialog.ui", "customgame")
        {
            Game game;

            selection_done = false;
            this.manager   = manager;
            games          = manager.AvailableGames;

            drawing_area = new GameDrawingArea();
            drawing_area.UseSolutionArea = false;
            preview_vbox.Add(drawing_area);
            drawing_area.Visible      = true;
            treeview.HeadersClickable = true;

            // Column: Game Name
            TreeViewColumn name_column = new TreeViewColumn(Catalog.GetString("Game Name"),
                                                            new CellRendererText(), "text", 0);

            name_column.Expand    = true;
            name_column.Clickable = true;
            name_column.Clicked  += delegate(object sender, EventArgs args)
            {
                Gtk.SortType       order;
                Gtk.TreeViewColumn column = (Gtk.TreeViewColumn)sender;

                if (column.SortOrder == Gtk.SortType.Ascending)
                {
                    order = Gtk.SortType.Descending;
                }
                else
                {
                    order = Gtk.SortType.Ascending;
                }

                column.SortOrder = order;
                games_store.SetSortColumnId(COL_NAME, order);
            };

            treeview.AppendColumn(name_column);

            // Column: Type
            TreeViewColumn type_column = new TreeViewColumn(Catalog.GetString("Type"),
                                                            new CellRendererText(), "text", 1);

            type_column.Expand = true;
            treeview.AppendColumn(type_column);
            type_column.Clickable = true;
            type_column.Clicked  += delegate(object sender, EventArgs args)
            {
                Gtk.SortType       order;
                Gtk.TreeViewColumn column = (Gtk.TreeViewColumn)sender;

                if (column.SortOrder == Gtk.SortType.Ascending)
                {
                    order = Gtk.SortType.Descending;
                }
                else
                {
                    order = Gtk.SortType.Ascending;
                }

                column.SortOrder = order;
                games_store.SetSortColumnId(COL_TYPE, order);
            };

            // Column: Selected
            CellRendererToggle toggle_cell   = new CellRendererToggle();
            TreeViewColumn     toggle_column = new TreeViewColumn(Catalog.GetString("Selected"),
                                                                  toggle_cell, "active", COL_ENABLED);

            toggle_cell.Activatable = true;
            toggle_cell.Toggled    += OnActiveToggled;
            toggle_column.Expand    = false;
            treeview.CursorChanged += OnCursorChanged;
            treeview.AppendColumn(toggle_column);

            if (games_store == null)
            {
                games_store = new ListStore(typeof(string), typeof(string), typeof(bool), typeof(Game), typeof(int));

                games_store.SetSortFunc(0, new Gtk.TreeIterCompareFunc(GameSort));
                games_store.SetSortColumnId(COL_TYPE, SortType.Ascending);

                // Data
                string type;
                for (int i = 0; i < games.Length; i++)
                {
                    if (games [i].IsGame == false)
                    {
                        continue;
                    }

                    game         = (Game)Activator.CreateInstance(games [i].TypeOf, true);
                    game.Variant = games [i].Variant;
                    type         = GameTypesDescription.GetLocalized(game.Type);
                    games_store.AppendValues(game.Name, type, true, game, i);
                }
            }

            treeview.Model = games_store;
            game           = (Game)Activator.CreateInstance(games [0].TypeOf, true);
            game.Variant   = 0;
            game.Begin();
            drawing_area.Drawable = game;
            drawing_area.Question = game.Question;
            treeview.ColumnsAutosize();
        }