コード例 #1
0
        void OnScrollEditor(object s, EventArgs args)
        {
            if (!autoRefill || dragging)
            {
                return;
            }

            DocumentLocation loc  = editor.PointToLocation(0, 0);
            DocumentLocation loc2 = editor.PointToLocation(0, editor.Allocation.Height);

            //bool moveCaret = editor.Caret.Line >= loc.Line && editor.Caret.Line <= loc2.Line;

            if (firstLine != int.MinValue && loc.Line < FillMarginLines)
            {
                int num = (FillMarginLines - loc.Line) * 2;
                int newLast;
                num = InsertLines(0, firstLine - num, firstLine - 1, out firstLine, out newLast);

                // Shift line numbers in the addresses dictionary
                var newLines = new Dictionary <string, int> ();
                foreach (var pair in addressLines)
                {
                    newLines [pair.Key] = pair.Value + num;
                }
                addressLines = newLines;

                //if (moveCaret)
                editor.Caret.Line += num;

                double hinc = num * editor.LineHeight;
                sw.Vadjustment.Value += hinc;

                UpdateCurrentLineMarker(false);
            }
            if (lastLine != int.MinValue && loc2.Line >= editor.Document.LineCount - FillMarginLines)
            {
                int num = (loc2.Line - (editor.Document.LineCount - FillMarginLines) + 1) * 2;
                int newFirst;
                InsertLines(editor.Document.TextLength, lastLine + 1, lastLine + num, out newFirst, out lastLine);
            }
        }
コード例 #2
0
		public AssemblyBrowserWidget ()
		{
			this.Build( );
			TreeView = new ExtensibleTreeView (new NodeBuilder[] { 
				new ErrorNodeBuilder (),
				new AssemblyNodeBuilder (this),
				new ModuleReferenceNodeBuilder (),
				new ModuleDefinitionNodeBuilder (this),
				new ReferenceFolderNodeBuilder (this),
				new ResourceFolderNodeBuilder (),
				new ResourceNodeBuilder (),
				new NamespaceBuilder (this),
				new DomTypeNodeBuilder (this),
				new DomMethodNodeBuilder (this),
				new DomFieldNodeBuilder (this),
				new DomEventNodeBuilder (this),
				new DomPropertyNodeBuilder (this),
				new BaseTypeFolderNodeBuilder (this),
				new DomReturnTypeNodeBuilder (this),
				new ReferenceNodeBuilder (this),
				}, new TreePadOption [] {
				new TreePadOption ("PublicApiOnly", GettextCatalog.GetString ("Show public members only"), true)
			});
			TreeView.Tree.Selection.Mode = Gtk.SelectionMode.Single;
			TreeView.Tree.CursorChanged += HandleCursorChanged;
			TreeView.ShadowType = ShadowType.In;
			treeViewPlaceholder.Add (TreeView);
			treeViewPlaceholder.ShowAll ();
			
//			this.descriptionLabel.ModifyFont (Pango.FontDescription.FromString ("Sans 9"));
			this.documentationLabel.ModifyFont (Pango.FontDescription.FromString ("Sans 12"));
			this.documentationLabel.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (255, 255, 225));
			this.documentationLabel.Wrap = true;
			
			var options = new MonoDevelop.Ide.Gui.CommonTextEditorOptions () {
				ShowFoldMargin = false,
				ShowIconMargin = false,
				ShowInvalidLines = false,
				ShowLineNumberMargin = false,
				ShowSpaces = false,
				ShowTabs = false,
				HighlightCaretLine = true,
			};
			inspectEditor = new Mono.TextEditor.TextEditor (new Mono.TextEditor.Document (), options);
			inspectEditor.ButtonPressEvent += HandleInspectEditorButtonPressEvent;
			
			this.inspectEditor.Document.ReadOnly = true;
