Exemplo n.º 1
0
		public DemoStockBrowser () : base ("Stock Icons and Items")
		{
			SetDefaultSize (-1, 500);
			BorderWidth = 8;

			HBox hbox = new HBox (false, 8);
			Add (hbox);

			ScrolledWindow sw = new ScrolledWindow ();
			sw.SetPolicy (PolicyType.Never, PolicyType.Automatic);
			hbox.PackStart (sw, false, false, 0);

			ListStore model = CreateModel ();

			TreeView treeview = new TreeView (model);
			sw.Add (treeview);

			TreeViewColumn column = new TreeViewColumn ();
			column.Title = "Name";
			CellRenderer renderer = new CellRendererPixbuf ();
			column.PackStart (renderer, false);
			column.SetAttributes (renderer, "stock_id", Column.Id);
			renderer = new CellRendererText ();
			column.PackStart (renderer, true);
			column.SetAttributes (renderer, "text", Column.Name);

			treeview.AppendColumn (column);
			treeview.AppendColumn ("Label", new CellRendererText (), "text", Column.Label);
			treeview.AppendColumn ("Accel", new CellRendererText (), "text", Column.Accel);
			treeview.AppendColumn ("ID", new CellRendererText (), "text", Column.Id);

			Alignment align = new Alignment (0.5f, 0.0f, 0.0f, 0.0f);
			hbox.PackEnd (align, false, false, 0);

			Frame frame = new Frame ("Selected Item");
			align.Add (frame);

			VBox vbox = new VBox (false, 8);
			vbox.BorderWidth = 8;
			frame.Add (vbox);

			typeLabel = new Label ();
			vbox.PackStart (typeLabel, false, false, 0);
			iconImage = new Gtk.Image ();
			vbox.PackStart (iconImage, false, false, 0);
			accelLabel = new Label ();
			vbox.PackStart (accelLabel, false, false, 0);
			nameLabel = new Label ();
			vbox.PackStart (nameLabel, false, false, 0);
			idLabel = new Label ();
			vbox.PackStart (idLabel, false, false, 0);

			treeview.Selection.Mode = Gtk.SelectionMode.Single;
			treeview.Selection.Changed += new EventHandler (SelectionChanged);

			ShowAll ();
		}
