Esempio n. 1
0
        public CheckConstraintEditorWidget(ISchemaProvider schemaProvider, SchemaActions action, CheckConstraintEditorSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }

            this.schemaProvider = schemaProvider;
            this.settings       = settings;
            this.action         = action;

            this.Build();

            store = new ListStore(typeof(string), typeof(string), typeof(bool), typeof(string), typeof(object));

            listCheck.Model = store;

            TreeViewColumn colName               = new TreeViewColumn();
            TreeViewColumn colColumn             = new TreeViewColumn();
            TreeViewColumn colIsColumnConstraint = new TreeViewColumn();

            colName.Title               = AddinCatalog.GetString("Name");
            colColumn.Title             = AddinCatalog.GetString("Column");
            colIsColumnConstraint.Title = AddinCatalog.GetString("Column Constraint");

            colColumn.MinWidth = 120;             //request a bigger width

            CellRendererText nameRenderer = new CellRendererText();

            columnRenderer = new CellRendererCombo();
            CellRendererToggle isColumnConstraintRenderer = new CellRendererToggle();

            nameRenderer.Editable = true;
            nameRenderer.Edited  += new EditedHandler(NameEdited);

            columnRenderer.TextColumn = SortedColumnListStore.ColNameIndex;
            columnRenderer.Editable   = true;
            columnRenderer.Edited    += new EditedHandler(ColumnEdited);

            isColumnConstraintRenderer.Activatable = true;
            isColumnConstraintRenderer.Toggled    += new ToggledHandler(IsColumnConstraintToggled);

            colName.PackStart(nameRenderer, true);
            colColumn.PackStart(columnRenderer, true);
            colIsColumnConstraint.PackStart(isColumnConstraintRenderer, true);

            colName.AddAttribute(nameRenderer, "text", colNameIndex);
            colColumn.AddAttribute(columnRenderer, "text", colColumnNameIndex);
            colIsColumnConstraint.AddAttribute(isColumnConstraintRenderer, "active", colIsColumnConstraintIndex);

            listCheck.AppendColumn(colName);
            if (settings.SupportsColumnConstraints)
            {
                listCheck.AppendColumn(colColumn);
            }
            if (settings.SupportsColumnConstraints && settings.SupportsTableConstraints)
            {
                listCheck.AppendColumn(colIsColumnConstraint);
            }

            listCheck.Selection.Changed += new EventHandler(OnSelectionChanged);
            sqlEditor.TextChanged       += new EventHandler(SourceChanged);

            ShowAll();
        }
Esempio n. 2
0
        public StringListWidget()
        {
            treeview = new Gtk.TreeView();
            treeview.HeadersVisible = false;
            PackStart(treeview, true, true, 0);
            ShowAll();

            var col = new TreeViewColumn {
                MinWidth = CellRendererAddRemove.MinWidth, Resizable = true, Sizing = Gtk.TreeViewColumnSizing.Autosize
            };
            var addRemoveRenderer = new CellRendererAddRemove();

            col.PackStart(addRemoveRenderer, false);
            col.SetCellDataFunc(addRemoveRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                if (treeStore.GetValue(iter, (int)ListColumn.Object) != null)
                {
                    addRemoveRenderer.Action = CellRendererAddRemove.AddRemoveAction.Remove;
                }
                else
                {
                    addRemoveRenderer.Action = CellRendererAddRemove.AddRemoveAction.Add;
                }
            });
            addRemoveRenderer.RemoveClicked += delegate {
                TreeIter iter;
                bool     hasSelection = treeview.Selection.GetSelected(out iter);
                PObject  obj          = null;
                if (hasSelection)
                {
                    obj = (PObject)treeStore.GetValue(iter, (int)ListColumn.Object);
                    treeStore.Remove(ref iter);

                    editing = true;
                    obj.Remove();
                    editing = false;
                }
            };
            addRemoveRenderer.AddClicked += delegate {
                PObject  obj = new PString(string.Empty);
                TreeIter iter;

                bool hasSelection = treeview.Selection.GetSelected(out iter);
                if (hasSelection)
                {
                    treeStore.SetValues(iter, string.Empty, obj);
                    AppendCreateNewEntry();

                    editing = true;
                    array.Add(obj);
                    editing = false;
                }
            };
            treeview.AppendColumn(col);

            var valueRenderer = new CellRendererCombo();

            valueRenderer.Mode       = CellRendererMode.Editable;
            valueRenderer.TextColumn = (int)ListColumn.DisplayValue;

            valueRenderer.Edited += delegate(object o, EditedArgs args) {
                TreeIter iter;

                if (!treeStore.GetIterFromString(out iter, args.Path))
                {
                    return;
                }

                var pObject = (PObject)treeStore.GetValue(iter, (int)ListColumn.Object);
                if (pObject == null)
                {
                    return;
                }

                string newValue = !string.IsNullOrEmpty(ValuePrefix) ? ValuePrefix + args.NewText : args.NewText;

                pObject.SetValue(newValue);
            };

            treeview.AppendColumn(GettextCatalog.GetString("Value"), valueRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                var text     = (string)tree_model.GetValue(iter, (int)ListColumn.DisplayValue);
                var obj      = (PObject)tree_model.GetValue(iter, (int)ListColumn.Object);
                var renderer = (CellRendererCombo)cell;

                renderer.Sensitive = obj != null;
                renderer.Editable  = obj != null;
                renderer.Text      = text;
            });

            treeview.EnableGridLines = TreeViewGridLines.Horizontal;
            treeview.Model           = treeStore;
        }
Esempio n. 3
0
        public DueDateColumn()
        {
            TreeViewColumn = new TreeViewColumn {
                Title = Catalog.GetString ("Due Date"),
                Sizing = TreeViewColumnSizing.Fixed,
                Alignment = 0f,
                FixedWidth = 90,
                Resizable = false,
                Clickable = true
            };

            var dueDateStore = new ListStore (typeof (string));
            var today = DateTime.Now;
            dueDateStore.AppendValues (
                today.ToString (Catalog.GetString ("M/d - ")) + Catalog.GetString ("Today"));
            dueDateStore.AppendValues (
                today.AddDays (1).ToString (Catalog.GetString ("M/d - ")) + Catalog.GetString ("Tomorrow"));
            dueDateStore.AppendValues (
                today.AddDays (2).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (3).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (4).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (5).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (6).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (7).ToString (Catalog.GetString ("M/d - ")) + Catalog.GetString ("In 1 Week"));
            dueDateStore.AppendValues (Catalog.GetString ("No Date"));
            dueDateStore.AppendValues (Catalog.GetString ("Choose Date..."));

            var renderer = new CellRendererCombo {
                Editable = true,
                HasEntry = false,
                Model = dueDateStore,
                TextColumn = 0,
                Xalign = 0.0f
            };

            renderer.EditingStarted += (o, args) => {
                TreeIter iter;
                var path = new TreePath (args.Path);
                if (!model.GetIter (out iter, path))
                    return;

                var task = model.GetValue (iter, 0) as ITask;
                if (task == null)
                    return;

                taskBeingEdited = new TaskBeingEdited (task, iter, path);
                if (CellEditingStarted != null)
                    CellEditingStarted (this, new TaskRowEditingEventArgs (task, iter, path));
            };

            renderer.EditingCanceled += delegate { EndCellEditing (); };

            renderer.Edited += (o, args) => {
                TreeIter iter;
                var path = new TreePath (args.Path);
                var newText = args.NewText;
                if (newText != null && model.GetIter (out iter, path)) {

                    //  2/11 - Today
                    //  2/12 - Tomorrow
                    //  2/13 - Wed
                    //  2/14 - Thu
                    //  2/15 - Fri
                    //  2/16 - Sat
                    //  2/17 - Sun
                    // --------------
                    //  2/18 - In 1 Week
                    // --------------
                    //  No Date
                    // ---------------
                    //  Choose Date...

                    var newDate = DateTime.MinValue;
                    var tday = DateTime.Now;
                    var task = model.GetValue (iter, 0) as ITask;

                    if (newText == tday.ToString (Catalog.GetString ("M/d - ")) + Catalog.GetString ("Today"))
                        newDate = tday;
                    else if (newText == tday.AddDays (1).ToString (Catalog.GetString ("M/d - "))
                             + Catalog.GetString ("Tomorrow"))
                        newDate = tday.AddDays (1);
                    else if (newText == Catalog.GetString ("No Date"))
                        newDate = DateTime.MinValue;
                    else if (newText == tday.AddDays (7).ToString (Catalog.GetString ("M/d - "))
                             + Catalog.GetString ("In 1 Week"))
                        newDate = tday.AddDays (7);
                    else if (newText == Catalog.GetString ("Choose Date...")) {
                        var tc = new TaskCalendar (task, view.TreeView.Parent);
                        tc.ShowCalendar ();
                        return;
                    } else {
                        for (int i = 2; i <= 6; i++) {
                            DateTime testDate = tday.AddDays (i);
                            if (testDate.ToString (Catalog.GetString ("M/d - ddd")) == newText) {
                                newDate = testDate;
                                break;
                            }
                        }
                    }

                    Logger.Debug ("task.State {0}", task.State);

                    if (task.State != TaskState.Completed) {
                        // Modify the due date
                        task.DueDate = newDate;
                    }
                }
                EndCellEditing ();
            };

            TreeViewColumn.PackStart (renderer, true);
            TreeViewColumn.SetCellDataFunc (renderer, DueDateCellDataFunc);
        }