//			this.inspectEditor.Document.SyntaxMode = new Mono.TextEditor.Highlighting.MarkupSyntaxMode ();
			this.inspectEditor.TextViewMargin.GetLink = delegate(Mono.TextEditor.MarginMouseEventArgs arg) {
				var loc = inspectEditor.PointToLocation (arg.X, arg.Y);
				int offset = inspectEditor.LocationToOffset (loc);
				var referencedSegment = ReferencedSegments != null ? ReferencedSegments.FirstOrDefault (seg => seg.Contains (offset)) : null;
				if (referencedSegment == null)
					return null;
				if (referencedSegment.Reference is TypeDefinition)
					return new DomCecilType ((TypeDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is MethodDefinition)
					return new DomCecilMethod ((MethodDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is PropertyDefinition)
					return new DomCecilProperty ((PropertyDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is FieldDefinition)
					return new DomCecilField ((FieldDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is EventDefinition)
					return new DomCecilEvent ((EventDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is FieldDefinition)
					return new DomCecilField ((FieldDefinition)referencedSegment.Reference).HelpUrl;
				
				if (referencedSegment.Reference is TypeReference) {
					var returnType = DomCecilMethod.GetReturnType ((TypeReference)referencedSegment.Reference);
					if (returnType.GenericArguments.Count == 0)
						return "T:" + returnType.FullName;
					return "T:" + returnType.FullName + "`" + returnType.GenericArguments.Count;
				}
				return referencedSegment.Reference.ToString ();
			};
			this.inspectEditor.LinkRequest += InspectEditorhandleLinkRequest;
			this.scrolledwindowEditor.Child = this.inspectEditor;
//			this.inspectLabel.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (255, 255, 250));
			
//			this.vpaned1.ExposeEvent += VPaneExpose;
			this.hpaned1.ExposeEvent += HPaneExpose;
/*			this.notebook1.SwitchPage += delegate {
				// Hack for the switch page select all bug.
//				this.inspectLabel.Selectable = false;
			};*/

			this.languageCombobox.AppendText (GettextCatalog.GetString ("Summary"));
			this.languageCombobox.AppendText (GettextCatalog.GetString ("IL"));
			this.languageCombobox.AppendText (GettextCatalog.GetString ("C#"));
			this.languageCombobox.Active = PropertyService.Get ("AssemblyBrowser.InspectLanguage", 2);
			this.languageCombobox.Changed += LanguageComboboxhandleChanged;
			this.searchentry1.Ready = true;
			this.searchentry1.WidthRequest = 200;
			this.searchentry1.Visible = true;
			this.searchentry1.EmptyMessage = GettextCatalog.GetString ("Search for types or members");
			this.searchentry1.InnerEntry.Changed += SearchEntryhandleChanged;
			
			CheckMenuItem checkMenuItem = this.searchentry1.AddFilterOption (0, GettextCatalog.GetString ("Types"));
			checkMenuItem.Active = true;
			checkMenuItem.Toggled += delegate {
				if (checkMenuItem.Active) {
					searchMode = AssemblyBrowserWidget.SearchMode.Type;
					CreateColumns ();
					StartSearch ();
				}
			};
			
			CheckMenuItem checkMenuItem1 = this.searchentry1.AddFilterOption (1, GettextCatalog.GetString ("Members"));
			checkMenuItem1.Toggled += delegate {
				if (checkMenuItem1.Active) {
					searchMode = AssemblyBrowserWidget.SearchMode.Member;
					CreateColumns ();
					StartSearch ();
				}
			};
			comboboxVisibilty.InsertText (0, GettextCatalog.GetString ("Only public members"));
			comboboxVisibilty.InsertText (1, GettextCatalog.GetString ("All members"));
			comboboxVisibilty.Active = 0;
			comboboxVisibilty.Changed += delegate {
				PublicApiOnly = comboboxVisibilty.Active == 0;
				this.TreeView.GetRootNode ().Options[ "PublicApiOnly"] = PublicApiOnly;
				FillInspectLabel ();
			};
			/*
			this.searchInCombobox.Active = 0;
			this.searchInCombobox.Changed += SearchInComboboxhandleChanged;
			*/
			this.notebook1.SetTabLabel (this.documentationScrolledWindow, new Label (GettextCatalog.GetString ("Documentation")));
			this.notebook1.SetTabLabel (this.notebookInspection, new Label (GettextCatalog.GetString ("Inspect")));
			this.notebook1.SetTabLabel (this.searchWidget, new Label (GettextCatalog.GetString ("Search")));
			//this.searchWidget.Visible = false;
				
			typeListStore = new Gtk.ListStore (typeof (Gdk.Pixbuf), // type image
			                                   typeof (string),     // name
			                                   typeof (string),     // namespace
			                                   typeof (string),     // assembly
				                               typeof (IMember)
			                                  );
			
			memberListStore = new Gtk.ListStore (typeof (Gdk.Pixbuf), // member image
			                                   typeof (string),     // name
			                                   typeof (string),     // Declaring type full name
			                                   typeof (string),     // assembly
				                               typeof (IMember)
			                                  );
			CreateColumns ();
			SetInspectWidget ();
//			this.searchEntry.Changed += SearchEntryhandleChanged;
			this.searchTreeview.RowActivated += SearchTreeviewhandleRowActivated;
			this.searchentry1.ShowAll ();
			this.buttonBack.Clicked += this.OnNavigateBackwardActionActivated;
			this.buttonForeward.Clicked += this.OnNavigateForwardActionActivated;
			this.notebook1.ShowTabs = false;
			this.notebookInspection.ShowTabs = false;
			this.ShowAll ();
		}