Exemplo n.º 2
0
        /// <summary>
        /// Appends the columns.
        /// </summary>
        public void appendColumns()
        {
            try {
                try {
                    for (int i = 0; i < treeview1.Columns.Length; i++)
                        treeview1.RemoveColumn (treeview1.Columns [i]);
                } catch {
                }

                g_regexList = new ListStore (typeof(string), typeof(string));

                TreeViewColumn ausdruck = new TreeViewColumn ();
                ausdruck.Title = "Ausdruck";
                ausdruck.PackStart (new CellRendererText (), true);
                ausdruck.SetAttributes (ausdruck.CellRenderers [0], "text", 0);

                TreeViewColumn datum = new TreeViewColumn ();
                datum.Title = "Datum";
                datum.PackStart (new CellRendererText (), true);
                datum.SetAttributes (datum.CellRenderers [0], "text", 1);

                treeview1.Model = g_regexList;
                treeview1.AppendColumn (ausdruck);
                treeview1.AppendColumn (datum);

            } catch (Exception ex) {
                MessageBox.Show (ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
            }
        }
		public RefactoringPreviewDialog (ProjectDom ctx, List<Change> changes)
		{
			this.Build ();
			this.changes = changes;
			treeviewPreview.Model = store;

			TreeViewColumn column = new TreeViewColumn ();

			// pixbuf column
			var pixbufCellRenderer = new CellRendererPixbuf ();
			column.PackStart (pixbufCellRenderer, false);
			column.SetAttributes (pixbufCellRenderer, "pixbuf", pixbufColumn);
			column.AddAttribute (pixbufCellRenderer, "visible", statusVisibleColumn);
			
			// text column
			CellRendererText cellRendererText = new CellRendererText ();
			column.PackStart (cellRendererText, false);
			column.SetAttributes (cellRendererText, "text", textColumn);
			column.AddAttribute (cellRendererText, "visible", statusVisibleColumn);
			
			// location column
			CellRendererText cellRendererText2 = new CellRendererText ();
			column.PackStart (cellRendererText2, false);
			column.SetCellDataFunc (cellRendererText2, new TreeCellDataFunc (SetLocationTextData));
			
			CellRendererDiff cellRendererDiff = new CellRendererDiff ();
			column.PackStart (cellRendererDiff, true);
			column.SetCellDataFunc (cellRendererDiff, new TreeCellDataFunc (SetDiffCellData));

			treeviewPreview.AppendColumn (column);
			treeviewPreview.HeadersVisible = false;
			
			buttonCancel.Clicked += delegate {
				Destroy ();
			};
			
			buttonOk.Clicked += delegate {
				IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBackgroundProgressMonitor (this.Title, null);
				RefactoringService.AcceptChanges (monitor, ctx, changes);
				
				Destroy ();
			};
			
			FillChanges ();
			Resize (IdeApp.Workbench.ActiveDocument.ActiveView.Control.Allocation.Width,
			        IdeApp.Workbench.ActiveDocument.ActiveView.Control.Allocation.Height);
		}
		public RefactoringPreviewDialog (IList<Change> changes)
		{
			this.Build ();
			this.changes = changes;
			treeviewPreview.Model = store;
			treeviewPreview.SearchColumn = -1; // disable the interactive search

			TreeViewColumn column = new TreeViewColumn ();

			// pixbuf column
			var pixbufCellRenderer = new CellRendererImage ();
			column.PackStart (pixbufCellRenderer, false);
			column.SetAttributes (pixbufCellRenderer, "image", pixbufColumn);
			column.AddAttribute (pixbufCellRenderer, "visible", statusVisibleColumn);
			
			// text column
			CellRendererText cellRendererText = new CellRendererText ();
			column.PackStart (cellRendererText, false);
			column.SetAttributes (cellRendererText, "text", textColumn);
			column.AddAttribute (cellRendererText, "visible", statusVisibleColumn);
			
			// location column
			CellRendererText cellRendererText2 = new CellRendererText ();
			column.PackStart (cellRendererText2, false);
			column.SetCellDataFunc (cellRendererText2, new TreeCellDataFunc (SetLocationTextData));
			
			CellRendererDiff cellRendererDiff = new CellRendererDiff ();
			column.PackStart (cellRendererDiff, true);
			column.SetCellDataFunc (cellRendererDiff, new TreeCellDataFunc (SetDiffCellData));

			treeviewPreview.AppendColumn (column);
			treeviewPreview.HeadersVisible = false;
			
			buttonCancel.Clicked += delegate {
				Destroy ();
			};
			
			buttonOk.Clicked += delegate {
				ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBackgroundProgressMonitor (this.Title, null);
				RefactoringService.AcceptChanges (monitor, changes);
				
				Destroy ();
			};
			
			FillChanges ();
		}
		public HighlightingPanel ()
		{
			this.Build ();
			var col = new TreeViewColumn ();
			var crpixbuf = new CellRendererPixbuf ();
			col.PackStart (crpixbuf, false);
			col.SetCellDataFunc (crpixbuf, ImageDataFunc);
			var crtext = new CellRendererText ();
			col.PackEnd (crtext, true);
			col.SetAttributes (crtext, "markup", 0);
			styleTreeview.AppendColumn (col);
			styleTreeview.Model = styleStore;
			styleTreeview.SearchColumn = -1; // disable the interactive search
			schemeName = DefaultSourceEditorOptions.Instance.ColorScheme;
			MonoDevelop.Ide.Gui.Styles.Changed += HandleThemeChanged;
		}
Exemplo n.º 6
0
		public HighlightingPanel ()
		{
			this.Build ();
			var col = new TreeViewColumn ();
			var crpixbuf = new CellRendererPixbuf ();
			col.PackStart (crpixbuf, false);
			col.SetCellDataFunc (crpixbuf, (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) => {
				var isError = (bool)styleStore.GetValue (iter, 2);
				crpixbuf.Visible = isError;
				crpixbuf.Pixbuf = isError ? errorPixbuf.Value : null;
			});
			var crtext = new CellRendererText ();
			col.PackEnd (crtext, true);
			col.SetAttributes (crtext, "markup", 0);
			styleTreeview.AppendColumn (col);
			styleTreeview.Model = styleStore;
			schemeName = DefaultSourceEditorOptions.Instance.ColorScheme;
		}
Exemplo n.º 7
0
        public Toolbox(ServiceContainer parentServices)
        {
            this.parentServices = parentServices;

            //we need this service, so create it if not present
            toolboxService = parentServices.GetService (typeof (IToolboxService)) as ToolboxService;
            if (toolboxService == null) {
                toolboxService = new ToolboxService ();
                parentServices.AddService (typeof (IToolboxService), toolboxService);
            }

            #region Toolbar
            toolbar = new Toolbar ();
            toolbar.ToolbarStyle = ToolbarStyle.Icons;
            toolbar.IconSize = IconSize.SmallToolbar;
            base.PackStart (toolbar, false, false, 0);

            filterToggleButton = new ToggleToolButton ();
            filterToggleButton.IconWidget = new Image (Stock.MissingImage, IconSize.SmallToolbar);
            filterToggleButton.Toggled += new EventHandler (toggleFiltering);
            toolbar.Insert (filterToggleButton, 0);

            catToggleButton = new ToggleToolButton ();
            catToggleButton.IconWidget = new Image (Stock.MissingImage, IconSize.SmallToolbar);
            catToggleButton.Toggled += new EventHandler (toggleCategorisation);
            toolbar.Insert (catToggleButton, 1);

            SeparatorToolItem sep = new SeparatorToolItem();
            toolbar.Insert (sep, 2);

            filterEntry = new Entry();
            filterEntry.WidthRequest = 150;
            filterEntry.Changed += new EventHandler (filterTextChanged);

            #endregion

            scrolledWindow = new ScrolledWindow ();
            base.PackEnd (scrolledWindow, true, true, 0);

            //Initialise model

            store = new ToolboxStore ();

            //initialise view
            nodeView = new NodeView (store);
            nodeView.Selection.Mode = SelectionMode.Single;
            nodeView.HeadersVisible = false;

            //cell renderers
            CellRendererPixbuf pixbufRenderer = new CellRendererPixbuf ();
            CellRendererText textRenderer = new CellRendererText ();
            textRenderer.Ellipsize = Pango.EllipsizeMode.End;

            //Main column with text, icons
            TreeViewColumn col = new TreeViewColumn ();

            col.PackStart (pixbufRenderer, false);
            col.SetAttributes (pixbufRenderer,
                                  "pixbuf", ToolboxStore.Columns.Icon,
                                  "visible", ToolboxStore.Columns.IconVisible,
                                  "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            col.PackEnd (textRenderer, true);
            col.SetAttributes (textRenderer,
                                  "text", ToolboxStore.Columns.Label,
                                  "weight", ToolboxStore.Columns.FontWeight,
                                  "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            nodeView.AppendColumn (col);

            //Initialise self
            scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
            scrolledWindow.HscrollbarPolicy = PolicyType.Never;
            scrolledWindow.WidthRequest = 150;
            scrolledWindow.AddWithViewport (nodeView);

            //selection events
            nodeView.NodeSelection.Changed += OnSelectionChanged;
            nodeView.RowActivated  += OnRowActivated;

            //update view when toolbox service updated
            toolboxService.ToolboxChanged += new EventHandler (tbsChanged);
            Refresh ();

            //track expanded state of nodes
            nodeView.RowCollapsed += new RowCollapsedHandler (whenRowCollapsed);
            nodeView.RowExpanded += new RowExpandedHandler (whenRowExpanded);

            //set initial state
            filterToggleButton.Active = false;
            catToggleButton.Active = true;
        }
		public CSharpFormattingProfileDialog (CSharpFormattingPolicy profile)
		{
			// ReSharper disable once DoNotCallOverridableMethodsInConstructor
			this.Build ();
			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;
				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 ("Style"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("Wrapping"));
			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.Child = 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.HeadersVisible = false;
			treeviewIndentOptions.Selection.Changed += TreeSelectionChanged;
			treeviewIndentOptions.AppendColumn (column);
			
			column = new TreeViewColumn ();
			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 case contents"), "class AClass { void Method (int x) { switch (x) { case 1: break; } } }");
			AddOption (indentationOptions, "IndentSwitchCaseSection", GettextCatalog.GetString ("Indent case labels"), "class AClass { void Method (int x) { switch (x) { case 1: break; } } }");
			AddOption (indentationOptions, "LabelPositioning", GettextCatalog.GetString ("Label indentation"), "enum AEnum { A, B, C }");
			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.HeadersVisible = false;
			treeviewNewLines.Selection.Changed += TreeSelectionChanged;
			treeviewNewLines.AppendColumn (column);
			
			column = new TreeViewColumn ();
			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()
{
	from o in col select o.Foo;
}");
			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.HeadersVisible = false;
			treeviewSpacing.Selection.Changed += TreeSelectionChanged;
			treeviewSpacing.AppendColumn (column);

			column = new TreeViewColumn ();
			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 withing 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 withing 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 ("Set spacing for brackets"), 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()
{
	for (int i =0; i < 10, i >5;i++)
	{
	}
}");
			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()
{
	for (int i =0; i < 10, i >5;i++)
	{
	}
}");
			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.HeadersVisible = false;
			treeviewStyle.Selection.Changed += TreeSelectionChanged;
			treeviewStyle.AppendColumn (column);

			column = new TreeViewColumn ();
			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, 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.HeadersVisible = false;
			treeviewWrapping.Selection.Changed += TreeSelectionChanged;
			treeviewWrapping.AppendColumn (column);

			column = new TreeViewColumn ();
			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
		}
Exemplo n.º 9
0
        /// <summary>Default constructor for ExplorerView</summary>
        public ExplorerView(ViewBase owner)
            : base(owner)
        {
            Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.ExplorerView.glade", "vbox1");
            gxml.Autoconnect(this);
            _mainWidget = vbox1;

            treeview1.Model = treemodel;
            TreeViewColumn column = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();
            column.PackStart(iconRender, false);
            textRender = new Gtk.CellRendererText();
            textRender.Editable = true;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            //            column.SetCellDataFunc(textRender, treecelldatafunc);
            treeview1.AppendColumn(column);
            treeview1.TooltipColumn = 2;

            treeview1.CursorChanged += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;

            TargetEntry[] target_table = new TargetEntry[] {
               new TargetEntry ("application/x-model-component", TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            //treeview1.EnableModelDragDest(target_table, actions);
            //treeview1.EnableModelDragSource(Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion += OnDragOver;
            treeview1.DragDrop += OnDragDrop;
            treeview1.DragBegin += OnDragBegin;
            treeview1.DragDataGet += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd += OnDragEnd;
            treeview1.DragDataDelete += OnDragDataDelete;
            treeview1.FocusInEvent += Treeview1_FocusInEvent;
            treeview1.FocusOutEvent += Treeview1_FocusOutEvent;
            _mainWidget.Destroyed += _mainWidget_Destroyed;
        }
Exemplo n.º 10
0
        public CategoryView()
        {
            PIXBUF_ALL_ITEMS = RenderIcon(Icons.Icon.Stock_File, ICON_SIZE);

            // all categories
            CATEGORIES = new CategoryInfo[] {
                _ci(Icons.Icon.Stock_Directory,			S._("Directories")),
                _ci(Icons.Icon.Category_Texts,			S._("Text")),
                _ci(Icons.Icon.Category_Documents,		S._("Documents")),
                _ci(Icons.Icon.Category_Music,			S._("Music")),
                _ci(Icons.Icon.Category_Movies,			S._("Movies")),
                _ci(Icons.Icon.Category_Images	,		S._("Images")),
                _ci(Icons.Icon.Category_Applications,	S._("Applications")),
                _ci(Icons.Icon.Category_Archives,		S._("Archives")),
                _ci(Icons.Icon.Category_Development,	S._("Development"))
            };

            // mimetype -> category mapping
            MIME_MAPPING = MimeCategoryMapping
                .GetMapping<CategoryInfo>(/*directoryCategoryData:*/	CATEGORIES[0],
                                          /*textCategoryData:*/			CATEGORIES[1],
                                          /*documentCategoryData:*/		CATEGORIES[2],
                                          /*musicCategoryData:*/		CATEGORIES[3],
                                          /*movieCategoryData:*/		CATEGORIES[4],
                                          /*imageCategoryData:*/		CATEGORIES[5],
                                          /*applicationCategoryData:*/	CATEGORIES[6],
                                          /*archiveCategoryData:*/		CATEGORIES[7],
                                          /*textCategoryData:*/			CATEGORIES[8]);

            allItems = new VolumeItem[0];

            //
            // set up columns
            //
            HeadersVisible = true;

            TreeViewColumn col;

            // column icon/category
            CellRendererPixbuf pix = new CellRendererPixbuf();
            CellRendererText txt = new CellRendererText();
            col = new TreeViewColumn();
            col.SortColumnId = 1;
            col.Resizable = true;
            col.Title = S._("Category");
            col.PackStart(pix, false);
            col.PackStart(txt, false);
            col.SetAttributes(pix, "pixbuf", 0);
            col.SetAttributes(txt, "text", 1);

            AppendColumn(col);

            Model = GetNewStore();
        }
Exemplo n.º 11
0
        private void InitView(VolumeType volType, out TreeModel model)
        {
            currentVolumeType = volType;
            TreeViewColumn col;

            switch (volType) {
                case VolumeType.FileSystemVolume:
                    HeadersVisible = false;

                    CellRendererPixbuf pix = new CellRendererPixbuf();
                    CellRendererText txt = new CellRendererText();

                    col = new TreeViewColumn();
                    col.PackStart(pix, false);
                    col.PackStart(txt, false);
                    col.SetAttributes(pix, "pixbuf", 0);
                    col.SetAttributes(txt, "text", 1);
                    col.SetCellDataFunc(txt, CellDataFunc);
                    AppendColumn(col);

                    // set up store
                    model = new TreeStore(typeof(Gdk.Pixbuf),
                                      typeof(string),
                                      /* VolumeItem - not visible */
                                      typeof(FileSystemVolumeItem));

                    item_col = 2;
                    break;
                case VolumeType.AudioCdVolume:
                    HeadersVisible = true;

                    col = new TreeViewColumn(string.Empty, new CellRendererPixbuf(), "pixbuf", 0);
                    col.Resizable = false;
                    col.Expand = false;
                    AppendColumn(col);

                    var tmp = new CellRendererText();
                    col = new TreeViewColumn(S._("Name"), tmp, "text", 1);
                    col.Resizable = true;
                    col.Expand = true;
                    col.SetCellDataFunc(tmp, CellDataFunc);
                    AppendColumn(col);

                    col = new TreeViewColumn(S._("Artist"), new CellRendererText(), "text", 2);
                    col.Resizable = true;
                    col.Expand = true;
                    AppendColumn(col);

                    col = new TreeViewColumn(S._("Duration"), new CellRendererText(), "text", 3);
                    col.Resizable = true;
                    col.Expand = false;
                    AppendColumn(col);

                    // set up store
                    model = new ListStore(typeof(Gdk.Pixbuf),
                                      typeof(string),
                                      typeof(string),
                                      typeof(string),
                                      /* VolumeItem - not visible */
                                      typeof(AudioTrackVolumeItem));

                    item_col = 4;
                    break;
                default:
                    throw new NotImplementedException("View initialization has not been implemented for this volumetype");
            }
        }
        private void BuildGui()
        {
            HBox headerBox = new HBox();
            headerBox.PackStart(new Label(GettextCatalog.GetString("Workspace") + ":"), false, false, 0);

            _workspaceComboBox.Model = _workspaceStore;
            var workspaceTextRenderer = new CellRendererText();
            _workspaceComboBox.PackStart(workspaceTextRenderer, true);
            _workspaceComboBox.SetAttributes(workspaceTextRenderer, "text", 1);

            headerBox.PackStart(_workspaceComboBox, false, false, 0);
            headerBox.PackStart(manageButton, false, false, 0);
            headerBox.PackStart(refreshButton, false, false, 0);
            _view.PackStart(headerBox, false, false, 0);

            HPaned mainBox = new HPaned();

            VBox treeViewBox = new VBox();

            TreeViewColumn treeColumn = new TreeViewColumn();
            treeColumn.Title = "Folders";
            var repoImageRenderer = new CellRendererPixbuf();
            treeColumn.PackStart(repoImageRenderer, false);
            treeColumn.SetAttributes(repoImageRenderer, "pixbuf", 1);
            var folderTextRenderer = new CellRendererText();
            treeColumn.PackStart(folderTextRenderer, true);
            treeColumn.SetAttributes(folderTextRenderer, "text", 2);
            _treeView.AppendColumn(treeColumn);

            treeViewBox.WidthRequest = 250;
            ScrolledWindow scrollContainer = new ScrolledWindow();
            scrollContainer.Add(_treeView);
            treeViewBox.PackStart(scrollContainer, true, true, 0);
            mainBox.Pack1(treeViewBox, false, false);

            VBox rightBox = new VBox();
            HBox headerRightBox = new HBox();

            headerRightBox.PackStart(new Label(GettextCatalog.GetString("Local Path") + ":"), false, false, 0);
            Alignment leftAlign = new Alignment(0, 0, 0, 0);
            _localFolder.Justify = Justification.Left;
            leftAlign.Add(_localFolder);
            headerRightBox.PackStart(leftAlign);
            rightBox.PackStart(headerRightBox, false, false, 0);

            var itemNameColumn = new TreeViewColumn();
            itemNameColumn.Title = "Name";
            var itemIconRenderer = new CellRendererPixbuf();
            itemNameColumn.PackStart(itemIconRenderer, false);
            itemNameColumn.SetAttributes(itemIconRenderer, "pixbuf", 1);
            var itemNameRenderer = new CellRendererText();
            itemNameColumn.PackStart(itemNameRenderer, true);
            itemNameColumn.SetAttributes(itemNameRenderer, "text", 2);
            _listView.AppendColumn(itemNameColumn);

            _listView.AppendColumn("Pending Change", new CellRendererText(), "text", 3);
            _listView.AppendColumn("User", new CellRendererText(), "text", 4);
            _listView.AppendColumn("Latest", new CellRendererText(), "text", 5);
            _listView.AppendColumn("Last Check-in", new CellRendererText(), "text", 6);

            _listView.Selection.Mode = SelectionMode.Multiple;
            _listView.Model = _listStore;
            var listViewScollWindow = new ScrolledWindow();
            listViewScollWindow.Add(_listView);
            rightBox.PackStart(listViewScollWindow, true, true, 0);
            mainBox.Pack2(rightBox, true, true);
            _view.PackStart(mainBox, true, true, 0);
            AttachEvents();
            _view.ShowAll();
        }
Exemplo n.º 13
0
		public POEditorWidget (TranslationProject project)
		{
			this.project = project;
			this.Build ();
			this.headersEditor = new CatalogHeadersWidget ();
			this.notebookPages.AppendPage (headersEditor, new Gtk.Label ());
			
			updateThread = new BackgroundWorker ();
			updateThread.WorkerSupportsCancellation = true;
			updateThread.DoWork += FilterWorker;
			
			updateTaskThread = new BackgroundWorker ();
			updateTaskThread.WorkerSupportsCancellation = true;
			updateTaskThread.DoWork += TaskUpdateWorker;
			
			AddButton (GettextCatalog.GetString ("Translation")).Active = true;
			AddButton (GettextCatalog.GetString ("Headers")).Active = false;
			
			// entries tree view 
			store = new ListStore (typeof(string), typeof(bool), typeof(string), typeof(string), typeof(CatalogEntry), typeof(Gdk.Color), typeof(int), typeof(Gdk.Color));
			this.treeviewEntries.Model = store;
			
			treeviewEntries.AppendColumn (String.Empty, new CellRendererIcon (), "stock_id", Columns.Stock, "cell-background-gdk", Columns.RowColor);
			
			CellRendererToggle cellRendFuzzy = new CellRendererToggle ();
			cellRendFuzzy.Toggled += new ToggledHandler (FuzzyToggled);
			cellRendFuzzy.Activatable = true;
			treeviewEntries.AppendColumn (GettextCatalog.GetString ("Fuzzy"), cellRendFuzzy, "active", Columns.Fuzzy, "cell-background-gdk", Columns.RowColor);
			
			CellRendererText original = new CellRendererText ();
			original.Ellipsize = Pango.EllipsizeMode.End;
			treeviewEntries.AppendColumn (GettextCatalog.GetString ("Original string"), original, "text", Columns.String, "cell-background-gdk", Columns.RowColor, "foreground-gdk", Columns.ForeColor);
			
			CellRendererText translation = new CellRendererText ();
			translation.Ellipsize = Pango.EllipsizeMode.End;
			treeviewEntries.AppendColumn (GettextCatalog.GetString ("Translated string"), translation, "text", Columns.Translation, "cell-background-gdk", Columns.RowColor, "foreground-gdk", Columns.ForeColor);
			treeviewEntries.Selection.Changed += new EventHandler (OnEntrySelected);
			
			treeviewEntries.GetColumn (0).SortIndicator = true;
			treeviewEntries.GetColumn (0).SortColumnId = (int)Columns.TypeSortIndicator;
			
			treeviewEntries.GetColumn (1).SortIndicator = true;
			treeviewEntries.GetColumn (1).SortColumnId = (int)Columns.Fuzzy;
			
			treeviewEntries.GetColumn (2).SortIndicator = true;
			treeviewEntries.GetColumn (2).SortColumnId = (int)Columns.String;
			treeviewEntries.GetColumn (2).Resizable = true;
			treeviewEntries.GetColumn (2).Expand = true;
			
			treeviewEntries.GetColumn (3).SortIndicator = true;
			treeviewEntries.GetColumn (3).SortColumnId = (int)Columns.Translation;
			treeviewEntries.GetColumn (3).Resizable = true;
			treeviewEntries.GetColumn (3).Expand = true;
			// found in tree view
			foundInStore = new ListStore (typeof(string), typeof(string), typeof(string), typeof(Pixbuf));
			this.treeviewFoundIn.Model = foundInStore;
			
			TreeViewColumn fileColumn = new TreeViewColumn ();
			var pixbufRenderer = new CellRendererPixbuf ();
			fileColumn.PackStart (pixbufRenderer, false);
			fileColumn.SetAttributes (pixbufRenderer, "pixbuf", FoundInColumns.Pixbuf);
			
			CellRendererText textRenderer = new CellRendererText ();
			fileColumn.PackStart (textRenderer, true);
			fileColumn.SetAttributes (textRenderer, "text", FoundInColumns.File);
			treeviewFoundIn.AppendColumn (fileColumn);
			
			treeviewFoundIn.AppendColumn ("", new CellRendererText (), "text", FoundInColumns.Line);
			treeviewFoundIn.HeadersVisible = false;
			treeviewFoundIn.GetColumn (1).FixedWidth = 100;
			
			treeviewFoundIn.RowActivated += delegate(object sender, RowActivatedArgs e) {
				Gtk.TreeIter iter;
				foundInStore.GetIter (out iter, e.Path);
				string line = foundInStore.GetValue (iter, (int)FoundInColumns.Line) as string;
				string file = foundInStore.GetValue (iter, (int)FoundInColumns.FullFileName) as string;
				int lineNr = 1;
				try {
					lineNr = 1 + int.Parse (line);
				} catch {
				}
				IdeApp.Workbench.OpenDocument (file, lineNr, 1, true);
			};
			this.notebookTranslated.RemovePage (0);
			this.searchEntryFilter.Entry.Text = "";
			searchEntryFilter.Entry.Changed += delegate {
				UpdateFromCatalog ();
			};
			
			this.togglebuttonFuzzy.Active = PropertyService.Get ("Gettext.ShowFuzzy", true);
			this.togglebuttonFuzzy.TooltipText = GettextCatalog.GetString ("Show fuzzy translations");
			this.togglebuttonFuzzy.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowFuzzy", this.togglebuttonFuzzy.Active);
				UpdateFromCatalog ();
			};
			
			this.togglebuttonMissing.Active = PropertyService.Get ("Gettext.ShowMissing", true);
			this.togglebuttonMissing.TooltipText = GettextCatalog.GetString ("Show missing translations");
			this.togglebuttonMissing.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowMissing", this.togglebuttonMissing.Active);
				UpdateFromCatalog ();
			};
			
			this.togglebuttonOk.Active = PropertyService.Get ("Gettext.ShowTranslated", true);
			this.togglebuttonOk.TooltipText = GettextCatalog.GetString ("Show valid translations");
			this.togglebuttonOk.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowTranslated", this.togglebuttonOk.Active);
				UpdateFromCatalog ();
			};
			
			this.textviewComments.Buffer.Changed += delegate {
				if (this.isUpdating)
					return;
				if (this.currentEntry != null) {
					string[] lines = StringEscaping.FromGettextFormat (textviewComments.Buffer.Text).Split (new string[] { System.Environment.NewLine }, System.StringSplitOptions.None);
					for (int i = 0; i < lines.Length; i++) {
						if (!lines[i].StartsWith ("#"))
							lines[i] = "# " + lines[i];
					}
					this.currentEntry.Comment = string.Join (System.Environment.NewLine, lines);
				}
				UpdateProgressBar ();
			};
			this.treeviewEntries.PopupMenu += delegate {
				ShowPopup ();
			};
			
			this.treeviewEntries.ButtonReleaseEvent += delegate(object sender, Gtk.ButtonReleaseEventArgs e) {
				if (e.Event.Button == 3)
					ShowPopup ();
			};
			
			searchEntryFilter.Ready = true;
			searchEntryFilter.Visible = true;
			searchEntryFilter.ForceFilterButtonVisible = true;
			searchEntryFilter.RequestMenu += delegate {
				searchEntryFilter.Menu = CreateOptionsMenu ();
			};
		
//			this.buttonOptions.Label = GettextCatalog.GetString ("Options");
			//			this.buttonOptions.StockImage = Gtk.Stock.Properties;
			//			this.buttonOptions.MenuCreator = ;
			widgets.Add (this);
			UpdateTasks ();
			//			this.vpaned2.AcceptPosition += delegate {
			//				PropertyService.Set ("Gettext.SplitPosition", vpaned2.Position / (double)Allocation.Height);
			//				inMove = false;
			//			};
			//			this.vpaned2.CancelPosition += delegate {
			//				inMove = false;
			//			};
			//			this.vpaned2.MoveHandle += delegate {
			//				inMove = true;
			//			};
			//			this.ResizeChecked += delegate {
			//				if (inMove)
			//					return;
			//				int newPosition = (int)(Allocation.Height * PropertyService.Get ("Gettext.SplitPosition", 0.3d));
			//				if (vpaned2.Position != newPosition)
			//					vpaned2.Position = newPosition;
			//			};
			checkbuttonWhiteSpaces.Toggled += CheckbuttonWhiteSpacesToggled;
			options.ShowLineNumberMargin = false;
			options.ShowFoldMargin = false;
			options.ShowIconMargin = false;
			options.ShowInvalidLines = false;
			options.ShowSpaces = options.ShowTabs = options.ShowEolMarkers = false;
			options.ColorScheme = PropertyService.Get ("ColorScheme", "Default");
			options.FontName = PropertyService.Get<string> ("FontName");
			
			this.scrolledwindowOriginal.Child = this.texteditorOriginal;
			this.scrolledwindowPlural.Child = this.texteditorPlural;
			this.texteditorOriginal.Show ();
			this.texteditorPlural.Show ();
			texteditorOriginal.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive));
			texteditorPlural.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive));
			this.texteditorOriginal.Options = options;
			this.texteditorPlural.Options = options;
			this.texteditorOriginal.Document.ReadOnly = true;
			this.texteditorPlural.Document.ReadOnly = true;
		}
