private bool readBlockAPI() { BlockAPIReader r = new BlockAPIReader(); allBlockList = r.readBlockDefinitions(); packageNameList = r.getPackageNames(); //Temporary-- parse every single block read in into one list foreach (List<Block> l in allBlockList) { foreach (Block b in l) { programStructureList.Add(b); } } if (allBlockList != null) return true; else return false; }
private bool readBlockAPI(bool loadFromServer, IEnumerable<XElement> xmlFile) { BlockAPIReader r = null; if (loadFromServer) { //do things r = new BlockAPIReader(xmlFile); } else { r = new BlockAPIReader(); } allBlockList = r.readBlockDefinitions(); packageNameList = r.getPackageNames(); reservedBlocks = r.getReservedBlocks(); //Add package marker blocks to the program structures palette for (int i = 0; i < allBlockList.Count; i++) { //First, check to make sure the package contains at least one non-program reserved block bool containsNonReserved = false; //Second, check to see which panel the package needs to be added to bool isPartOfProgramPanel = true; foreach (Block b in allBlockList[i]) { if (!b.flag_programOnly) { containsNonReserved = true; if (b.flag_robotOnly) { isPartOfProgramPanel = false; } break; } } if (containsNonReserved && isPartOfProgramPanel) { //If it does, create a marker block for that package Block packageBlock = new Block(packageNameList[i], ((Block)allBlockList[i][0]).blockColor); packageBlock.LayoutRoot.Width = blockPalette.Width-30; packageBlock.flag_isPackage = true; programStructureList.Add(packageBlock); } else if (containsNonReserved && !isPartOfProgramPanel) { Block packageBlock = new Block(packageNameList[i], ((Block)allBlockList[i][0]).blockColor); packageBlock.LayoutRoot.Width = blockPalette.Width - 30; packageBlock.flag_isPackage = true; robotFunctionsList.Add(packageBlock); } } if (allBlockList != null) return true; else return false; }
private bool readBlockAPI(bool loadFromServer, IEnumerable <XElement> xmlFile) { BlockAPIReader r = null; if (loadFromServer) { //do things r = new BlockAPIReader(xmlFile); } else { r = new BlockAPIReader(); } allBlockList = r.readBlockDefinitions(); packageNameList = r.getPackageNames(); reservedBlocks = r.getReservedBlocks(); //Add package marker blocks to the program structures palette for (int i = 0; i < allBlockList.Count; i++) { //First, check to make sure the package contains at least one non-program reserved block bool containsNonReserved = false; //Second, check to see which panel the package needs to be added to bool isPartOfProgramPanel = true; foreach (Block b in allBlockList[i]) { if (!b.flag_programOnly) { containsNonReserved = true; if (b.flag_robotOnly) { isPartOfProgramPanel = false; } break; } } if (containsNonReserved && isPartOfProgramPanel) { //If it does, create a marker block for that package Block packageBlock = new Block(packageNameList[i], ((Block)allBlockList[i][0]).blockColor); packageBlock.LayoutRoot.Width = blockPalette.Width - 30; packageBlock.flag_isPackage = true; programStructureList.Add(packageBlock); } else if (containsNonReserved && !isPartOfProgramPanel) { Block packageBlock = new Block(packageNameList[i], ((Block)allBlockList[i][0]).blockColor); packageBlock.LayoutRoot.Width = blockPalette.Width - 30; packageBlock.flag_isPackage = true; robotFunctionsList.Add(packageBlock); } } if (allBlockList != null) { return(true); } else { return(false); } }