Exemple #1
0
        void InitializeProjectsListView()
        {
            projectStore?.Clear();

            // Recreate the list view each time. This is a workaround for the
            // list view not displaying items on re-populating if it has been sorted.
            if (projectsListView != null)
            {
                projectsListViewVBox.Remove(projectsListView);
                projectsListView.Dispose();
            }

            projectStore?.Dispose();

            projectCheckedField = new DataField <bool> ();
            projectNameField    = new DataField <string> ();
            packageVersionField = new DataField <string> ();
            projectField        = new DataField <ManageProjectViewModel> ();
            projectStore        = new ListStore(projectCheckedField, projectNameField, packageVersionField, projectField);

            projectsListView            = new ListView();
            projectsListView.DataSource = projectStore;

            // Selected project check box column.
            if (projectCheckBoxCellView != null)
            {
                projectCheckBoxCellView.Toggled -= ProjectCheckBoxCellViewToggled;
            }
            projectCheckBoxCellView             = new CheckBoxCellView();
            projectCheckBoxCellView.ActiveField = projectCheckedField;
            projectCheckBoxCellView.Editable    = true;
            projectCheckBoxCellView.Toggled    += ProjectCheckBoxCellViewToggled;
            var column = new ListViewColumn(string.Empty, projectCheckBoxCellView);

            projectsListView.Columns.Add(column);

            // Project column.
            var textCellView = new TextCellView();

            textCellView.TextField = projectNameField;
            column = new ListViewColumn(GettextCatalog.GetString("Project"), textCellView)
            {
                CanResize     = true,
                SortDataField = projectNameField
            };
            projectsListView.Columns.Add(column);

            // Package version column
            textCellView           = new TextCellView();
            textCellView.TextField = packageVersionField;
            column = new ListViewColumn(GettextCatalog.GetString("Version"), textCellView)
            {
                CanResize     = true,
                SortDataField = packageVersionField
            };
            projectsListView.Columns.Add(column);

            // Add list view to dialog.
            projectsListViewVBox.PackStart(projectsListView, true, true);
        }
        public ExtractInterfaceDialog()
        {
            this.Build();
            this.buttonSelectAll.Clicked += delegate {
                for (int i = 0; i < treeStore.RowCount; i++)
                {
                    treeStore.SetValue(i, symbolIncludedField, true);
                }
                UpdateOkButton();
            };

            this.buttonDeselectAll.Clicked += delegate {
                for (int i = 0; i < treeStore.RowCount; i++)
                {
                    treeStore.SetValue(i, symbolIncludedField, false);
                }
                UpdateOkButton();
            };

            listViewPublicMembers.HeadersVisible = false;
            listViewPublicMembers.DataSource     = treeStore;
            var checkBoxCellView = new CheckBoxCellView(symbolIncludedField);

            checkBoxCellView.Editable = true;
            checkBoxCellView.Toggled += delegate { UpdateOkButton(); };
            listViewPublicMembers.Columns.Add("", checkBoxCellView);
            listViewPublicMembers.Columns.Add("", new ImageCellView(symbolIconField), new TextCellView(symbolTextField));


            this.entryName.Changed     += delegate { UpdateOkButton(); };
            this.entryFileName.Changed += delegate { UpdateOkButton(); };
        }