Exemplo n.º 14
0
        /// <summary>
        /// Create the UI
        /// </summary>
        private void CreateEdit()
        {
            CmisTreeStore cmisStore = new CmisTreeStore ();
            Gtk.TreeView treeView = new Gtk.TreeView (cmisStore.CmisStore);

            RootFolder root = new RootFolder () {
                Name = this.Name,
                Id = credentials.RepoId,
                Address = credentials.Address.ToString()
            };
            IgnoredFolderLoader.AddIgnoredFolderToRootNode(root, Ignores);
            LocalFolderLoader.AddLocalFolderToRootNode(root, localPath);

            AsyncNodeLoader asyncLoader = new AsyncNodeLoader (root, credentials, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);
            asyncLoader.UpdateNodeEvent += delegate {
                cmisStore.UpdateCmisTree(root);
            };
            cmisStore.UpdateCmisTree (root);
            asyncLoader.Load (root);

            Header = CmisSync.Properties_Resources.EditTitle;

            VBox layout_vertical   = new VBox (false, 12);

            Controller.CloseWindowEvent += delegate
            {
                asyncLoader.Cancel();
            };

            Button cancel_button = new Button (CmisSync.Properties_Resources.Cancel);
            cancel_button.Clicked += delegate {
                Close();
            };

            Button finish_button = new Button (CmisSync.Properties_Resources.SaveChanges);
            finish_button.Clicked += delegate {
                Ignores = NodeModelUtils.GetIgnoredFolder(root);
                Controller.SaveFolder();
                Close();
            };

            Gtk.TreeIter iter;
            treeView.HeadersVisible = false;
            treeView.Selection.Mode = SelectionMode.Single;

            TreeViewColumn column = new TreeViewColumn ();
            column.Title = "Name";
            CellRendererToggle renderToggle = new CellRendererToggle ();
            column.PackStart (renderToggle, false);
            renderToggle.Activatable = true;
            column.AddAttribute (renderToggle, "active", (int)CmisTreeStore.Column.ColumnSelected);
            column.AddAttribute (renderToggle, "inconsistent", (int)CmisTreeStore.Column.ColumnSelectedThreeState);
            column.AddAttribute (renderToggle, "radio", (int)CmisTreeStore.Column.ColumnRoot);
            renderToggle.Toggled += delegate (object render, ToggledArgs args) {
                TreeIter iterToggled;
                if (! cmisStore.CmisStore.GetIterFromString (out iterToggled, args.Path))
                {
                    Console.WriteLine("Toggled GetIter Error " + args.Path);
                    return;
                }

                Node node = cmisStore.CmisStore.GetValue(iterToggled,(int)CmisTreeStore.Column.ColumnNode) as Node;
                if (node == null)
                {
                    Console.WriteLine("Toggled GetValue Error " + args.Path);
                    return;
                }

                if (node.Parent == null)
                {
                    node.Selected = true;
                }
                else
                {
                    if (node.Selected == false)
                    {
                        node.Selected = true;
                    }
                    else
                    {
                        node.Selected = false;
                    }
                }
                cmisStore.UpdateCmisTree(root);
            };
            CellRendererText renderText = new CellRendererText ();
            column.PackStart (renderText, false);
            column.SetAttributes (renderText, "text", (int)CmisTreeStore.Column.ColumnName);
            column.Expand = true;
            treeView.AppendColumn (column);

            treeView.AppendColumn ("Status", new StatusCellRenderer (), "text", (int)CmisTreeStore.Column.ColumnStatus);

            treeView.RowExpanded += delegate (object o, RowExpandedArgs args) {
                Node node = cmisStore.CmisStore.GetValue(args.Iter, (int)CmisTreeStore.Column.ColumnNode) as Node;
                asyncLoader.Load(node);
            };

            ScrolledWindow sw = new ScrolledWindow() {
                ShadowType = Gtk.ShadowType.In
            };
            sw.Add(treeView);

            layout_vertical.PackStart (new Label(""), false, false, 0);
            layout_vertical.PackStart (sw, true, true, 0);
            Add(layout_vertical);
            AddButton(cancel_button);
            AddButton(finish_button);

            finish_button.GrabDefault ();

            this.ShowAll();
        }
