public void BuildTextResourcesTreeView()
        {
            TreeViewColumn keysColumn = new TreeViewColumn
            {
                Title     = string.Empty,
                Resizable = true
            };

            keysColumn.AddNotification("width", (object o, GLib.NotifyArgs args) => OnColumnWidthChanged(keysColumn));
            _textResourcesTreeView.AppendColumn(keysColumn);

            CellRendererText keyCell = new Gtk.CellRendererText
            {
                Editable   = true,
                Width      = 300,
                Background = "black"
            };

            keyCell.Edited += OnKeyCellEdited;
            keysColumn.PackStart(keyCell, true);

            keysColumn.SetCellDataFunc(keyCell, new Gtk.TreeCellDataFunc(HandleKeyCellDataFunc));

            foreach (var textResource in _textResourcesManager.TextResources)
            {
                TreeViewColumn resourcesColumn = new TreeViewColumn
                {
                    Title     = textResource.Name,
                    Resizable = true
                };
                keysColumn.AddNotification("width", (object o, GLib.NotifyArgs args) => OnColumnWidthChanged(resourcesColumn));
                _textResourcesTreeView.AppendColumn(resourcesColumn);

                CellRendererText valueCell = new Gtk.CellRendererText
                {
                    Width               = 200,
                    Editable            = true,
                    WrapWidth           = 200,
                    SingleParagraphMode = false,
                    WrapMode            = Pango.WrapMode.WordChar,
                };
                valueCell.Edited += (o, args) => OnValueCellEdited((CellRendererText)o, args, textResource);
                resourcesColumn.PackStart(valueCell, true);

                resourcesColumn.SetCellDataFunc(valueCell, new Gtk.TreeCellDataFunc(HandleValueCellDataFunc));
            }

            foreach (var key in _textResourcesManager.GetAllKeys())
            {
                _resourcesListStore.AppendValues(key);
            }

            _textResourcesTreeView.Model = _filter;
        }
Exemplo n.º 2
0
        /// <summary>Add a column to the list view.</summary>
        /// <param name="columnName">The column heading.</param>
        public void AddColumn(string columnName)
        {
            columnTypes.Add(typeof(string));
            var cell = new CellRendererText();

            cells.Add(cell);
            var colIndex = -1;

            if (SortColumn != null)
            {
                colIndex = columns.Count;
            }
            var newColumn = new TreeViewColumn
            {
                Title        = columnName,
                Resizable    = true,
                SortColumnId = colIndex,
                Sizing       = TreeViewColumnSizing.GrowOnly
            };

            newColumn.PackStart(cell, false);
            newColumn.AddAttribute(cell, "text", columns.Count);
            newColumn.AddNotification("width", OnColumnWidthChange);
            newColumn.SetCellDataFunc(cell, OnFormatColumn);
            columns.Add(newColumn);
            tree.AppendColumn(newColumn);
        }
        public ObjectValueTreeView()
        {
            store          = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(ObjectValue), typeof(bool), typeof(bool), typeof(bool), typeof(string), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(Gdk.Pixbuf), typeof(bool));
            Model          = store;
            RulesHint      = true;
            Selection.Mode = SelectionMode.Multiple;
            ResetColumnSizes();

            Pango.FontDescription newFont = this.Style.FontDescription.Copy();
            newFont.Size = (newFont.Size * 8) / 10;

            liveIcon   = ImageService.GetPixbuf(Gtk.Stock.Execute, IconSize.Menu);
            noLiveIcon = ImageService.MakeTransparent(liveIcon, 0.5);

            expCol       = new TreeViewColumn();
            expCol.Title = GettextCatalog.GetString("Name");
            CellRendererIcon crp = new CellRendererIcon();

            expCol.PackStart(crp, false);
            expCol.AddAttribute(crp, "stock_id", IconCol);
            crtExp = new CellRendererText();
            expCol.PackStart(crtExp, true);
            expCol.AddAttribute(crtExp, "text", NameCol);
            expCol.AddAttribute(crtExp, "editable", NameEditableCol);
            expCol.AddAttribute(crtExp, "foreground", NameColorCol);
            expCol.Resizable = true;
            expCol.Sizing    = TreeViewColumnSizing.Fixed;
            expCol.MinWidth  = 15;
            expCol.AddNotification("width", OnColumnWidthChanged);
//			expCol.Expand = true;
            AppendColumn(expCol);

            valueCol         = new TreeViewColumn();
            valueCol.Title   = GettextCatalog.GetString("Value");
            crpViewer        = new CellRendererIcon();
            crpViewer.IconId = Gtk.Stock.ZoomIn;
            valueCol.PackStart(crpViewer, false);
            valueCol.AddAttribute(crpViewer, "visible", ViewerButtonVisibleCol);
            crpButton           = new CellRendererIcon();
            crpButton.StockSize = (uint)Gtk.IconSize.Menu;
            crpButton.IconId    = Gtk.Stock.Refresh;
            valueCol.PackStart(crpButton, false);
            valueCol.AddAttribute(crpButton, "visible", ValueButtonVisibleCol);
            crtValue = new CellRendererText();
            valueCol.PackStart(crtValue, true);
            valueCol.AddAttribute(crtValue, "text", ValueCol);
            valueCol.AddAttribute(crtValue, "editable", ValueEditableCol);
            valueCol.AddAttribute(crtValue, "foreground", ValueColorCol);
            valueCol.Resizable = true;
            valueCol.MinWidth  = 15;
            valueCol.AddNotification("width", OnColumnWidthChanged);
//			valueCol.Expand = true;
            valueCol.Sizing = TreeViewColumnSizing.Fixed;
            AppendColumn(valueCol);

            typeCol       = new TreeViewColumn();
            typeCol.Title = GettextCatalog.GetString("Type");
            crtType       = new CellRendererText();
            typeCol.PackStart(crtType, true);
            typeCol.AddAttribute(crtType, "text", TypeCol);
            typeCol.Resizable = true;
            typeCol.Sizing    = TreeViewColumnSizing.Fixed;
            typeCol.MinWidth  = 15;
            typeCol.AddNotification("width", OnColumnWidthChanged);
//			typeCol.Expand = true;
            AppendColumn(typeCol);

            pinCol = new TreeViewColumn();
            crpPin = new CellRendererIcon();
            pinCol.PackStart(crpPin, false);
            pinCol.AddAttribute(crpPin, "stock_id", PinIconCol);
            crpLiveUpdate = new CellRendererIcon();
            pinCol.PackStart(crpLiveUpdate, false);
            pinCol.AddAttribute(crpLiveUpdate, "pixbuf", LiveUpdateIconCol);
            pinCol.Resizable = false;
            pinCol.Visible   = false;
            pinCol.Expand    = false;
            AppendColumn(pinCol);

            state = new TreeViewState(this, NameCol);

            crtExp.Edited            += OnExpEdited;
            crtExp.EditingStarted    += OnExpEditing;
            crtExp.EditingCanceled   += OnEditingCancelled;
            crtValue.EditingStarted  += OnValueEditing;
            crtValue.Edited          += OnValueEdited;
            crtValue.EditingCanceled += OnEditingCancelled;

            this.EnableAutoTooltips();

            createMsg = GettextCatalog.GetString("Click here to add a new watch");
        }