Esempio n. 4
0
        public PropertyGridTable()
        {
            Build();

            items     = new List <TreeItem> ();
            pitems    = new List <TreeItem> ();
            eitems    = new List <EventItem> ();
            nulliter  = new TreeIter();
            sortgroup = true;

            var column1 = new TreeViewColumn();

            column1.Sizing     = TreeViewColumnSizing.Fixed;
            column1.FixedWidth = 100;
            column1.Resizable  = true;
            column1.Title      = "Name";

            var textCell1 = new CellRendererText();

            textCell1.Underline = Pango.Underline.Single;
            column1.PackStart(textCell1, false);

            var textCell2 = new CellRendererText();

            column1.PackStart(textCell2, false);

            var idCell = new CellRendererText();

            idCell.Visible = false;
            column1.PackStart(idCell, false);

            treeview1.AppendColumn(column1);

            var column2 = new TreeViewColumn();

            column2.Sizing    = TreeViewColumnSizing.Fixed;
            column2.Resizable = true;
            column2.Title     = "Value";

            var editTextCell = new CellRendererText();

            editTextCell.Edited += delegate(object o, EditedArgs args) {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected(out model, out iter))
                {
                    int id = Convert.ToInt32(model.GetValue(iter, 11));

                    for (int i = 0; i < eitems.Count; i++)
                    {
                        if (eitems[i].id == id)
                        {
                            if (eitems[i].eventHandler != null)
                            {
                                var fwidget = new FalseWidget(args.NewText);
                                eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                model.SetValue(iter, 4, args.NewText);
                                break;
                            }
                        }
                    }
                }
            };

            column2.PackStart(editTextCell, false);

            var editTextCell2 = new CellRendererText();
            editTextCell2.Editable        = true;
            editTextCell2.EditingStarted += delegate {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected(out model, out iter))
                {
                    var dialog = new CollectionEditorDialog(window, model.GetValue(iter, 14).ToString());
                    if (dialog.Run() == (int)ResponseType.Ok)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for (int i = 0; i < eitems.Count; i++)
                        {
                            if (eitems[i].id == id)
                            {
                                if (eitems[i].eventHandler != null)
                                {
                                    var fwidget = new FalseWidget(dialog.text);
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 14, dialog.text);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart(editTextCell2, false);

            var editTextCell4 = new CellRendererText();
            editTextCell4.Editable        = true;
            editTextCell4.EditingStarted += delegate {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected(out model, out iter))
                {
                    var col      = new Microsoft.Xna.Framework.Color();
                    int response = (int)ResponseType.Reject;

                    if (Global.GtkMajorVersion < 3 || (Global.GtkMajorVersion == 3 && Global.GtkMinorVersion < 3))
                    {
                        var dialog = new ColorSelectionDialog("Color Chooser");
                        dialog.TransientFor = window;
                        dialog.ColorSelection.HasPalette        = true;
                        dialog.ColorSelection.HasOpacityControl = true;

                        try
                        {
                            string[] cvalues = model.GetValue(iter, 15).ToString().Replace(":", " ").Replace("}", " ").Split(' ');

                            byte red   = (byte)Convert.ToInt16(cvalues [1]);
                            byte green = (byte)Convert.ToInt16(cvalues [3]);
                            byte blue  = (byte)Convert.ToInt16(cvalues [5]);
                            int  alpha = Convert.ToInt32(cvalues [7]);

                            dialog.ColorSelection.CurrentColor = new Gdk.Color(red, green, blue);
                            dialog.ColorSelection.CurrentAlpha = (ushort)(alpha * 257);
                        }
                        catch { }

                        response = dialog.Run();

                        col.R = (byte)Convert.ToInt32(dialog.ColorSelection.CurrentColor.Red);
                        col.G = (byte)Convert.ToInt32(dialog.ColorSelection.CurrentColor.Green);
                        col.B = (byte)Convert.ToInt32(dialog.ColorSelection.CurrentColor.Blue);
                        col.A = (byte)(dialog.ColorSelection.CurrentAlpha / 257);

                        dialog.Destroy();
                    }
                    else
                    {
                        #if LINUX
                        Gdk.RGBA rgba = new Gdk.RGBA();

                        try
                        {
                            string[] cvalues = model.GetValue(iter, 15).ToString().Replace(":", " ").Replace("}", " ").Split(' ');
                            rgba.Parse("rgba(" + cvalues [1] + "," + cvalues [3] + "," + cvalues [5] + "," + cvalues [7] + ")");
                        }
                        catch { }

                        var dialog = new ColorChooserDialog(window, "Color Chooser");
                        dialog.ColorChooser.CurrentRgba = rgba;
                        response = (int)dialog.Run();

                        rgba = dialog.ColorChooser.CurrentRgba;
                        dialog.Destroy();

                        string[] split = rgba.ToString().Split('(', ')')[1].Split(',');

                        col.R = (byte)Convert.ToInt32(split[0]);
                        col.G = (byte)Convert.ToInt32(split[1]);
                        col.B = (byte)Convert.ToInt32(split[2]);

                        if (split.Length == 4)
                        {
                            col.A = (byte)Convert.ToInt32(double.Parse(split[3]) * 255);
                        }
                        else
                        {
                            col.A = 255;
                        }
                        #endif
                    }

                    if (response == (int)ResponseType.Ok)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for (int i = 0; i < eitems.Count; i++)
                        {
                            if (eitems[i].id == id)
                            {
                                if (eitems[i].eventHandler != null)
                                {
                                    var fwidget = new FalseWidget(col.ToString());
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 15, col.ToString());
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart(editTextCell4, false);

            var editTextCell3 = new CellRendererText();
            editTextCell3.Visible = false;
            column2.PackStart(editTextCell3, false);

            var comboCell = new CellRendererCombo();
            comboCell.TextColumn = 0;
            comboCell.IsExpanded = true;
            comboCell.Editable   = true;
            comboCell.HasEntry   = false;
            comboCell.Edited    += delegate(object o, EditedArgs args) {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected(out model, out iter))
                {
                    int id = Convert.ToInt32(model.GetValue(iter, 11));

                    for (int i = 0; i < eitems.Count; i++)
                    {
                        if (eitems[i].id == id)
                        {
                            if (eitems[i].eventHandler != null && args.NewText != null && args.NewText != "")
                            {
                                var fwidget = new FalseWidget(args.NewText);
                                eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                model.SetValue(iter, 8, args.NewText);
                                break;
                            }
                        }
                    }
                }
            };

            column2.PackStart(comboCell, false);

            var editFilePathCell = new CellRendererText();
            editFilePathCell.Editable        = true;
            editFilePathCell.EditingStarted += delegate(object o, EditingStartedArgs args) {
                #if GTK2
                TreeModel model;
                #elif GTK3
                ITreeModel model;
                #endif
                TreeIter iter;

                if (treeview1.Selection.GetSelected(out model, out iter))
                {
                    var dialog     = new CustomFolderDialog(window, model.GetValue(iter, 17).ToString());
                    var responseid = dialog.Run();
                    var fileName   = dialog.FileName;
                    dialog.Destroy();

                    if (responseid != (int)ResponseType.Ok)
                    {
                        return;
                    }

                    int id = Convert.ToInt32(model.GetValue(iter, 11));

                    for (int i = 0; i < eitems.Count; i++)
                    {
                        if (eitems[i].id != id || eitems[i].eventHandler == null)
                        {
                            continue;
                        }

                        var fwidget = new FalseWidget(fileName);
                        eitems[i].eventHandler(fwidget, EventArgs.Empty);
                        model.SetValue(iter, 17, fileName);

                        break;
                    }
                }
            };
            column2.PackStart(editFilePathCell, false);

            treeview1.AppendColumn(column2);

            column1.AddAttribute(textCell1, "text", 0);
            column1.AddAttribute(textCell1, "visible", 1);
            column1.AddAttribute(textCell2, "text", 2);
            column1.AddAttribute(textCell2, "visible", 3);
            column2.AddAttribute(editTextCell, "text", 4);
            column2.AddAttribute(editTextCell, "visible", 5);
            column2.AddAttribute(editTextCell, "editable", 6);
            column2.AddAttribute(comboCell, "model", 7);
            column2.AddAttribute(comboCell, "text", 8);
            column2.AddAttribute(comboCell, "editable", 9);
            column2.AddAttribute(comboCell, "visible", 10);
            column1.AddAttribute(idCell, "text", 11);
            column2.AddAttribute(editTextCell2, "text", 12);
            column2.AddAttribute(editTextCell2, "visible", 13);
            column2.AddAttribute(editTextCell3, "text", 14);
            column2.AddAttribute(editTextCell4, "text", 15);
            column2.AddAttribute(editTextCell4, "visible", 16);
            column2.AddAttribute(editFilePathCell, "text", 17);
            column2.AddAttribute(editFilePathCell, "visible", 18);

            listStore       = new TreeStore(typeof(string), typeof(bool), typeof(string), typeof(bool), typeof(string), typeof(bool), typeof(bool), typeof(TreeStore), typeof(string), typeof(bool), typeof(bool), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(bool));
            treeview1.Model = listStore;
        }
Esempio n. 5
0
        public PropertyGridTable()
        {
            Build();

            items     = new List <TreeItem> ();
            pitems    = new List <TreeItem> ();
            eitems    = new List <EventItem> ();
            nulliter  = new TreeIter();
            sortgroup = true;

            var column1 = new TreeViewColumn();

            column1.Sizing     = TreeViewColumnSizing.Fixed;
            column1.FixedWidth = 100;
            column1.Resizable  = true;
            column1.Title      = "Name";

            var textCell1 = new CellRendererText();

            textCell1.Underline = Pango.Underline.Single;
            column1.PackStart(textCell1, false);

            var textCell2 = new CellRendererText();

            column1.PackStart(textCell2, false);

            var idCell = new CellRendererText();

            idCell.Visible = false;
            column1.PackStart(idCell, false);

            treeview1.AppendColumn(column1);

            var column2 = new TreeViewColumn();

            column2.Sizing    = TreeViewColumnSizing.Fixed;
            column2.Resizable = true;
            column2.Title     = "Value";

            var editTextCell = new CellRendererText();

            editTextCell.Edited += delegate(object o, EditedArgs args) {
                TreeModel model;
                TreeIter  iter;

                if (treeview1.Selection.GetSelected(out model, out iter))
                {
                    int id = Convert.ToInt32(model.GetValue(iter, 11));

                    for (int i = 0; i < eitems.Count; i++)
                    {
                        if (eitems[i].id == id)
                        {
                            if (eitems[i].eventHandler != null)
                            {
                                var fwidget = new FalseWidget(args.NewText);
                                eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                model.SetValue(iter, 4, args.NewText);
                                break;
                            }
                        }
                    }
                }
            };

            column2.PackStart(editTextCell, false);

            var editTextCell2 = new CellRendererText();

            editTextCell2.Editable        = true;
            editTextCell2.EditingStarted += delegate {
                TreeModel model;
                TreeIter  iter;

                if (treeview1.Selection.GetSelected(out model, out iter))
                {
                    var dialog = new CollectionEditorDialog(model.GetValue(iter, 14).ToString());
                    dialog.TransientFor = window;
                    if (dialog.Run() == (int)ResponseType.Ok)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for (int i = 0; i < eitems.Count; i++)
                        {
                            if (eitems[i].id == id)
                            {
                                if (eitems[i].eventHandler != null)
                                {
                                    var fwidget = new FalseWidget(dialog.text);
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 14, dialog.text);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart(editTextCell2, false);

            var editTextCell4 = new CellRendererText();

            editTextCell4.Editable        = true;
            editTextCell4.EditingStarted += delegate {
                TreeModel model;
                TreeIter  iter;

                if (treeview1.Selection.GetSelected(out model, out iter))
                {
                    var dialog = new ColorPickerDialog(model.GetValue(iter, 15).ToString());
                    dialog.TransientFor = window;
                    if (dialog.Run() == (int)ResponseType.Ok)
                    {
                        int id = Convert.ToInt32(model.GetValue(iter, 11));

                        for (int i = 0; i < eitems.Count; i++)
                        {
                            if (eitems[i].id == id)
                            {
                                if (eitems[i].eventHandler != null)
                                {
                                    var fwidget = new FalseWidget(dialog.data);
                                    eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                    model.SetValue(iter, 15, dialog.data);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            column2.PackStart(editTextCell4, false);

            var editTextCell3 = new CellRendererText();

            editTextCell3.Visible = false;
            column2.PackStart(editTextCell3, false);

            var comboCell = new CellRendererCombo();

            comboCell.TextColumn = 0;
            comboCell.IsExpanded = true;
            comboCell.Editable   = true;
            comboCell.HasEntry   = false;
            comboCell.Edited    += delegate(object o, EditedArgs args) {
                TreeModel model;
                TreeIter  iter;

                if (treeview1.Selection.GetSelected(out model, out iter))
                {
                    int id = Convert.ToInt32(model.GetValue(iter, 11));

                    for (int i = 0; i < eitems.Count; i++)
                    {
                        if (eitems[i].id == id)
                        {
                            if (eitems[i].eventHandler != null && args.NewText != null && args.NewText != "")
                            {
                                var fwidget = new FalseWidget(args.NewText);
                                eitems[i].eventHandler(fwidget, EventArgs.Empty);
                                model.SetValue(iter, 8, args.NewText);
                                break;
                            }
                        }
                    }
                }
            };

            column2.PackStart(comboCell, false);

            treeview1.AppendColumn(column2);

            column1.AddAttribute(textCell1, "text", 0);
            column1.AddAttribute(textCell1, "visible", 1);
            column1.AddAttribute(textCell2, "text", 2);
            column1.AddAttribute(textCell2, "visible", 3);
            column2.AddAttribute(editTextCell, "text", 4);
            column2.AddAttribute(editTextCell, "visible", 5);
            column2.AddAttribute(editTextCell, "editable", 6);
            column2.AddAttribute(comboCell, "model", 7);
            column2.AddAttribute(comboCell, "text", 8);
            column2.AddAttribute(comboCell, "editable", 9);
            column2.AddAttribute(comboCell, "visible", 10);
            column1.AddAttribute(idCell, "text", 11);
            column2.AddAttribute(editTextCell2, "text", 12);
            column2.AddAttribute(editTextCell2, "visible", 13);
            column2.AddAttribute(editTextCell3, "text", 14);
            column2.AddAttribute(editTextCell4, "text", 15);
            column2.AddAttribute(editTextCell4, "visible", 16);

            listStore       = new TreeStore(typeof(string), typeof(bool), typeof(string), typeof(bool), typeof(string), typeof(bool), typeof(bool), typeof(TreeStore), typeof(string), typeof(bool), typeof(bool), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(bool));
            treeview1.Model = listStore;
        }
Esempio n. 6
0
 public override void RenderValue(CustomPropertiesWidget widget, CellRendererCombo renderer)
 {
     renderer.Sensitive = false;
     renderer.Text      = string.Format(GettextCatalog.GetPluralString("({0} item)", "({0} items)", Count), Count);
 }
Esempio n. 7
0
 public override void RenderValue(CustomPropertiesWidget widget, CellRendererCombo renderer)
 {
     renderer.Sensitive = false;
     renderer.Text      = string.Format("byte[{0}]", Value != null ? Value.Length : 0);
 }
        public LoadBankTransferDocumentDlg()
        {
            this.Build();
            _uow    = UnitOfWorkFactory.CreateWithoutRoot();
            TabName = "Загрузка из банк-клиента";

            var txtFilter = new FileFilter();

            txtFilter.AddPattern("*.txt");
            txtFilter.Name = "Текстовые файлы (*.txt)";
            var allFilter = new FileFilter();

            allFilter.AddPattern("*");
            allFilter.Name = "Все файлы";
            filechooser.AddFilter(txtFilter);
            filechooser.AddFilter(allFilter);

            labelDescription1.Markup = String.Format("<span background=\"{0}\">     </span> - объект будет создан", NeedToAdd);

            foreach (var category in _categoryRepository.ExpenseCategories(_uow))
            {
                expenseCategories.AppendValues(category.Name, category);
            }
            foreach (var category in _categoryRepository.IncomeCategories(_uow))
            {
                incomeCategories.AppendValues(category.Name, category);
            }

            TreeViewColumn checkColumn = new TreeViewColumn();

            checkColumn.Title = "";
            CellRendererToggle checkCell = new CellRendererToggle();

            checkCell.Activatable = true;
            checkCell.Toggled    += CheckCell_Toggled;
            checkColumn.PackStart(checkCell, true);
            checkColumn.AddAttribute(checkCell, "active", (int)Columns.CheckCol);


            TreeViewColumn numberColumn = new TreeViewColumn();

            numberColumn.Title = "№";
            CellRendererText numberCell = new CellRendererText();

            numberCell.Background = EvenRowColor;
            numberColumn.PackStart(numberCell, true);
            numberColumn.AddAttribute(numberCell, "text", (int)Columns.NumberCol);

            TreeViewColumn dateColumn = new TreeViewColumn();

            dateColumn.Title = "Дата";
            CellRendererText dateCell = new CellRendererText();

            dateColumn.PackStart(dateCell, true);
            dateColumn.AddAttribute(dateCell, "text", (int)Columns.DateCol);

            TreeViewColumn totalColumn = new TreeViewColumn();

            totalColumn.Title = "Сумма";
            CellRendererText totalCell = new CellRendererText();

            totalCell.Background = EvenRowColor;
            totalColumn.PackStart(totalCell, true);
            totalColumn.AddAttribute(totalCell, "text", (int)Columns.TotalCol);

            TreeViewColumn payerColumn = new TreeViewColumn();

            payerColumn.Title = "Плательщик";
            CellRendererText payerCell = new CellRendererText();

            payerCell.WidthChars = 40;
            payerColumn.PackStart(payerCell, true);
            payerColumn.AddAttribute(payerCell, "text", (int)Columns.PayerNameCol);
            payerColumn.AddAttribute(payerCell, "background", (int)Columns.PayerNameColorCol);
            payerColumn.Resizable = true;

            TreeViewColumn payerAccountColumn = new TreeViewColumn();

            payerAccountColumn.Title = "Счет плательщика";
            CellRendererText payerAccountCell = new CellRendererText();

            payerAccountColumn.PackStart(payerAccountCell, true);
            payerAccountColumn.AddAttribute(payerAccountCell, "text", (int)Columns.PayerAccountCol);
            payerAccountColumn.AddAttribute(payerAccountCell, "background", (int)Columns.PayerAccountColorCol);
            payerAccountColumn.Visible = false;

            TreeViewColumn payerBankColumn = new TreeViewColumn();

            payerBankColumn.Title = "Банк плательщика";
            CellRendererText payerBankCell = new CellRendererText();

            payerBankCell.WidthChars = 40;
            payerBankColumn.PackStart(payerBankCell, true);
            payerBankColumn.AddAttribute(payerBankCell, "text", (int)Columns.PayerBankCol);
            payerBankColumn.AddAttribute(payerBankCell, "background", (int)Columns.PayerBankColorCol);
            payerBankColumn.Resizable = true;
            payerBankColumn.Visible   = false;

            TreeViewColumn recipientColumn = new TreeViewColumn();

            recipientColumn.Title = "Получатель";
            CellRendererText recipientCell = new CellRendererText();

            recipientCell.WidthChars = 40;
            recipientColumn.PackStart(recipientCell, true);
            recipientColumn.AddAttribute(recipientCell, "text", (int)Columns.RecipientNameCol);
            recipientColumn.AddAttribute(recipientCell, "background", (int)Columns.RecipientNameColorCol);
            recipientColumn.Resizable = true;

            TreeViewColumn recipientAccountColumn = new TreeViewColumn();

            recipientAccountColumn.Title = "Счет получателя";
            CellRendererText recipientAccountCell = new CellRendererText();

            recipientAccountColumn.PackStart(recipientAccountCell, true);
            recipientAccountColumn.AddAttribute(recipientAccountCell, "text", (int)Columns.RecipientAccountCol);
            recipientAccountColumn.AddAttribute(recipientAccountCell, "background", (int)Columns.RecipientAccountColorCol);
            recipientAccountColumn.Visible = false;

            TreeViewColumn recipientBankColumn = new TreeViewColumn();

            recipientBankColumn.Title = "Банк получателя";
            CellRendererText recipientBankCell = new CellRendererText();

            recipientBankCell.WidthChars = 40;
            recipientBankColumn.PackStart(recipientBankCell, true);
            recipientBankColumn.AddAttribute(recipientBankCell, "text", (int)Columns.RecipientBankCol);
            recipientBankColumn.AddAttribute(recipientBankCell, "background", (int)Columns.RecipientBankColorCol);
            recipientBankColumn.Resizable = true;
            recipientBankColumn.Visible   = false;

            TreeViewColumn paymentReasonColumn = new TreeViewColumn();

            paymentReasonColumn.Title = "Назначение платежа";
            CellRendererText paymentReasonCell = new CellRendererText();

            paymentReasonCell.WidthChars = 40;
            paymentReasonColumn.PackStart(paymentReasonCell, true);
            paymentReasonColumn.AddAttribute(paymentReasonCell, "text", (int)Columns.PaymentReasonCol);
            paymentReasonColumn.Resizable = true;

            TreeViewColumn categoryColumn = new TreeViewColumn();

            categoryColumn.Title = "Категория дохода/расхода";
            CellRendererCombo categoryCombo = new CellRendererCombo();

            categoryCombo.TextColumn = 0;
            categoryCombo.Editable   = true;
            categoryCombo.HasEntry   = false;
            categoryCombo.Edited    += CategoryCombo_Edited;
            categoryColumn.PackStart(categoryCombo, true);
            categoryColumn.AddAttribute(categoryCombo, "model", (int)Columns.CategoryComboModel);
            categoryColumn.AddAttribute(categoryCombo, "text", (int)Columns.CategoryName);

            treeDocuments.AppendColumn(checkColumn);
            treeDocuments.AppendColumn(numberColumn);
            treeDocuments.AppendColumn(dateColumn);
            treeDocuments.AppendColumn(totalColumn);
            treeDocuments.AppendColumn(categoryColumn);
            treeDocuments.AppendColumn(payerColumn);
            treeDocuments.AppendColumn(payerAccountColumn);
            treeDocuments.AppendColumn(payerBankColumn);
            treeDocuments.AppendColumn(recipientColumn);
            treeDocuments.AppendColumn(recipientAccountColumn);
            treeDocuments.AppendColumn(recipientBankColumn);
            treeDocuments.AppendColumn(paymentReasonColumn);

            treeDocuments.Model         = documents;
            treeDocuments.TooltipColumn = (int)Columns.PaymentReasonCol;

            buttonUpload.Sensitive   = buttonReadFile.Sensitive = false;
            checkButtonAll.Sensitive = false;
        }
Esempio n. 9
0
        public CheckConstraintEditorWidget(ISchemaProvider schemaProvider, SchemaActions action, TableSchema table, ColumnSchemaCollection columns, ConstraintSchemaCollection constraints)
        {
            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }
            if (constraints == null)
            {
                throw new ArgumentNullException("constraints");
            }
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }

            this.schemaProvider = schemaProvider;
            this.table          = table;
            this.columns        = columns;
            this.constraints    = constraints;
            this.action         = action;

            this.Build();

            store        = new ListStore(typeof(string), typeof(string), typeof(bool), typeof(string), typeof(object));
            storeColumns = new SortedColumnListStore(columns);

            listCheck.Model = store;

            TreeViewColumn colName               = new TreeViewColumn();
            TreeViewColumn colColumn             = new TreeViewColumn();
            TreeViewColumn colIsColumnConstraint = new TreeViewColumn();

            colName.Title               = GettextCatalog.GetString("Name");
            colColumn.Title             = GettextCatalog.GetString("Column");
            colIsColumnConstraint.Title = GettextCatalog.GetString("Column Constraint");

            colColumn.MinWidth = 120;             //request a bigger width

            CellRendererText   nameRenderer               = new CellRendererText();
            CellRendererCombo  columnRenderer             = new CellRendererCombo();
            CellRendererToggle isColumnConstraintRenderer = new CellRendererToggle();

            nameRenderer.Editable = true;
            nameRenderer.Edited  += new EditedHandler(NameEdited);

            columnRenderer.Model      = storeColumns.Store;
            columnRenderer.TextColumn = SortedColumnListStore.ColNameIndex;
            columnRenderer.Editable   = true;
            columnRenderer.Edited    += new EditedHandler(ColumnEdited);

            isColumnConstraintRenderer.Activatable = true;
            isColumnConstraintRenderer.Toggled    += new ToggledHandler(IsColumnConstraintToggled);

            colName.PackStart(nameRenderer, true);
            colColumn.PackStart(columnRenderer, true);
            colIsColumnConstraint.PackStart(isColumnConstraintRenderer, true);

            colName.AddAttribute(nameRenderer, "text", colNameIndex);
            colColumn.AddAttribute(columnRenderer, "text", colColumnNameIndex);
            colIsColumnConstraint.AddAttribute(isColumnConstraintRenderer, "active", colIsColumnConstraintIndex);

            IDbFactory fac = schemaProvider.ConnectionPool.DbFactory;

            columnConstraintsSupported = fac.IsCapabilitySupported("TableColumn", action, TableCapabilities.CheckConstraint);
            tableConstraintsSupported  = fac.IsCapabilitySupported("Table", action, TableCapabilities.CheckConstraint);

            listCheck.AppendColumn(colName);
            if (columnConstraintsSupported)
            {
                listCheck.AppendColumn(colColumn);
            }
            if (columnConstraintsSupported && tableConstraintsSupported)
            {
                listCheck.AppendColumn(colIsColumnConstraint);
            }

            listCheck.Selection.Changed += new EventHandler(OnSelectionChanged);
            sqlEditor.TextChanged       += new EventHandler(SourceChanged);

            foreach (CheckConstraintSchema check in constraints.GetConstraints(ConstraintType.Check))
            {
                AddConstraint(check);
            }
            //TODO: also col constraints

            ShowAll();
        }
Esempio n. 10
0
        void HandleEditedHandler(object o, EditedArgs args)
        {
            CellRendererCombo cell = (CellRendererCombo)o;

            cell.Text = args.NewText;
        }
Esempio n. 11
0
        public CodeIssuePanelWidget(string mimeType)
        {
            this.mimeType = mimeType;
            Build();

            var col1 = treeviewInspections.AppendColumn("Title", new CellRendererText(), "markup", 0);

            col1.Expand = true;

            searchentryFilter.Ready          = true;
            searchentryFilter.Visible        = true;
            searchentryFilter.Entry.Changed += ApplyFilter;

            var comboRenderer = new CellRendererCombo();

            comboRenderer.Alignment = Pango.Alignment.Center;
            var col = treeviewInspections.AppendColumn("Severity", comboRenderer);

            col.Sizing   = TreeViewColumnSizing.GrowOnly;
            col.MinWidth = 100;
            col.Expand   = false;

            var comboBoxStore = new ListStore(typeof(string), typeof(Severity));

            comboBoxStore.AppendValues(GetDescription(Severity.None), Severity.None);
            comboBoxStore.AppendValues(GetDescription(Severity.Error), Severity.Error);
            comboBoxStore.AppendValues(GetDescription(Severity.Warning), Severity.Warning);
            comboBoxStore.AppendValues(GetDescription(Severity.Hint), Severity.Hint);
            comboBoxStore.AppendValues(GetDescription(Severity.Suggestion), Severity.Suggestion);
            comboRenderer.Model      = comboBoxStore;
            comboRenderer.Mode       = CellRendererMode.Activatable;
            comboRenderer.TextColumn = 0;

            comboRenderer.Editable = true;
            comboRenderer.HasEntry = false;

            comboRenderer.Edited += delegate(object o, Gtk.EditedArgs args) {
                Gtk.TreeIter iter;
                if (!treeStore.GetIterFromString(out iter, args.Path))
                {
                    return;
                }

                Gtk.TreeIter storeIter;
                if (!comboBoxStore.GetIterFirst(out storeIter))
                {
                    return;
                }
                do
                {
                    if ((string)comboBoxStore.GetValue(storeIter, 0) == args.NewText)
                    {
                        var provider = (BaseCodeIssueProvider)treeStore.GetValue(iter, 1);
                        var severity = (Severity)comboBoxStore.GetValue(storeIter, 1);
                        severities[provider] = severity;
                        return;
                    }
                } while (comboBoxStore.IterNext(ref storeIter));
            };

            col.SetCellDataFunc(comboRenderer, delegate(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) {
                var provider = (BaseCodeIssueProvider)model.GetValue(iter, 1);
                if (provider == null)
                {
                    comboRenderer.Visible = false;
                    return;
                }
                var severity                = severities[provider];
                comboRenderer.Visible       = true;
                comboRenderer.Text          = GetDescription(severity);
                comboRenderer.BackgroundGdk = GetColor(severity);
            });
            treeviewInspections.HeadersVisible     = false;
            treeviewInspections.Model              = treeStore;
            treeviewInspections.Selection.Changed += HandleSelectionChanged;
            GetAllSeverities();
            FillInspectors(null);
        }
Esempio n. 12
0
        public PaymentsWindow()
        {
            Window window = new Window("Haushaltsplan");

            window.SetSizeRequest(500, 200);
            window.DeleteEvent += DeleteEvent;
            window.BorderWidth  = 20;

            Table table = new Table(2, 2, true);

            window.Add(table);


            ListStore expensesStore = new ListStore(
                typeof(string),
                typeof(Frequency),
                typeof(DateTime),
                typeof(DateTime)
                );
            TreeView expensesView = new TreeView(expensesStore);

            expensesView.AppendColumn("Beschreibung", new CellRendererText(), "text", 0);
            ListStore frequencyStore = new ListStore(typeof(Frequency), typeof(string));

            frequencyStore.AppendValues(Frequency.Once, "einmalig");
            frequencyStore.AppendValues(Frequency.Daily, "täglich");
            CellRendererCombo frequencyCell = new CellRendererCombo
            {
                Model      = frequencyStore,
                Editable   = true,
                HasEntry   = false,
                TextColumn = 1
            };

            frequencyCell.Edited += HandleEditedHandler;
            frequencyCell.AddNotification("Text", FrequencyTextChanged);
            TreeViewColumn frequencyColumn = new TreeViewColumn
            {
                Title = "Frequenz"
            };

            frequencyColumn.PackStart(frequencyCell, false);
            frequencyColumn.AddAttribute(frequencyCell, "text", 1);
            frequencyColumn.SetCellDataFunc(frequencyCell, HandleTreeCellDataFunc);
            expensesView.AppendColumn(frequencyColumn);

            expensesStore.AppendValues("Zahlung 1", Frequency.Once, DateTime.Parse("2018-12-24"));


            table.Attach(expensesView, 0, 1, 0, 1);

            expensesView.Show();

            /* Create second button */

            Button button2 = new Button("button 2");

            /* When the button is clicked, we call the "callback" function
             * with a pointer to "button 2" as its argument */

            button2.Clicked += Callback;

            /* Insert button 2 into the upper right quadrant of the table */
            table.Attach(button2, 1, 2, 0, 1);

            button2.Show();

            /* Create "Quit" button */
            Button quitbutton = new Button("Quit");

            /* When the button is clicked, we call the "delete_event" function
             * and the program exits */
            quitbutton.Clicked += ExitEvent;

            /* Insert the quit button into the both
             * lower quadrants of the table */
            table.Attach(quitbutton, 0, 2, 1, 2);

            quitbutton.Show();

            table.Show();
            window.ShowAll();
        }
        public ColumnsEditorWidget(ISchemaProvider schemaProvider, SchemaActions action, ColumnEditorSettings settings)
        {
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            this.schemaProvider = schemaProvider;
            this.action         = action;
            this.settings       = settings;

            this.Build();

            storeTypes                     = new ListStore(typeof(string), typeof(object));
            storeColumns                   = new ListStore(typeof(bool), typeof(string), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(object));
            treeColumns.Model              = storeColumns;
            treeColumns.Selection.Changed += new EventHandler(OnSelectionChanged);

            //TODO: cols for scale, precision, ... ?
            TreeViewColumn colPK       = new TreeViewColumn();
            TreeViewColumn colName     = new TreeViewColumn();
            TreeViewColumn colType     = new TreeViewColumn();
            TreeViewColumn colLength   = new TreeViewColumn();
            TreeViewColumn colNullable = new TreeViewColumn();
            TreeViewColumn colComment  = new TreeViewColumn();

            colPK.Title       = AddinCatalog.GetString("PK");
            colName.Title     = AddinCatalog.GetString("Name");
            colType.Title     = AddinCatalog.GetString("Type");
            colLength.Title   = AddinCatalog.GetString("Length");
            colNullable.Title = AddinCatalog.GetString("Nullable");
            colComment.Title  = AddinCatalog.GetString("Comment");

            colType.MinWidth = 120;             //request a bigger width

            CellRendererToggle pkRenderer       = new CellRendererToggle();
            CellRendererText   nameRenderer     = new CellRendererText();
            CellRendererCombo  typeRenderer     = new CellRendererCombo();
            CellRendererText   lengthRenderer   = new CellRendererText();
            CellRendererToggle nullableRenderer = new CellRendererToggle();
            CellRendererText   commentRenderer  = new CellRendererText();

            nameRenderer.Editable = true;
            nameRenderer.Edited  += new EditedHandler(NameEdited);

            typeRenderer.Model = storeTypes;
            storeTypes.SetSortColumnId(0, SortType.Ascending);
            typeRenderer.TextColumn = 0;
            typeRenderer.Editable   = true;
            typeRenderer.Edited    += new EditedHandler(TypeEdited);

            lengthRenderer.Editable = true;
            lengthRenderer.Edited  += new EditedHandler(LengthEdited);

            pkRenderer.Activatable = true;
            pkRenderer.Toggled    += new ToggledHandler(PkToggled);

            nullableRenderer.Activatable = true;
            nullableRenderer.Toggled    += new ToggledHandler(NullableToggled);

            commentRenderer.Editable = true;
            commentRenderer.Edited  += new EditedHandler(CommentEdited);

            colPK.PackStart(pkRenderer, true);
            colName.PackStart(nameRenderer, true);
            colType.PackStart(typeRenderer, true);
            colLength.PackStart(lengthRenderer, true);
            colNullable.PackStart(nullableRenderer, true);
            colComment.PackStart(commentRenderer, true);

            colPK.AddAttribute(pkRenderer, "active", colPKIndex);
            colName.AddAttribute(nameRenderer, "text", colNameIndex);
            colType.AddAttribute(typeRenderer, "text", colTypeIndex);
            colLength.AddAttribute(lengthRenderer, "text", colLengthIndex);
            colNullable.AddAttribute(nullableRenderer, "active", colNullableIndex);
            colComment.AddAttribute(commentRenderer, "text", colCommentIndex);

            if (settings.ShowPrimaryKeyColumn)
            {
                treeColumns.AppendColumn(colPK);
            }
            if (settings.ShowNameColumn)
            {
                treeColumns.AppendColumn(colName);
            }
            if (settings.ShowTypeColumn)
            {
                treeColumns.AppendColumn(colType);
            }
            if (settings.ShowLengthColumn)
            {
                treeColumns.AppendColumn(colLength);
            }
            if (settings.ShowNullableColumn)
            {
                treeColumns.AppendColumn(colNullable);
            }
            if (settings.ShowCommentColumn)
            {
                treeColumns.AppendColumn(colComment);
            }

            treeColumns.Reorderable      = false;
            treeColumns.HeadersClickable = false;
            treeColumns.HeadersVisible   = true;
            //Gtk# 2.10:treeColumns.EnableGridLines = TreeViewGridLines.Both;
            treeColumns.EnableSearch = false;

            if (action == SchemaActions.Alter)
            {
                buttonAdd.Sensitive    = settings.ShowAddButton;
                buttonRemove.Sensitive = settings.ShowRemoveButton;
                buttonUp.Sensitive     = settings.AllowReorder;
            }

            ShowAll();
        }
Esempio n. 14
0
        public TypedCodeFormattingPolicyPanelWidget()
        {
            store = new Gtk.TreeStore(typeof(string), typeof(string), typeof(string), typeof(object), typeof(string), typeof(bool), typeof(bool), typeof(bool));

            TreeViewColumn column = new TreeViewColumn();

            // pixbuf column
            pixbufCellRenderer = new CellRendererPixbuf();
            column.PackStart(pixbufCellRenderer, false);
            column.SetCellDataFunc(pixbufCellRenderer, new Gtk.TreeCellDataFunc(RenderIcon));

            // text column
            CellRendererText cellRendererText = new CellRendererText();

            cellRendererText.Ypad = 1;
            column.PackStart(cellRendererText, true);
            column.SetAttributes(cellRendererText, "text", keyColumn);

            TreeviewCategories.AppendColumn(column);

            column = new TreeViewColumn();
            CellRendererCombo cellRendererCombo = new CellRendererCombo();

            cellRendererCombo.Ypad       = 1;
            cellRendererCombo.Mode       = CellRendererMode.Editable;
            cellRendererCombo.TextColumn = 1;
            cellRendererCombo.Model      = comboBoxStore;
            cellRendererCombo.HasEntry   = false;
            cellRendererCombo.Editable   = true;
            column.PackStart(cellRendererCombo, false);
            column.SetAttributes(cellRendererCombo, "markup", valueDisplayTextColumn, "visible", comboVisibleColumn);

            CellRendererToggle cellRendererToggle = new CellRendererToggle();

            cellRendererToggle.Ypad     = 1;
            cellRendererToggle.Toggled += CellRendererToggleToggled;
            column.PackStart(cellRendererToggle, false);
            column.SetAttributes(cellRendererToggle, "active", toggleColumn, "visible", toggleVisibleColumn);

            TreeviewCategories.AppendColumn(column);

            cellRendererCombo.EditingStarted += delegate(object o, EditingStartedArgs args) {
                CodeFormatType type = description.GetCodeFormatType(settings, option);
                comboBoxStore.Clear();
                foreach (KeyValuePair <string, string> v in type.Values)
                {
                    comboBoxStore.AppendValues(v.Key, GettextCatalog.GetString(v.Value));
                }
            };

            cellRendererCombo.Edited += delegate(object o, EditedArgs args) {
                CodeFormatType type = description.GetCodeFormatType(settings, option);
                foreach (KeyValuePair <string, string> v in type.Values)
                {
                    if (args.NewText == GettextCatalog.GetString(v.Value))
                    {
                        description.SetValue(settings, option, v.Key);
                        TreeIter iter;
                        if (store.GetIterFromString(out iter, args.Path))
                        {
                            store.SetValue(iter, valueColumn, v.Key);
                            store.SetValue(iter, valueDisplayTextColumn, args.NewText);
                        }
                        break;
                    }
                }
                UpdateExample();
            };

            TreeviewCategories.HeadersVisible = false;

            TreeviewCategories.Selection.Changed += TreeSelectionChanged;
            TreeviewCategories.Model              = store;
        }
Esempio n. 15
0
        public void SetLevel(LevelDescription desc)
        {
            GtkHelpers.FlushAllDeferredEvents();

            Destroyed += LevelEditLayout_Destroyed;

            if (null != Layout)
            {
                Layout.Hide();
                Layout.Destroy();
                Layout = null;
            }

            LevelDesc = desc;

            Layout = new VBox(false, 0);
            AddWithViewport(Layout);

            HBox field = GtkHelpers.TextEntryField("Level Name", desc.Name, Name_Changed, true);

            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.TextEntryField("Lives", desc.Lives.ToString(), Lives_Changed, true, GtkHelpers.ValueType.Int);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.ComboBox("Width", LayoutOptions, (desc.FieldWidth / 5 - 1), Width_Changed, true);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.ComboBox("Depth", LayoutOptions, (desc.FieldDepth / 5 - 1), Depth_Changed, true);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.TextEntryField("Starting Coins", desc.StartingCoins.ToString(), StartingCoins_Changed, true, GtkHelpers.ValueType.Int);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.TextEntryField("Description Heading", desc.DescriptionHeading, DescriptionHeading_Changed);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            field = GtkHelpers.TextEntryField("Description Body", desc.DescriptionBody, DescriptionBody_Changed);
            Layout.PackStart(field, false, false, 0);
            field.Show();


            WavesTree = new TreeView();
            Layout.PackStart(WavesTree, false, false, 0);
            WavesTree.Show();

            List <EnemyDescription> enemies  = LevelManager.GetEnemies();
            ComboBoxText            comboBox = new ComboBoxText();

            foreach (EnemyDescription enemy in enemies)
            {
                comboBox.AppendText(enemy.Name);
            }
            comboBox.Active = 0;


            TreeViewColumn enemyCoumn            = new TreeViewColumn();
            TreeViewColumn countColumn           = new TreeViewColumn();
            TreeViewColumn difficultyColumn      = new TreeViewColumn();
            TreeViewColumn descriptionBodyColumn = new TreeViewColumn();

            CellRendererCombo comboCellRenderer = new CellRendererCombo();

            comboCellRenderer.Editable   = true;
            comboCellRenderer.Edited    += ComboCellRenderer_Edited;
            comboCellRenderer.TextColumn = 0;
            comboCellRenderer.HasEntry   = false;

            CellRendererText countCellRenderer = new CellRendererText();

            countCellRenderer.Editable = true;
            countCellRenderer.Edited  += CountCell_Edited;


            CellRendererText difficultyCellRenderer = new CellRendererText();

            difficultyCellRenderer.Editable = true;
            difficultyCellRenderer.Edited  += DifficultyCell_Edited;

            CellRendererText descriptionbodyRenderer = new CellRendererText();

            descriptionbodyRenderer.Editable = true;
            descriptionbodyRenderer.Edited  += DescriptionbodyRenderer_Edited;

            enemyCoumn.PackStart(comboCellRenderer, true);
            enemyCoumn.Title = "Enemy";
            enemyCoumn.AddAttribute(comboCellRenderer, "text", 1);
            WavesTree.AppendColumn(enemyCoumn);

            countColumn.PackStart(countCellRenderer, true);
            countColumn.Title = "Count";
            countColumn.AddAttribute(countCellRenderer, "text", 2);
            WavesTree.AppendColumn(countColumn);

            difficultyColumn.PackStart(difficultyCellRenderer, true);
            difficultyColumn.Title = "Difficulty Multiplier";
            difficultyColumn.AddAttribute(difficultyCellRenderer, "text", 3);
            WavesTree.AppendColumn(difficultyColumn);

            descriptionBodyColumn.PackStart(descriptionbodyRenderer, true);
            descriptionBodyColumn.Title = "Description Body";
            descriptionBodyColumn.AddAttribute(difficultyCellRenderer, "text", 4);
            WavesTree.AppendColumn(descriptionBodyColumn);

            //
            // Add column:  Max damage that can be dished to a single enemy given turret coverage + enemy speed
            //

            //
            // Add column: Max hit points of the wave
            //

            //
            // Add column: Max hit points of all the turrets combined firing at full capacity
            //

            //
            // Add column: Given all the factors, theoretical headroom of DPS
            //

            WavesModel               = new ListStore(typeof(int), typeof(string), typeof(int), typeof(float), typeof(string));
            WavesTree.Model          = WavesModel;
            WavesTree.Selection.Mode = SelectionMode.Single;

            PopulateTreeWithWaves(desc);

            field = new HBox(false, 5);
            Layout.PackStart(field, false, false, 0);
            field.Show();

            Button b = new Button("+");

            b.Clicked += NewWave_Clicked;
            b.Show();
            field.PackStart(b, false, false, 0);

            b          = new Button("-");
            b.Clicked += RemoveWave_Clicked;
            b.Show();
            field.PackStart(b, false, false, 0);


            Table map = GetFieldTable(desc);

            Layout.PackStart(map, false, true, 0);
            map.Show();

            ErrorEntry            = new Entry();
            ErrorEntry.IsEditable = false;
            ErrorEntry.Text       = "No issues";
            Layout.PackStart(ErrorEntry, false, false, 10);
            ErrorEntry.Show();

            ValidateDescriptionAndReportIssues();

            //
            // Allowed turrets
            //

            field = new HBox(true, 10);
            Layout.PackStart(field, true, false, 0);
            field.Show();

            AvailTurretTree   = new TreeView();
            AllowedTurretTree = new TreeView();

            TreeViewColumn availCol   = new TreeViewColumn();
            TreeViewColumn allowedCol = new TreeViewColumn();

            CellRendererText availCellrenderer = new CellRendererText();

            availCellrenderer.Editable = false;

            CellRendererText allowedCellRenderer = new CellRendererText();

            allowedCellRenderer.Editable = false;

            availCol.PackStart(availCellrenderer, true);
            availCol.Title = "Not allowed turrets";
            availCol.AddAttribute(availCellrenderer, "text", 1);
            AvailTurretTree.AppendColumn(availCol);


            allowedCol.PackStart(allowedCellRenderer, true);
            allowedCol.Title = "Allowed Turrets";
            allowedCol.AddAttribute(allowedCellRenderer, "text", 1);
            AllowedTurretTree.AppendColumn(allowedCol);

            AvailTurretModel               = new ListStore(typeof(int), typeof(string));
            AvailTurretTree.Model          = AvailTurretModel;
            AvailTurretTree.Selection.Mode = SelectionMode.Multiple;

            AllowedTurretModel               = new ListStore(typeof(int), typeof(string));
            AllowedTurretTree.Model          = AllowedTurretModel;
            AllowedTurretTree.Selection.Mode = SelectionMode.Multiple;

            field.PackStart(AvailTurretTree, true, true, 0);
            AvailTurretTree.Show();

            VBox turretButtons = new VBox(true, 0);

            field.PackStart(turretButtons, true, true, 0);
            turretButtons.Show();

            b = new Button(">>");
            turretButtons.PackStart(b, false, false, 0);
            b.Clicked += AddAllTurrets_Clicked;
            b.Show();

            b = new Button(">");
            turretButtons.PackStart(b, false, false, 0);
            b.Clicked += AddSelectedTurrets_Clicked;
            b.Show();

            b = new Button("<");
            turretButtons.PackStart(b, false, false, 0);
            b.Clicked += RemoveSelectedTurrets_Clicked;
            b.Show();

            b = new Button("<<");
            turretButtons.PackStart(b, false, false, 0);
            b.Clicked += RemoveAllTurrets_Clicked;
            b.Show();

            field.PackEnd(AllowedTurretTree, true, true, 0);
            AllowedTurretTree.Show();

            PopulateTurretTrees(desc);


            Show();
            ShowAll();
        }
Esempio n. 16
0
        //TODO: difference between columns and reference columns + combo events
        public ForeignKeyConstraintEditorWidget(ISchemaProvider schemaProvider, SchemaActions action, TableSchemaCollection tables, TableSchema table, ColumnSchemaCollection columns, ConstraintSchemaCollection constraints)
        {
            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }
            if (constraints == null)
            {
                throw new ArgumentNullException("constraints");
            }
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }
            if (tables == null)
            {
                throw new ArgumentNullException("tables");
            }

            this.schemaProvider = schemaProvider;
            this.table          = table;
            this.tables         = tables;
            this.columns        = columns;
            this.constraints    = constraints;
            this.action         = action;

            this.Build();

            store        = new ListStore(typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(string), typeof(string), typeof(object));
            listFK.Model = store;

            storeActions = new ListStore(typeof(string), typeof(int));
            storeTables  = new ListStore(typeof(string));

            IDbFactory fac = schemaProvider.ConnectionPool.DbFactory;

            if (fac.IsCapabilitySupported("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.Cascade))
            {
                storeActions.AppendValues("Cascade", ForeignKeyAction.Cascade);
            }
            if (fac.IsCapabilitySupported("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.Restrict))
            {
                storeActions.AppendValues("Restrict", ForeignKeyAction.Restrict);
            }
            if (fac.IsCapabilitySupported("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.NoAction))
            {
                storeActions.AppendValues("No Action", ForeignKeyAction.NoAction);
            }
            if (fac.IsCapabilitySupported("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.SetNull))
            {
                storeActions.AppendValues("Set Null", ForeignKeyAction.SetNull);
            }
            if (fac.IsCapabilitySupported("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.SetDefault))
            {
                storeActions.AppendValues("Set Default", ForeignKeyAction.SetDefault);
            }

            foreach (TableSchema tbl in tables)
            {
                if (tbl.Name != table.Name)
                {
                    storeTables.AppendValues(tbl.Name);
                }
            }

            TreeViewColumn colName               = new TreeViewColumn();
            TreeViewColumn colRefTable           = new TreeViewColumn();
            TreeViewColumn colIsColumnConstraint = new TreeViewColumn();
            TreeViewColumn colDeleteAction       = new TreeViewColumn();
            TreeViewColumn colUpdateAction       = new TreeViewColumn();

            colName.Title               = GettextCatalog.GetString("Name");
            colRefTable.Title           = GettextCatalog.GetString("Reference Table");
            colIsColumnConstraint.Title = GettextCatalog.GetString("Column Constraint");
            colDeleteAction.Title       = GettextCatalog.GetString("Delete Action");
            colUpdateAction.Title       = GettextCatalog.GetString("Update Action");

            colRefTable.MinWidth = 120;

            CellRendererText   nameRenderer               = new CellRendererText();
            CellRendererCombo  refTableRenderer           = new CellRendererCombo();
            CellRendererToggle isColumnConstraintRenderer = new CellRendererToggle();
            CellRendererCombo  deleteActionRenderer       = new CellRendererCombo();
            CellRendererCombo  updateActionRenderer       = new CellRendererCombo();

            nameRenderer.Editable = true;
            nameRenderer.Edited  += new EditedHandler(NameEdited);

            refTableRenderer.Model      = storeTables;
            refTableRenderer.TextColumn = 0;
            refTableRenderer.Editable   = true;
            refTableRenderer.Edited    += new EditedHandler(RefTableEdited);

            isColumnConstraintRenderer.Activatable = true;
            isColumnConstraintRenderer.Toggled    += new ToggledHandler(IsColumnConstraintToggled);

            deleteActionRenderer.Model      = storeActions;
            deleteActionRenderer.TextColumn = 0;
            deleteActionRenderer.Editable   = true;
            deleteActionRenderer.Edited    += new EditedHandler(DeleteActionEdited);

            updateActionRenderer.Model      = storeActions;
            updateActionRenderer.TextColumn = 0;
            updateActionRenderer.Editable   = true;
            updateActionRenderer.Edited    += new EditedHandler(UpdateActionEdited);

            colName.PackStart(nameRenderer, true);
            colRefTable.PackStart(refTableRenderer, true);
            colIsColumnConstraint.PackStart(isColumnConstraintRenderer, true);
            colDeleteAction.PackStart(deleteActionRenderer, true);
            colUpdateAction.PackStart(updateActionRenderer, true);

            colName.AddAttribute(nameRenderer, "text", colNameIndex);
            colRefTable.AddAttribute(refTableRenderer, "text", colReferenceTableIndex);
            colIsColumnConstraint.AddAttribute(isColumnConstraintRenderer, "active", colIsColumnConstraintIndex);
            colDeleteAction.AddAttribute(deleteActionRenderer, "text", colDeleteActionIndex);
            colUpdateAction.AddAttribute(updateActionRenderer, "text", colUpdateActionIndex);

            listFK.AppendColumn(colName);
            listFK.AppendColumn(colRefTable);
            listFK.AppendColumn(colIsColumnConstraint);
            listFK.AppendColumn(colDeleteAction);
            listFK.AppendColumn(colUpdateAction);

            columnSelecter.ColumnToggled          += new EventHandler(ColumnToggled);
            referenceColumnSelecter.ColumnToggled += new EventHandler(ReferenceColumnToggled);
            listFK.Selection.Changed += new EventHandler(SelectionChanged);

            ShowAll();
        }
Esempio n. 17
0
 public override void RenderValue(CustomPropertiesWidget widget, CellRendererCombo renderer)
 {
     renderer.Sensitive = true;
     renderer.Text      = Value.ToString();
 }
        public CustomPropertiesWidget(PListScheme scheme)
        {
            Scheme      = scheme ?? PListScheme.Empty;
            CurrentTree = new Dictionary <PObject, PListScheme.SchemaItem> ();
            treeview    = new PopupTreeView(this)
            {
                DoubleBuffered = true
            };
            treeview.HeadersClickable = true;

            RefreshKeyStore();
            PackStart(treeview, true, true, 0);
            FindOrAddNewEntry(TreeIter.Zero);
            ShowAll();

            var keyRenderer = new CellRendererCombo();

            keyRenderer.Editable        = true;
            keyRenderer.Model           = keyStore;
            keyRenderer.Mode            = CellRendererMode.Editable;
            keyRenderer.TextColumn      = 0;
            keyRenderer.EditingStarted += KeyRendererEditingStarted;
            keyRenderer.Edited         += KeyRendererEditingFinished;
            var col = new TreeViewColumn();

            col.Resizable = true;
            col.Title     = GettextCatalog.GetString("Property");
            col.PackStart(keyRenderer, true);
            col.SetCellDataFunc(keyRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                var renderer = (CellRendererCombo)cell;
                string id    = (string)tree_model.GetValue(iter, 0) ?? "";
                var obj      = (PObject)tree_model.GetValue(iter, 1);
                if (obj == null)
                {
                    renderer.Text      = id;
                    renderer.Editable  = false;
                    renderer.Sensitive = false;
                    return;
                }

                var key            = (PListScheme.SchemaItem)tree_model.GetValue(iter, 2);
                var parentPArray   = obj.Parent is PArray;
                renderer.Editable  = !parentPArray;
                renderer.Sensitive = !parentPArray;
                if (parentPArray)
                {
                    renderer.Text = "";
                }
                else
                {
                    renderer.Text = key != null && ShowDescriptions ? key.Description : id;
                }
            });
            treeview.AppendColumn(col);

            col = new TreeViewColumn {
                MinWidth = 25, Resizable = false, Sizing = Gtk.TreeViewColumnSizing.Fixed
            };

            var removeRenderer = new CellRendererButton(ImageService.GetPixbuf("gtk-remove", IconSize.Menu));

            removeRenderer.Clicked += RemoveElement;
            col.PackEnd(removeRenderer, false);
            col.SetCellDataFunc(removeRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                removeRenderer.Visible = treeview.Selection.IterIsSelected(iter) && !AddKeyNode.Equals(treeStore.GetValue(iter, 0));
            });

            var addRenderer = new CellRendererButton(ImageService.GetPixbuf("gtk-add", IconSize.Menu));

            addRenderer.Clicked += AddElement;
            col.PackEnd(addRenderer, false);
            col.SetCellDataFunc(addRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                addRenderer.Visible = treeview.Selection.IterIsSelected(iter) && AddKeyNode.Equals(treeStore.GetValue(iter, 0));
            });
            treeview.AppendColumn(col);

            treeview.RowActivated += delegate(object o, RowActivatedArgs args) {
                TreeIter iter;
                if (treeStore.GetIter(out iter, args.Path) && AddKeyNode.Equals(treeStore.GetValue(iter, 0)))
                {
                    AddElement(o, EventArgs.Empty);
                }
            };

            var comboRenderer = new CellRendererCombo();

            var typeModel = new ListStore(typeof(string));

            typeModel.AppendValues(PArray.Type);
            typeModel.AppendValues(PDictionary.Type);
            typeModel.AppendValues(PBoolean.Type);
            typeModel.AppendValues(PData.Type);
            typeModel.AppendValues(PData.Type);
            typeModel.AppendValues(PNumber.Type);
            typeModel.AppendValues(PString.Type);
            comboRenderer.Model      = typeModel;
            comboRenderer.Mode       = CellRendererMode.Editable;
            comboRenderer.HasEntry   = false;
            comboRenderer.TextColumn = 0;
            comboRenderer.Edited    += delegate(object o, EditedArgs args) {
                TreeIter selIter;
                if (!treeStore.GetIterFromString(out selIter, args.Path))
                {
                    return;
                }

                PObject oldObj = (PObject)treeStore.GetValue(selIter, 1);
                if (oldObj != null && oldObj.TypeString != args.NewText)
                {
                    oldObj.Replace(PObject.Create(args.NewText));
                }
            };

            treeview.AppendColumn(GettextCatalog.GetString("Type"), comboRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                var renderer           = (CellRendererCombo)cell;
                var value              = (string)tree_model.GetValue(iter, 0);
                var obj                = (PObject)tree_model.GetValue(iter, 1);
                var key                = (PListScheme.SchemaItem)tree_model.GetValue(iter, 2);
                renderer.Editable      = key == null && !AddKeyNode.Equals(value);
                renderer.ForegroundGdk = Style.Text(renderer.Editable ? StateType.Normal : StateType.Insensitive);
                renderer.Text          = obj == null ? "" : obj.TypeString;
            });

            var propRenderer = new CellRendererCombo();

            propRenderer.Model           = valueStore;
            propRenderer.Mode            = CellRendererMode.Editable;
            propRenderer.TextColumn      = 0;
            propRenderer.EditingStarted += PropRendererEditingStarted;
            propRenderer.Edited         += PropRendererEditingFinished;

            treeview.AppendColumn(GettextCatalog.GetString("Value"), propRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                var renderer = (CellRendererCombo)cell;
                var obj      = (PObject)tree_model.GetValue(iter, 1);

                renderer.Sensitive = obj != null && !(obj is PDictionary || obj is PArray || obj is PData);
                renderer.Editable  = renderer.Sensitive;
                if (!renderer.Sensitive)
                {
                    renderer.Text = "";
                    return;
                }

                if (ShowDescriptions)
                {
                    var identifier = (string)tree_model.GetValue(iter, 0);
                    var values     = PListScheme.AvailableValues(obj, CurrentTree);
                    var item       = values == null ? null : values.FirstOrDefault(v => v.Identifier == identifier);
                    if (item != null && obj is IPValueObject)
                    {
                        // Ensure that we only display the Description if the items value matches the description/identifier.
                        // For example when setting the Document Type Name we wish to display whatever identifer the user types
                        // in and not the literal string 'Document Type Name'. However for somegthing like UISupportedDeviceOrientations
                        // we can safely display the description 'iPhone' or 'iPad' and not hide important information.
                        var actualValue = ((IPValueObject)obj).Value;
                        if (actualValue != null && (actualValue.ToString() == item.Description || actualValue.ToString() == item.Identifier))
                        {
                            renderer.Text = item.Description ?? item.Identifier;
                            return;
                        }
                    }
                }

                switch (obj.TypeString)
                {
                case PDictionary.Type:
                    renderer.Text = string.Format(GettextCatalog.GetPluralString("({0} item)", "({0} items)", ((PDictionary)obj).Count), ((PDictionary)obj).Count);
                    break;

                case PArray.Type:
                    renderer.Text = string.Format(GettextCatalog.GetPluralString("({0} item)", "({0} items)", ((PArray)obj).Count, ((PArray)obj).Count));
                    break;

                case PBoolean.Type:
                    renderer.Text = ((PBoolean)obj).Value ? GettextCatalog.GetString("Yes") : GettextCatalog.GetString("No");
                    break;

                case PData.Type:
                    renderer.Text = string.Format("byte[{0}]", ((PData)obj).Value.Length);
                    break;

                default:
                    if (obj is IPValueObject)
                    {
                        renderer.Text = (((IPValueObject)obj).Value ?? "").ToString();
                    }
                    else
                    {
                        renderer.Sensitive = false;
                        renderer.Text      = GettextCatalog.GetString("Could not render {0}.", obj.GetType().Name);
                    }
                    break;
                }
            });
            treeview.EnableGridLines = TreeViewGridLines.Horizontal;
            treeview.Model           = treeStore;
        }
Esempio n. 19
0
 public override void RenderValue(CustomPropertiesWidget widget, CellRendererCombo renderer)
 {
     renderer.Sensitive = true;
     renderer.Text      = Value ? GettextCatalog.GetString("Yes") : GettextCatalog.GetString("No");
 }
Esempio n. 20
0
        public XmlSchemasPanelWidget()
        {
            this.Build();

            //set up tree view for default schemas
            CellRendererText textRenderer = new CellRendererText();

            registeredSchemasStore      = new ListStore(typeof(XmlSchemaCompletionData));
            registeredSchemasView.Model = registeredSchemasStore;

            registeredSchemasView.AppendColumn(GettextCatalog.GetString("Namespace"), textRenderer,
                                               delegate(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
                ((Gtk.CellRendererText)cell).Text = ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData)model.GetValue(iter, 0)).NamespaceUri;
            });

            registeredSchemasView.AppendColumn(GettextCatalog.GetString("Type"), textRenderer,
                                               delegate(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
                bool builtIn = ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData)model.GetValue(iter, 0)).ReadOnly;
                ((Gtk.CellRendererText)cell).Text = builtIn?
                                                    GettextCatalog.GetString("Built in")
                                        : GettextCatalog.GetString("User schema");
            });

            registeredSchemasStore.SetSortFunc(0,
                                               delegate(TreeModel model, TreeIter a, TreeIter b) {
                return(string.Compare(
                           ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData)model.GetValue(a, 0)).NamespaceUri,
                           ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData)model.GetValue(b, 0)).NamespaceUri
                           ));
            });
            registeredSchemasStore.SetSortColumnId(0, SortType.Ascending);

            //update state of "remove" button depending on whether schema is read-only and anything's slected
            registeredSchemasView.Selection.Changed += delegate {
                MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData data = GetSelectedSchema();
                registeredSchemasRemoveButton.Sensitive = (data != null && !data.ReadOnly);
            };
            registeredSchemasRemoveButton.Sensitive = false;

            //set up cells for associations
            CellRendererText extensionTextRenderer = new CellRendererText();

            extensionTextRenderer.Editable = true;
            CellRendererText prefixTextRenderer = new CellRendererText();

            prefixTextRenderer.Editable = true;

            CellRendererCombo comboEditor = new CellRendererCombo();

            registeredSchemasComboModel = new ListStore(typeof(string));
            comboEditor.Model           = registeredSchemasComboModel;
            comboEditor.Mode            = CellRendererMode.Editable;
            comboEditor.TextColumn      = 0;
            comboEditor.Editable        = true;
            comboEditor.HasEntry        = false;

            //rebuild combo's model from default schemas whenever editing starts
            comboEditor.EditingStarted += delegate(object sender, EditingStartedArgs args) {
                registeredSchemasComboModel.Clear();
                registeredSchemasComboModel.AppendValues(string.Empty);
                foreach (Gtk.TreeIter iter in WalkStore(registeredSchemasStore))
                {
                    registeredSchemasComboModel.AppendValues(
                        ((MonoDevelop.XmlEditor.Completion.XmlSchemaCompletionData)registeredSchemasStore.GetValue(iter, 0)).NamespaceUri
                        );
                }
                args.RetVal = true;
                registeredSchemasComboModel.SetSortColumnId(0, Gtk.SortType.Ascending);
            };

            //set up tree view for associations
            defaultAssociationsStore      = new ListStore(typeof(string), typeof(string), typeof(string), typeof(bool));
            defaultAssociationsView.Model = defaultAssociationsStore;
            defaultAssociationsView.AppendColumn(GettextCatalog.GetString("File Extension"), extensionTextRenderer, "text", DACols.Extension);
            defaultAssociationsView.AppendColumn(GettextCatalog.GetString("Namespace"), comboEditor, "text", DACols.Namespace);
            defaultAssociationsView.AppendColumn(GettextCatalog.GetString("Prefix"), prefixTextRenderer, "text", DACols.Prefix);
            defaultAssociationsStore.SetSortColumnId((int)DACols.Extension, SortType.Ascending);

            //editing handlers
            extensionTextRenderer.Edited += handleExtensionSet;
            comboEditor.Edited           += delegate(object sender, EditedArgs args) {
                setAssocValAndMarkChanged(args.Path, DACols.Namespace, args.NewText);
            };
            prefixTextRenderer.Edited += delegate(object sender, EditedArgs args) {
                foreach (char c in args.NewText)
                {
                    if (!char.IsLetterOrDigit(c))
                    {
                        //FIXME: give an error message?
                        return;
                    }
                }
                setAssocValAndMarkChanged(args.Path, DACols.Prefix, args.NewText);
            };

            //update state of "remove" button depending on whether anything's slected
            defaultAssociationsView.Selection.Changed += delegate {
                Gtk.TreeIter iter;
                defaultAssociationsRemoveButton.Sensitive =
                    defaultAssociationsView.Selection.GetSelected(out iter);
            };
            defaultAssociationsRemoveButton.Sensitive = false;
        }
Esempio n. 21
0
        public XmlSchemasPanelWidget()
        {
            Build();

            //set up tree view for default schemas
            var textRenderer = new CellRendererText();

            registeredSchemasStore      = new ListStore(typeof(XmlSchemaCompletionData));
            registeredSchemasView.Model = registeredSchemasStore;

            registeredSchemasView.AppendColumn(GettextCatalog.GetString("Namespace"), textRenderer,
                                               (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) => {
                ((CellRendererText)cell).Text = GetSchema(iter).NamespaceUri;
            }
                                               );

            registeredSchemasView.AppendColumn(GettextCatalog.GetString("Type"), textRenderer,
                                               (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) => {
                ((CellRendererText)cell).Text = GetSchema(iter).ReadOnly?
                                                GettextCatalog.GetString("Built in")
                                                : GettextCatalog.GetString("User schema");
            });

            registeredSchemasStore.SetSortFunc(0,
                                               (model, a, b) => string.Compare(GetSchema(a).NamespaceUri, GetSchema(b).NamespaceUri, StringComparison.Ordinal));

            registeredSchemasStore.SetSortColumnId(0, SortType.Ascending);

            //update state of "remove" button depending on whether schema is read-only and anything's slected
            registeredSchemasView.Selection.Changed += delegate {
                var data = GetSelectedSchema();
                registeredSchemasRemoveButton.Sensitive = (data != null && !data.ReadOnly);
            };
            registeredSchemasRemoveButton.Sensitive = false;

            //set up cells for associations
            var extensionTextRenderer = new CellRendererText();

            extensionTextRenderer.Editable = true;
            var prefixTextRenderer = new CellRendererText();

            prefixTextRenderer.Editable = true;

            var comboEditor = new CellRendererCombo();

            registeredSchemasComboModel = new ListStore(typeof(string));
            comboEditor.Model           = registeredSchemasComboModel;
            comboEditor.Mode            = CellRendererMode.Editable;
            comboEditor.TextColumn      = 0;
            comboEditor.Editable        = true;
            comboEditor.HasEntry        = false;

            //rebuild combo's model from default schemas whenever editing starts
            comboEditor.EditingStarted += delegate(object sender, EditingStartedArgs args) {
                registeredSchemasComboModel.Clear();
                registeredSchemasComboModel.AppendValues(string.Empty);
                foreach (TreeIter iter in WalkStore(registeredSchemasStore))
                {
                    registeredSchemasComboModel.AppendValues(
                        GetSchema(iter).NamespaceUri
                        );
                }
                args.RetVal = true;
                registeredSchemasComboModel.SetSortColumnId(0, SortType.Ascending);
            };

            //set up tree view for associations
            defaultAssociationsStore      = new ListStore(typeof(string), typeof(string), typeof(string), typeof(bool));
            defaultAssociationsView.Model = defaultAssociationsStore;
            defaultAssociationsView.AppendColumn(GettextCatalog.GetString("File Extension"), extensionTextRenderer, "text", COL_EXT);
            defaultAssociationsView.AppendColumn(GettextCatalog.GetString("Namespace"), comboEditor, "text", COL_NS);
            defaultAssociationsView.AppendColumn(GettextCatalog.GetString("Prefix"), prefixTextRenderer, "text", COL_PREFIX);
            defaultAssociationsStore.SetSortColumnId(COL_EXT, SortType.Ascending);

            //editing handlers
            extensionTextRenderer.Edited += handleExtensionSet;
            comboEditor.Edited           += (sender, args) => setAssocValAndMarkChanged(args.Path, COL_NS, args.NewText ?? "");
            prefixTextRenderer.Edited    += delegate(object sender, EditedArgs args) {
                foreach (char c in args.NewText)
                {
                    if (!char.IsLetterOrDigit(c))
                    {
                        //FIXME: give an error message?
                        return;
                    }
                }
                setAssocValAndMarkChanged(args.Path, COL_PREFIX, args.NewText);
            };

            //update state of "remove" button depending on whether anything's slected
            defaultAssociationsView.Selection.Changed += delegate {
                TreeIter iter;
                defaultAssociationsRemoveButton.Sensitive =
                    defaultAssociationsView.Selection.GetSelected(out iter);
            };
            defaultAssociationsRemoveButton.Sensitive = false;
        }
Esempio n. 22
0
        public TriggersEditorWidget(ISchemaProvider schemaProvider, SchemaActions action)
        {
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }

            this.schemaProvider = schemaProvider;
            this.action         = action;

            this.Build();

            sqlEditor.Editable     = false;
            sqlEditor.TextChanged += new EventHandler(SourceChanged);

            store                           = new ListStore(typeof(string), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(object));
            storeTypes                      = new ListStore(typeof(string));
            storeEvents                     = new ListStore(typeof(string));
            listTriggers.Model              = store;
            listTriggers.Selection.Changed += new EventHandler(OnSelectionChanged);

            foreach (string name in Enum.GetNames(typeof(TriggerType)))
            {
                storeTypes.AppendValues(name);
            }
            foreach (string name in Enum.GetNames(typeof(TriggerEvent)))
            {
                storeEvents.AppendValues(name);
            }

            TreeViewColumn colName     = new TreeViewColumn();
            TreeViewColumn colType     = new TreeViewColumn();
            TreeViewColumn colEvent    = new TreeViewColumn();
            TreeViewColumn colFireType = new TreeViewColumn();
            TreeViewColumn colPosition = new TreeViewColumn();
            TreeViewColumn colActive   = new TreeViewColumn();
            TreeViewColumn colComment  = new TreeViewColumn();

            colName.Title     = GettextCatalog.GetString("Name");
            colType.Title     = GettextCatalog.GetString("Type");
            colEvent.Title    = GettextCatalog.GetString("Event");
            colFireType.Title = GettextCatalog.GetString("Each Row");
            colPosition.Title = GettextCatalog.GetString("Position");
            colActive.Title   = GettextCatalog.GetString("Active");
            colComment.Title  = GettextCatalog.GetString("Comment");

            colType.MinWidth  = 120;
            colEvent.MinWidth = 120;

            CellRendererText   nameRenderer     = new CellRendererText();
            CellRendererCombo  typeRenderer     = new CellRendererCombo();
            CellRendererCombo  eventRenderer    = new CellRendererCombo();
            CellRendererToggle fireTypeRenderer = new CellRendererToggle();
            CellRendererText   positionRenderer = new CellRendererText();
            CellRendererToggle activeRenderer   = new CellRendererToggle();
            CellRendererText   commentRenderer  = new CellRendererText();

            nameRenderer.Editable = true;
            nameRenderer.Edited  += new EditedHandler(NameEdited);

            typeRenderer.Model      = storeTypes;
            typeRenderer.TextColumn = 0;
            typeRenderer.Editable   = true;
            typeRenderer.Edited    += new EditedHandler(TypeEdited);

            eventRenderer.Model      = storeEvents;
            eventRenderer.TextColumn = 0;
            eventRenderer.Editable   = true;
            eventRenderer.Edited    += new EditedHandler(EventEdited);

            fireTypeRenderer.Activatable = true;
            fireTypeRenderer.Toggled    += new ToggledHandler(FireTypeToggled);

            positionRenderer.Editable = true;
            positionRenderer.Edited  += new EditedHandler(PositionEdited);

            activeRenderer.Activatable = true;
            activeRenderer.Toggled    += new ToggledHandler(ActiveToggled);

            commentRenderer.Editable = true;
            commentRenderer.Edited  += new EditedHandler(CommentEdited);

            colName.PackStart(nameRenderer, true);
            colType.PackStart(typeRenderer, true);
            colEvent.PackStart(eventRenderer, true);
            colFireType.PackStart(fireTypeRenderer, true);
            colPosition.PackStart(positionRenderer, true);
            colActive.PackStart(activeRenderer, true);
            colComment.PackStart(commentRenderer, true);

            colName.AddAttribute(nameRenderer, "text", colNameIndex);
            colType.AddAttribute(typeRenderer, "text", colTypeIndex);
            colEvent.AddAttribute(eventRenderer, "text", colEventIndex);
            colFireType.AddAttribute(fireTypeRenderer, "active", colFireTypeIndex);
            colPosition.AddAttribute(positionRenderer, "text", colPositionIndex);
            colActive.AddAttribute(activeRenderer, "active", colActiveIndex);
            colComment.AddAttribute(commentRenderer, "text", colCommentIndex);

            listTriggers.AppendColumn(colName);
            listTriggers.AppendColumn(colType);
            listTriggers.AppendColumn(colEvent);
            listTriggers.AppendColumn(colFireType);
            listTriggers.AppendColumn(colPosition);
            listTriggers.AppendColumn(colActive);
            listTriggers.AppendColumn(colComment);

            ShowAll();
        }
Esempio n. 23
0
        private EncapsulateFieldDialog(MonoDevelop.Ide.Gui.Document editor, IType declaringType, IField field)
        {
            this.editor        = editor;
            this.declaringType = declaringType;
            this.Build();

            Title = GettextCatalog.GetString("Encapsulate Fields");
            buttonOk.Sensitive = true;
            store           = new ListStore(typeof(bool), typeof(string), typeof(string), typeof(string), typeof(bool), typeof(IField));
            visibilityStore = new ListStore(typeof(string));

            // Column #1
            CellRendererToggle cbRenderer = new CellRendererToggle();

            cbRenderer.Activatable = true;
            cbRenderer.Toggled    += OnSelectedToggled;
            TreeViewColumn cbCol = new TreeViewColumn();

            cbCol.Title = "";
            cbCol.PackStart(cbRenderer, false);
            cbCol.AddAttribute(cbRenderer, "active", colCheckedIndex);
            treeview.AppendColumn(cbCol);

            // Column #2
            CellRendererText fieldRenderer = new CellRendererText();

            fieldRenderer.Weight = (int)Pango.Weight.Bold;
            TreeViewColumn fieldCol = new TreeViewColumn();

            fieldCol.Title  = GettextCatalog.GetString("Field");
            fieldCol.Expand = true;
            fieldCol.PackStart(fieldRenderer, true);
            fieldCol.AddAttribute(fieldRenderer, "text", colFieldNameIndex);
            treeview.AppendColumn(fieldCol);

            // Column #3
            CellRendererText propertyRenderer = new CellRendererText();

            propertyRenderer.Editable = true;
            propertyRenderer.Edited  += new EditedHandler(OnPropertyEdited);
            TreeViewColumn propertyCol = new TreeViewColumn();

            propertyCol.Title  = GettextCatalog.GetString("Property");
            propertyCol.Expand = true;
            propertyCol.PackStart(propertyRenderer, true);
            propertyCol.AddAttribute(propertyRenderer, "text", colPropertyNameIndex);
            propertyCol.SetCellDataFunc(propertyRenderer, new TreeCellDataFunc(RenderPropertyName));
            treeview.AppendColumn(propertyCol);

            // Column #4
            CellRendererCombo visiComboRenderer = new CellRendererCombo();

            visiComboRenderer.Model      = visibilityStore;
            visiComboRenderer.Editable   = true;
            visiComboRenderer.Edited    += new EditedHandler(OnVisibilityEdited);
            visiComboRenderer.HasEntry   = false;
            visiComboRenderer.TextColumn = 0;

            TreeViewColumn visiCol = new TreeViewColumn();

            visiCol.Title = GettextCatalog.GetString("Visibility");
            visiCol.PackStart(visiComboRenderer, false);
            visiCol.AddAttribute(visiComboRenderer, "text", colVisibilityIndex);
            treeview.AppendColumn(visiCol);

            // Column #5
            CellRendererToggle roRenderer = new CellRendererToggle();

            roRenderer.Activatable = true;
            roRenderer.Xalign      = 0.0f;
            roRenderer.Toggled    += new ToggledHandler(OnReadOnlyToggled);
            TreeViewColumn roCol = new TreeViewColumn();

            roCol.Title = GettextCatalog.GetString("Read only");
            roCol.PackStart(roRenderer, false);
            roCol.AddAttribute(roRenderer, "active", colReadOnlyIndex);
            treeview.AppendColumn(roCol);

            visibilityStore.AppendValues("Public");
            visibilityStore.AppendValues("Private");
            visibilityStore.AppendValues("Protected");
            visibilityStore.AppendValues("Internal");

            treeview.Model = store;

            foreach (IField ifield in declaringType.Fields)
            {
                bool   enabled      = field != null && (field.Name == ifield.Name);
                string propertyName = GeneratePropertyName(ifield.Name);
                store.AppendValues(enabled, ifield.Name, propertyName,
                                   "Public", ifield.IsReadonly || ifield.IsLiteral, ifield);

                if (enabled)
                {
                    CheckAndUpdateConflictMessage(propertyName, false);
                }
            }

            store.SetSortColumnId(colFieldNameIndex, SortType.Ascending);
            buttonSelectAll.Clicked   += OnSelectAllClicked;
            buttonUnselectAll.Clicked += OnUnselectAllClicked;
            buttonOk.Clicked          += OnOKClicked;
            buttonCancel.Clicked      += OnCancelClicked;

            UpdateOKButton();
        }
Esempio n. 24
0
        public DueDateColumn()
        {
            TreeViewColumn = new TreeViewColumn {
                Title      = Catalog.GetString("Due Date"),
                Sizing     = TreeViewColumnSizing.Fixed,
                Alignment  = 0f,
                FixedWidth = 90,
                Resizable  = false,
                Clickable  = true
            };

            var dueDateStore = new ListStore(typeof(string));
            var today        = DateTime.Now;

            dueDateStore.AppendValues(
                today.ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Today"));
            dueDateStore.AppendValues(
                today.AddDays(1).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Tomorrow"));
            dueDateStore.AppendValues(
                today.AddDays(2).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(3).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(4).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(5).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(6).ToString(Catalog.GetString("M/d - ddd")));
            dueDateStore.AppendValues(
                today.AddDays(7).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("In 1 Week"));
            dueDateStore.AppendValues(Catalog.GetString("No Date"));
            dueDateStore.AppendValues(Catalog.GetString("Choose Date..."));

            var renderer = new CellRendererCombo {
                Editable   = true,
                HasEntry   = false,
                Model      = dueDateStore,
                TextColumn = 0,
                Xalign     = 0.0f
            };

            renderer.EditingStarted += (o, args) => {
                TreeIter iter;
                var      path = new TreePath(args.Path);
                if (!model.GetIter(out iter, path))
                {
                    return;
                }

                var task = model.GetValue(iter, 0) as ITask;
                if (task == null)
                {
                    return;
                }

                taskBeingEdited = new TaskBeingEdited(task, iter, path);
                if (CellEditingStarted != null)
                {
                    CellEditingStarted(this, new TaskRowEditingEventArgs(task, iter, path));
                }
            };

            renderer.EditingCanceled += delegate { EndCellEditing(); };

            renderer.Edited += (o, args) => {
                TreeIter iter;
                var      path    = new TreePath(args.Path);
                var      newText = args.NewText;
                if (newText != null && model.GetIter(out iter, path))
                {
                    //  2/11 - Today
                    //  2/12 - Tomorrow
                    //  2/13 - Wed
                    //  2/14 - Thu
                    //  2/15 - Fri
                    //  2/16 - Sat
                    //  2/17 - Sun
                    // --------------
                    //  2/18 - In 1 Week
                    // --------------
                    //  No Date
                    // ---------------
                    //  Choose Date...

                    var newDate = DateTime.MinValue;
                    var tday    = DateTime.Now;
                    var task    = model.GetValue(iter, 0) as ITask;

                    if (newText == tday.ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Today"))
                    {
                        newDate = tday;
                    }
                    else if (newText == tday.AddDays(1).ToString(Catalog.GetString("M/d - "))
                             + Catalog.GetString("Tomorrow"))
                    {
                        newDate = tday.AddDays(1);
                    }
                    else if (newText == Catalog.GetString("No Date"))
                    {
                        newDate = DateTime.MinValue;
                    }
                    else if (newText == tday.AddDays(7).ToString(Catalog.GetString("M/d - "))
                             + Catalog.GetString("In 1 Week"))
                    {
                        newDate = tday.AddDays(7);
                    }
                    else if (newText == Catalog.GetString("Choose Date..."))
                    {
                        var tc = new TaskCalendar(task, view.TreeView.Parent);
                        tc.ShowCalendar();
                        return;
                    }
                    else
                    {
                        for (int i = 2; i <= 6; i++)
                        {
                            DateTime testDate = tday.AddDays(i);
                            if (testDate.ToString(Catalog.GetString("M/d - ddd")) == newText)
                            {
                                newDate = testDate;
                                break;
                            }
                        }
                    }

                    Logger.Debug("task.State {0}", task.State);

                    if (task.State != TaskState.Completed)
                    {
                        // Modify the due date
                        task.DueDate = newDate;
                    }
                }
                EndCellEditing();
            };

            TreeViewColumn.PackStart(renderer, true);
            TreeViewColumn.SetCellDataFunc(renderer, DueDateCellDataFunc);
        }
        protected virtual void Build()
        {
            // Widget MainWindow
            Name                            = "MainWindow";
            Title                           = "Настройки " + ServiceName;
            WindowPosition                  = ((WindowPosition)(4));
            DefaultWidth                    = 700;
            DefaultHeight                   = 800;
            GtkScrolledWindow1              = new ScrolledWindow();
            GtkScrolledWindow1.Name         = "GtkScrolledWindow1";
            GtkScrolledWindow1.ShadowType   = ((ShadowType)(1));
            GtkScrolledWindow1.WidthRequest = 500;

            HBox hbox = new HBox();

            tree = new TreeView();
            tree.RowActivated += new RowActivatedHandler(SelectRow);
            GtkScrolledWindow1.Add(tree);

            TreeViewColumn   col2 = new TreeViewColumn();
            CellRendererText col2TextRendererFirst = new CellRendererText();

            col2.PackStart(col2TextRendererFirst, true);

            TreeViewColumn col3 = new TreeViewColumn();

            col3.Expand = false;
            col3.Title  = "Столбец ввода значений у свойств с bool переменными и простыми записями после них";
            CellRendererText col3TextRenderer = new CellRendererText();

            col3TextRenderer.Editable = true;


            CellRendererToggle col3Toggle = new CellRendererToggle();

            col3Toggle.Activatable = true;

            CellRendererSpin col3SpinR = new CellRendererSpin();

            col3SpinR.Editable = true;
            Adjustment adjCol3SpinR = new Adjustment(0, 0, 100000, 1, 10, 0);

            col3SpinR.Adjustment = adjCol3SpinR;

            CellRendererCombo col3Combo = new CellRendererCombo();

            col3Combo.Editable   = true;
            col3Combo.TextColumn = 0;
            col3Combo.HasEntry   = false;

            //Using the same(no need to create another)
            col3TextRenderer.Edited += Cell_Edited;
            col3SpinR.Edited        += Cell_Edited;
            //Using the same causes abnormal heigth change in selected row
            col3Combo.Edited += Combo_Edited;
            col3Toggle.Xalign = 0;
            col3SpinR.Xalign  = 0;
            col3Combo.Xalign  = 0;

            col3.PackStart(col3TextRenderer, false);
            col3.PackStart(col3Toggle, false);
            col3.PackStart(col3SpinR, false);
            col3.PackStart(col3Combo, false);

            tree.AppendColumn(col2);
            tree.AppendColumn(col3);

            col3.AddAttribute(col3Toggle, "active", 1);
            col3.AddAttribute(col3TextRenderer, "text", 2);
            col3.AddAttribute(col3SpinR, "text", 2);
            col3.AddAttribute(col3Combo, "text", 2);
            //First Option, then there goes values for configs,string below works also for Numbers and ComboBox
            Store = new TreeStore(typeof(Options), typeof(bool), typeof(string));

            //ToggleFunc
            col3Toggle.Toggled += delegate(object o, ToggledArgs args) {
                TreeIter iter;
                if (Store.GetIter(out iter, new TreePath(args.Path)))
                {
                    bool temp = !(bool)Store.GetValue(iter, 1);
                    Store.SetValue(iter, 1, temp);
                    ((Options)Store.GetValue(iter, 0)).Value = temp.ToString();
                }
            };
            Store.AppendValues(Options[0], null, "");
            for (int i = 1; i < Options.Count; i++)
            {
                TreeIter iter    = Store.AppendValues(Options[i], null, null);
                int      length2 = Options[i].childs.Count;
                for (int j = 0; j < length2; j++)
                {
                    fillStore(iter, Options[i].childs[j]);
                }
            }

            col2.SetCellDataFunc(col2TextRendererFirst, new TreeCellDataFunc(RenderText));
            col3.SetCellDataFunc(col3Toggle, new TreeCellDataFunc(RenderToggle));
            col3.SetCellDataFunc(col3TextRenderer, new TreeCellDataFunc(RenderEditableText));
            col3.SetCellDataFunc(col3SpinR, new TreeCellDataFunc(RenderSpinner));
            col3.SetCellDataFunc(col3Combo, new TreeCellDataFunc(RenderCombo));

            tree.Model = Store;

            hbox.Add(GtkScrolledWindow1);

            name.LabelProp      = "";
            name.Wrap           = true;
            name.Justify        = ((Justification)(2));
            name.SingleLineMode = true;


            //ListOrOne
            TreeViewColumn ListCol = new TreeViewColumn();

            ListCol.Title = "Значение(я)";
            CellRendererText ListTextRenderer = new CellRendererText();

            ListTextRenderer.Editable          = true;
            ListTextRenderer.Background        = "white";
            ListTextRenderer.TraceConstruction = true;
            ListTextRenderer.Edited           += ListCell_Edited;
            ListCol.PackStart(ListTextRenderer, true);
            Listtree.AppendColumn(ListCol);
            ListCol.AddAttribute(ListTextRenderer, "text", 0);
            Listtree.Model = ListStore;

            //ListWithValues
            TreeViewColumn ListWithValuesCol1 = new TreeViewColumn();

            ListWithValuesCol1.Title = "1 Значение";
            TreeViewColumn ListWithValuesCol2 = new TreeViewColumn();

            ListWithValuesCol2.Title = "2 Значение";

            CellRendererText ListWithValuesTR = new CellRendererText();

            ListWithValuesTR.Editable          = true;
            ListWithValuesTR.Background        = "white";
            ListWithValuesTR.TraceConstruction = true;
            ListWithValuesTR.Edited           += ListWithValuesCell_Edited;

            CellRendererText ListWithValuesTR2 = new CellRendererText();

            ListWithValuesTR2.Editable          = true;
            ListWithValuesTR2.Background        = "white";
            ListWithValuesTR2.TraceConstruction = true;
            ListWithValuesTR2.Edited           += ListWithValues2Cell_Edited;

            ListWithValuesCol1.PackStart(ListWithValuesTR, true);
            ListWithValuesCol2.PackStart(ListWithValuesTR2, true);
            ListWithValuesTree.AppendColumn(ListWithValuesCol1);
            ListWithValuesTree.AppendColumn(ListWithValuesCol2);
            ListWithValuesCol1.AddAttribute(ListWithValuesTR, "text", 0);
            ListWithValuesCol2.AddAttribute(ListWithValuesTR2, "text", 1);
            ListWithValuesTree.Model = ListWithValuesStore;


            CombinedViewForValueTypes.PackStart(name, false, false, 0);
            CombinedViewForValueTypes.PackStart(Listtree, false, false, 0);
            CombinedViewForValueTypes.PackStart(ListWithValuesTree, false, false, 0);
            hbox.Add(CombinedViewForValueTypes);
            Add(hbox);

            ShowAll();
            CombinedViewForValueTypes.Visible = false;
        }
        public InspectionPanelWidget(string mimeType)
        {
            this.Build();
//			this.mimeType = mimeType;


            treeviewInspections.AppendColumn("Title", new CellRendererText(), "text", 0);


            var comboRenderer = new CellRendererCombo();
            var col           = treeviewInspections.AppendColumn("Severity", comboRenderer);

            var comboBoxStore = new ListStore(typeof(string), typeof(QuickTaskSeverity));

            comboBoxStore.AppendValues(GetDescription(QuickTaskSeverity.None), QuickTaskSeverity.None);
            comboBoxStore.AppendValues(GetDescription(QuickTaskSeverity.Error), QuickTaskSeverity.Error);
            comboBoxStore.AppendValues(GetDescription(QuickTaskSeverity.Warning), QuickTaskSeverity.Warning);
            comboBoxStore.AppendValues(GetDescription(QuickTaskSeverity.Hint), QuickTaskSeverity.Hint);
            comboBoxStore.AppendValues(GetDescription(QuickTaskSeverity.Suggestion), QuickTaskSeverity.Suggestion);
            comboRenderer.Model      = comboBoxStore;
            comboRenderer.Mode       = CellRendererMode.Activatable;
            comboRenderer.TextColumn = 0;
            comboRenderer.Editable   = true;
            comboRenderer.HasEntry   = false;

            comboRenderer.Edited += delegate(object o, Gtk.EditedArgs args) {
                Gtk.TreeIter iter;
                if (!treeStore.GetIterFromString(out iter, args.Path))
                {
                    return;
                }

                Gtk.TreeIter storeIter;
                if (!comboBoxStore.GetIterFirst(out storeIter))
                {
                    return;
                }
                Console.WriteLine("new text:" + args.NewText);
                do
                {
                    if ((string)comboBoxStore.GetValue(storeIter, 0) == args.NewText)
                    {
                        treeStore.SetValue(iter, 1, (QuickTaskSeverity)comboBoxStore.GetValue(storeIter, 1));
                        return;
                    }
                } while (comboBoxStore.IterNext(ref storeIter));
            };

            col.SetCellDataFunc(comboRenderer, delegate(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) {
                var severity       = (QuickTaskSeverity)treeStore.GetValue(iter, 1);
                comboRenderer.Text = GetDescription(severity);
            });
            treeviewInspections.HeadersVisible     = false;
            treeviewInspections.Model              = treeStore;
            treeviewInspections.Selection.Changed += HandleSelectionChanged;

            foreach (var node in RefactoringService.GetInspectors(mimeType))
            {
                treeStore.AppendValues(node.Title, node.GetSeverity(), node);
            }
        }
Esempio n. 27
0
        public CodeIssuePanelWidget(string mimeType)
        {
            this.mimeType = mimeType;
            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            Build();

            // lock description label to allocated width so it can wrap
            labelDescription.Wrap           = true;
            labelDescription.WidthRequest   = 100;
            labelDescription.SizeAllocated += (o, args) => {
                if (labelDescription.WidthRequest != args.Allocation.Width)
                {
                    labelDescription.WidthRequest = args.Allocation.Width;
                }
            };

            // ensure selected row remains visible
            treeviewInspections.SizeAllocated += (o, args) => {
                TreeIter iter;
                if (treeviewInspections.Selection.GetSelected(out iter))
                {
                    var path = treeviewInspections.Model.GetPath(iter);
                    treeviewInspections.ScrollToCell(path, treeviewInspections.Columns[0], false, 0f, 0f);
                }
            };

            var cellRendererText = new CellRendererText {
                Ellipsize = Pango.EllipsizeMode.End
            };
            var col1 = treeviewInspections.AppendColumn("Title", cellRendererText, "markup", 0);

            col1.Expand = true;

            searchentryFilter.Ready          = true;
            searchentryFilter.Visible        = true;
            searchentryFilter.Entry.Changed += ApplyFilter;

            var comboRenderer = new CellRendererCombo {
                Alignment = Pango.Alignment.Center
            };
            var col = treeviewInspections.AppendColumn("Severity", comboRenderer);

            col.Sizing   = TreeViewColumnSizing.GrowOnly;
            col.MinWidth = 100;
            col.Expand   = false;

            var comboBoxStore = new ListStore(typeof(string), typeof(Severity));

            comboBoxStore.AppendValues(GetDescription(Severity.None), Severity.None);
            comboBoxStore.AppendValues(GetDescription(Severity.Error), Severity.Error);
            comboBoxStore.AppendValues(GetDescription(Severity.Warning), Severity.Warning);
            comboBoxStore.AppendValues(GetDescription(Severity.Hint), Severity.Hint);
            comboBoxStore.AppendValues(GetDescription(Severity.Suggestion), Severity.Suggestion);
            comboRenderer.Model      = comboBoxStore;
            comboRenderer.Mode       = CellRendererMode.Activatable;
            comboRenderer.TextColumn = 0;

            comboRenderer.Editable = true;
            comboRenderer.HasEntry = false;

            comboRenderer.Edited += delegate(object o, EditedArgs args) {
                TreeIter iter;
                if (!treeStore.GetIterFromString(out iter, args.Path))
                {
                    return;
                }

                TreeIter storeIter;
                if (!comboBoxStore.GetIterFirst(out storeIter))
                {
                    return;
                }
                do
                {
                    if ((string)comboBoxStore.GetValue(storeIter, 0) == args.NewText)
                    {
                        var provider = (BaseCodeIssueProvider)treeStore.GetValue(iter, 1);
                        var severity = (Severity)comboBoxStore.GetValue(storeIter, 1);
                        severities[provider] = severity;
                        return;
                    }
                } while (comboBoxStore.IterNext(ref storeIter));
            };

            col.SetCellDataFunc(comboRenderer, delegate(TreeViewColumn treeColumn, CellRenderer cell, TreeModel model, TreeIter iter) {
                var provider = (BaseCodeIssueProvider)model.GetValue(iter, 1);
                if (provider == null)
                {
                    comboRenderer.Visible = false;
                    return;
                }
                var severity                = severities[provider];
                comboRenderer.Visible       = true;
                comboRenderer.Text          = GetDescription(severity);
                comboRenderer.BackgroundGdk = GetColor(severity);
            });
            treeviewInspections.HeadersVisible     = false;
            treeviewInspections.Model              = treeStore;
            treeviewInspections.Selection.Changed += HandleSelectionChanged;
            GetAllSeverities();
            FillInspectors(null);
        }
Esempio n. 28
0
        public CustomPropertiesWidget(PListScheme scheme)
        {
            this.scheme = scheme = scheme ?? PListScheme.Empty;
            treeview    = new PopupTreeView(this);
            treeview.HeadersClickable = true;
            this.PackStart(treeview, true, true, 0);
            ShowAll();

            var keyRenderer = new CellRendererCombo();

            keyRenderer.Editable   = true;
            keyRenderer.Model      = keyStore;
            keyRenderer.Mode       = CellRendererMode.Editable;
            keyRenderer.TextColumn = 0;
            keyRenderer.Edited    += delegate(object o, EditedArgs args) {
                TreeIter selIter;
                if (!treeStore.GetIterFromString(out selIter, args.Path))
                {
                    return;
                }
                if (args.NewText == (string)treeStore.GetValue(selIter, 0))
                {
                    return;
                }

                var obj = (PObject)treeStore.GetValue(selIter, 1);

                var dict = obj.Parent as PDictionary;
                if (dict == null)
                {
                    return;
                }

                var key    = scheme.Keys.FirstOrDefault(k => k.Identifier == args.NewText || k.Description == args.NewText);
                var newKey = key != null ? key.Identifier : args.NewText;

                dict.ChangeKey(obj, newKey, key == null || obj.TypeString == key.Type ? null : CreateNewObject(key.Type));
            };
            var col = new TreeViewColumn();

            col.Resizable = true;
            col.Title     = GettextCatalog.GetString("Property");
            col.PackStart(keyRenderer, true);
            col.SetCellDataFunc(keyRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                var renderer = (CellRendererCombo)cell;
                string id    = (string)tree_model.GetValue(iter, 0) ?? "";
                var obj      = (PObject)tree_model.GetValue(iter, 1);
                if (obj == null)
                {
                    renderer.Text      = id;
                    renderer.Editable  = false;
                    renderer.Sensitive = false;
                    return;
                }

                var key            = scheme.GetKey(id);
                renderer.Editable  = !(obj.Parent is PArray);
                renderer.Sensitive = true;
                renderer.Text      = key != null && ShowDescriptions ? GettextCatalog.GetString(key.Description) : id;
            });
            treeview.AppendColumn(col);

            var iconSize = IconSize.Menu;

            col = new TreeViewColumn {
                MinWidth = 25, Resizable = true, Sizing = Gtk.TreeViewColumnSizing.Autosize
            };

            var removeRenderer = new CellRendererButton(ImageService.GetPixbuf("gtk-remove", IconSize.Menu));

            removeRenderer.Clicked += delegate {
                TreeIter iter;
                bool     hasSelection = treeview.Selection.GetSelected(out iter);
                PObject  obj          = null;
                if (hasSelection)
                {
                    obj = (PObject)treeStore.GetValue(iter, 1);
                    obj.Remove();
                }
            };
            col.PackEnd(removeRenderer, false);
            col.SetCellDataFunc(removeRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                removeRenderer.Visible = treeview.Selection.IterIsSelected(iter) && !AddKeyNode.Equals(treeStore.GetValue(iter, 0));
            });

            var addRenderer = new CellRendererButton(ImageService.GetPixbuf("gtk-add", IconSize.Menu));

            addRenderer.Clicked += delegate {
                Gtk.TreeIter iter = Gtk.TreeIter.Zero;
                if (!treeview.Selection.GetSelected(out iter))
                {
                    return;
                }

                PObject obj = null;
                if (treeStore.IterParent(out iter, iter))
                {
                    obj = (PObject)treeStore.GetValue(iter, 1);
                }
                obj = obj ?? nsDictionary;

                var newObj = new PString("");
                if (obj is PArray)
                {
                    var arr = (PArray)obj;
                    arr.Add(newObj);
                }
                else if (obj is PDictionary)
                {
                    string name = "newNode";
                    var    dict = (PDictionary)obj;
                    while (dict.ContainsKey(name))
                    {
                        name += "_";
                    }
                    dict.Add(name, newObj);
                }
                else
                {
                    return;
                }
            };

            col.PackEnd(addRenderer, false);
            col.SetCellDataFunc(addRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                addRenderer.Visible = treeview.Selection.IterIsSelected(iter) && AddKeyNode.Equals(treeStore.GetValue(iter, 0));
            });
            treeview.AppendColumn(col);

            treeview.RowExpanded += delegate(object o, RowExpandedArgs args) {
                var obj = (PObject)treeStore.GetValue(args.Iter, 1);
                expandedObjects.Add(obj);
            };
            treeview.RowCollapsed += delegate(object o, RowCollapsedArgs args) {
                var obj = (PObject)treeStore.GetValue(args.Iter, 1);
                expandedObjects.Remove(obj);
            };
            var comboRenderer = new CellRendererCombo();

            var typeModel = new ListStore(typeof(string));

            typeModel.AppendValues("Array");
            typeModel.AppendValues("Dictionary");
            typeModel.AppendValues("Boolean");
            typeModel.AppendValues("Data");
            typeModel.AppendValues("Date");
            typeModel.AppendValues("Number");
            typeModel.AppendValues("String");
            comboRenderer.Model      = typeModel;
            comboRenderer.Mode       = CellRendererMode.Editable;
            comboRenderer.HasEntry   = false;
            comboRenderer.TextColumn = 0;
            comboRenderer.Edited    += delegate(object o, EditedArgs args) {
                TreeIter selIter;
                if (!treeStore.GetIterFromString(out selIter, args.Path))
                {
                    return;
                }

                PObject oldObj = (PObject)treeStore.GetValue(selIter, 1);
                if (oldObj != null && oldObj.TypeString != args.NewText)
                {
                    oldObj.Replace(CreateNewObject(args.NewText));
                }
            };

            treeview.AppendColumn(GettextCatalog.GetString("Type"), comboRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                var renderer = (CellRendererCombo)cell;
                string id    = (string)tree_model.GetValue(iter, 0) ?? "";
                var key      = scheme.GetKey(id);
                var obj      = (PObject)tree_model.GetValue(iter, 1);
                if (obj == null)
                {
                    renderer.Editable = false;
                    renderer.Text     = "";
                    return;
                }
                renderer.Editable      = key == null;
                renderer.ForegroundGdk = Style.Text(renderer.Editable ? StateType.Normal : StateType.Insensitive);
                renderer.Text          = obj.TypeString;
            });

            var propRenderer = new CellRendererCombo();

            propRenderer.Model           = valueStore;
            propRenderer.Mode            = CellRendererMode.Editable;
            propRenderer.TextColumn      = 0;
            propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
                valueStore.Clear();
                if (Scheme == null)
                {
                    return;
                }
                TreeIter iter;
                if (!treeStore.GetIterFromString(out iter, args.Path))
                {
                    return;
                }
                var pObject = (PObject)treeStore.GetValue(iter, 1);
                if (pObject == null)
                {
                    return;
                }
                var key = Parent != null?Scheme.GetKey(pObject.Parent.Key) : null;

                if (key != null)
                {
                    var descr = new List <string> (key.Values.Select(v => v.Description));
                    descr.Sort();
                    foreach (var val in descr)
                    {
                        valueStore.AppendValues(val);
                    }
                }
            };

            propRenderer.Edited += delegate(object o, EditedArgs args) {
                TreeIter iter;
                if (!treeStore.GetIterFromString(out iter, args.Path))
                {
                    return;
                }
                var pObject = (PObject)treeStore.GetValue(iter, 1);
                if (pObject == null)
                {
                    return;
                }
                string newText = args.NewText;
                var    key     = Parent != null?Scheme.GetKey(pObject.Parent.Key) : null;

                if (key != null)
                {
                    foreach (var val in key.Values)
                    {
                        if (newText == val.Description)
                        {
                            newText = val.Identifier;
                            break;
                        }
                    }
                }
                pObject.SetValue(newText);
            };

            /*		propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) {
             *                      TreeIter iter;
             *                      if (!treeStore.GetIterFromString (out iter, args.Path))
             *                              return;
             *                      PObject obj = (PObject)treeStore.GetValue (iter, 1);
             *                      if (obj is PBoolean) {
             *                              ((PBoolean)obj).Value = !((PBoolean)obj).Value;
             *                              propRenderer.StopEditing (false);
             *                      }
             *              };*/


            treeview.AppendColumn(GettextCatalog.GetString("Value"), propRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) {
                var renderer = (CellRendererCombo)cell;
                var obj      = (PObject)tree_model.GetValue(iter, 1);
                if (obj == null)
                {
                    renderer.Editable = false;
                    renderer.Text     = "";
                    return;
                }
                renderer.Editable = !(obj is PArray || obj is PDictionary || obj is PData);
                obj.RenderValue(this, renderer);
            });
            treeview.EnableGridLines = TreeViewGridLines.Horizontal;
            treeview.Model           = treeStore;
        }
        void BuildGui()
        {
            CellRendererText cellId   = new CellRendererText();
            TreeViewColumn   idColumn = new TreeViewColumn();

            idColumn.Title = GettextCatalog.GetString("ID");
            idColumn.PackStart(cellId, false);
            idColumn.AddAttribute(cellId, "text", 0);

            CellRendererText cellTitle   = new CellRendererText();
            TreeViewColumn   titleColumn = new TreeViewColumn();

            titleColumn.Title  = "Title";
            titleColumn.Expand = true;
            titleColumn.Sizing = TreeViewColumnSizing.Fixed;
            titleColumn.PackStart(cellTitle, true);
            titleColumn.AddAttribute(cellTitle, "text", 1);

            CellRendererCombo cellAction   = new CellRendererCombo();
            TreeViewColumn    actionColumn = new TreeViewColumn();

            actionColumn.Title = "Action";
            actionColumn.PackStart(cellAction, false);
            actionColumn.AddAttribute(cellAction, "text", 2);
            cellAction.Editable   = true;
            cellAction.Model      = checkinActions;
            cellAction.TextColumn = 0;
            cellAction.HasEntry   = false;
            cellAction.Edited    += OnActionChanged;
            //checkinActions.AppendValues(WorkItemCheckinAction.None.ToString());
            checkinActions.AppendValues(WorkItemCheckinAction.Associate.ToString());
            //checkinActions.AppendValues(WorkItemCheckinAction.Resolve.ToString());

            workItemsView.AppendColumn(idColumn);
            workItemsView.AppendColumn(titleColumn);
            workItemsView.AppendColumn(actionColumn);

            workItemsView.Model         = workItemStore;
            workItemsView.WidthRequest  = 300;
            workItemsView.HeightRequest = 120;

            this.PackStart(workItemsView, true, true, 3);

            VButtonBox buttonBox = new VButtonBox();
            Button     addButton = new Button();

            addButton.Label        = GettextCatalog.GetString("Add Work Item");
            addButton.Clicked     += OnAddWorkItem;
            removeButton.Label     = GettextCatalog.GetString("Remove Work Item");
            removeButton.Sensitive = false;
            removeButton.Clicked  += OnRemoveWorkItem;

            addButton.WidthRequest = removeButton.WidthRequest = 150;

            buttonBox.PackStart(addButton);
            buttonBox.PackStart(removeButton);
            buttonBox.Layout = ButtonBoxStyle.Start;

            this.PackStart(buttonBox, false, false, 3);

            this.ShowAll();
        }
Esempio n. 30
0
 public abstract void RenderValue(CustomPropertiesWidget widget, CellRendererCombo renderer);
Esempio n. 31
0
        public CSharpFormattingProfileDialog(CSharpFormattingPolicy profile)
        {
            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            this.Build();
            this.DefaultWidth     = 1400;
            this.DefaultHeight    = 600;
            this.hpaned1.Position = (int)(DefaultWidth * 0.618);

            this.profile = profile;
            this.Title   = profile.IsBuiltIn ? GettextCatalog.GetString("Show built-in profile") : GettextCatalog.GetString("Edit Profile");

            notebookCategories.SwitchPage += delegate {
                TreeView treeView;
                switch (notebookCategories.Page)
                {
                case 0:
                    treeView = treeviewIndentOptions;
                    break;

                case 1:
                    treeView = treeviewNewLines;
                    break;

                case 2:                 // Blank lines
                    treeView = treeviewSpacing;
                    break;

                case 3:
                    treeView = treeviewWrapping;
                    break;

                case 4:
                    treeView = treeviewStyle;
                    break;

                default:
                    return;
                }

                TreeModel model;
                TreeIter  iter;
                if (treeView.Selection.GetSelected(out model, out iter))
                {
                    UpdateExample(model, iter);
                }
            };
            notebookCategories.ShowTabs = false;
            comboboxCategories.AppendText(GettextCatalog.GetString("Indentation"));
            comboboxCategories.AppendText(GettextCatalog.GetString("New Lines"));
            comboboxCategories.AppendText(GettextCatalog.GetString("Spacing"));
            comboboxCategories.AppendText(GettextCatalog.GetString("Wrapping"));
            comboboxCategories.AppendText(GettextCatalog.GetString("Style"));
            comboboxCategories.Changed += delegate {
                texteditor.Text         = "";
                notebookCategories.Page = comboboxCategories.Active;
            };
            comboboxCategories.Active = 0;

            var options = DefaultSourceEditorOptions.Instance;

            texteditor.Options    = DefaultSourceEditorOptions.PlainEditor;
            texteditor.IsReadOnly = true;
            texteditor.MimeType   = CSharpFormatter.MimeType;
            scrolledwindow.AddWithViewport(texteditor);
            ShowAll();

            #region Indent options
            indentationOptions = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));

            var column = new TreeViewColumn();
            // pixbuf column
            var pixbufCellRenderer = new CellRendererImage();
            column.PackStart(pixbufCellRenderer, false);
            column.SetCellDataFunc(pixbufCellRenderer, RenderIcon);

            // text column
            var cellRendererText = new CellRendererText();
            cellRendererText.Ypad = 1;
            column.PackStart(cellRendererText, true);
            column.SetAttributes(cellRendererText, "text", 1);

            treeviewIndentOptions.Model              = indentationOptions;
            treeviewIndentOptions.SearchColumn       = -1;       // disable the interactive search
            treeviewIndentOptions.HeadersVisible     = false;
            treeviewIndentOptions.Selection.Changed += TreeSelectionChanged;

            var cellRendererCombo = new CellRendererCombo();
            cellRendererCombo.Ypad       = 1;
            cellRendererCombo.Mode       = CellRendererMode.Editable;
            cellRendererCombo.TextColumn = 1;
            cellRendererCombo.Model      = ComboBoxStore;
            cellRendererCombo.HasEntry   = false;
            cellRendererCombo.Editable   = !profile.IsBuiltIn;

            cellRendererCombo.Edited += new ComboboxEditedHandler(this, indentationOptions).ComboboxEdited;

            column.PackStart(cellRendererCombo, false);
            column.SetAttributes(cellRendererCombo, "visible", comboVisibleColumn);
            column.SetCellDataFunc(cellRendererCombo, ComboboxDataFunc);

            var cellRendererToggle = new CellRendererToggle();
            cellRendererToggle.Ypad        = 1;
            cellRendererToggle.Activatable = !profile.IsBuiltIn;
            cellRendererToggle.Toggled    += new CellRendererToggledHandler(this, treeviewIndentOptions, indentationOptions).Toggled;
            column.PackStart(cellRendererToggle, false);
            column.SetAttributes(cellRendererToggle, "visible", toggleVisibleColumn);
            column.SetCellDataFunc(cellRendererToggle, ToggleDataFunc);
            treeviewIndentOptions.AppendColumn(column);


            AddOption(indentationOptions, "IndentBlock", GettextCatalog.GetString("Indent block contents"), @"namespace Test
{
	class AClass
	{
		void Method ()
		{
			int x;
			int y;
		}
	}
}");
            AddOption(indentationOptions, "IndentBraces", GettextCatalog.GetString("Indent open and close braces"), @"class AClass
{
	int aField;

	void AMethod()
	{
	}
}");
            AddOption(indentationOptions, "IndentSwitchSection", GettextCatalog.GetString("Indent switch sections"), @"class AClass
{
	void Method(int x)
	{
		switch (x)
		{
			case 1:
			break;
		}
	}
}");
            AddOption(indentationOptions, "IndentSwitchCaseSection", GettextCatalog.GetString("Indent case sections"), @"class AClass
{
	void Method(int x)
	{
		switch (x)
		{
			case 1:
			break;
		}
	}
}");
            AddOption(indentationOptions, "LabelPositioning", GettextCatalog.GetString("Label indentation"), @"class Test
{
	void Method()
	{
	label:
		Console.WriteLine (""Hello World"");
	}

}");
            treeviewIndentOptions.ExpandAll();
            #endregion

            #region New line options
            newLineOptions = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));

            column = new TreeViewColumn();
            // pixbuf column
            column.PackStart(pixbufCellRenderer, false);
            column.SetCellDataFunc(pixbufCellRenderer, RenderIcon);

            // text column
            cellRendererText      = new CellRendererText();
            cellRendererText.Ypad = 1;
            column.PackStart(cellRendererText, true);
            column.SetAttributes(cellRendererText, "text", 1);

            treeviewNewLines.Model              = newLineOptions;
            treeviewNewLines.SearchColumn       = -1;       // disable the interactive search
            treeviewNewLines.HeadersVisible     = false;
            treeviewNewLines.Selection.Changed += TreeSelectionChanged;

            cellRendererCombo            = new CellRendererCombo();
            cellRendererCombo.Ypad       = 1;
            cellRendererCombo.Mode       = CellRendererMode.Editable;
            cellRendererCombo.TextColumn = 1;
            cellRendererCombo.Model      = ComboBoxStore;
            cellRendererCombo.HasEntry   = false;
            cellRendererCombo.Editable   = !profile.IsBuiltIn;
            cellRendererCombo.Edited    += new ComboboxEditedHandler(this, newLineOptions).ComboboxEdited;

            column.PackStart(cellRendererCombo, false);
            column.SetAttributes(cellRendererCombo, "visible", comboVisibleColumn);
            column.SetCellDataFunc(cellRendererCombo, ComboboxDataFunc);

            cellRendererToggle             = new CellRendererToggle();
            cellRendererToggle.Activatable = !profile.IsBuiltIn;
            cellRendererToggle.Ypad        = 1;
            cellRendererToggle.Toggled    += new CellRendererToggledHandler(this, treeviewNewLines, newLineOptions).Toggled;
            column.PackStart(cellRendererToggle, false);
            column.SetAttributes(cellRendererToggle, "visible", toggleVisibleColumn);
            column.SetCellDataFunc(cellRendererToggle, ToggleDataFunc);

            treeviewNewLines.AppendColumn(column);

            var category = AddOption(newLineOptions, null, GettextCatalog.GetString("New line options for braces"), null);
            AddOption(newLineOptions, category, "NewLinesForBracesInTypes", GettextCatalog.GetString("Place open brace on new line for types"), @"class Example
{
}");
            AddOption(newLineOptions, category, "NewLinesForBracesInMethods", GettextCatalog.GetString("Place open brace on new line for methods"), @"void Example()
{
}");
            AddOption(newLineOptions, category, "NewLinesForBracesInProperties", GettextCatalog.GetString("Place open brace on new line for properties"), @"int Example { 
	get  { 
		return 1;
	}
	set {
		// nothing
	}
}
"
                      );

            AddOption(newLineOptions, category, "NewLinesForBracesInAccessors", GettextCatalog.GetString("Place open brace on new line for property accessors"), @"int Example { 
	get  { 
		return 1;
	}
	set {
		// nothing
	}
}
"
                      );


            AddOption(newLineOptions, category, "NewLinesForBracesInAnonymousMethods", GettextCatalog.GetString("Place open brace on new line for anonymous methods"), @"void Example()
{
	var del = new delegate (int i, int j) {
	};
}");
            AddOption(newLineOptions, category, "NewLinesForBracesInControlBlocks", GettextCatalog.GetString("Place open brace on new line for control blocks"), @"void Example()
{
	if (true)
	{
	}
}");
            AddOption(newLineOptions, category, "NewLinesForBracesInAnonymousTypes", GettextCatalog.GetString("Place open brace on new line for anonymous types"), @"void Example()
{
	var c = new
	{
		A = 1,
		B = 2
	};
}");
            AddOption(newLineOptions, category, "NewLinesForBracesInObjectCollectionArrayInitializers", GettextCatalog.GetString("Place open brace on new line for object initializers"), @"void Example()
{
	new MyObject
	{
		A = 1,
		B = 2 
	};
}");
            AddOption(newLineOptions, category, "NewLinesForBracesInLambdaExpressionBody", GettextCatalog.GetString("Place open brace on new line for lambda expression"), @"void Example()
{
	Action act = () =>
	{
	};
}");

            category = AddOption(newLineOptions, null, GettextCatalog.GetString("New line options for keywords"), null);
            AddOption(newLineOptions, category, "NewLineForElse", GettextCatalog.GetString("Place \"else\" on new line"), @"void Example()
{
	if (true) {
		// ...
	} else {
		// ...
	}
}");
            AddOption(newLineOptions, category, "NewLineForCatch", GettextCatalog.GetString("Place \"catch\" on new line"), @"void Example()
{
	try {
	} catch {
	} finally {
	}
}");
            AddOption(newLineOptions, category, "NewLineForFinally", GettextCatalog.GetString("Place \"finally\" on new line"), @"void Example()
{
	try {
	} catch {
	} finally {
	}
}");

            category = AddOption(newLineOptions, null, GettextCatalog.GetString("New line options for expressions"), null);
            AddOption(newLineOptions, category, "NewLineForMembersInObjectInit", GettextCatalog.GetString("Place members in object initializers on new line"), @"void Example()
{
	new MyObject {
		A = 1, B = 2
	};
}");
            AddOption(newLineOptions, category, "NewLineForMembersInAnonymousTypes", GettextCatalog.GetString("Place members in anonymous types on new line"), @"void Example()
{
	var c = new
	{
		A = 1, B = 2
	};
}");
            AddOption(newLineOptions, category, "NewLineForClausesInQuery", GettextCatalog.GetString("Place query expression clauses on new line"), @"void Example()
{
    var q = from a in e
            from b in e select a * b;
}");
            treeviewNewLines.ExpandAll();
            #endregion

            #region Spacing options
            spacingOptions = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));

            column = new TreeViewColumn();
            // pixbuf column
            column.PackStart(pixbufCellRenderer, false);
            column.SetCellDataFunc(pixbufCellRenderer, RenderIcon);

            // text column
            cellRendererText.Ypad = 1;
            column.PackStart(cellRendererText, true);
            column.SetAttributes(cellRendererText, "text", 1);

            treeviewSpacing.Model              = spacingOptions;
            treeviewSpacing.SearchColumn       = -1;       // disable the interactive search
            treeviewSpacing.HeadersVisible     = false;
            treeviewSpacing.Selection.Changed += TreeSelectionChanged;

            cellRendererCombo            = new CellRendererCombo();
            cellRendererCombo.Ypad       = 1;
            cellRendererCombo.Mode       = CellRendererMode.Editable;
            cellRendererCombo.TextColumn = 1;
            cellRendererCombo.Model      = ComboBoxStore;
            cellRendererCombo.HasEntry   = false;
            cellRendererCombo.Editable   = !profile.IsBuiltIn;
            cellRendererCombo.Edited    += new ComboboxEditedHandler(this, spacingOptions).ComboboxEdited;

            column.PackStart(cellRendererCombo, false);
            column.SetAttributes(cellRendererCombo, "visible", comboVisibleColumn);
            column.SetCellDataFunc(cellRendererCombo, ComboboxDataFunc);

            cellRendererToggle             = new CellRendererToggle();
            cellRendererToggle.Activatable = !profile.IsBuiltIn;
            cellRendererToggle.Ypad        = 1;
            cellRendererToggle.Toggled    += new CellRendererToggledHandler(this, treeviewSpacing, spacingOptions).Toggled;
            column.PackStart(cellRendererToggle, false);
            column.SetAttributes(cellRendererToggle, "visible", toggleVisibleColumn);
            column.SetCellDataFunc(cellRendererToggle, ToggleDataFunc);

            treeviewSpacing.AppendColumn(column);

            category = AddOption(spacingOptions, null, GettextCatalog.GetString("Set spacing for method declarations"), null);
            AddOption(spacingOptions, category, "SpacingAfterMethodDeclarationName", GettextCatalog.GetString("Insert space between method name and its opening parenthesis"),
                      @"void Example()
{
}");

            AddOption(spacingOptions, category, "SpaceWithinMethodDeclarationParenthesis", GettextCatalog.GetString("Insert space within argument list parentheses"),
                      @"void Example(int i, int j)
{
}");
            AddOption(spacingOptions, category, "SpaceBetweenEmptyMethodDeclarationParentheses", GettextCatalog.GetString("Insert space within empty argument list parentheses"), @"void Example()
{
}");

            category = AddOption(spacingOptions, null, GettextCatalog.GetString("Set spacing for method calls"), null);
            AddOption(spacingOptions, category, "SpaceAfterMethodCallName", GettextCatalog.GetString("Insert space between method name and its opening parenthesis"), @"void Example()
{
	Test();
}");
            AddOption(spacingOptions, category, "SpaceWithinMethodCallParentheses", GettextCatalog.GetString("Insert space within argument list parentheses"), @"void Example()
{
	Test(1, 2);
}");
            AddOption(spacingOptions, category, "SpaceBetweenEmptyMethodCallParentheses", GettextCatalog.GetString("Insert space within empty argument list parentheses"), @"void Example()
{
	Test();
}");

            category = AddOption(spacingOptions, null, GettextCatalog.GetString("Set other spacing options"), null);
            AddOption(spacingOptions, category, "SpaceAfterControlFlowStatementKeyword", GettextCatalog.GetString("Insert space after keywords in control flow statements"), @"void Example()
{
	if (condition)
	{
	}
}");

            AddOption(spacingOptions, category, "SpaceWithinExpressionParentheses", GettextCatalog.GetString("Insert space within parentheses of expressions"), @"void Example()
{
	i = (5 + 3) * 2;
}");
            AddOption(spacingOptions, category, "SpaceWithinCastParentheses", GettextCatalog.GetString("Insert space within parentheses of type casts"), @"void Example()
{
	test = (ITest)o;
}");
            AddOption(spacingOptions, category, "SpaceWithinOtherParentheses", GettextCatalog.GetString("Insert space within parentheses of control flow statements"), @"void Example()
{
	if (condition)
	{
	}
}");

            AddOption(spacingOptions, category, "SpaceAfterCast", GettextCatalog.GetString("Insert space after casts"), @"void Example()
{
	test = (ITest)o;
}");
            AddOption(spacingOptions, category, "SpacesIgnoreAroundVariableDeclaration", GettextCatalog.GetString("Ignore spaces in declaration statements"), @"void Example()
{
	int x=5;
}");

            category = AddOption(spacingOptions, null, GettextCatalog.GetString("Set spacing for brackets"), null);
            AddOption(spacingOptions, category, "SpaceBeforeOpenSquareBracket", GettextCatalog.GetString("Insert space before open square bracket"), @"void Example()
{
	i[5] = 3;
}");
            AddOption(spacingOptions, category, "SpaceBetweenEmptySquareBrackets", GettextCatalog.GetString("Insert space within empty square brackets"), @"void Example()
{
	new int[] {1, 2};
}");
            AddOption(spacingOptions, category, "SpaceWithinSquareBrackets", GettextCatalog.GetString("Insert space within square brackets"), @"void Example()
{
	i[5] = 3;
}");

            category = AddOption(spacingOptions, null, GettextCatalog.GetString("Other"), null);
            AddOption(spacingOptions, category, "SpaceAfterColonInBaseTypeDeclaration", GettextCatalog.GetString("Insert space after colon for base or interface in type declaration"), @"class Foo : Bar
{
}");
            AddOption(spacingOptions, category, "SpaceAfterComma", GettextCatalog.GetString("Insert space after comma"), @"void Example()
{
	var array = { 1,2,3,4 };
}");
            AddOption(spacingOptions, category, "SpaceAfterDot", GettextCatalog.GetString("Insert space after dot"), @"void Example()
{
	Foo.Bar.Test();
}");
            AddOption(spacingOptions, category, "SpaceAfterSemicolonsInForStatement", GettextCatalog.GetString("Insert space after semicolon in \"for\" statement"), @"void Example()
{
	for (int i = 0; i< 10; i++)
	{
	}
}");
            AddOption(spacingOptions, category, "SpaceBeforeColonInBaseTypeDeclaration", GettextCatalog.GetString("Insert space before colon for base or interface in type declaration"), @"class Foo : Bar
{
}");
            AddOption(spacingOptions, category, "SpaceBeforeComma", GettextCatalog.GetString("Insert space before comma"), @"void Example()
{
	var array = { 1,2,3,4 };
}");
            AddOption(spacingOptions, category, "SpaceBeforeDot", GettextCatalog.GetString("Insert space before dot"), @"void Example()
{
	Foo.Bar.Test();
}");
            AddOption(spacingOptions, category, "SpaceBeforeSemicolonsInForStatement", GettextCatalog.GetString("Insert space before semicolon in \"for\" statement"), @"void Example()
{
	for (int i = 0; i< 10; i++)
	{
	}
}");

            AddOption(spacingOptions, category, "SpacingAroundBinaryOperator", GettextCatalog.GetString("Set spacing for operators"), @"void Example()
{
	i = (5 + 3) * 2;
}");

            treeviewSpacing.ExpandAll();
            #endregion

            #region Style options
            styleOptions = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));

            column = new TreeViewColumn();
            // pixbuf column
            column.PackStart(pixbufCellRenderer, false);
            column.SetCellDataFunc(pixbufCellRenderer, RenderIcon);

            // text column
            cellRendererText.Ypad = 1;
            column.PackStart(cellRendererText, true);
            column.SetAttributes(cellRendererText, "text", 1);


            treeviewStyle.Model              = styleOptions;
            treeviewStyle.SearchColumn       = -1;       // disable the interactive search
            treeviewStyle.HeadersVisible     = false;
            treeviewStyle.Selection.Changed += TreeSelectionChanged;

            cellRendererCombo            = new CellRendererCombo();
            cellRendererCombo.Ypad       = 1;
            cellRendererCombo.Mode       = CellRendererMode.Editable;
            cellRendererCombo.TextColumn = 1;
            cellRendererCombo.Model      = ComboBoxStore;
            cellRendererCombo.HasEntry   = false;
            cellRendererCombo.Editable   = !profile.IsBuiltIn;
            cellRendererCombo.Edited    += new ComboboxEditedHandler(this, styleOptions).ComboboxEdited;

            column.PackStart(cellRendererCombo, false);
            column.SetAttributes(cellRendererCombo, "visible", comboVisibleColumn);
            column.SetCellDataFunc(cellRendererCombo, ComboboxDataFunc);

            cellRendererToggle             = new CellRendererToggle();
            cellRendererToggle.Activatable = !profile.IsBuiltIn;
            cellRendererToggle.Ypad        = 1;
            cellRendererToggle.Toggled    += new CellRendererToggledHandler(this, treeviewSpacing, styleOptions).Toggled;
            column.PackStart(cellRendererToggle, false);
            column.SetAttributes(cellRendererToggle, "visible", toggleVisibleColumn);
            column.SetCellDataFunc(cellRendererToggle, ToggleDataFunc);

            treeviewStyle.AppendColumn(column);

            AddOption(styleOptions, "PlaceSystemDirectiveFirst", GettextCatalog.GetString("Place System directives first when sorting usings"), "");

            // AddOption (styleOptions, category, null, GettextCatalog.GetString ("Qualify member access with 'this'"), null);
            // AddOption (styleOptions, category, null, GettextCatalog.GetString ("Use 'var' when generating locals"), null);

            treeviewStyle.ExpandAll();
            #endregion

            #region Wrapping options
            wrappingOptions = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool));

            column = new TreeViewColumn();
            // pixbuf column
            column.PackStart(pixbufCellRenderer, false);
            column.SetCellDataFunc(pixbufCellRenderer, RenderIcon);

            // text column
            cellRendererText.Ypad = 1;
            column.PackStart(cellRendererText, true);
            column.SetAttributes(cellRendererText, "text", 1);

            treeviewWrapping.Model              = wrappingOptions;
            treeviewWrapping.SearchColumn       = -1;       // disable the interactive search
            treeviewWrapping.HeadersVisible     = false;
            treeviewWrapping.Selection.Changed += TreeSelectionChanged;

            cellRendererCombo            = new CellRendererCombo();
            cellRendererCombo.Ypad       = 1;
            cellRendererCombo.Mode       = CellRendererMode.Editable;
            cellRendererCombo.TextColumn = 1;
            cellRendererCombo.Model      = ComboBoxStore;
            cellRendererCombo.HasEntry   = false;
            cellRendererCombo.Editable   = !profile.IsBuiltIn;
            cellRendererCombo.Edited    += new ComboboxEditedHandler(this, wrappingOptions).ComboboxEdited;

            column.PackStart(cellRendererCombo, false);
            column.SetAttributes(cellRendererCombo, "visible", comboVisibleColumn);
            column.SetCellDataFunc(cellRendererCombo, ComboboxDataFunc);

            cellRendererToggle             = new CellRendererToggle();
            cellRendererToggle.Activatable = !profile.IsBuiltIn;
            cellRendererToggle.Ypad        = 1;
            cellRendererToggle.Toggled    += new CellRendererToggledHandler(this, treeviewSpacing, wrappingOptions).Toggled;
            column.PackStart(cellRendererToggle, false);
            column.SetAttributes(cellRendererToggle, "visible", toggleVisibleColumn);
            column.SetCellDataFunc(cellRendererToggle, ToggleDataFunc);

            treeviewWrapping.AppendColumn(column);

            AddOption(wrappingOptions, "WrappingPreserveSingleLine", GettextCatalog.GetString("Leave block on single line"), "");
            AddOption(wrappingOptions, "WrappingKeepStatementsOnSingleLine", GettextCatalog.GetString("Leave statements and member declarations on the same line"), "");

            treeviewWrapping.ExpandAll();
            #endregion
        }
Esempio n. 32
0
        public PriorityColumn()
        {
            TreeViewColumn = new TreeViewColumn {
                Title = Catalog.GetString ("Priority"),
                Sizing = TreeViewColumnSizing.Fixed,
                Alignment = 0.5f,
                FixedWidth = 30,
                Resizable = false,
                Clickable = true
            };

            var priorityStore = new ListStore (typeof (string));
            priorityStore.AppendValues (Catalog.GetString ("1")); // High
            priorityStore.AppendValues (Catalog.GetString ("2")); // Medium
            priorityStore.AppendValues (Catalog.GetString ("3")); // Low
            priorityStore.AppendValues (Catalog.GetString ("-")); // None

            var renderer = new CellRendererCombo {
                Editable = true,
                HasEntry = false,
                Model = priorityStore,
                TextColumn = 0,
                Xalign = 0.5f
            };

            renderer.EditingStarted += (o, args) => {
                TreeIter iter;
                var path = new TreePath (args.Path);
                if (!model.GetIter (out iter, path))
                    return;

                var task = model.GetValue (iter, 0) as ITask;
                if (task == null)
                    return;

                taskBeingEdited = new TaskBeingEdited (task, iter, path);
                if (CellEditingStarted != null)
                    CellEditingStarted (this, new TaskRowEditingEventArgs (task, iter, path));
            };

            renderer.EditingCanceled += delegate { EndCellEditing (); };

            renderer.Edited += (o, args) => {
                TreeIter iter;
                var path = new TreePath (args.Path);
                if (model.GetIter (out iter, path)) {
                    TaskPriority newPriority;
                    var newText = args.NewText;
                    if (newText == Catalog.GetString ("3"))
                        newPriority = TaskPriority.Low;
                    else if (newText == Catalog.GetString ("2"))
                        newPriority = TaskPriority.Medium;
                    else if (newText == Catalog.GetString ("1"))
                        newPriority = TaskPriority.High;
                    else
                        newPriority = TaskPriority.None;

                    // Update the priority if it's different
                    var task = model.GetValue (iter, 0) as ITask;
                    if (task.Priority != newPriority)
                        task.Priority = newPriority;
                }
                EndCellEditing ();
            };

            TreeViewColumn.PackStart (renderer, true);
            TreeViewColumn.SetCellDataFunc (renderer, TaskPriorityCellDataFunc);
        }