Exemple #3
0
        void BuildGui()
        {
            this.Title     = "Select Projects";
            this.Resizable = false;
            var vBox = new VBox();
            var hbox = new HBox();

            collectionsList.DataSource = collectionStore;
            collectionsList.Views.Add(new TextCellView(collectionName));
            collectionsList.MinWidth  = 200;
            collectionsList.MinHeight = 300;
            hbox.PackStart(collectionsList);

            projectsList.DataSource = projectsStore;
            projectsList.MinWidth   = 200;
            projectsList.MinHeight  = 300;
            var checkView = new CheckBoxCellView(isProjectSelected)
            {
                Editable = true
            };

            checkView.Toggled += (sender, e) =>
            {
                var row        = projectsList.CurrentEventRow;
                var node       = projectsStore.GetNavigatorAt(row);
                var isSelected = !node.GetValue(isProjectSelected); //Xwt gives previous value
                var project    = node.GetValue(projectItem);
                if (isSelected && !SelectedProjects.Any(p => string.Equals(p.Uri, project.Uri)))
                {
                    SelectedProjects.Add(project);
                }
                if (!isSelected && SelectedProjects.Any(p => string.Equals(p.Uri, project.Uri)))
                {
                    SelectedProjects.RemoveAll(p => string.Equals(p.Uri, project.Uri));
                }
            };
            projectsList.Columns.Add(new ListViewColumn("", checkView));
            projectsList.Columns.Add(new ListViewColumn("Name", new TextCellView(projectName)));
            hbox.PackEnd(projectsList);

            vBox.PackStart(hbox);

            Button ok = new Button(GettextCatalog.GetString("OK"));

            ok.Clicked += (sender, e) => Respond(Command.Ok);

            Button cancel = new Button(GettextCatalog.GetString("Cancel"));

            cancel.Clicked += (sender, e) => Respond(Command.Cancel);

            ok.MinWidth = cancel.MinWidth = Constants.ButtonWidth;

            var buttonBox = new HBox();

            buttonBox.PackEnd(ok);
            buttonBox.PackEnd(cancel);
            vBox.PackStart(buttonBox);

            this.Content = vBox;
        }
        void BuildGui()
        {
            this.Title     = GettextCatalog.GetString("Check Out");
            this.Resizable = false;
            var content = new VBox();

            content.PackStart(new Label(GettextCatalog.GetString("Files") + ":"));
            fileView.WidthRequest  = 500;
            fileView.HeightRequest = 150;
            var checkView = new CheckBoxCellView(isCheckedField);

            checkView.Editable = true;
            fileView.Columns.Add("Name", checkView, new TextCellView(nameField));
            fileView.Columns.Add("Folder", folderField);
            fileView.DataSource = fileStore;
            content.PackStart(fileView, true, true);

            var lockBox = new HBox();

            lockBox.PackStart(new Label(GettextCatalog.GetString("Select lock type") + ":"));
            lockBox.PackStart(lockLevelBox, true, true);
            content.PackStart(lockBox);

            this.Buttons.Add(Command.Ok, Command.Cancel);

            this.Content = content;
        }
        public PickMembersDialog()
        {
            this.Build();
            this.buttonSelectAll.Clicked += delegate {
                for (int i = 0; i < treeStore.RowCount; i++)
                {
                    treeStore.SetValue(i, symbolIncludedField, true);
                }
                UpdateOkButton();
            };

            this.buttonDeselectAll.Clicked += delegate {
                for (int i = 0; i < treeStore.RowCount; i++)
                {
                    treeStore.SetValue(i, symbolIncludedField, false);
                }
                UpdateOkButton();
            };

            listBoxPublicMembers.DataSource = treeStore;
            var checkBoxCellView = new CheckBoxCellView(symbolIncludedField);

            checkBoxCellView.Editable = true;
            checkBoxCellView.Toggled += delegate { UpdateOkButton(); };
            listBoxPublicMembers.Views.Add(checkBoxCellView);
            listBoxPublicMembers.Views.Add(new ImageCellView(symbolIconField));
            listBoxPublicMembers.Views.Add(new TextCellView(symbolTextField));
        }
        public ListView2()
        {
            ListView list = new ListView();
            var      editableActiveField    = new DataField <bool> ();
            var      nonEditableActiveField = new DataField <bool> ();
            var      textField            = new DataField <string> ();
            var      textField2           = new DataField <string> ();
            var      editableField        = new DataField <bool> ();
            var      somewhatEditableData = new DataField <bool>();

            ListStore store = new ListStore(editableActiveField, nonEditableActiveField, textField, textField2, editableField, somewhatEditableData);

            list.DataSource       = store;
            list.GridLinesVisible = GridLines.Horizontal;

            var checkCellView = new CheckBoxCellView {
                Editable = true, ActiveField = editableActiveField
            };

            checkCellView.Toggled += (sender, e) => {
                if (list.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    store.SetValue(list.CurrentEventRow, textField, "Toggled");
                }
            };

            list.Columns.Add(new ListViewColumn("Editable", checkCellView));
            list.Columns.Add(new ListViewColumn("Not Editable", new CheckBoxCellView {
                Editable = false, ActiveField = nonEditableActiveField
            }));
            list.Columns.Add(new ListViewColumn("Editable", new TextCellView {
                Editable = true, TextField = textField
            }));
            list.Columns.Add(new ListViewColumn("Somewhat Editable", new CheckBoxCellView {
                EditableField = editableField, ActiveField = somewhatEditableData
            }));
            list.Columns.Add(new ListViewColumn("Somewhat Editable", new TextCellView {
                EditableField = editableField, TextField = textField2
            }));

            Random rand = new Random();

            for (int n = 0; n < 100; n++)
            {
                var r = store.AddRow();
                store.SetValue(r, editableActiveField, rand.Next(0, 2) == 0);
                store.SetValue(r, nonEditableActiveField, rand.Next(0, 2) == 0);
                store.SetValue(r, somewhatEditableData, rand.Next(0, 2) == 0);
                store.SetValue(r, textField, n.ToString());
                var edit = (n % 2) == 0;
                store.SetValue(r, editableField, edit);
                store.SetValue(r, textField2, edit ? "editable" : "not editable");
            }
            PackStart(list, true);
        }
 protected override void Dispose(bool disposing)
 {
     if (checkBox != null)
     {
         checkBox.Toggled -= OnCheckboxToggled;
         checkBox          = null;
     }
     base.Dispose(disposing);
 }
