Esempio n. 1
0
        private void InitializeMenuLayout(Gtk.TreeView menuLayout, MenuLayoutViewModel dataContext)
        {
            menuLayout.SetValue(IFakeDependencyObjectHelpers.DataContextPropertyName, dataContext);
            var column = new Gtk.TreeViewColumn();

            Gtk.CellRenderer cellRenderer = new Gtk.CellRendererPixbuf();
            column.PackStart(cellRenderer, true);
            column.SetCellDataFunc(cellRenderer, (l, c, m, i) => VisualHelpers.CellImageColumnRenderer <FileNodeViewModel>(l, c, m, i, p => p.Icon));
            ////column.Sizing = Gtk.TreeViewColumnSizing.Fixed;
            ////column.FixedWidth = 20;
            menuLayout.AppendColumn(column);

            column = new Gtk.TreeViewColumn()
            {
                Title = MenuLayoutViewModel.LongNameHeader
            };
            cellRenderer    = new Gtk.CellRendererText();
            _longNameEditor = new TextCellInPlaceEditor(menuLayout, column, cellRenderer as Gtk.CellRendererText, FileSystemConstants.MaxLongNameLength)
            {
                IsValidCharacter = INTV.Core.Model.Grom.Characters.Contains
            };
            _longNameEditor.EditorClosed += HandleInPlaceEditorClosed;
            column.PackStart(cellRenderer, true);
            column.SetCellDataFunc(cellRenderer, (l, c, m, i) => VisualHelpers.CellTextColumnRenderer <FileNodeViewModel>(l, c, m, i, p => p.LongName.SafeString()));
            column.Sizing     = Gtk.TreeViewColumnSizing.Fixed;
            column.FixedWidth = Properties.Settings.Default.MenuLayoutLongNameColWidth;
            column.Resizable  = true;
            menuLayout.AppendColumn(column);

            column = new Gtk.TreeViewColumn()
            {
                Title = MenuLayoutViewModel.ShortNameHeader
            };
            cellRenderer     = new Gtk.CellRendererText();
            _shortNameEditor = new TextCellInPlaceEditor(menuLayout, column, cellRenderer as Gtk.CellRendererText, FileSystemConstants.MaxShortNameLength)
            {
                IsValidCharacter = INTV.Core.Model.Grom.Characters.Contains
            };
            _shortNameEditor.EditorClosed += HandleInPlaceEditorClosed;
            column.PackStart(cellRenderer, true);
            column.SetCellDataFunc(cellRenderer, (l, c, m, i) => VisualHelpers.CellTextColumnRenderer <FileNodeViewModel>(l, c, m, i, p => p.ShortName.SafeString()));
            column.Sizing     = Gtk.TreeViewColumnSizing.Fixed;
            column.FixedWidth = Properties.Settings.Default.MenuLayoutShortNameColWidth;
            column.Resizable  = true;
            menuLayout.AppendColumn(column);

            column = new Gtk.TreeViewColumn()
            {
                Title = MenuLayoutViewModel.ManualHeader
            };
            cellRenderer = new Gtk.CellRendererText();
            column.PackStart(cellRenderer, true);
            column.SetCellDataFunc(cellRenderer, (l, c, m, i) => VisualHelpers.CellTextColumnRenderer <FileNodeViewModel>(l, c, m, i, GetManualColumnStringValue));
            column.Sizing     = Gtk.TreeViewColumnSizing.Fixed;
            column.FixedWidth = Properties.Settings.Default.MenuLayoutManualColWidth;
            column.Resizable  = true;
            menuLayout.AppendColumn(column);

            column = new Gtk.TreeViewColumn()
            {
                Title = MenuLayoutViewModel.SaveDataHeader
            };
            cellRenderer = new Gtk.CellRendererText();
            column.PackStart(cellRenderer, true);
            ////column.SetCellDataFunc(cellRenderer, (l,c,m,i) => VisualHelpers.CellTextColumnRenderer<ProgramDescriptionViewModel>(l,c,m,i, p => p.Name));
            ////column.Sizing = Gtk.TreeViewColumnSizing.Fixed;
            ////column.FixedWidth = Properties.Settings.Default.MenuLayoutSaveDataColWidth;
            column.Resizable = true;
            column.Visible   = Properties.Settings.Default.ShowAdvancedFeatures;
            menuLayout.AppendColumn(column);

            menuLayout.HasTooltip    = true;
            menuLayout.QueryTooltip += HandleMenuLayoutQueryTooltip;

            var menuLayoutStore = new Gtk.TreeStore(typeof(FileNodeViewModel));

            dataContext.SynchronizeToTreeStore(menuLayoutStore);
            menuLayout.Model = menuLayoutStore;

            menuLayout.EnableModelDragSource(Gdk.ModifierType.Button1Mask, DragDropSourceEntries, Gdk.DragAction.Move);
            menuLayout.EnableModelDragDest(DragDropTargetEntries, Gdk.DragAction.Copy | Gdk.DragAction.Move);
            menuLayout.Selection.Changed += HandleSelectionChanged;

            dataContext.PropertyChanged += HandleMenuLayoutPropertyChanged;
        }