Exemplo n.º 15
0
 /// <summary>
 /// Appends the columns.
 /// </summary>
 public void appendColumns()
 {
     try {
         try {
             //Clearing collumns
             for (int i = 0; i < treeview1.Columns.Length; i++)
                 treeview1.RemoveColumn (treeview1.Columns [i]);
         } catch {
         }
         //Add new Columns
         //TODO: i18n
         TreeViewColumn ausdruck = new TreeViewColumn ();
         ausdruck.Title = "Ausdruck";
         TreeViewColumn titel = new TreeViewColumn ();
         titel.Title = "Titel";
         TreeViewColumn description = new TreeViewColumn ();
         description.Title = "Beschreibung";
         treeview1.AppendColumn (ausdruck);
         treeview1.AppendColumn (titel);
         treeview1.AppendColumn (description);
         //treeview1.AppendColumn (new TreeViewColumn () {Title = "Pfad" });
         g_regexList = new ListStore (typeof(string), typeof(string), typeof(string), typeof(string));
         treeview1.Model = g_regexList;
         ausdruck.PackStart (new CellRendererText (), true);
         titel.PackStart (new CellRendererText (), true);
         description.PackStart (new CellRendererText (), true);
         ausdruck.SetAttributes (ausdruck.CellRenderers [0], "text", 0);
         //treeview1.Columns [3].PackStart (new CellRendererText (), true);
         //treeview1.Columns [3].SetAttributes (treeview1.Columns [3].CellRenderers [0], "text", 3);
         titel.SetAttributes (titel.CellRenderers [0], "text", 1);
         description.SetAttributes (description.CellRenderers [0], "text", 2);
     } catch (Exception ex) {
         MessageBox.Show (ex.Message, cTerminus.g_programName, ButtonsType.Close, MessageType.Error);
     }
 }
Exemplo n.º 16
0
        /// <summary>
        /// Construtor
        /// </summary>
        public LegendView(ViewBase owner)
            : base(owner)
        {
            Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.LegendView.glade", "hbox1");
            gxml.Autoconnect(this);
            _mainWidget = hbox1;
            combobox1.Model = comboModel;
            combobox1.PackStart(comboRender, false);
            combobox1.AddAttribute(comboRender, "text", 0);
            combobox1.Changed += OnPositionComboChanged;
            combobox1.Focused += OnTitleTextBoxEnter;

            listview.Model = listModel;
            TreeViewColumn column = new TreeViewColumn();
            column.Title = "Series name";
            column.PackStart(listToggle, false);
            listRender.Editable = false;
            column.PackStart(listRender, true);
            column.SetAttributes(listToggle, "active", 0);
            column.SetAttributes(listRender, "text", 1);
            listview.AppendColumn(column);
            listToggle.Activatable = true;
            listToggle.Toggled += OnItemChecked;
            _mainWidget.Destroyed += _mainWidget_Destroyed;
        }