Exemple #8
0
        void BuildGui()
        {
            this.Title              = GettextCatalog.GetString("Check In files");
            this.Resizable          = false;
            notebook.TabOrientation = NotebookTabOrientation.Left;

            var checkInTab = new VBox();

            checkInTab.PackStart(new Label(GettextCatalog.GetString("Pending Changes") + ":"));
            filesView.WidthRequest  = 500;
            filesView.HeightRequest = 150;
            var checkView = new CheckBoxCellView(isCheckedField);

            checkView.Editable = true;
            filesView.Columns.Add("Name", checkView, new TextCellView(nameField));
            filesView.Columns.Add("Changes", changesField);
            filesView.Columns.Add("Folder", folderField);
            filesView.DataSource = fileStore;
            checkInTab.PackStart(filesView, true, true);

            checkInTab.PackStart(new Label(GettextCatalog.GetString("Comment") + ":"));
            commentEntry.MultiLine = true;
            checkInTab.PackStart(commentEntry);

            notebook.Add(checkInTab, GettextCatalog.GetString("Pending Changes"));


            var workItemsTab     = new HBox();
            var workItemsListBox = new VBox();

            workItemsListBox.PackStart(new Label(GettextCatalog.GetString("Work Items") + ":"));
            workItemsView.Columns.Add("Id", idField);
            workItemsView.Columns.Add("Title", titleField);
            workItemsView.DataSource = workItemsStore;
            workItemsListBox.PackStart(workItemsView, true);
            workItemsTab.PackStart(workItemsListBox, true, true);

            var workItemButtonBox = new VBox();
            var addWorkItemButton = new Button(GettextCatalog.GetString("Add Work Item"));

            addWorkItemButton.Clicked += OnAddWorkItem;
            workItemButtonBox.PackStart(addWorkItemButton);
            var removeWorkItemButton = new Button(GettextCatalog.GetString("Remove Work Item"));

            removeWorkItemButton.Clicked += OnRemoveWorkItem;
            workItemButtonBox.PackStart(removeWorkItemButton);
            workItemsTab.PackStart(workItemButtonBox);

            notebook.Add(workItemsTab, GettextCatalog.GetString("Work Items"));


            this.Buttons.Add(Command.Ok, Command.Cancel);


            this.Content = notebook;
        }
        void BuildGui()
        {
            this.Title     = "Get";
            this.Resizable = false;
            VBox content = new VBox();

            content.PackStart(new Label(GettextCatalog.GetString("Files") + ":"));

            listStore = new ListStore(itemField, isSelectedField, nameField, pathField);
            var checkSell = new CheckBoxCellView(isSelectedField);

            checkSell.Editable = true;
            listView.Columns.Add("Name", checkSell, new TextCellView(nameField));
            listView.Columns.Add("Folder", new TextCellView(pathField));
            listView.MinHeight  = 200;
            listView.DataSource = listStore;

            content.PackStart(listView);

            HBox typeBox = new HBox();

            typeBox.PackStart(new Label(GettextCatalog.GetString("Version") + ":"));
            versionBox.Items.Add(0, "Changeset");
            versionBox.Items.Add(1, "Latest Version");
            versionBox.SelectedItem      = 1;
            versionBox.SelectionChanged += (sender, e) => changeSetNumber.Visible = (int)versionBox.SelectedItem == 0;
            typeBox.PackStart(versionBox);
            changeSetNumber.Visible        = false;
            changeSetNumber.WidthRequest   = 100;
            changeSetNumber.MinimumValue   = 1;
            changeSetNumber.MaximumValue   = int.MaxValue;
            changeSetNumber.Value          = 0;
            changeSetNumber.IncrementValue = 1;
            changeSetNumber.Digits         = 0;
            typeBox.PackStart(changeSetNumber);
            content.PackStart(typeBox);

            content.PackStart(forceGet);
            //content.PackStart(overrideGet);

            HBox   buttonBox = new HBox();
            Button okButton  = new Button(GettextCatalog.GetString("Get"));

            okButton.Clicked += OnGet;
            Button cancelButton = new Button(GettextCatalog.GetString("Cancel"));

            cancelButton.Clicked += (sender, e) => Respond(Command.Cancel);
            okButton.WidthRequest = cancelButton.WidthRequest = Constants.ButtonWidth;

            buttonBox.PackEnd(cancelButton);
            buttonBox.PackEnd(okButton);
            content.PackStart(buttonBox);

            this.Content = content;
        }
        public override Control CreatePanelWidget()
        {
            var vbox = new VBox();

            vbox.Spacing = 6;

            featuresListStore           = new ListStore(featureNameDataField, featureEnabledDataField, featureDataField);
            featuresListView            = new ListView();
            featuresListView.DataSource = featuresListStore;

            var cellView = new TextCellView();

            cellView.TextField = featureNameDataField;
            var column = new ListViewColumn("Feature", cellView);

            featuresListView.Columns.Add(column);

            var featuresComboBoxDataSource = new List <string> ();
            var checkBoxCellView           = new CheckBoxCellView();

            checkBoxCellView.Editable    = true;
            checkBoxCellView.ActiveField = featureEnabledDataField;
            checkBoxCellView.Toggled    += FeatureEnabledCheckBoxToggled;
            column = new ListViewColumn("Enabled", checkBoxCellView);
            featuresListView.Columns.Add(column);

            vbox.PackStart(featuresListView, true, true);

            var restartLabel = new Label();

            restartLabel.Text          = GettextCatalog.GetString("Some features may require a restart of {0}", BrandingService.ApplicationName);
            restartLabel.TextAlignment = Alignment.Start;
            vbox.PackStart(restartLabel);

            var restartButtonHBox = new HBox();

            vbox.PackStart(restartButtonHBox, false, false);

            restartButton       = new Button();
            restartButton.Label = GettextCatalog.GetString("Restart {0}", BrandingService.ApplicationName);
            restartButtonHBox.PackStart(restartButton, false, false);

            restartButton.Clicked += RestartButtonClicked;

            AddFeatures();

            widget = vbox.ToGtkWidget();
            return(widget);
        }
        public override void Initialize(OptionsDialog dialog, object dataObject)
        {
            base.Initialize(dialog, dataObject);

            config = (SolutionRunConfigInfo)dataObject;

            store    = new ListStore(selectedField, projectNameField, projectField, runConfigField, projectRunConfigsField);
            listView = new ListView(store);

            var col1 = new ListViewColumn(GettextCatalog.GetString("Solution Item"));
            var cb   = new CheckBoxCellView(selectedField);

            cb.Toggled += SelectionChanged;
            cb.Editable = true;
            col1.Views.Add(cb);
            col1.Views.Add(new TextCellView(projectNameField));
            listView.Columns.Add(col1);

            var configSelView = new ComboBoxCellView(runConfigField);

            configSelView.Editable   = true;
            configSelView.ItemsField = projectRunConfigsField;
            var col2 = new ListViewColumn(GettextCatalog.GetString("Run Configuration"), configSelView);

            listView.Columns.Add(col2);

            foreach (var it in config.Solution.GetAllSolutionItems().Where(si => si.SupportsExecute()).OrderBy(si => si.Name))
            {
                var row     = store.AddRow();
                var si      = config.EditedConfig.Items.FirstOrDefault(i => i.SolutionItem == it);
                var sc      = si?.RunConfiguration?.Name ?? it.GetDefaultRunConfiguration()?.Name;
                var configs = new ItemCollection();
                foreach (var pc in it.GetRunConfigurations())
                {
                    configs.Add(pc.Name);
                }
                store.SetValues(row, selectedField, si != null, projectNameField, it.Name, projectField, it, runConfigField, sc, projectRunConfigsField, configs);
            }
        }
        void IOptionsPanel.Initialize(OptionsDialog dialog, object dataObject)
        {
            this.ExpandHorizontal = true;
            this.ExpandVertical   = true;
            this.HeightRequest    = 400;
            list  = new ListView();
            store = new ListStore(language, completeOnSpace, completeOnChars);

            var languageColumn = list.Columns.Add(GettextCatalog.GetString("Language"), language);

            languageColumn.CanResize = true;

            var checkBoxCellView = new CheckBoxCellView(completeOnSpace);

            checkBoxCellView.Editable = true;
            var completeOnSpaceColumn = list.Columns.Add(GettextCatalog.GetString("Complete on space"), checkBoxCellView);

            completeOnSpaceColumn.CanResize = true;

            var textCellView = new TextCellView(completeOnChars);

            textCellView.Editable = true;
            var doNotCompleteOnColumn = list.Columns.Add(GettextCatalog.GetString("Do complete on"), textCellView);

            doNotCompleteOnColumn.CanResize = true;
            list.DataSource = store;
            PackStart(list, true, true);

            var hbox   = new HBox();
            var button = new Button("Reset to default");

            button.Clicked += delegate {
                FillStore(CompletionCharacters.GetDefaultCompletionCharacters());
            };
            hbox.PackEnd(button, false, false);
            PackEnd(hbox, false, true);
            FillStore(CompletionCharacters.GetCompletionCharacters());
        }
