Example #1
0
        /// <summary>
        /// Displays the proper assembly definition according to the depth of the activated row.
        /// </summary>
        /// <param name='o'>
        /// The Gtk.TreeView assemblyTree.
        /// </param>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        void HandleRowActivated(object o, Gtk.RowActivatedArgs args)
        {
            //SelectionEventArgs selectionArgs = new SelectionEventArgs();
            //SelectionChangedEvent(o, selectionArgs);

            assemblyTree.Model.GetIter(out iter, args.Path);

            object             currentObj = (object)assemblyTree.Model.GetValue(iter, 0);
            SelectionEventArgs selectionArgs;

            switch (args.Path.Depth)
            {
            case 1:
                curAssembly = currentObj as AssemblyDefinition;
                Debug.Assert(curAssembly != null, "Assembly cannot be null.");
                AttachSubTree(assemblyTree.Model, iter, curAssembly.Modules.ToArray());
                selectionArgs = new SelectionEventArgs(null, null, curAssembly);
                SelectionChangedEvent(o, selectionArgs);
                break;

            case 2:
                curModule = currentObj as ModuleDefinition;
                Debug.Assert(curModule != null, "CurModule is null!?");
                AttachSubTree(assemblyTree.Model, iter, curModule.Types.ToArray());
                selectionArgs = new SelectionEventArgs(null, curModule, curAssembly);
                SelectionChangedEvent(o, selectionArgs);
                break;

            case 3:
                curType = currentObj as TypeDefinition;
                Debug.Assert(curType != null, "CurType is null!?");
                List <IMemberDefinition> members = new List <IMemberDefinition>();
                members.AddRange(curType.Fields.ToArray());
                members.AddRange(curType.Methods.ToArray());
                members.AddRange(curType.Events.ToArray());
                AttachSubTree(assemblyTree.Model, iter, members.ToArray());
                selectionArgs = new SelectionEventArgs(curType, curModule, curAssembly);
                SelectionChangedEvent(o, selectionArgs);
                break;

            case 4:
                curMember = currentObj as MemberReference;
                Debug.Assert(curMember != null, "MemberDef is null!?");
                selectionArgs = new SelectionEventArgs(curMember, curModule, curAssembly);
                SelectionChangedEvent(o, selectionArgs);
                //DumpMember(memberDef);
                break;
            }

            assemblyTree.ShowAll();
            //ShowAll();
        }