Exemplo n.º 17
0
		public POEditorWidget (TranslationProject project)
		{
			this.project = project;
			this.Build ();
			
			//FIXME: avoid unnecessary creation of old treeview
			scrolledwindow1.Remove (treeviewEntries);
			treeviewEntries.Destroy ();
			treeviewEntries = new MonoDevelop.Components.ContextMenuTreeView ();
			treeviewEntries.ShowAll ();
			scrolledwindow1.Add (treeviewEntries);
			((MonoDevelop.Components.ContextMenuTreeView)treeviewEntries).DoPopupMenu = ShowPopup;
			
			this.headersEditor = new CatalogHeadersWidget ();
			this.notebookPages.AppendPage (headersEditor, new Gtk.Label ());
			
			updateTaskThread = new BackgroundWorker ();
			updateTaskThread.WorkerSupportsCancellation = true;
			updateTaskThread.DoWork += TaskUpdateWorker;
			
			AddButton (GettextCatalog.GetString ("Translation")).Active = true;
			AddButton (GettextCatalog.GetString ("Headers")).Active = false;
			
			// entries tree view 
			store = new ListStore (typeof(CatalogEntry));
			this.treeviewEntries.Model = store;
			
			TreeViewColumn fuzzyColumn = new TreeViewColumn ();
			fuzzyColumn.SortIndicator = true;
			fuzzyColumn.SortColumnId = 0;
				
			fuzzyColumn.Title = GettextCatalog.GetString ("Fuzzy");
			var iconRenderer = new CellRendererImage ();
			fuzzyColumn.PackStart (iconRenderer, false);
			fuzzyColumn.SetCellDataFunc (iconRenderer, CatalogIconDataFunc);
			
			CellRendererToggle cellRendFuzzy = new CellRendererToggle ();
			cellRendFuzzy.Activatable = true;
			cellRendFuzzy.Toggled += HandleCellRendFuzzyToggled;
			fuzzyColumn.PackStart (cellRendFuzzy, false);
			fuzzyColumn.SetCellDataFunc (cellRendFuzzy, FuzzyToggleDataFunc);
			treeviewEntries.AppendColumn (fuzzyColumn);
			
			TreeViewColumn originalColumn = new TreeViewColumn ();
			originalColumn.Expand = true;
			originalColumn.SortIndicator = true;
			originalColumn.SortColumnId = 1;
			originalColumn.Title = GettextCatalog.GetString ("Original string");
			CellRendererText original = new CellRendererText ();
			original.Ellipsize = Pango.EllipsizeMode.End;
			originalColumn.PackStart (original, true);
			originalColumn.SetCellDataFunc (original, OriginalTextDataFunc);
			treeviewEntries.AppendColumn (originalColumn);
			
			TreeViewColumn translatedColumn = new TreeViewColumn ();
			translatedColumn.Expand = true;
			translatedColumn.SortIndicator = true;
			translatedColumn.SortColumnId = 2;
			translatedColumn.Title = GettextCatalog.GetString ("Translated string");
			CellRendererText translation = new CellRendererText ();
			translation.Ellipsize = Pango.EllipsizeMode.End;
			translatedColumn.PackStart (translation, true);
			translatedColumn.SetCellDataFunc (translation, TranslationTextDataFunc);
			treeviewEntries.AppendColumn (translatedColumn);
			
			treeviewEntries.Selection.Changed += OnEntrySelected;
			
			// found in tree view
			foundInStore = new ListStore (typeof(string), typeof(string), typeof(string), typeof(Xwt.Drawing.Image));
			this.treeviewFoundIn.Model = foundInStore;
			
			TreeViewColumn fileColumn = new TreeViewColumn ();
			var pixbufRenderer = new CellRendererImage ();
			fileColumn.PackStart (pixbufRenderer, false);
			fileColumn.SetAttributes (pixbufRenderer, "image", FoundInColumns.Pixbuf);
			
			CellRendererText textRenderer = new CellRendererText ();
			fileColumn.PackStart (textRenderer, true);
			fileColumn.SetAttributes (textRenderer, "text", FoundInColumns.File);
			treeviewFoundIn.AppendColumn (fileColumn);
			
			treeviewFoundIn.AppendColumn ("", new CellRendererText (), "text", FoundInColumns.Line);
			treeviewFoundIn.HeadersVisible = false;
			treeviewFoundIn.GetColumn (1).FixedWidth = 100;
			
			treeviewFoundIn.RowActivated += delegate(object sender, RowActivatedArgs e) {
				Gtk.TreeIter iter;
				foundInStore.GetIter (out iter, e.Path);
				string line = foundInStore.GetValue (iter, (int)FoundInColumns.Line) as string;
				string file = foundInStore.GetValue (iter, (int)FoundInColumns.FullFileName) as string;
				int lineNr = 1;
				try {
					lineNr = 1 + int.Parse (line);
				} catch {
				}
				IdeApp.Workbench.OpenDocument (file, lineNr, 1);
			};
			this.notebookTranslated.RemovePage (0);
			this.searchEntryFilter.Entry.Text = "";
			searchEntryFilter.Entry.Changed += delegate {
				UpdateFromCatalog ();
			};
			
			this.togglebuttonFuzzy.Active = PropertyService.Get ("Gettext.ShowFuzzy", true);
			this.togglebuttonFuzzy.TooltipText = GettextCatalog.GetString ("Show fuzzy translations");
			this.togglebuttonFuzzy.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowFuzzy", this.togglebuttonFuzzy.Active);
				UpdateFromCatalog ();
			};
			
			this.togglebuttonMissing.Active = PropertyService.Get ("Gettext.ShowMissing", true);
			this.togglebuttonMissing.TooltipText = GettextCatalog.GetString ("Show missing translations");
			this.togglebuttonMissing.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowMissing", this.togglebuttonMissing.Active);
				UpdateFromCatalog ();
			};
			
			this.togglebuttonOk.Active = PropertyService.Get ("Gettext.ShowTranslated", true);
			this.togglebuttonOk.TooltipText = GettextCatalog.GetString ("Show valid translations");
			this.togglebuttonOk.Toggled += delegate {
				MonoDevelop.Core.PropertyService.Set ("Gettext.ShowTranslated", this.togglebuttonOk.Active);
				UpdateFromCatalog ();
			};
			
			this.textviewComments.Buffer.Changed += delegate {
				if (this.isUpdating)
					return;
				if (this.currentEntry != null) {
					string[] lines =  textviewComments.Buffer.Text.Split (CatalogParser.LineSplitStrings, System.StringSplitOptions.None);
					for (int i = 0; i < lines.Length; i++) {
						if (!lines[i].StartsWith ("#"))
							lines[i] = "# " + lines[i];
					}
					this.currentEntry.Comment = string.Join (System.Environment.NewLine, lines);
				}
				UpdateProgressBar ();
			};
			
			searchEntryFilter.Ready = true;
			searchEntryFilter.Visible = true;
			searchEntryFilter.ForceFilterButtonVisible = true;
			searchEntryFilter.RequestMenu += delegate {
				searchEntryFilter.Menu = CreateOptionsMenu ();
			};
			
			widgets.Add (this);
			
			checkbuttonWhiteSpaces.Toggled += CheckbuttonWhiteSpacesToggled;
			options.ShowLineNumberMargin = false;
			options.ShowFoldMargin = false;
			options.ShowIconMargin = false;
			options.ColorScheme = IdeApp.Preferences.ColorScheme;
			options.FontName = PropertyService.Get<string> ("FontName");
			
			this.scrolledwindowOriginal.Child = this.texteditorOriginal;
			this.scrolledwindowPlural.Child = this.texteditorPlural;
			this.texteditorOriginal.Show ();
			this.texteditorPlural.Show ();
			texteditorOriginal.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive));
			texteditorPlural.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Insensitive));
			this.texteditorOriginal.Options = options;
			this.texteditorPlural.Options = options;
			this.texteditorOriginal.Document.ReadOnly = true;
			this.texteditorPlural.Document.ReadOnly = true;
		}
Exemplo n.º 18
0
        private void BuildColumns()
        {
            priorityColumn = new TreeViewColumn ();
            filenameColumn = new TreeViewColumn ();
            progressColumn = new TreeViewColumn ();

            filenameColumn.Resizable = true;

            priorityColumn.Title = "";
            filenameColumn.Title = _("Filename");
            progressColumn.Title = _("Progress");

            Gtk.CellRendererPixbuf priorityCell = new CellRendererPixbuf ();
            Gtk.CellRendererText filenameCell = new CellRendererText ();
            Gtk.CellRendererProgress progressCell = new CellRendererProgress ();

            priorityColumn.PackStart (priorityCell, true);
            priorityColumn.SetAttributes (priorityCell, "pixbuf", 2);
            filenameColumn.PackStart (filenameCell, true);
            filenameColumn.SetAttributes (filenameCell, "text", 3);
            progressColumn.PackStart(progressCell, true);
            progressColumn.SetCellDataFunc (progressCell, new Gtk.TreeCellDataFunc (RenderProgress));

            AppendColumn (priorityColumn);
            AppendColumn (filenameColumn);
            AppendColumn (progressColumn);
        }
Exemplo n.º 19
0
        /// <summary>Default constructor for ExplorerView</summary>
        public ExplorerView(ViewBase owner)
            : base(owner)
        {
            Glade.XML gxml = new Glade.XML("ApsimNG.Resources.Glade.ExplorerView.glade", "vpaned1");
            gxml.Autoconnect(this);
            _mainWidget = vpaned1;

            progressbar1.Visible = false;
            statusWindow.HeightRequest = 20;
            treeview1.Model = treemodel;
            TreeViewColumn column = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();
            column.PackStart(iconRender, false);
            textRender = new Gtk.CellRendererText();
            textRender.Editable = true;
            textRender.EditingStarted += OnBeforeLabelEdit;
            textRender.Edited += OnAfterLabelEdit;
            column.PackStart(textRender, true);
            column.SetAttributes(iconRender, "pixbuf", 1);
            column.SetAttributes(textRender, "text", 0);
            //            column.SetCellDataFunc(textRender, treecelldatafunc);
            treeview1.AppendColumn(column);

            treeview1.CursorChanged += OnAfterSelect;
            treeview1.ButtonReleaseEvent += OnButtonUp;

            TargetEntry[] target_table = new TargetEntry[] {
               new TargetEntry ("application/x-model-component", TargetFlags.App, 0)
            };

            Gdk.DragAction actions = Gdk.DragAction.Copy | Gdk.DragAction.Link | Gdk.DragAction.Move;
            //treeview1.EnableModelDragDest(target_table, actions);
            //treeview1.EnableModelDragSource(Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.SourceSet(treeview1, Gdk.ModifierType.Button1Mask, target_table, actions);
            Drag.DestSet(treeview1, 0, target_table, actions);
            treeview1.DragMotion += OnDragOver;
            treeview1.DragDrop += OnDragDrop;
            treeview1.DragBegin += OnDragBegin;
            treeview1.DragDataGet += OnDragDataGet;
            treeview1.DragDataReceived += OnDragDataReceived;
            treeview1.DragEnd += OnDragEnd;
            treeview1.DragDataDelete += OnDragDataDelete;

            TextTag tag = new TextTag("error");
            tag.Foreground = "red";
            statusWindow.Buffer.TagTable.Add(tag);
            tag = new TextTag("warning");
            tag.Foreground = "brown";
            statusWindow.Buffer.TagTable.Add(tag);
            tag = new TextTag("normal");
            tag.Foreground = "blue";
            statusWindow.ModifyBase(StateType.Normal, new Gdk.Color(0xff, 0xff, 0xf0));
            _mainWidget.Destroyed += _mainWidget_Destroyed;
        }
