private void treeViewInventory_AfterSelect(object sender, TreeViewEventArgs e)
        {
            dataGridView.Tag = null;
            dataGridView.Rows.Clear();
            dataGridView.Columns[1].Visible = true;
            dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView.Columns[0].ReadOnly = true;
            dataGridView.Columns[1].ReadOnly = false;
            //dataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect;
            dataGridView.AllowUserToAddRows = false;
            dataGridView.AllowUserToDeleteRows = false;
            dataGridView.Columns[0].HeaderText = "Property";
            dataGridView.Columns[1].HeaderText = "Value";
            //dataGridView.MultiSelect = false;

            while (dataGridView.Columns.Count > 2)
            {
                dataGridView.Columns.RemoveAt(2);
            }

            if (e.Node.Tag != null)
            {
                TreeNodeData tnd = e.Node.Tag as TreeNodeData;

                dataGridView.Tag = tnd.Data;

                /*
                if (tnd.Data is MFComponent)
                {
                    AddNodeEnumToPropertyGrid("Processor", ((MFComponent)tnd.Data).Name, tnd.Data, treeViewInventory.Nodes[0].Nodes["Processors"], new ToolStripItemClickedEventHandler(OnProcessorContextMenuItem), true);
                }
                */
                /*
                else if (tnd.Data is ISARef)
                {
                    AddNodeEnumToPropertyGrid("ISA", ((ISARef)tnd.Data).Name, tnd.Data, treeViewInventory.Nodes[0].Nodes["ISAs"], new ToolStripItemClickedEventHandler(OnISAContextMenuItem));
                }
                */
                if (tnd.Data is BuildToolRef)
                {
                    AddNodeEnumToPropertyGrid("BuildTool", ((BuildToolRef)tnd.Data).Name, tnd.Data, treeViewInventory.Nodes[0].Nodes["BuildTools"], new ToolStripItemClickedEventHandler(OnBuildToolContextMenuItem));
                }
                else if (tnd.Data is MFComponent)
                {
                    MFComponent cmp = (MFComponent)tnd.Data;

                    switch (cmp.ComponentType)
                    {
                        case MFComponentType.LibraryCategory:
                            AddNodeEnumToPropertyGrid("LibraryCategory", cmp.Name, tnd.Data, treeViewInventory.Nodes[0].Nodes["LibraryCategories"], new ToolStripItemClickedEventHandler(OnLibraryCategoryContextMenuItem), true);
                            break;
                        case MFComponentType.Processor:
                            AddNodeEnumToPropertyGrid("Processor", cmp.Name, tnd.Data, treeViewInventory.Nodes[0].Nodes["Processors"], new ToolStripItemClickedEventHandler(OnProcessorContextMenuItem),true);
                            break;
                        case MFComponentType.ISA:
                        case MFComponentType.Library:
                            dataGridView.Columns[0].HeaderText = "Name";
                            dataGridView.Columns[1].HeaderText = "Condition";
                            dataGridView.Rows.Add(cmp.Name, cmp.Conditional);
                            break;
                        case MFComponentType.Feature:
                            if (e.Node.Text == "FeatureAssociation")
                            {
                                AddNodeEnumToPropertyGrid("Feature", cmp.Name, cmp, treeViewInventory.Nodes[0].Nodes["Features"], new ToolStripItemClickedEventHandler(OnFeatureSelect), true);
                            }
                            break;
                    }
                }
                /*
                else if (tnd.Data is LibraryCategoryRef)
                {
                    AddNodeEnumToPropertyGrid("LibraryCategory", ((LibraryCategoryRef)tnd.Data).Name, tnd.Data, treeViewInventory.Nodes[0].Nodes["LibraryCategories"], new ToolStripItemClickedEventHandler(OnLibraryCategoryRefContextMenuItem), true);
                }
                */
                else if (tnd.Data is List<ToolFlag>)
                {
                    dataGridView.Columns[0].HeaderText = "Conditional";
                    dataGridView.Columns[1].HeaderText = "Flags";

                    List<ToolFlag> tfs = (tnd.Data as List<ToolFlag>);
                    if (tfs.Count == 0)
                    {
                        ToolFlag tf = new ToolFlag();
                        tf.Conditional = "'$(FLAVOR)'=='Debug'";
                        tfs.Add(tf);

                        tf = new ToolFlag();
                        tf.Conditional = "'$(FLAVOR)'=='Release'";
                        tfs.Add(tf);

                        tf = new ToolFlag();
                        tf.Conditional = "'$(FLAVOR)'=='RTM'";
                        tfs.Add(tf);
                    }

                    foreach (ToolFlag var in tfs)
                    {
                        dataGridView.Rows.Add(var.Conditional, var.Flag);
                    }

                    dataGridView.Columns[0].ReadOnly = false;
                    //dataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
                    dataGridView.AllowUserToDeleteRows = true;
                    dataGridView.AllowUserToAddRows = true;
                    //dataGridView.MultiSelect = true;
                }
                else if (tnd.Data is IList<MFProject>)
                {
                }
                else if (tnd.Data is IList<ISA>)
                {
                }
                else if (tnd.Data is IList<BuildToolRef>)
                {
                }
                else if (tnd.Data is List<MemorySymbol>)
                {
                    dataGridView.Columns.Add("Description", "Description");
                    dataGridView.Columns.Add("Conditional", "Conditional");
                    dataGridView.Columns[0].HeaderText = "Name";
                    dataGridView.Columns[1].HeaderText = "Options";
                    dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dataGridView.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                    foreach (MemorySymbol var in (tnd.Data as List<MemorySymbol>))
                    {
                        dataGridView.Rows.Add(var.Name, var.Options, var.Description, var.Conditional);
                    }

                    dataGridView.Columns[0].ReadOnly = false;
                    //dataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
                    dataGridView.AllowUserToDeleteRows = true;
                    dataGridView.AllowUserToAddRows = true;
                }
                else if (tnd.Data is List<BuildParameter>)
                {
                    dataGridView.Columns.Add("Description", "Description");
                    dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                    foreach (BuildParameter var in (tnd.Data as List<BuildParameter>))
                    {
                        dataGridView.Rows.Add(var.Parameter, var.Action, var.Description);
                    }

                    dataGridView.Columns[0].ReadOnly = false;
                    //dataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
                    dataGridView.AllowUserToDeleteRows = true;
                    dataGridView.AllowUserToAddRows = true;
                }
                else if (tnd.Data is List<BuildParameter>)
                {
                    dataGridView.Columns.Add("Description", "Description");
                    dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                    foreach (BuildParameter var in (tnd.Data as List<BuildParameter>))
                    {
                        dataGridView.Rows.Add(var.Parameter, var.Action, var.Description);
                    }

                    dataGridView.Columns[0].ReadOnly = false;
                    //dataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
                    dataGridView.AllowUserToDeleteRows = true;
                    dataGridView.AllowUserToAddRows = true;
                }
                else if (tnd.Data is List<MFBuildFile>)
                {
                    dataGridView.Columns[0].HeaderText = "File";
                    dataGridView.Columns[0].ReadOnly = false;
                    dataGridView.Columns[1].HeaderText = "Condition";
                    dataGridView.Columns[1].ReadOnly = false;
                    dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    foreach (MFBuildFile file in (List<MFBuildFile>)tnd.Data)
                    {
                        dataGridView.Rows.Add(file.File, file.Condition);
                    }
                    dataGridView.AllowUserToDeleteRows = true;
                    dataGridView.AllowUserToAddRows = true;
                }
                else if (tnd.Data is List<MFProperty>)
                {
                    dataGridView.Columns.Add("Conditional", "Conditional");
                    dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                    foreach (MFProperty prop in (List<MFProperty>)tnd.Data)
                    {
                        dataGridView.Rows.Add(prop.Name, prop.Value, prop.Condition);
                    }

                    dataGridView.Columns[0].ReadOnly = false;
                    dataGridView.AllowUserToDeleteRows = true;
                    dataGridView.AllowUserToAddRows = true;
                }
                else if (tnd.Data is EnvVars)
                {
                    dataGridView.Columns.Add("Conditional", "Conditional");
                    dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                    foreach (EnvVar var in (tnd.Data as EnvVars).EnvVarCollection)
                    {
                        dataGridView.Rows.Add(var.Name, var.Value, var.Conditional);
                    }

                    dataGridView.Columns[0].ReadOnly = false;
                    //dataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
                    dataGridView.AllowUserToDeleteRows = true;
                    dataGridView.AllowUserToAddRows = true;
                }
                /*
                else if (tnd.Data is List<XsdInventoryFormatObject.MFComponent>)
                {
                    dataGridView.Columns[1].ReadOnly = true;

                    List<XsdInventoryFormatObject.MFComponent> ptrc = (tnd.Data as List<XsdInventoryFormatObject.MFComponent>);

                    dataGridView.Tag = ptrc;

                    Type t = (e.Node.Parent.Tag as TreeNodeData).Data.GetType();

                    foreach (Inventory inv in m_fileToInventory.Values)
                    {
                        //todo:
                        foreach (ISA pt in inv.ISAs)
                        {
                            XsdInventoryFormatObject.MFComponent theProcType = null;

                            foreach (XsdInventoryFormatObject.MFComponent ptr in ptrc)
                            {
                                if (ptr.Guid == pt.Guid)
                                {
                                    theProcType = ptr;
                                    break;
                                }
                            }

                            int idx = dataGridView.Rows.Add(pt.Name, theProcType != null);

                            if (theProcType == null)
                            {
                                theProcType = new XsdInventoryFormatObject.MFComponent();
                                theProcType.Guid = pt.Guid;
                                theProcType.Name = pt.Name;
                            }

                            dataGridView.Rows[idx].Tag = theProcType;
                            dataGridView.Rows[idx].Cells[1].ToolTipText = "Double-Click to Change";
                        }
                    }
                }
                */
                else if (tnd.Data is List<MFComponent>)
                {
                    //dataGridView.Columns[1].DataPropertyName = "Name";

                    if (e.Node.Text == "FeatureAssociations")
                    {
                        dataGridView.AllowUserToDeleteRows = true;
                        foreach (MFComponent featCmp in (List<MFComponent>)tnd.Data)
                        {
                            AddNodeEnumToPropertyGrid("Feature", featCmp.Name, featCmp, treeViewInventory.Nodes[0].Nodes["Features"], new ToolStripItemClickedEventHandler (OnFeatureSelect), true);
                        }
                    }

                    /*
                    dataGridView.Columns.Add();
                    dataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                    dataGridView.Columns[2].HeaderText = "Condition";
                    dataGridView.Columns[2].ReadOnly = false;

                    foreach (MFComponent c in (List<MFComponent>)tnd.Data)
                    {
                        dataGridView.Rows.Add(c.Name, c.Conditional);
                    }
                    */

                    /*
                    List<MFComponent> cc = (tnd.Data as List<MFComponent>);


                    Type t = (e.Node.Parent.Tag as TreeNodeData).Data.GetType();
                    TreeNodeData parentData = (e.Node.Parent.Tag as TreeNodeData);
                    if ((t == typeof(Feature) && e.Node.Text == "Libraries") ||
                        (t == typeof(MFSolution) && e.Node.Text == "Include") ||
                        (t == typeof(Library)) || (t == typeof(LibraryCategory)))
                    {
                        int colIdx = dataGridView.Columns.Add("Conditional", "Conditional");
                        dataGridView.Columns[colIdx].ReadOnly = false;
                        dataGridView.Columns[colIdx].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                        colIdx = dataGridView.Columns.Add("Type", "Type");
                        dataGridView.Columns[colIdx].ReadOnly = true;
                        dataGridView.Columns[colIdx].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                        colIdx = dataGridView.Columns.Add("Description", "Description");
                        dataGridView.Columns[colIdx].ReadOnly = true;
                        dataGridView.Columns[colIdx].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                        foreach (Inventory inv in m_fileToInventory.Values)
                        {
                            if (t != typeof(MFSolution))
                            {
                                foreach (LibraryCategory libType in inv.LibraryCategories)
                                {
                                    MFComponent theComp = null;
                                    foreach (MFComponent c in cc)
                                    {
                                        if (c.Guid == libType.Guid)
                                        {
                                            theComp = c;
                                            break;
                                        }
                                    }

                                    string conditional = "";
                                    if (theComp != null)
                                    {
                                        conditional = theComp.Conditional;
                                    }

                                    int idx = dataGridView.Rows.Add(libType.Name, theComp != null, conditional, "LibaryType: " + libType.Level, libType.Description);

                                    if (theComp == null)
                                    {
                                        theComp = new MFComponent(MFComponentType.LibraryCategory);
                                        theComp.Guid = libType.Guid;
                                        theComp.Name = libType.Name;
                                    }

                                    dataGridView.Rows[idx].Tag = theComp;
                                    dataGridView.Rows[idx].Cells[1].ToolTipText = "Double-Click to Change";
                                }
                            }

                            if (e.Node.Text != "LibraryCategories")
                            {
                                foreach (Library lib in inv.Libraries)
                                {
                                    // do not alow circular dependencies
                                    if (t == typeof(Library) && ((Library)((TreeNodeData)e.Node.Parent.Tag).Data).Guid.Equals(lib.Guid))
                                    {
                                        continue;
                                    }
                                    // nothing execept for a MFSolution should have a dependency on a HAL library
                                    if (t != typeof(MFSolution) && lib.Level == LibraryLevel.HAL)
                                    {
                                        continue;
                                    }

                                    // only show library types as only platforms should be able to include explicit libraries.
                                    if (t != typeof(MFSolution) && (lib.LibraryCategory != null) && !string.IsNullOrEmpty(lib.LibraryCategory.Guid))
                                    {
                                        continue;
                                    }

                                    MFComponent theComp = null;
                                    foreach (MFComponent c in cc)
                                    {
                                        if (c.Guid == lib.Guid)
                                        {
                                            theComp = c;
                                            break;
                                        }
                                    }

                                    string conditional = "";
                                    if (theComp != null)
                                    {
                                        conditional = theComp.Conditional;
                                    }

                                    int idx = dataGridView.Rows.Add(lib.Name, theComp != null || (t == typeof(MFSolution) && lib.Required), conditional, lib.Level, lib.Description);

                                    if (theComp == null)
                                    {
                                        theComp = new MFComponent(MFComponentType.Library);
                                        theComp.Guid = lib.Guid;
                                        theComp.Name = lib.Name;

                                        if (t == typeof(MFSolution) && lib.Required)
                                        {
                                            (tnd.Data as List<MFComponent>).Add(theComp);
                                        }
                                    }

                                    dataGridView.Rows[idx].Tag = theComp;
                                    dataGridView.Rows[idx].Cells[1].ToolTipText = "Double-Click to Change";
                                }
                            }
                        }
                    }
                    if ((t == typeof(Feature) && e.Node.Text == "Dependencies") ||
                        (t == typeof(MFSolution) && e.Node.Text == "Features"))
                    {
                        int colIdx = dataGridView.Columns.Add("Conditional", "Conditional");
                        dataGridView.Columns[colIdx].ReadOnly = false;
                        dataGridView.Columns[colIdx].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                        colIdx = dataGridView.Columns.Add("Description", "Description");
                        dataGridView.Columns[colIdx].ReadOnly = true;
                        dataGridView.Columns[colIdx].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

                        foreach (Inventory inv in m_fileToInventory.Values)
                        {
                            foreach (Feature feat in inv.Features)
                            {
                                if (t == typeof(Feature) && ((Feature)((TreeNodeData)e.Node.Parent.Tag).Data).Guid.Equals(feat.Guid))
                                {
                                    continue;
                                }

                                MFComponent theComp = null;
                                foreach (MFComponent c in cc)
                                {
                                    if (c.Guid == feat.Guid)
                                    {
                                        theComp = c;
                                        break;
                                    }
                                }

                                string conditional = "";
                                if (theComp != null)
                                {
                                    conditional = theComp.Conditional;
                                }

                                int idx = dataGridView.Rows.Add(feat.Name, theComp != null, conditional, feat.Description);

                                if (theComp == null)
                                {
                                    theComp = new MFComponent(MFComponentType.Feature);
                                    theComp.Guid = feat.Guid;
                                    theComp.Name = feat.Name;
                                }

                                dataGridView.Rows[idx].Tag = theComp;
                                dataGridView.Rows[idx].Cells[1].ToolTipText = "Double-Click to Change";

                            }
                        }
                    }
                     */
                }
                else if (tnd.Data.GetType() == typeof(List<BuildScript>))
                {
                    dataGridView.Columns[0].HeaderText = "Conditional";
                    dataGridView.Columns[1].HeaderText = "Build Commands";

                    foreach (BuildScript bs in (tnd.Data as List<BuildScript>))
                    {
                        dataGridView.Rows.Add(bs.Conditional, bs.Script);
                    }
                    dataGridView.Columns[0].ReadOnly = false;
                    //dataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
                    dataGridView.AllowUserToDeleteRows = true;
                    dataGridView.AllowUserToAddRows = true;
                }
                else if (tnd.Data.GetType() == typeof(List<ApiTemplate>))
                {
                    dataGridView.Columns[0].HeaderText = "File";
                    dataGridView.Columns[1].HeaderText = "Description";

                    foreach (ApiTemplate bs in (tnd.Data as List<ApiTemplate>))
                    {
                        dataGridView.Rows.Add(bs.FilePath, bs.Description);
                    }
                    dataGridView.Columns[0].ReadOnly = false;
                    //dataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
                    dataGridView.AllowUserToDeleteRows = true;
                    dataGridView.AllowUserToAddRows = true;
                }
                /*
            else if (tnd.Data is MFComponent)
            {
                // stub library
                TreeNodeData parentTnd = e.Node.Parent.Tag as TreeNodeData;
                XsdInventoryFormatObject.Library lib = parentTnd.Data as XsdInventoryFormatObject.Library;
                XsdInventoryFormatObject.LibraryCategory type = parentTnd.Data as XsdInventoryFormatObject.LibraryCategory;

                if (lib != null || type != null)
                {
                    if (lib == null || !lib.IsStub)
                    {
                        string typeGuid = type != null ? type.Guid : (lib.LibraryCategory != null) ? lib.LibraryCategory.Guid : "";
                        string stubGuid = ((MFComponent)tnd.Data).Guid;

                        bool fGuidCheck = !string.IsNullOrEmpty(typeGuid);

                        dataGridView.Columns[0].HeaderText = "Stub Library";
                        dataGridView.Columns[1].HeaderText = "Value";
                        dataGridView.Columns.Add("FileColumn", "File");

                        foreach (Inventory inv in m_fileToInventory.Values)
                        {
                            foreach (Library stub in inv.Libraries)
                            {
                                if (stub.IsStub)
                                {
                                    bool check = (0 == string.Compare(stubGuid, stub.Guid, true));

                                    if (fGuidCheck)
                                    {
                                        if (stub.LibraryCategory != null && (0 == string.Compare(typeGuid, stub.LibraryCategory.Guid, true)))
                                        {
                                            int row = dataGridView.Rows.Add(stub.Name, check, stub.LibraryFile);
                                            dataGridView.Rows[row].Tag = stub;
                                        }
                                    }
                                    else
                                    {
                                        int row = dataGridView.Rows.Add(stub.Name, check, stub.LibraryFile);
                                        dataGridView.Rows[row].Tag = stub;
                                    }
                                }
                            }
                        }

                        //AddNodeEnumToPropertyGrid("Stub Library", lib != null? lib.Name: type.Name, tnd.Data, treeViewInventory.Nodes[0].Nodes["Processors"], new ToolStripItemClickedEventHandler(OnProcessorContextMenuItem), true);
                    }
                }
            }
            */
                else
                {
                    AddPropertiesToGrid((e.Node.Tag as TreeNodeData).Data);
                }
            }
            dataGridView.Invalidate();
            if (dataGridView.Rows.Count > 0)
            {
                dataGridView.Sort(dataGridView.Columns[0], ListSortDirection.Ascending);
            }
        }
        private ToolChainOptions LoadToolChainOptions(ProjectPropertyGroupElement grp)
        {
            ToolChainOptions opts = new ToolChainOptions();
            List<ProjectPropertyElement> remList = new List<ProjectPropertyElement>();

            foreach (ProjectPropertyElement bp in grp.Properties)
            {
                ToolFlag flag;
                remList.Add(bp);

                switch (bp.Name)
                {
                    case "ToolName":
                        opts.ToolName = bp.Value;
                        break;
                    case "DEVICE_TYPE":
                        opts.DeviceType = bp.Value;
                        break;
                    case CommonToolFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.CommonFlags.Add(flag);
                        break;
                    case CCppCommonFlagTag:
                    case CCppTargFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.C_CppFlags.Add(flag);
                        break;
                    case CppFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.CppFlags.ToolFlags.Add(flag);
                        break;
                    case AsmFlagTag:
                    case AsmArmFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.AsmFlags.ToolFlags.Add(flag);
                        break;
                    case ArchiverFlagTag:
                    case ArchiverArmFlagTag:
                    case ArchiverPlatFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.ArchiverFlags.ToolFlags.Add(flag);
                        break;
                    case LinkerFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.LinkerFlags.ToolFlags.Add(flag);
                        break;

                    default:
                        {
                            string uc = bp.Name.ToUpper();

                            if (uc.Contains("CC_CPP_"))
                            {
                                flag = new ToolFlag();
                                flag.Flag = RemoveCommonFlags(bp.Value);
                                flag.Conditional = bp.Condition;
                                opts.C_CppFlags.Add(flag);
                            }
                            else if (uc.Contains("CC_"))
                            {
                                flag = new ToolFlag();
                                flag.Flag = RemoveCommonFlags(bp.Value);
                                flag.Conditional = bp.Condition;
                                opts.CFlags.ToolFlags.Add(flag);
                            }
                            else if (uc.Contains("AS_"))
                            {
                                flag = new ToolFlag();
                                flag.Flag = RemoveCommonFlags(bp.Value);
                                flag.Conditional = bp.Condition;
                                opts.AsmFlags.ToolFlags.Add(flag);
                            }
                            else
                            {
                                remList.Remove(bp);
                            }
                        }
                        break;
                }
            }
            foreach (ProjectPropertyElement bp in remList)
            {
                grp.RemoveChild(bp);
            }

            return opts;
        }
        void SaveGridView()
        {
            dataGridView.EndEdit();
            if (dataGridView.Tag is EnvVars)
            {
                List<EnvVar> evc = (dataGridView.Tag as EnvVars).EnvVarCollection;

                evc.Clear();
                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    if (row.Cells[0].Value != null)
                    {
                        EnvVar env = new EnvVar();
                        env.Name = row.Cells[0].Value.ToString();
                        env.Value = (row.Cells[1].Value == null ? "" : row.Cells[1].Value.ToString());
                        env.Conditional = row.Cells[2].Value == null? "" : row.Cells[2].Value.ToString();
                        evc.Add(env);
                    }
                }
            }
            else if (dataGridView.Tag is List<ToolFlag>)
            {
                List<ToolFlag> flags = (dataGridView.Tag as List<ToolFlag>);

                flags.Clear();
                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    if (row.Cells[0].Value != null || row.Cells[1].Value != null)
                    {
                        ToolFlag flag = new ToolFlag();
                        flag.Conditional = (row.Cells[0].Value == null ? "" : row.Cells[0].Value.ToString());
                        flag.Flag = (row.Cells[1].Value == null ? "" : row.Cells[1].Value.ToString());
                        flags.Add(flag);
                    }
                }
            }
            else if (dataGridView.Tag is List<BuildParameter>)
            {
                List<BuildParameter> parms = (dataGridView.Tag as List<BuildParameter>);

                parms.Clear();
                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    if (row.Cells[0].Value != null && row.Cells[1].Value != null)
                    {
                        BuildParameter parm = new BuildParameter();
                        parm.Parameter   = (string)row.Cells[0].Value;
                        parm.Action      = (string)row.Cells[1].Value;
                        parm.Description = (string)row.Cells[2].Value;
                        parms.Add(parm);
                    }
                }
            }
            else if (dataGridView.Tag is List<MemorySymbol>)
            {
                List<MemorySymbol> msc = dataGridView.Tag as List<MemorySymbol>;

                msc.Clear();
                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    if (row.Cells[0].Value != null && row.Cells[1].Value != null)
                    {
                        MemorySymbol parm = new MemorySymbol();
                        parm.Name        = (string)row.Cells[0].Value;
                        parm.Options     = (string)row.Cells[1].Value;
                        parm.Description = (string)row.Cells[2].Value;
                        parm.Conditional = (string)row.Cells[3].Value;
                        msc.Add(parm);
                    }
                }
            }
            else if (dataGridView.Tag is List<BuildScript>)
            {
                List<BuildScript> al = dataGridView.Tag as List<BuildScript>;
                al.Clear();

                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    if (row.Cells[1].Value != null)
                    {
                        BuildScript bs = new BuildScript();
                        bs.Conditional = row.Cells[0].Value as string;
                        bs.Script = row.Cells[1].Value as string;

                        al.Add(bs);
                    }
                }
            }
            else if (dataGridView.Tag is List<ApiTemplate>)
            {
                List<ApiTemplate> al = dataGridView.Tag as List<ApiTemplate>;
                al.Clear();

                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    if (!string.IsNullOrEmpty(row.Cells[0].Value as string))
                    {
                        ApiTemplate at = new ApiTemplate();
                        at.FilePath = row.Cells[0].Value as string;
                        at.Description = row.Cells[1].Value as string;

                        al.Add(at);
                    }
                }
            }
            else if (dataGridView.Tag is MFComponent)
            {
                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    /*
                    if ((bool)row.Cells[1].Value)
                    {
                        Library lib = row.Tag as Library;
                        MFComponent comp = dataGridView.Tag as MFComponent;
                        comp.Guid = lib.Guid;
                        comp.Name = lib.Name;
                        break;
                    }
                    */
                }
            }
        }