Exemple #13
0
        public TreeViews()
        {
            TreeView  view  = new TreeView();
            TreeStore store = new TreeStore(triState, check, option1, option2, option3, text, desc);

            view.GridLinesVisible = GridLines.Both;

            var triStateCellView = new CheckBoxCellView(triState)
            {
                Editable = true, AllowMixed = true
            };

            triStateCellView.Toggled += (object sender, WidgetEventArgs e) => {
                if (view.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "TriState Toggled");
                }
            };
            var checkCellView = new CheckBoxCellView(check)
            {
                Editable = true
            };

            checkCellView.Toggled += (object sender, WidgetEventArgs e) => {
                if (view.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "Toggled " + checkCellView.Active);
                }
            };
            var optionCellView1 = new RadioButtonCellView(option1)
            {
                Editable = true
            };

            optionCellView1.Toggled += (object sender, WidgetEventArgs e) => {
                if (view.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    store.GetNavigatorAt(view.CurrentEventRow).SetValue(option2, optionCellView1.Active);
                }
            };
            var optionCellView2 = new RadioButtonCellView(option2)
            {
                Editable = true
            };

            optionCellView2.Toggled += (object sender, WidgetEventArgs e) => {
                if (view.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    store.GetNavigatorAt(view.CurrentEventRow).SetValue(option1, optionCellView2.Active);
                }
            };

            TreePosition initialActive   = null;
            var          optionCellView3 = new RadioButtonCellView(option3)
            {
                Editable = true
            };

            optionCellView3.Toggled += (object sender, WidgetEventArgs e) => {
                if (view.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    if (initialActive != null)
                    {
                        store.GetNavigatorAt(initialActive).SetValue(option3, false);
                    }
                    initialActive = view.CurrentEventRow;
                }
            };

            view.Columns.Add("TriCheck", triStateCellView);
            view.Columns.Add("Check", checkCellView);
            view.Columns.Add("Radio", optionCellView1, optionCellView2, optionCellView3);
            view.Columns.Add("Item", text);
            view.Columns.Add("Desc", desc);
            view.Columns[2].Expands   = true;           // expand third column, aligning last column to the right side
            view.Columns[2].CanResize = true;
            view.Columns[3].CanResize = true;

            store.AddNode().SetValue(text, "One").SetValue(desc, "First").SetValue(triState, CheckBoxState.Mixed);
            store.AddNode().SetValue(text, "Two").SetValue(desc, "Second").AddChild()
            .SetValue(text, "Sub two").SetValue(desc, "Sub second");
            store.AddNode().SetValue(text, "Three").SetValue(desc, "Third").AddChild()
            .SetValue(text, "Sub three").SetValue(desc, "Sub third");
            PackStart(view, true);

            Menu contextMenu = new Menu();

            contextMenu.Items.Add(new MenuItem("Test menu"));
            view.ButtonPressed += delegate(object sender, ButtonEventArgs e) {
                TreePosition    tmpTreePos;
                RowDropPosition tmpRowDrop;
                if ((e.Button == PointerButton.Right) && view.GetDropTargetRow(e.X, e.Y, out tmpRowDrop, out tmpTreePos))
                {
                    // Set actual row to selected
                    view.SelectRow(tmpTreePos);
                    contextMenu.Popup(view, e.X, e.Y);
                }
            };

            view.DataSource = store;

            Label la = new Label();

            PackStart(la);

            view.SetDragDropTarget(DragDropAction.All, TransferDataType.Text);
            view.SetDragSource(DragDropAction.All, TransferDataType.Text);

            view.DragDrop += delegate(object sender, DragEventArgs e) {
                TreePosition    node;
                RowDropPosition pos;
                view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node);
                var nav = store.GetNavigatorAt(node);
                la.Text  += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue(text) + "\" " + pos + "\n";
                e.Success = true;
            };
            view.DragOver += delegate(object sender, DragOverEventArgs e) {
                TreePosition    node;
                RowDropPosition pos;
                view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node);
                if (pos == RowDropPosition.Into)
                {
                    e.AllowedAction = DragDropAction.None;
                }
                else
                {
                    e.AllowedAction = e.Action;
                }
            };
            view.DragStarted += delegate(object sender, DragStartedEventArgs e) {
                var val = store.GetNavigatorAt(view.SelectedRow).GetValue(text);
                e.DragOperation.Data.AddValue(val);
                var img = Image.FromResource(GetType(), "class.png");
                e.DragOperation.SetDragImage(img, (int)img.Size.Width, (int)img.Size.Height);
                e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) {
                    Console.WriteLine("D:" + args.DeleteSource);
                };
            };
            view.RowExpanding += delegate(object sender, TreeViewRowEventArgs e) {
                var val = store.GetNavigatorAt(e.Position).GetValue(text);
                Console.WriteLine("Expanding: " + val);
            };
            view.RowExpanded += delegate(object sender, TreeViewRowEventArgs e) {
                var val = store.GetNavigatorAt(e.Position).GetValue(text);
                Console.WriteLine("Expanded: " + val);
            };
            view.RowCollapsing += delegate(object sender, TreeViewRowEventArgs e) {
                var val = store.GetNavigatorAt(e.Position).GetValue(text);
                Console.WriteLine("Collapsing: " + val);
            };
            view.RowCollapsed += delegate(object sender, TreeViewRowEventArgs e) {
                var val = store.GetNavigatorAt(e.Position).GetValue(text);
                Console.WriteLine("Collapsed: " + val);
            };

            RadioButtonGroup group = new RadioButtonGroup();

            foreach (SelectionMode mode in Enum.GetValues(typeof(SelectionMode)))
            {
                var radio = new RadioButton(mode.ToString());
                radio.Group      = group;
                radio.Activated += delegate {
                    view.SelectionMode = mode;
                };
                PackStart(radio);
            }

            int addCounter = 0;

            view.KeyPressed += (sender, e) => {
                if (e.Key == Key.Insert)
                {
                    TreeNavigator n;
                    if (view.SelectedRow != null)
                    {
                        n = store.InsertNodeAfter(view.SelectedRow).SetValue(text, "Inserted").SetValue(desc, "Desc");
                    }
                    else
                    {
                        n = store.AddNode().SetValue(text, "Inserted").SetValue(desc, "Desc");
                    }
                    view.ExpandToRow(n.CurrentPosition);
                    view.ScrollToRow(n.CurrentPosition);
                    view.UnselectAll();
                    view.SelectRow(n.CurrentPosition);
                    view.FocusedRow = n.CurrentPosition;
                }
            };
            Button addButton = new Button("Add");

            addButton.Clicked += delegate(object sender, EventArgs e) {
                addCounter++;
                TreeNavigator n;
                if (view.SelectedRow != null)
                {
                    n = store.AddNode(view.SelectedRow).SetValue(text, "Added " + addCounter).SetValue(desc, "Desc");
                }
                else
                {
                    n = store.AddNode().SetValue(text, "Added " + addCounter).SetValue(desc, "Desc");
                }
                view.ExpandToRow(n.CurrentPosition);
                view.ScrollToRow(n.CurrentPosition);
                view.SelectRow(n.CurrentPosition);
            };
            PackStart(addButton);

            Button removeButton = new Button("Remove Selection");

            removeButton.Clicked += delegate(object sender, EventArgs e) {
                foreach (TreePosition row in view.SelectedRows)
                {
                    store.GetNavigatorAt(row).Remove();
                }
            };
            PackStart(removeButton);

            Button clearButton = new Button("Clear");

            clearButton.Clicked += delegate(object sender, EventArgs e) {
                store.Clear();
            };
            PackStart(clearButton);

            var label = new Label();

            PackStart(label);

            view.RowExpanded += (sender, e) => label.Text = "Row expanded: " + store.GetNavigatorAt(e.Position).GetValue(text);
        }
