public static void showInTreeView(this MethodMappings methodMappings, TreeView treeView, string filter, bool showSourceCodeSnippets, bool onlyShowSourceCodeLine) { treeView.parent().backColor("LightPink"); treeView.visible(false); treeView.clear(); var indexedMappings = methodMappings.indexedByKey(filter); if (onlyShowSourceCodeLine) { //do this so that we don't add more than one item per line var indexedByFileAndLine = new Dictionary<string, MethodMapping>(); foreach(var item in indexedMappings) foreach(var methodMapping in item.Value) if (methodMapping.File.valid()) { var key = "{0}_{1}".format(methodMapping.File, methodMapping.Start_Line); indexedByFileAndLine.add(key, methodMapping); } // now group then by the same text in the SourceCodeLine var indexedBySourceCodeLine = new Dictionary<string, List<MethodMapping>>(); foreach(var methodMapping in indexedByFileAndLine.Values) indexedBySourceCodeLine.add(methodMapping.sourceCodeLine(), methodMapping); //Finally show then foreach(var item in indexedBySourceCodeLine) { var uniqueTextNode = treeView.add_Node(item.Key, item.Value,true); } } else { foreach(var item in indexedMappings) { var keyNodeText = "{0} ({1})".format(item.Key, item.Value.size()); var keyNode= treeView.add_Node(keyNodeText, item.Value,true); } treeView.afterSelect<List<MethodMapping>>( (mappings)=>{ var keyNode = treeView.selected(); keyNode.clear(); foreach(var methodMapping in mappings) { var nodeText = (showSourceCodeSnippets) ? methodMapping.sourceCodeLine() : "{0} - {1}".format(methodMapping.INodeType,methodMapping.SourceCode); keyNode.add_Node(nodeText, methodMapping); } }); } treeView.parent().backColor("Control"); treeView.visible(true); }
public void loadFiles(string filesPath, List<string> filesToLoad) { sourceCode.set_Text("Loading files from: {0}".format(filesPath)); Path.set_Text(filesPath); var filesContent = new Dictionary<string,string>(); var nonBinaryFiles = new List<string>(); foreach(var file in filesToLoad) if (file.isBinaryFormat().isFalse()) nonBinaryFiles.add(file); foreach(var file in nonBinaryFiles) filesContent.add(file.remove(filesPath),file.contents()); searchEngine = new SearchEngine(); searchEngine.loadFiles(nonBinaryFiles); //searchEngine.fixH2FileLoadingIssue(); leftPanel.clear(); treeView = leftPanel.add_TreeViewWithFilter(filesContent); treeView.afterSelect<string>( (fileContents)=>{ sourceCode.open(filesPath + treeView.selected().get_Text()); }); sourceCode.colorCodeForExtension(treeView.selected().str()); sourceCode.set_Text(""); textSearch_TextBox = leftPanel.controls<TextBox>(true)[1]; textSearch_TextBox.onEnter( (text)=>{ var searchResults = searchEngine.searchFor(text); dataGridView.loadInDataGridView_textSearchResults(searchResults); }); }
public static API_AmazonEC2 addStopInstanceGui(this API_AmazonEC2 amazonEC2, Panel targetPanel, TreeView treeViewWithInstances) { Action startTimer = null; Action stopTimer = null; var instancesToStop = targetPanel.add_GroupBox("Stop Instance in {0} minutes".format((amazonEC2.TimerCount * amazonEC2.TimerCount / 60))) .add_TreeView(); var timerBar = instancesToStop.insert_Below(20).add_ProgressBar(); instancesToStop.add_ContextMenu().add_MenuItem("Stop now",true, ()=>{ "Stopping {0} instances now".debug(instancesToStop.nodes().size()); foreach(var node in instancesToStop.nodes()) amazonEC2.stopInstance((RunningInstance)node.get_Tag()); }) .add_MenuItem("Clear list", ()=>instancesToStop.clear()); var startTimerLink = instancesToStop.insert_Above(15).add_Link("Add instance to list",0,0, ()=>{ var selectedNode = treeViewWithInstances.selected(); if (selectedNode.notNull()) { var tag = selectedNode.get_Tag(); if (tag is RunningInstance) { var selectedInstance = (RunningInstance)tag; var nodeText = "{0} - {1}".format(selectedInstance.InstanceId, selectedInstance.IpAddress); instancesToStop.add_Node(nodeText, selectedInstance); } } //treeViewWithInstances.nodes().showInfo(); }) .append_Link("Start timer", ()=>startTimer()); var timerEnabled = false; var stopTimerLink = startTimerLink.append_Link("Stop timer", ()=>stopTimer()).enabled(false); startTimer = ()=>{ "starting timer".info(); timerEnabled = true; timerBar.maximum(amazonEC2.TimerCount); timerBar.value(0); startTimerLink.enabled(false); stopTimerLink.enabled(true); while(timerEnabled && timerBar.Value < amazonEC2.TimerCount) { "In StopInstances Timer [{0}/{1}], sleeping for {2} seconds".info(timerBar.Value, amazonEC2.TimerCount, amazonEC2.TimerSleep/1000); timerBar.sleep(amazonEC2.TimerSleep, false); timerBar.increment(1); } if (timerEnabled) { "Timer is completed stopping {0} instances now".debug(instancesToStop.nodes().size()); foreach(var node in instancesToStop.nodes()) amazonEC2.stopInstance((RunningInstance)node.get_Tag()); } else "Timer was stopped so nothing to do".debug(); startTimerLink.enabled(true); stopTimerLink.enabled(false); }; stopTimer = ()=>{ "stopping timer".info(); timerEnabled = false; startTimerLink.enabled(true); stopTimerLink.enabled(false); }; targetPanel.onClosed(()=> timerEnabled=false); return amazonEC2; }
public void addEditMenuItemsToTreeView(TreeView treeView) { var contextMenu = treeView.add_ContextMenu(); contextMenu.add_MenuItem("delete selected page (you must be an admin)", ()=>{ var pageToDelete = treeView.selected().get_Text(); if (pageToDelete.valid()) if (WikiApi.deletePage(pageToDelete)) treeView.remove_Node(treeView.selected()); }); /* contextMenu.add_MenuItem("reload all pages", ()=>{ treeView.clear(); treeView.add_Nodes(WikiApi.allPages()); }); */ var renameMenuItem = contextMenu.add_MenuItem("rename (user will copy, admin will move)"); var renameTextBox = renameMenuItem.add_TextBox("rename"); renameMenuItem.add_MenuItem("rename page with new title (set above)", ()=> { var currentTitle = treeView.selected().get_Text(); var newTitle = renameTextBox.get_Text(); if (WikiApi.movePage(currentTitle, newTitle)) { treeView.selected().set_Text(newTitle); } //"renaming page '{0}' to '{1}'".info(currentTitle, newTitle); }); treeView.afterSelect<string>( (page)=> { renameTextBox.set_Text(page); renameTextBox.width(page.size() * 7); }); }
public void buildGui() { try { var topPanel = this.add_Panel(); //serializedString = topPanel.insert_Right(200).add_GroupBox("Serialized Object").add_SourceCodeViewer(); //var serializedStringPanel = serializedString.splitContainer().panel2Collapsed(true); propertyGrid = topPanel.add_GroupBox("").add_PropertyGrid().helpVisible(false); treeView = propertyGrid.parent().insert_Left<Panel>().add_TreeView().sort(); //treeView.splitterDistance(300); var toStringValue = propertyGrid.parent().insert_Below<Panel>(100).add_GroupBox("ToString Value (not editable):").add_TextArea(); var optionsPanel = treeView.insert_Below<Panel>(70); var objectName = toStringValue.parent().insert_Above<Panel>(20).add_TextBox("name", ""); //propertyGrid.onValueChange(updateSerializedString); //setSerializedStringSyncWithPropertyGrid(); //serializedString.insert_Above(20).add_Link("Sync Serialized String With PropertyGrid", 0, 0, () => updateSerializedStringSyncWithPropertyGrid()); LinkLabel invokeLink = null; invokeLink = optionsPanel.add_CheckBox("Show Methods", 0, 0, (value) => { ShowMethods = value; invokeLink.enabled(value); refresh(); }) .append_Link("invoke", invokeSelectedMethod) .leftAdd(-16).topAdd(5).bringToFront() .enabled(false); optionsPanel.add_CheckBox("Show Property and Field info", 22, 0, (value) => { ShowPropertyAndFieldInfo = value; refresh(); }) .autoSize() .append_Link("refresh", () => refresh()) .left(200); optionsPanel.add_CheckBox("Sort Values", 0, 135, (value) => { Sorted = value; try { treeView.sort(Sorted); // throwing "Unable to cast object of type 'System.Boolean' to type 'System.Windows.Forms.TreeView'" } catch//(Exception ex) { //ex.log(); } }).@checked(true); simpleView_CheckBox = optionsPanel.add_CheckBox("Simple View", 0, 220, (value) => { SimpleView = value; //propertyGrid.splitContainer().panel1Collapsed(value); refresh(); }) .bringToFront(); /*showSerializedString_CheckBox = optionsPanel.add_CheckBox("Show serialized string", 44, 0, (value) => { ShowSerializedString = value; serializedStringPanel.panel2Collapsed(!value); refresh(); }) .autoSize();*/ createObjectWhenNull_CheckBox = optionsPanel.add_CheckBox("Create Object When Null", 44, 150, (value) => { CreateObjectWhenNull = value; }) .bringToFront() .autoSize(); treeView.afterSelect<object>( (selectedObject) => { var treeNode = treeView.selected(); objectName.set_Text(treeNode.get_Text()); var tag = WinForms_ExtensionMethods_TreeView.get_Tag(treeNode); if (tag.notNull())// && tag.str() != treeNode.get_Text()) { propertyGrid.show(selectedObject); var toString = selectedObject.str(); if (toString == "System.__ComObject") toString += " : {0}".format(selectedObject.comObject_TypeName()); toStringValue.set_Text(toString); propertyGrid.parent().set_Text(selectedObject.typeFullName()); if (treeNode.nodes().size() == 0) { addObjectPropertyAndFields(treeNode, selectedObject); } } else if (treeNode.nodes().size() == 0) { propertyGrid.show(null as object); propertyGrid.parent().set_Text("[null value]"); toStringValue.set_Text("[null value]"); objectName.set_Text(""); treeNode.color(Color.Red); } }); treeView.add_ContextMenu().add_MenuItem("Invoke Method", () => invokeSelectedMethod()); } catch (Exception ex) { ex.log("in buildGui", true); } guiReady = true; }