//creates new ObservableCollection with new return block and set returnBox item source to new OC list public void CreateMethodReturnBlock() { Block newReturnBlock = MainPage.createReservedBlock("RETURN"); ComboBoxItem ci = (ComboBoxItem)returnType.SelectedItem; TextBlock tb = (TextBlock)ci.Content; //get the TextBlock aka return type //newReturnBlock.metadataList[1] = tb.Text; newReturnBlock.returnType = tb.Text; newReturnBlock = newReturnBlock.cloneSelf(false); newReturnBlock.LayoutRoot.Width = returnBox.Width - 20; newReturnBlock.LayoutRoot.Height = returnBox.Height - 15; ObservableCollection <Block> returnList = new ObservableCollection <Block>(); if (!tb.Text.Equals("VOID")) { returnList.Add(newReturnBlock); } returnBox.ItemsSource = returnList; //UpdateMethodBlocks(); foreach (EditorDragDropTarget EDDT in MainPage.editorLists) { //replace based on block name ((ListBox)EDDT.Content).ItemsSource = EDDT.switchBlocks(newReturnBlock.cloneSelf(true), false); } }
//finds each method and updates that method in the editor windows of all tabs private void UpdateMethodBlocks(Block methodBlock) { foreach (EditorDragDropTarget EDDT in MainPage.editorLists) { //replace based on block user generated name //((ListBox)EDDT.Content).ItemsSource = EDDT.switchBlocks(methodBlock.cloneSelf(true), true); EDDT.switchBlocks(EDDT.Content as ListBox, methodBlock.cloneSelf(true), true); ObservableCollection <Block> collection = ((ListBox)EDDT.Content).ItemsSource as ObservableCollection <Block>; Parsing.SocketReader.ReplaceMethodBlocks(collection, methodBlock.cloneSelf(true)); } }