Exemplo n.º 20
0
        private void ShowAdd2Page()
        {
            CmisTreeStore cmisStore = new CmisTreeStore ();
            Gtk.TreeView treeView = new Gtk.TreeView (cmisStore.CmisStore);

            bool firstRepo = true;
            List<RootFolder> repositories = new List<RootFolder>();
            Dictionary<string,AsyncNodeLoader> loader = new Dictionary<string, AsyncNodeLoader> ();
            foreach (KeyValuePair<String, String> repository in Controller.repositories)
            {
                RootFolder root = new RootFolder () {
                    Name = repository.Value,
                    Id = repository.Key,
                    Address = Controller.saved_address.ToString()
                };
                if (firstRepo)
                {
                    root.Selected = true;
                    firstRepo = false;
                }
                else
                {
                    root.Selected = false;
                }
                repositories.Add (root);
                CmisRepoCredentials cred = new CmisRepoCredentials () {
                    UserName = Controller.saved_user,
                    Password = Controller.saved_password,
                    Address = Controller.saved_address,
                    RepoId = repository.Key
                };
                AsyncNodeLoader asyncLoader = new AsyncNodeLoader (root, cred, PredefinedNodeLoader.LoadSubFolderDelegate, PredefinedNodeLoader.CheckSubFolderDelegate);
                asyncLoader.UpdateNodeEvent += delegate {
                    cmisStore.UpdateCmisTree(root);
                };
                cmisStore.UpdateCmisTree (root);
                asyncLoader.Load (root);
                loader.Add (root.Id, asyncLoader);
            }

            Header = CmisSync.Properties_Resources.Which;

            VBox layout_vertical   = new VBox (false, 12);

            Button cancel_button = new Button (cancelText);
            cancel_button.Clicked += delegate {
                foreach (AsyncNodeLoader task in loader.Values)
                    task.Cancel();
                Controller.PageCancelled ();
            };

            Button continue_button = new Button (continueText)
            {
                Sensitive = (repositories.Count > 0)
            };

            continue_button.Clicked += delegate {
                RootFolder root = repositories.Find (x => (x.Selected != false));
                if (root != null)
                {
                    foreach (AsyncNodeLoader task in loader.Values)
                        task.Cancel();
                    Controller.saved_repository = root.Id;
                    List<string> ignored = NodeModelUtils.GetIgnoredFolder(root);
                    List<string> selected = NodeModelUtils.GetSelectedFolder(root);
                    Controller.Add2PageCompleted (root.Id, root.Path, ignored.ToArray(), selected.ToArray());
                }
            };

            Button back_button = new Button (backText)
            {
                Sensitive = true
            };

            back_button.Clicked += delegate {
                foreach (AsyncNodeLoader task in loader.Values)
                    task.Cancel();
                Controller.BackToPage1();
            };

            Gtk.TreeIter iter;
            treeView.HeadersVisible = false;
            treeView.Selection.Mode = SelectionMode.Single;

            TreeViewColumn column = new TreeViewColumn ();
            column.Title = "Name";
            CellRendererToggle renderToggle = new CellRendererToggle ();
            column.PackStart (renderToggle, false);
            renderToggle.Activatable = true;
            column.AddAttribute (renderToggle, "active", (int)CmisTreeStore.Column.ColumnSelected);
            column.AddAttribute (renderToggle, "inconsistent", (int)CmisTreeStore.Column.ColumnSelectedThreeState);
            column.AddAttribute (renderToggle, "radio", (int)CmisTreeStore.Column.ColumnRoot);
            renderToggle.Toggled += delegate (object render, ToggledArgs args) {
                TreeIter iterToggled;
                if (! cmisStore.CmisStore.GetIterFromString (out iterToggled, args.Path))
                {
                    Console.WriteLine("Toggled GetIter Error " + args.Path);
                    return;
                }

                Node node = cmisStore.CmisStore.GetValue(iterToggled,(int)CmisTreeStore.Column.ColumnNode) as Node;
                if (node == null)
                {
                    Console.WriteLine("Toggled GetValue Error " + args.Path);
                    return;
                }

                RootFolder selectedRoot = repositories.Find (x => (x.Selected != false));
                Node parent = node;
                while (parent.Parent != null)
                {
                    parent = parent.Parent;
                }
                RootFolder root = parent as RootFolder;
                if (root != selectedRoot)
                {
                    selectedRoot.Selected = false;
                    cmisStore.UpdateCmisTree(selectedRoot);
                }

                if (node.Parent == null)
                {
                    node.Selected = true;
                }
                else
                {
                    if (node.Selected == false)
                    {
                        node.Selected = true;
                    }
                    else
                    {
                        node.Selected = false;
                    }
                }
                cmisStore.UpdateCmisTree(root);
            };
            CellRendererText renderText = new CellRendererText ();
            column.PackStart (renderText, false);
            column.SetAttributes (renderText, "text", (int)CmisTreeStore.Column.ColumnName);
            column.Expand = true;
            treeView.AppendColumn (column);

            treeView.AppendColumn ("Status", new StatusCellRenderer (), "text", (int)CmisTreeStore.Column.ColumnStatus);

            treeView.RowExpanded += delegate (object o, RowExpandedArgs args) {
                Node node = cmisStore.CmisStore.GetValue(args.Iter, (int)CmisTreeStore.Column.ColumnNode) as Node;
                Node parent = node;
                while (parent.Parent != null)
                {
                    parent = parent.Parent;
                }
                RootFolder root = parent as RootFolder;
                loader[root.Id].Load(node);
            };

            ScrolledWindow sw = new ScrolledWindow() {
                ShadowType = Gtk.ShadowType.In
            };
            sw.Add(treeView);

            layout_vertical.PackStart (new Label(""), false, false, 0);
            layout_vertical.PackStart (sw, true, true, 0);
            Add(layout_vertical);
            AddButton(back_button);
            AddButton(cancel_button);
            AddButton(continue_button);

            if (repositories.Count > 0)
            {
                continue_button.GrabDefault ();
                continue_button.GrabFocus ();
            }
            else
            {
                back_button.GrabDefault ();
                back_button.GrabFocus ();
            }
        }
		public CSharpFormattingProfileDialog (CSharpFormattingPolicy profile)
		{
			this.Build ();
			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 = treeviewBracePositions;
					break;
				case 2: // Blank lines
					UpdateExample (blankLineExample);
					return;
				case 3: // white spaces
					treeView = treeviewInsertWhiteSpaceCategory;
					return;
				case 4:
					treeView = treeviewNewLines;
					break;
				default:
					return;
				}
				
				var model = treeView.Model;
				Gtk.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 ("Braces"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("Blank lines"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("White Space"));
			comboboxCategories.AppendText (GettextCatalog.GetString ("New Lines"));
			comboboxCategories.Changed += delegate(object sender, EventArgs e) {
				texteditor.Text = "";
				notebookCategories.Page = comboboxCategories.Active;
			};
			comboboxCategories.Active = 0;
			
			var options = MonoDevelop.SourceEditor.DefaultSourceEditorOptions.Instance;
			texteditor.Options.FontName = options.FontName;
			texteditor.Options.ColorScheme = options.ColorScheme;
			texteditor.Options.ShowFoldMargin = false;
			texteditor.Options.ShowIconMargin = false;
			texteditor.Options.ShowLineNumberMargin = false;
			texteditor.Options.ShowInvalidLines = false;
			texteditor.Document.ReadOnly = true;
			texteditor.Document.MimeType = CSharpFormatter.MimeType;
			scrolledwindow.Child = texteditor;
			ShowAll ();
			
			#region Indent options
			indentOptions = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof(bool), typeof(bool));
			
			TreeViewColumn column = new TreeViewColumn ();
			// pixbuf column
			var pixbufCellRenderer = new CellRendererPixbuf ();
			column.PackStart (pixbufCellRenderer, false);
			column.SetCellDataFunc (pixbufCellRenderer, RenderIcon);
			
			// text column
			CellRendererText cellRendererText = new CellRendererText ();
			cellRendererText.Ypad = 1;
			column.PackStart (cellRendererText, true);
			column.SetAttributes (cellRendererText, "text", 1);
			 
			treeviewIndentOptions.Model = indentOptions;
			treeviewIndentOptions.HeadersVisible = false;
			treeviewIndentOptions.Selection.Changed += TreeSelectionChanged;
			treeviewIndentOptions.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 = !profile.IsBuiltIn;

			cellRendererCombo.Edited +=  new ComboboxEditedHandler (this, indentOptions).ComboboxEdited;
			
			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", comboVisibleColumn);
			column.SetCellDataFunc (cellRendererCombo, ComboboxDataFunc);
			
			CellRendererToggle cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Toggled += new CellRendererToggledHandler (this, treeviewIndentOptions, indentOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
			
			treeviewIndentOptions.AppendColumn (column);
			var category = AddOption (indentOptions, null, GettextCatalog.GetString ("Declarations"), null);
			AddOption (indentOptions, category, "IndentNamespaceBody", GettextCatalog.GetString ("within namespaces"), "namespace Test { class AClass {} }");
			
			AddOption (indentOptions, category, "IndentClassBody", GettextCatalog.GetString ("within classes"), "class AClass { int aField; void AMethod () {}}");
			AddOption (indentOptions, category, "IndentInterfaceBody", GettextCatalog.GetString ("within interfaces"), "interface IAInterfaces { int AProperty {get;set;} void AMethod ();}");
			AddOption (indentOptions, category, "IndentStructBody", GettextCatalog.GetString ("within structs"), "struct AStruct { int aField; void AMethod () {}}");
			AddOption (indentOptions, category, "IndentEnumBody", GettextCatalog.GetString ("within enums"), "enum AEnum { A, B, C }");
			
			AddOption (indentOptions, category, "IndentMethodBody", GettextCatalog.GetString ("within methods"), methodSpaceExample);
			AddOption (indentOptions, category, "IndentPropertyBody", GettextCatalog.GetString ("within properties"), propertyExample);
			AddOption (indentOptions, category, "IndentEventBody", GettextCatalog.GetString ("within events"), eventExample);
			
			category = AddOption (indentOptions, null, GettextCatalog.GetString ("Statements"), null);
			AddOption (indentOptions, category, "IndentBlocks", GettextCatalog.GetString ("within blocks"), spaceExample);
			AddOption (indentOptions, category, "IndentSwitchBody", GettextCatalog.GetString ("Indent 'switch' body"), spaceExample);
			AddOption (indentOptions, category, "IndentCaseBody", GettextCatalog.GetString ("Indent 'case' body"), spaceExample);
			AddOption (indentOptions, category, "IndentBreakStatements", GettextCatalog.GetString ("Indent 'break' statements"), spaceExample);
			
			AddOption (indentOptions, category, "AlignEmbeddedIfStatements", GettextCatalog.GetString ("Align embedded 'if' statements"), "class AClass { void AMethod () { if (a) if (b) { int c; } } } ");
			AddOption (indentOptions, category, "AlignEmbeddedUsingStatements", GettextCatalog.GetString ("Align embedded 'using' statements"), "class AClass { void AMethod () {using (IDisposable a = null) using (IDisposable b = null) { int c; } } }");
			treeviewIndentOptions.ExpandAll ();
			#endregion
			
			#region Brace options
			bacePositionOptions = new Gtk.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);
			
			treeviewBracePositions.Model = bacePositionOptions;
			treeviewBracePositions.HeadersVisible = false;
			treeviewBracePositions.Selection.Changed += TreeSelectionChanged;
			treeviewBracePositions.AppendColumn (column);
			
			column = new TreeViewColumn ();
			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, bacePositionOptions).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, treeviewBracePositions, bacePositionOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
			
			treeviewBracePositions.AppendColumn (column);
			
			AddOption (bacePositionOptions, "NamespaceBraceStyle", GettextCatalog.GetString ("Namespace declaration"), "namespace TestNameSpace {}");
			
			AddOption (bacePositionOptions, "ClassBraceStyle", GettextCatalog.GetString ("Class declaration"), "class ClassDeclaration {}");
			AddOption (bacePositionOptions, "InterfaceBraceStyle", GettextCatalog.GetString ("Interface declaration"), "interface InterfaceDeclaraction {}");
			AddOption (bacePositionOptions, "StructBraceStyle", GettextCatalog.GetString ("Struct declaration"), "struct StructDeclaration {}");
			AddOption (bacePositionOptions, "EnumBraceStyle", GettextCatalog.GetString ("Enum declaration"), "enum EnumDeclaration { A, B, C}");
			
			AddOption (bacePositionOptions, "MethodBraceStyle", GettextCatalog.GetString ("Method declaration"), "class ClassDeclaration { void MyMethod () {} }");
			AddOption (bacePositionOptions, "AnonymousMethodBraceStyle", GettextCatalog.GetString ("Anonymous methods"), "class ClassDeclaration { void MyMethod () { MyEvent += delegate (object sender, EventArgs e) { if (true) Console.WriteLine (\"Hello World\"); }; } }");
			AddOption (bacePositionOptions, "ConstructorBraceStyle", GettextCatalog.GetString ("Constructor declaration"), "class ClassDeclaration { public ClassDeclaration () {} }");
			AddOption (bacePositionOptions, "DestructorBraceStyle", GettextCatalog.GetString ("Destructor declaration"), "class ClassDeclaration { ~ClassDeclaration () {} }");
			
			AddOption (bacePositionOptions, "StatementBraceStyle", GettextCatalog.GetString ("Statements"), spaceExample);
			
			category = AddOption (bacePositionOptions, "PropertyBraceStyle", GettextCatalog.GetString ("Property declaration"), propertyExample);
			AddOption (bacePositionOptions, category, "PropertyGetBraceStyle", GettextCatalog.GetString ("Get declaration"), propertyExample);
			AddOption (bacePositionOptions, category, "AllowPropertyGetBlockInline", GettextCatalog.GetString ("Allow one line get"), propertyExample);
			AddOption (bacePositionOptions, category, "PropertySetBraceStyle", GettextCatalog.GetString ("Set declaration"), propertyExample);
			AddOption (bacePositionOptions, category, "AllowPropertySetBlockInline", GettextCatalog.GetString ("Allow one line set"), propertyExample);
			
			
			category = AddOption (bacePositionOptions, "EventBraceStyle", GettextCatalog.GetString ("Event declaration"), eventExample);
			AddOption (bacePositionOptions, category, "EventAddBraceStyle", GettextCatalog.GetString ("Add declaration"), eventExample);
			AddOption (bacePositionOptions, category, "AllowEventAddBlockInline", GettextCatalog.GetString ("Allow one line add"), eventExample);
			AddOption (bacePositionOptions, category, "EventRemoveBraceStyle", GettextCatalog.GetString ("Remove declaration"), eventExample);
			AddOption (bacePositionOptions, category, "AllowEventRemoveBlockInline", GettextCatalog.GetString ("Allow one line remove"), eventExample);
			
			category = AddOption (bacePositionOptions, null, GettextCatalog.GetString ("Brace forcement"), null);
			AddOption (bacePositionOptions, category, "IfElseBraceForcement", GettextCatalog.GetString ("'if...else' statement"), @"class ClassDeclaration { 
	public void Test ()
		{
			if (true) {
				Console.WriteLine (""Hello World!"");
			}
			if (true)
				Console.WriteLine (""Hello World!"");
		}
	}");
			AddOption (bacePositionOptions, category, "ForBraceForcement", GettextCatalog.GetString ("'for' statement"), @"class ClassDeclaration { 
		public void Test ()
		{
			for (int i = 0; i < 10; i++) {
				Console.WriteLine (""Hello World "" + i);
			}
			for (int i = 0; i < 10; i++)
				Console.WriteLine (""Hello World "" + i);
		}
	}");
			AddOption (bacePositionOptions, category, "WhileBraceForcement", GettextCatalog.GetString ("'while' statement"), @"class ClassDeclaration { 
		public void Test ()
		{
			int i = 0;
			while (i++ < 10) {
				Console.WriteLine (""Hello World "" + i);
			}
			while (i++ < 20)
				Console.WriteLine (""Hello World "" + i);
		}
	}");
			AddOption (bacePositionOptions, category, "UsingBraceForcement", GettextCatalog.GetString ("'using' statement"), simpleUsingStatement);
			AddOption (bacePositionOptions, category, "FixedBraceForcement", GettextCatalog.GetString ("'fixed' statement"), simpleFixedStatement);
			treeviewBracePositions.ExpandAll ();
			#endregion
			
			#region New line options
			newLineOptions = new Gtk.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);
			
			treeviewNewLines.Model = newLineOptions;
			treeviewNewLines.HeadersVisible = false;
			treeviewNewLines.Selection.Changed += TreeSelectionChanged;
			treeviewNewLines.AppendColumn (column);
			
			column = new TreeViewColumn ();
			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);
			
			AddOption (newLineOptions, "PlaceElseOnNewLine", GettextCatalog.GetString ("Place 'else' on new line"), simpleIf);
			AddOption (newLineOptions, "PlaceElseIfOnNewLine", GettextCatalog.GetString ("Place 'else if' on new line"), simpleIf);
			AddOption (newLineOptions, "PlaceCatchOnNewLine", GettextCatalog.GetString ("Place 'catch' on new line"), simpleCatch);
			AddOption (newLineOptions, "PlaceFinallyOnNewLine", GettextCatalog.GetString ("Place 'finally' on new line"), simpleCatch);
			AddOption (newLineOptions, "PlaceWhileOnNewLine", GettextCatalog.GetString ("Place 'while' on new line"), simpleDoWhile);
			AddOption (newLineOptions, "PlaceArrayInitializersOnNewLine", GettextCatalog.GetString ("Place array initializers on new line"), simpleArrayInitializer);
			treeviewNewLines.ExpandAll ();
			#endregion
			
			#region White space options
			whiteSpaceOptions = new Gtk.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);
			
			treeviewInsertWhiteSpaceCategory.Model = whiteSpaceOptions;
			treeviewInsertWhiteSpaceCategory.HeadersVisible = false;
			treeviewInsertWhiteSpaceCategory.Selection.Changed += TreeSelectionChanged;
			treeviewInsertWhiteSpaceCategory.AppendColumn (column);
			
			column = new TreeViewColumn ();
			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, whiteSpaceOptions).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, treeviewInsertWhiteSpaceCategory, whiteSpaceOptions).Toggled;
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", toggleVisibleColumn);
			column.SetCellDataFunc (cellRendererToggle, ToggleDataFunc);
			
			treeviewInsertWhiteSpaceCategory.AppendColumn (column);
			
			string example = @"class Example {
		void Test ()
		{
		}
		
		void Test (int a, int b, int c)
		{
		}
}";
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Declarations"), example);
			AddOption (whiteSpaceOptions, category, "BeforeMethodDeclarationParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinMethodDeclarationParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyMethodDeclarationParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeMethodDeclarationParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterMethodDeclarationParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			example = @"class Example {
		int a, b, c;
}";
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Fields"), example);
			AddOption (whiteSpaceOptions, category, "BeforeFieldDeclarationComma", GettextCatalog.GetString ("before comma in multiple field declarations"), example);
			AddOption (whiteSpaceOptions, category, "AfterFieldDeclarationComma", GettextCatalog.GetString ("after comma in multiple field declarations"), example);
			
			example = @"class Example {
	Example () 
	{
	}

	Example (int a, int b, int c) 
	{
	}
}";
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Constructors"), example);
			AddOption (whiteSpaceOptions, category, "BeforeConstructorDeclarationParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinConstructorDeclarationParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyConstructorDeclarationParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeConstructorDeclarationParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterConstructorDeclarationParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			example = @"class Example {
	public int this[int a, int b] {
		get {
			return a + b;
		}
	}
}";
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Indexer"), example);
			AddOption (whiteSpaceOptions, category, "BeforeIndexerDeclarationBracket", GettextCatalog.GetString ("before opening bracket"), example);
			AddOption (whiteSpaceOptions, category, "WithinIndexerDeclarationBracket", GettextCatalog.GetString ("within brackets"), example);
			AddOption (whiteSpaceOptions, category, "BeforeIndexerDeclarationParameterComma", GettextCatalog.GetString ("before comma in brackets"), example);
			AddOption (whiteSpaceOptions, category, "AfterIndexerDeclarationParameterComma", GettextCatalog.GetString ("after comma in brackets"), example);
			
			example = @"delegate void FooBar (int a, int b, int c);
delegate void BarFoo ();
";
			
			category = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Delegates"), example);
			AddOption (whiteSpaceOptions, category, "BeforeDelegateDeclarationParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinDelegateDeclarationParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyDelegateDeclarationParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeDelegateDeclarationParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterDelegateDeclarationParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			var upperCategory = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Statements"), null);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'if'"), simpleIf);
			AddOption (whiteSpaceOptions, category, "IfParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleIf);
			AddOption (whiteSpaceOptions, category, "WithinIfParentheses", GettextCatalog.GetString ("within parenthesis"), simpleIf);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'while'"), simpleWhile);
			AddOption (whiteSpaceOptions, category, "WhileParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleWhile);
			AddOption (whiteSpaceOptions, category, "WithinWhileParentheses", GettextCatalog.GetString ("within parenthesis"), simpleWhile);

			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'for'"), simpleFor);
			AddOption (whiteSpaceOptions, category, "ForParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleFor);
			AddOption (whiteSpaceOptions, category, "WithinForParentheses", GettextCatalog.GetString ("within parenthesis"), simpleFor);
			AddOption (whiteSpaceOptions, category, "SpacesBeforeForSemicolon", GettextCatalog.GetString ("before semicolon"), simpleFor);
			AddOption (whiteSpaceOptions, category, "SpacesAfterForSemicolon", GettextCatalog.GetString ("after semicolon"), simpleFor);

			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'foreach'"), simpleForeach);
			AddOption (whiteSpaceOptions, category, "ForeachParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleForeach);
			AddOption (whiteSpaceOptions, category, "WithinForEachParentheses", GettextCatalog.GetString ("within parenthesis"), simpleForeach);

			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'catch'"), simpleCatch);
			AddOption (whiteSpaceOptions, category, "CatchParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleCatch);
			AddOption (whiteSpaceOptions, category, "WithinCatchParentheses", GettextCatalog.GetString ("within parenthesis"), simpleCatch);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'switch'"), switchExample);
			AddOption (whiteSpaceOptions, category, "SwitchParentheses", GettextCatalog.GetString ("before opening parenthesis"), switchExample);
			AddOption (whiteSpaceOptions, category, "WithinSwitchParentheses", GettextCatalog.GetString ("within parenthesis"), switchExample);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'lock'"), simpleLock);
			AddOption (whiteSpaceOptions, category, "LockParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleLock);
			AddOption (whiteSpaceOptions, category, "WithinLockParentheses", GettextCatalog.GetString ("within parenthesis"), simpleLock);

			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'using'"), simpleUsingStatement);
			AddOption (whiteSpaceOptions, category, "UsingParentheses", GettextCatalog.GetString ("before opening parenthesis"), simpleUsingStatement);
			AddOption (whiteSpaceOptions, category, "WithinUsingParentheses", GettextCatalog.GetString ("within parenthesis"), simpleUsingStatement);
			
			
			upperCategory = AddOption (whiteSpaceOptions, null, GettextCatalog.GetString ("Expressions"), null);
			
			example = @"class Example {
		void Test ()
		{
			Console.WriteLine();
			Console.WriteLine(""{0} {1}!"", ""Hello"", ""World"");
		}
}";
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Method invocations"), example);
			AddOption (whiteSpaceOptions, category, "BeforeMethodCallParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinMethodCallParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyMethodCallParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeMethodCallParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterMethodCallParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Object creation"), example);
			example = @"partial class Example {
		void Test ()
		{
			var anExample = new Example (1, 2, 3);
			var emptyExample = new Example ();
		}
}";
			AddOption (whiteSpaceOptions, category, "NewParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinNewParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BetweenEmptyNewParentheses", GettextCatalog.GetString ("between empty parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "BeforeNewParameterComma", GettextCatalog.GetString ("before comma in parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "AfterNewParameterComma", GettextCatalog.GetString ("after comma in parenthesis"), example);
			
			
			example = @"class Example {
		void Test ()
		{
			a[1,2] = b[3];
		}
}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Element access"), example);
			AddOption (whiteSpaceOptions, category, "SpacesBeforeBrackets", GettextCatalog.GetString ("before opening bracket"), example);
			AddOption (whiteSpaceOptions, category, "SpacesWithinBrackets", GettextCatalog.GetString ("within brackets"), example);
			AddOption (whiteSpaceOptions, category, "BeforeBracketComma", GettextCatalog.GetString ("before comma in brackets"), example);
			AddOption (whiteSpaceOptions, category, "AfterBracketComma", GettextCatalog.GetString ("after comma in brackets"), example);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Parentheses"), operatorExample);
			AddOption (whiteSpaceOptions, category, "WithinParentheses", GettextCatalog.GetString ("within parenthesis"), operatorExample);
			
			example = @"class ClassDeclaration { 
		public void Test (object o)
		{
			int i = (int)o;
		}
	}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Type cast"), example);
			AddOption (whiteSpaceOptions, category, "WithinCastParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "SpacesAfterTypecast", GettextCatalog.GetString ("after type cast"), example);
			
			example = @"class ClassDeclaration { 
		public void Test ()
		{
			int i = sizeof (ClassDeclaration);
		}
	}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'sizeof'"), example);
			AddOption (whiteSpaceOptions, category, "BeforeSizeOfParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinSizeOfParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			
			example = @"class ClassDeclaration { 
		public void Test ()
		{
			Type t = typeof (ClassDeclaration);
		}
	}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("'typeof'"), example);
			AddOption (whiteSpaceOptions, category, "BeforeTypeOfParentheses", GettextCatalog.GetString ("before opening parenthesis"), example);
			AddOption (whiteSpaceOptions, category, "WithinTypeOfParentheses", GettextCatalog.GetString ("within parenthesis"), example);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Around Operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundAssignmentParentheses", GettextCatalog.GetString ("Assignment (=, +=, -=, ...)"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundLogicalOperatorParentheses", GettextCatalog.GetString ("Logical (&&, ||) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundEqualityOperatorParentheses", GettextCatalog.GetString ("Equality (==, !=) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundRelationalOperatorParentheses", GettextCatalog.GetString ("Relational (<, >, <=, >=) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundBitwiseOperatorParentheses", GettextCatalog.GetString ("Bitwise &, |, ^, ~() operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundAdditiveOperatorParentheses", GettextCatalog.GetString ("Additive (+, -) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundMultiplicativeOperatorParentheses", GettextCatalog.GetString ("Multiplicative (*, /, %) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundShiftOperatorParentheses", GettextCatalog.GetString ("Shift (<<, >>) operators"), operatorExample);
			AddOption (whiteSpaceOptions, category, "AroundNullCoalescingOperator", GettextCatalog.GetString ("Null coalescing (??) operator"), operatorExample);
			
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Conditional Operator (?:)"), condOpExample);
			AddOption (whiteSpaceOptions, category, "ConditionalOperatorBeforeConditionSpace", GettextCatalog.GetString ("before '?'"), condOpExample);
			AddOption (whiteSpaceOptions, category, "ConditionalOperatorAfterConditionSpace", GettextCatalog.GetString ("after '?'"), condOpExample);
			AddOption (whiteSpaceOptions, category, "ConditionalOperatorBeforeSeparatorSpace", GettextCatalog.GetString ("before ':'"), condOpExample);
			AddOption (whiteSpaceOptions, category, "ConditionalOperatorAfterSeparatorSpace", GettextCatalog.GetString ("after ':'"), condOpExample);
			
			example = @"class ClassDeclaration { 
		string[][] field;
		int[] test;
	}";
			category = AddOption (whiteSpaceOptions, upperCategory, null, GettextCatalog.GetString ("Array Declarations"), example);
			AddOption (whiteSpaceOptions, category, "SpacesBeforeArrayDeclarationBrackets", GettextCatalog.GetString ("before opening bracket"), example);
			/*
			whiteSpaceOptions= new ListStore (typeof (Option), typeof (bool), typeof (bool)); 
			column = new TreeViewColumn ();
			// text column
			column.PackStart (cellRendererText, true);
			column.SetCellDataFunc (cellRendererText, delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
				((CellRendererText)cell).Text = ((Option)model.GetValue (iter, 0)).DisplayName;
			});
			treeviewInsertWhiteSpaceOptions.AppendColumn (column);
			
			column = new TreeViewColumn ();
			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 += delegate(object o, EditedArgs args) {
				TreeIter iter;
				var model = whiteSpaceOptions;
				if (model.GetIterFromString (out iter, args.Path)) {
					var option = (Option)model.GetValue (iter, 0);
					PropertyInfo info = GetPropertyByName (option.PropertyName);
					if (info == null)
						return;
					var value = Enum.Parse (info.PropertyType, args.NewText);
					info.SetValue (profile, value, null);
					UpdateExample (texteditor.Document.Text);
				}
			};
			
			column.PackStart (cellRendererCombo, false);
			column.SetAttributes (cellRendererCombo, "visible", 2);
			column.SetCellDataFunc (cellRendererCombo,  delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
				((CellRendererCombo)cell).Text = GetValue (((Option)model.GetValue (iter, 0)).PropertyName).ToString ();
			});
			
			cellRendererToggle = new CellRendererToggle ();
			cellRendererToggle.Activatable = !profile.IsBuiltIn;
			cellRendererToggle.Ypad = 1;
			cellRendererToggle.Toggled += delegate(object o, ToggledArgs args) {
				TreeIter iter;
				var model = whiteSpaceOptions;
				if (model.GetIterFromString (out iter, args.Path)) {
					var option = (Option)model.GetValue (iter, 0);
					PropertyInfo info = GetPropertyByName (option.PropertyName);
					if (info == null || info.PropertyType != typeof(bool))
						return;
					bool value = (bool)info.GetValue (this.profile, null);
					info.SetValue (profile, !value, null);
					UpdateExample (texteditor.Document.Text);
				}
			};
			
			column.PackStart (cellRendererToggle, false);
			column.SetAttributes (cellRendererToggle, "visible", 1);
			column.SetCellDataFunc (cellRendererToggle,  delegate (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) {
				((CellRendererToggle)cell).Active = (bool)GetValue (((Option)model.GetValue (iter, 0)).PropertyName);
			});
			
			treeviewInsertWhiteSpaceOptions.AppendColumn (column);
			
			treeviewInsertWhiteSpaceOptions.Model = whiteSpaceOptions;*/
			treeviewInsertWhiteSpaceCategory.ExpandAll ();
			#endregion
			
			#region Blank line options
			entryBeforUsings.Text = profile.BlankLinesBeforeUsings.ToString ();
			entryAfterUsings.Text = profile.BlankLinesAfterUsings.ToString ();
			
			entryBeforeFirstDeclaration.Text = profile.BlankLinesBeforeFirstDeclaration.ToString ();
			entryBetweenTypes.Text = profile.BlankLinesBetweenTypes.ToString ();
			
			entryBetweenFields.Text = profile.BlankLinesBetweenFields.ToString ();
			entryBetweenEvents.Text = profile.BlankLinesBetweenEventFields.ToString ();
			entryBetweenMembers.Text = profile.BlankLinesBetweenMembers.ToString ();
			
			entryBeforUsings.Changed += HandleEntryBeforUsingsChanged;
			entryAfterUsings.Changed += HandleEntryBeforUsingsChanged;
			entryBeforeFirstDeclaration.Changed += HandleEntryBeforUsingsChanged;
			entryBetweenTypes.Changed += HandleEntryBeforUsingsChanged;
			entryBetweenFields.Changed += HandleEntryBeforUsingsChanged;
			entryBetweenEvents.Changed += HandleEntryBeforUsingsChanged;
			entryBetweenMembers.Changed += HandleEntryBeforUsingsChanged;
			#endregion
		}
Exemplo n.º 22
0
        /// <summary>
        /// Default constructor that configures the Completion form.
        /// </summary>
        public EditorView(ViewBase owner)
            : base(owner)
        {
            scroller = new ScrolledWindow();
            textEditor = new MonoTextEditor();
            scroller.Add(textEditor);
            _mainWidget = scroller;
            TextEditorOptions options = new TextEditorOptions();
            options.EnableSyntaxHighlighting = true;
            options.ColorScheme = "Visual Studio";
            options.HighlightCaretLine = true;
            textEditor.Options = options;
            textEditor.Document.LineChanged += OnTextHasChanged;
            textEditor.LeaveNotifyEvent += OnTextBoxLeave;
            _mainWidget.Destroyed += _mainWidget_Destroyed;

            CompletionForm = new Window(WindowType.Toplevel);
            CompletionForm.Decorated = false;
            CompletionForm.SkipPagerHint = true;
            CompletionForm.SkipTaskbarHint = true;
            Frame completionFrame = new Frame();
            CompletionForm.Add(completionFrame);
            ScrolledWindow completionScroller = new ScrolledWindow();
            completionFrame.Add(completionScroller);
            completionModel = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string));
            CompletionView = new TreeView(completionModel);
            completionScroller.Add(CompletionView);
            TreeViewColumn column = new TreeViewColumn();
            CellRendererPixbuf iconRender = new Gtk.CellRendererPixbuf();
            column.PackStart(iconRender, false);
            CellRendererText textRender = new Gtk.CellRendererText();
            textRender.Editable = false;
            column.PackStart(textRender, true);
            column.SetAttributes(iconRender, "pixbuf", 0);
            column.SetAttributes(textRender, "text", 1);
            column.Title = "Item";
            column.Resizable = true;
            CompletionView.AppendColumn(column);
            textRender = new CellRendererText();
            column = new TreeViewColumn("Units", textRender, "text", 2);
            column.Resizable = true;
            CompletionView.AppendColumn(column);
            textRender = new CellRendererText();
            column = new TreeViewColumn("Type", textRender, "text", 3);
            column.Resizable = true;
            CompletionView.AppendColumn(column);
            textRender = new CellRendererText();
            column = new TreeViewColumn("Descr", textRender, "text", 4);
            column.Resizable = true;
            CompletionView.AppendColumn(column);
            functionPixbuf = new Gdk.Pixbuf(null, "ApsimNG.Resources.Function.png", 16, 16);
            propertyPixbuf = new Gdk.Pixbuf(null, "ApsimNG.Resources.Property.png", 16, 16);
            textEditor.TextArea.KeyPressEvent += OnKeyPress;
            CompletionView.HasTooltip = true;
            CompletionView.TooltipColumn = 5;
            CompletionForm.FocusOutEvent += OnLeaveCompletion;
            CompletionView.ButtonPressEvent += OnContextListMouseDoubleClick;
            CompletionView.KeyPressEvent += OnContextListKeyDown;
            CompletionView.KeyReleaseEvent += CompletionView_KeyReleaseEvent;
            IntelliSenseChars = ".";
        }