Exemple #14
0
        internal static FrameworkElementFactory CreateBoundCellRenderer(ApplicationContext ctx, WidgetBackend parent, CellView view, string dataPath = ".")
        {
            ICellViewFrontend fr       = view;
            TextCellView      textView = view as TextCellView;

            if (textView != null)
            {
                // if it's an editable textcontrol, use a TextBox, if not use a TextBlock. Reason for this is that
                // a user usually expects to be able to edit a text if a text cursor is appearing above a field.
                FrameworkElementFactory factory;
                if (textView.Editable || textView.EditableField != null)
                {
                    factory = new FrameworkElementFactory(typeof(SWC.TextBox));
                    if (textView.Editable)
                    {
                        factory.SetValue(SWC.TextBox.IsReadOnlyProperty, false);
                    }
                    else
                    {
                        factory.SetBinding(SWC.TextBox.IsEnabledProperty, new Binding(dataPath + "[" + textView.EditableField.Index + "]"));
                    }

                    if (textView.TextField != null)
                    {
                        factory.SetBinding(SWC.TextBox.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]"));
                    }
                    else
                    {
                        factory.SetValue(SWC.TextBox.TextProperty, textView.Text);
                    }
                }
                else
                {
                    factory = new FrameworkElementFactory(typeof(SWC.TextBlock));

                    if (textView.MarkupField != null)
                    {
                        factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(dataPath + "[" + textView.MarkupField.Index + "]")
                        {
                            Converter = new MarkupToPlainTextConverter()
                        });
                    }
                    else if (textView.TextField != null)
                    {
                        factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]"));
                    }
                    else
                    {
                        factory.SetValue(SWC.TextBlock.TextProperty, textView.Text);
                    }
                }

                var cb = new TextCellViewBackend();
                cb.Initialize(view, factory, parent as ICellRendererTarget);
                fr.AttachBackend(parent.Frontend, cb);
                return(factory);
            }

            ImageCellView imageView = view as ImageCellView;

            if (imageView != null)
            {
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(ImageBox));

                if (imageView.ImageField != null)
                {
                    var binding = new Binding(dataPath + "[" + imageView.ImageField.Index + "]");
                    binding.Converter = new ImageToImageSourceConverter(ctx);

                    factory.SetBinding(ImageBox.ImageSourceProperty, binding);
                }

                var cb = new CellViewBackend();
                cb.Initialize(view, factory, parent as ICellRendererTarget);
                fr.AttachBackend(parent.Frontend, cb);
                return(factory);
            }

            CanvasCellView canvasView = view as CanvasCellView;

            if (canvasView != null)
            {
                var cb = new CanvasCellViewBackend();
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CanvasCellViewPanel));
                factory.SetValue(CanvasCellViewPanel.CellViewBackendProperty, cb);

                cb.Initialize(view, factory, parent as ICellRendererTarget);
                fr.AttachBackend(parent.Frontend, cb);
                return(factory);
            }

            CheckBoxCellView cellView = view as CheckBoxCellView;

            if (cellView != null)
            {
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(SWC.CheckBox));
                if (cellView.EditableField == null)
                {
                    factory.SetValue(FrameworkElement.IsEnabledProperty, cellView.Editable);
                }
                else
                {
                    factory.SetBinding(SWC.CheckBox.IsEnabledProperty, new Binding(dataPath + "[" + cellView.EditableField.Index + "]"));
                }

                factory.SetValue(SWC.CheckBox.IsThreeStateProperty, cellView.AllowMixed);
                if (cellView.ActiveField != null)
                {
                    factory.SetBinding(SWC.CheckBox.IsCheckedProperty, new Binding(dataPath + "[" + cellView.ActiveField.Index + "]"));
                }

                var cb = new CheckBoxCellViewBackend();
                cb.Initialize(view, factory, parent as ICellRendererTarget);
                fr.AttachBackend(parent.Frontend, cb);
                return(factory);
            }

            throw new NotImplementedException();
        }
        public TreeViews()
        {
            TreeView  view  = new TreeView();
            TreeStore store = new TreeStore(triState, check, text, desc);

            view.GridLinesVisible = GridLines.Both;

            var triStateCellView = new CheckBoxCellView(triState)
            {
                Editable = true, AllowMixed = true
            };

            triStateCellView.Toggled += (object sender, WidgetEventArgs e) => {
                if (view.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "TriState Toggled");
                }
            };
            var checkCellView = new CheckBoxCellView(check)
            {
                Editable = true
            };

            checkCellView.Toggled += (object sender, WidgetEventArgs e) => {
                if (view.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "Toggled");
                }
            };
            view.Columns.Add("TriCheck", triStateCellView);
            view.Columns.Add("Check", checkCellView);
            view.Columns.Add("Item", text);
            view.Columns.Add("Desc", desc);

            store.AddNode().SetValue(text, "One").SetValue(desc, "First").SetValue(triState, CheckBoxState.Mixed);
            store.AddNode().SetValue(text, "Two").SetValue(desc, "Second").AddChild()
            .SetValue(text, "Sub two").SetValue(desc, "Sub second");
            store.AddNode().SetValue(text, "Three").SetValue(desc, "Third").AddChild()
            .SetValue(text, "Sub three").SetValue(desc, "Sub third");
            PackStart(view, true);

            Menu contextMenu = new Menu();

            contextMenu.Items.Add(new MenuItem("Test menu"));
            view.ButtonPressed += delegate(object sender, ButtonEventArgs e) {
                TreePosition    tmpTreePos;
                RowDropPosition tmpRowDrop;
                if ((e.Button == PointerButton.Right) && view.GetDropTargetRow(e.X, e.Y, out tmpRowDrop, out tmpTreePos))
                {
                    // Set actual row to selected
                    view.SelectRow(tmpTreePos);
                    contextMenu.Popup(view, e.X, e.Y);
                }
            };

            view.DataSource = store;

            Label la = new Label();

            PackStart(la);

            view.SetDragDropTarget(DragDropAction.All, TransferDataType.Text);
            view.SetDragSource(DragDropAction.All, TransferDataType.Text);

            view.DragDrop += delegate(object sender, DragEventArgs e) {
                TreePosition    node;
                RowDropPosition pos;
                view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node);
                var nav = store.GetNavigatorAt(node);
                la.Text  += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue(text) + "\" " + pos + "\n";
                e.Success = true;
            };
            view.DragOver += delegate(object sender, DragOverEventArgs e) {
                TreePosition    node;
                RowDropPosition pos;
                view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node);
                if (pos == RowDropPosition.Into)
                {
                    e.AllowedAction = DragDropAction.None;
                }
                else
                {
                    e.AllowedAction = e.Action;
                }
            };
            view.DragStarted += delegate(object sender, DragStartedEventArgs e) {
                var val = store.GetNavigatorAt(view.SelectedRow).GetValue(text);
                e.DragOperation.Data.AddValue(val);
                e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) {
                    Console.WriteLine("D:" + args.DeleteSource);
                };
            };
            view.RowExpanding += delegate(object sender, TreeViewRowEventArgs e) {
                var val = store.GetNavigatorAt(e.Position).GetValue(text);
                Console.WriteLine("Expanding: " + val);
            };
            view.RowExpanded += delegate(object sender, TreeViewRowEventArgs e) {
                var val = store.GetNavigatorAt(e.Position).GetValue(text);
                Console.WriteLine("Expanded: " + val);
            };
            view.RowCollapsing += delegate(object sender, TreeViewRowEventArgs e) {
                var val = store.GetNavigatorAt(e.Position).GetValue(text);
                Console.WriteLine("Collapsing: " + val);
            };
            view.RowCollapsed += delegate(object sender, TreeViewRowEventArgs e) {
                var val = store.GetNavigatorAt(e.Position).GetValue(text);
                Console.WriteLine("Collapsed: " + val);
            };

            int addCounter = 0;

            view.KeyPressed += (sender, e) => {
                if (e.Key == Key.Insert)
                {
                    TreeNavigator n;
                    if (view.SelectedRow != null)
                    {
                        n = store.InsertNodeAfter(view.SelectedRow).SetValue(text, "Inserted").SetValue(desc, "Desc");
                    }
                    else
                    {
                        n = store.AddNode().SetValue(text, "Inserted").SetValue(desc, "Desc");
                    }
                    view.ExpandToRow(n.CurrentPosition);
                    view.ScrollToRow(n.CurrentPosition);
                    view.UnselectAll();
                    view.SelectRow(n.CurrentPosition);
                    view.FocusedRow = n.CurrentPosition;
                }
            };
            Button addButton = new Button("Add");

            addButton.Clicked += delegate(object sender, EventArgs e) {
                addCounter++;
                TreeNavigator n;
                if (view.SelectedRow != null)
                {
                    n = store.AddNode(view.SelectedRow).SetValue(text, "Added " + addCounter).SetValue(desc, "Desc");
                }
                else
                {
                    n = store.AddNode().SetValue(text, "Added " + addCounter).SetValue(desc, "Desc");
                }
                view.ExpandToRow(n.CurrentPosition);
                view.ScrollToRow(n.CurrentPosition);
                view.SelectRow(n.CurrentPosition);
            };
            PackStart(addButton);

            Button removeButton = new Button("Remove Selection");

            removeButton.Clicked += delegate(object sender, EventArgs e) {
                foreach (TreePosition row in view.SelectedRows)
                {
                    store.GetNavigatorAt(row).Remove();
                }
            };
            PackStart(removeButton);

            var label = new Label();

            PackStart(label);

            view.RowExpanded += (sender, e) => label.Text = "Row expanded: " + store.GetNavigatorAt(e.Position).GetValue(text);
        }
        public FixAllPreviewDialog(string diagnosticId, string scopeLabel, FixAllScope scope, ImmutableArray <CodeActionOperation> operations, TextEditor baseEditor)
        {
            Width  = 800;
            Height = 600;

            this.baseEditor = baseEditor;
            this.operations = operations;

            // TODO: checkbox dependencies
            store    = new TreeStore(nodeCheck, nodeLabel, nodeIcon, nodeIconVisible, nodeEditor, nodeOffset);
            treeView = new TreeView {
                DataSource     = store,
                HeadersVisible = false,
            };
            changedEditor         = TextEditorFactory.CreateNewEditor(baseEditor.FileName, baseEditor.MimeType);
            changedEditor.Options = new CustomEditorOptions(DefaultSourceEditorOptions.PlainEditor)
            {
                ShowLineNumberMargin = true,
            };
            changedEditor.IsReadOnly = true;

            if (scope != FixAllScope.Document)
            {
                // No implementation yet for project/solution scopes
                // Requires global undo and a lot more work
                throw new NotImplementedException();
            }

            var mainBox = new VBox {
                MarginTop    = 6,
                MarginLeft   = 8,
                MarginRight  = 8,
                MarginBottom = 8,
            };

            // scopeLabel can be document filename, project/solution name.
            var treeViewHeaderText = GettextCatalog.GetString(
                "Fix all '{0}' in '{1}'",
                string.Format("<b>{0}</b>", diagnosticId),
                string.Format("<b>{0}</b>", scopeLabel)
                );

            mainBox.PackStart(new Label {
                Markup = treeViewHeaderText,
            });

            var col = new ListViewColumn();

            checkBox = new CheckBoxCellView(nodeCheck)
            {
                Editable = true,
            };
            checkBox.Toggled += OnCheckboxToggled;
            col.Views.Add(checkBox);
            col.Views.Add(new ImageCellView(nodeIcon)
            {
                VisibleField = nodeIconVisible,
            });
            col.Views.Add(new TextCellView(nodeLabel));
            treeView.Columns.Add(col);

            treeView.SelectionChanged += OnSelectionChanged;

            mainBox.PackStart(new ScrollView(treeView), true);

            var previewHeaderText = GettextCatalog.GetString("Preview Code Changes:");

            mainBox.PackStart(new Label(previewHeaderText)
            {
                MarginTop = 12,
            });

            mainBox.PackStart(new FrameBox(changedEditor)
            {
                BorderWidth = 2,
                BorderColor = Ide.Gui.Styles.FrameBoxBorderColor,
            }, true);

            Content = mainBox;
            Buttons.Add(Command.Cancel, Command.Apply);

            var rootNode             = store.AddNode();
            var fixAllOccurencesText = GettextCatalog.GetString("Fix all occurrences");

            rootNode.SetValues(nodeCheck, CheckBoxState.On, nodeLabel, fixAllOccurencesText, nodeIcon, ImageService.GetIcon("md-csharp-file"), nodeIconVisible, true);
        }
Exemple #17
0
        public void LoadQuery(StoredQuery query)
        {
            listView.Columns.Clear();
            using (var progress = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor(true, false, false))
            {
                var           fields = CachedMetaData.Instance.Fields;
                WorkItemStore store  = new WorkItemStore(query);
                var           data   = store.LoadByPage(progress);
                if (data.Count > 0)
                {
                    var firstItem = data[0];
                    List <IDataField> dataFields = new List <IDataField>();
                    var mapping = new Dictionary <Field, IDataField <object> >();
                    foreach (var item in firstItem.WorkItemInfo.Keys)
                    {
                        var field     = fields[item];
                        var dataField = new DataField <object>();
                        dataFields.Add(dataField);
                        mapping.Add(field, dataField);
                    }

                    if (dataFields.Any())
                    {
                        if (ShowCheckboxes)
                        {
                            isCheckedField = new DataField <bool>();
                            dataFields.Insert(0, isCheckedField);
                            var checkColumn = new CheckBoxCellView(isCheckedField)
                            {
                                Editable = true
                            };
                            checkColumn.Toggled += (sender, e) =>
                            {
                                var astore   = (TreeStore)listView.DataSource;
                                var node     = astore.GetNavigatorAt(listView.CurrentEventRow);
                                var workItem = node.GetValue(workItemField);
                                if (!node.GetValue(isCheckedField))
                                {
                                    if (OnSelectWorkItem != null)
                                    {
                                        OnSelectWorkItem(workItem);
                                    }
                                }
                                else
                                {
                                    if (OnRemoveWorkItem != null)
                                    {
                                        OnRemoveWorkItem(workItem);
                                    }
                                }
                            };
                            listView.Columns.Add("", checkColumn);
                        }
                        workItemField = new DataField <WorkItem>();
                        dataFields.Insert(0, workItemField);
                        var listStore = new TreeStore(dataFields.ToArray());
                        foreach (var map in mapping)
                        {
                            listView.Columns.Add(map.Key.Name, map.Value);
                        }
                        listView.DataSource = listStore;
                        foreach (var workItem in data)
                        {
                            var row = listStore.AddNode();
                            row.SetValue(workItemField, workItem);
                            foreach (var map in mapping)
                            {
                                object value;
                                if (workItem.WorkItemInfo.TryGetValue(map.Key.ReferenceName, out value))
                                {
                                    row.SetValue(map.Value, value);
                                }
                                else
                                {
                                    row.SetValue(map.Value, null);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #18
0
        internal static FrameworkElementFactory CreateBoundCellRenderer(CellView view, string dataPath = ".")
        {
            TextCellView textView = view as TextCellView;

            if (textView != null)
            {
                // if it's an editable textcontrol, use a TextBox, if not use a TextBlock. Reason for this is that
                // a user usually expects to be able to edit a text if a text cursor is appearing above a field.
                FrameworkElementFactory factory;
                if (textView.EditableField == null)
                {
                    if (textView.Editable)
                    {
                        factory = new FrameworkElementFactory(typeof(SWC.TextBox));
                        factory.SetValue(FrameworkElement.MarginProperty, CellMargins);
                        factory.SetValue(SWC.TextBox.IsReadOnlyProperty, false);
                        if (textView.TextField != null)
                        {
                            factory.SetBinding(SWC.TextBox.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]"));
                        }
                    }
                    else
                    {
                        factory = new FrameworkElementFactory(typeof(SWC.TextBlock));
                        factory.SetValue(FrameworkElement.MarginProperty, CellMargins);
                        if (textView.TextField != null)
                        {
                            factory.SetBinding(SWC.TextBlock.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]"));
                        }
                    }
                }
                else
                {
                    factory = new FrameworkElementFactory(typeof(SWC.TextBox));
                    factory.SetValue(FrameworkElement.MarginProperty, CellMargins);
                    factory.SetBinding(SWC.TextBox.IsEnabledProperty, new Binding(dataPath + "[" + textView.EditableField.Index + "]"));
                    if (textView.TextField != null)
                    {
                        factory.SetBinding(SWC.TextBox.TextProperty, new Binding(dataPath + "[" + textView.TextField.Index + "]"));
                    }
                }

                return(factory);
            }

            ImageCellView imageView = view as ImageCellView;

            if (imageView != null)
            {
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(ImageBox));
                factory.SetValue(FrameworkElement.MarginProperty, CellMargins);

                if (imageView.ImageField != null)
                {
                    var binding = new Binding(dataPath + "[" + imageView.ImageField.Index + "]")
                    {
                        Converter = new ImageToImageSourceConverter()
                    };

                    factory.SetBinding(ImageBox.ImageSourceProperty, binding);
                }

                return(factory);
            }

            CanvasCellView canvasView = view as CanvasCellView;

            if (canvasView != null)
            {
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CanvasCellViewBackend));
                factory.SetValue(FrameworkElement.MarginProperty, CellMargins);

                factory.SetValue(CanvasCellViewBackend.CellViewProperty, view);

                return(factory);
            }

            CheckBoxCellView cellView = view as CheckBoxCellView;

            if (cellView != null)
            {
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(SWC.CheckBox));
                if (cellView.EditableField == null)
                {
                    factory.SetValue(FrameworkElement.IsEnabledProperty, cellView.Editable);
                }
                else
                {
                    factory.SetBinding(SWC.CheckBox.IsEnabledProperty, new Binding(dataPath + "[" + cellView.EditableField.Index + "]"));
                }

                factory.SetValue(SWC.CheckBox.IsThreeStateProperty, cellView.AllowMixed);
                factory.SetValue(FrameworkElement.MarginProperty, CellMargins);
                if (cellView.ActiveField != null)
                {
                    factory.SetBinding(SWC.CheckBox.IsCheckedProperty, new Binding(dataPath + "[" + cellView.ActiveField.Index + "]"));
                }

                return(factory);
            }

            throw new NotImplementedException();
        }
Exemple #19
0
        public TreeViews()
        {
            TreeView  view  = new TreeView();
            TreeStore store = new TreeStore(triState, check, text, desc);

            var triStateCellView = new CheckBoxCellView(triState)
            {
                Editable = true, AllowMixed = true
            };

            triStateCellView.Toggled += (object sender, WidgetEventArgs e) => {
                if (view.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "TriState Toggled");
                }
            };
            var checkCellView = new CheckBoxCellView(check)
            {
                Editable = true
            };

            checkCellView.Toggled += (object sender, WidgetEventArgs e) => {
                if (view.CurrentEventRow == null)
                {
                    MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen");
                }
                else
                {
                    store.GetNavigatorAt(view.CurrentEventRow).SetValue(text, "Toggled");
                }
            };
            view.Columns.Add("TriCheck", triStateCellView);
            view.Columns.Add("Check", checkCellView);
            view.Columns.Add("Item", text);
            view.Columns.Add("Desc", desc);

            store.AddNode().SetValue(text, "One").SetValue(desc, "First").SetValue(triState, CheckBoxState.Mixed);
            store.AddNode().SetValue(text, "Two").SetValue(desc, "Second").AddChild()
            .SetValue(text, "Sub two").SetValue(desc, "Sub second");
            store.AddNode().SetValue(text, "Three").SetValue(desc, "Third").AddChild()
            .SetValue(text, "Sub three").SetValue(desc, "Sub third");
            PackStart(view, true);

            view.DataSource = store;

            Label la = new Label();

            PackStart(la);

            view.SetDragDropTarget(DragDropAction.All, TransferDataType.Text);
            view.SetDragSource(DragDropAction.All, TransferDataType.Text);

            view.DragDrop += delegate(object sender, DragEventArgs e) {
                TreePosition    node;
                RowDropPosition pos;
                view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node);
                var nav = store.GetNavigatorAt(node);
                la.Text  += "Dropped \"" + e.Data.Text + "\" into \"" + nav.GetValue(text) + "\" " + pos + "\n";
                e.Success = true;
            };
            view.DragOver += delegate(object sender, DragOverEventArgs e) {
                TreePosition    node;
                RowDropPosition pos;
                view.GetDropTargetRow(e.Position.X, e.Position.Y, out pos, out node);
                if (pos == RowDropPosition.Into)
                {
                    e.AllowedAction = DragDropAction.None;
                }
                else
                {
                    e.AllowedAction = e.Action;
                }
            };
            view.DragStarted += delegate(object sender, DragStartedEventArgs e) {
                var val = store.GetNavigatorAt(view.SelectedRow).GetValue(text);
                e.DragOperation.Data.AddValue(val);
                e.DragOperation.Finished += delegate(object s, DragFinishedEventArgs args) {
                    Console.WriteLine("D:" + args.DeleteSource);
                };
            };

            Button addButton = new Button("Add");

            addButton.Clicked += delegate(object sender, EventArgs e) {
                store.AddNode().SetValue(text, "Added").SetValue(desc, "Desc");
            };
            PackStart(addButton);

            Button removeButton = new Button("Remove Selection");

            removeButton.Clicked += delegate(object sender, EventArgs e) {
                foreach (TreePosition row in view.SelectedRows)
                {
                    store.GetNavigatorAt(row).Remove();
                }
            };
            PackStart(removeButton);

            var label = new Label();

            PackStart(label);

            view.RowExpanded += (sender, e) => label.Text = "Row expanded: " + store.GetNavigatorAt(e.Position).GetValue(text);
        }