public Library FindLibrary(MFComponent comp)
        {
            if (comp.ComponentType != MFComponentType.Library)
            {
                return(null);
            }

            Library l = FindLibrary(comp.Guid);

            if (l == null)
            {
                l = FindLibraryByProject(comp.ProjectPath);
            }
            if (l == null)
            {
                l = FindLibraryByFile(comp.Name + ".$(LIB_EXT)");
            }

            // some components are delay loaded, so fill in the data if need be
            if (l != null && (0 != string.Compare(comp.Guid, l.Guid, true)))
            {
                comp.Guid        = l.Guid;
                comp.Name        = l.Name;
                comp.ProjectPath = l.ProjectPath;
            }

            return(l);
        }
Example #2
0
        private void tv_LibraryView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            MFComponent ctn = e.Node.Tag as MFComponent;

            if (ctn != null)
            {
                DisplayDescription(ctn, rtb_LibraryDescription);

                cbLibraryCond.SelectedIndex = (int)ConvertConditionStringToIndex(ctn.Conditional);

                if (cbLibraryCond.SelectedIndex == 0)
                {
                    if (!string.IsNullOrEmpty(ctn.Conditional))
                    {
                        cbLibraryCond.Text = ctn.Conditional;
                    }
                    else
                    {
                        cbLibraryCond.Text = "";
                    }
                }
            }
            else
            {
                DisplayDescription(null, rtb_LibraryDescription);
            }
        }
Example #3
0
        private void tv_LibraryView_AfterCheck(object sender, TreeViewEventArgs e)
        {
            MFComponent      ctn = e.Node.Tag as MFComponent;
            ProjectComboData pcd = cbProjectSelect_Library.SelectedItem as ProjectComboData;

            if (ctn != null && ctn.ComponentType == MFComponentType.Library)
            {
                if (e.Node.Parent != null && e.Node.Checked)
                {
                    foreach (TreeNode sib in e.Node.Parent.Nodes)
                    {
                        if (sib != e.Node)
                        {
                            MFComponent ctnSib = sib.Tag as MFComponent;

                            if (sib.Checked && string.IsNullOrEmpty(ctnSib.Conditional))
                            {
                                sib.Checked = false;
                            }
                        }
                    }
                }

                ApplyToAllProjects(pcd, ctn, e.Node.Checked);

                if (e.Node.Checked && e.Node.Parent != null)
                {
                    e.Node.Parent.Checked = true;
                }
            }

            //
            // Checking the root node will cause all "Generate Template" nodes to be checked.
            //
            if (e.Node.Parent == null)
            {
                foreach (TreeNode child in e.Node.Nodes)
                {
                    foreach (TreeNode sib in child.Nodes)
                    {
                        MFComponent ctnSib = sib.Tag as MFComponent;

                        if (ctnSib.Name == c_GenerateTemplateString)
                        {
                            if (sib.Checked != e.Node.Checked)
                            {
                                sib.Checked = e.Node.Checked;

                                ctn = sib.Tag as MFComponent;

                                ApplyToAllProjects(pcd, ctn, e.Node.Checked);
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        private void cbLibraryCond_SelectedIndexCommitted(object sender, EventArgs e)
        {
            if (tv_LibraryView.SelectedNode == null)
            {
                return;
            }

            string cond = cbLibraryCond.Text;

            if (cbLibraryCond.SelectedIndex != -1)
            {
                cond = ConvertConditionIndexToString((ConditionIndex)cbLibraryCond.SelectedIndex);
            }

            MFComponent tnd = tv_LibraryView.SelectedNode.Tag as MFComponent;

            if (tnd != null)
            {
                tnd.Conditional = cond;

                if (cbProjectSelect_Library.SelectedItem == m_pcdAll)
                {
                    foreach (ProjectComboData pcd in cbProjectSelect_Library.Items)
                    {
                        if (pcd == m_pcdAll)
                        {
                            continue;
                        }

                        int idx = pcd.Proj.Libraries.IndexOf(tnd);

                        if (idx >= 0)
                        {
                            pcd.Proj.Libraries[idx].Conditional = cond;
                        }
                    }
                }
                else
                {
                    ProjectComboData pcd = cbProjectSelect_Library.SelectedItem as ProjectComboData;

                    if (pcd != null)
                    {
                        int idx = pcd.Proj.Libraries.IndexOf(tnd);

                        if (idx >= 0)
                        {
                            pcd.Proj.Libraries[idx].Conditional = cond;
                        }
                    }
                }
            }
        }
Example #5
0
        private void UpdateProjectDependencies(ProjectComboData pcd, List <LibraryCategory> unresolvedItems, List <LibraryCategory> removedItems)
        {
            bool fReanalyze = true;
            int  retries    = 20;

            List <TreeNode> nodeList = new List <TreeNode>();

            Dictionary <string, MFComponent> resolveMap = new Dictionary <string, MFComponent>();

            while (fReanalyze && retries-- > 0)
            {
                unresolvedItems.Clear();
                removedItems.Clear();

                //LoadProjectLibraryData(pcd, m_pcdAll, true);
                pcd.Proj.AnalyzeLibraries(m_helper, m_solution, unresolvedItems, removedItems);

                fReanalyze = (removedItems.Count > 0);

                foreach (LibraryCategory lc in unresolvedItems)
                {
                    if (!resolveMap.ContainsKey(lc.Guid))
                    {
                        AddGenerateTemplateNode(pcd, lc);

                        Library sel = AutoSelectLibrary(pcd, lc);

                        if (sel != null)
                        {
                            fReanalyze = true;

                            MFComponent cmpNew = new MFComponent(MFComponentType.Library, sel.Name, sel.Guid, sel.ProjectPath);

                            resolveMap[lc.Guid] = cmpNew;

                            ApplyToProject(pcd, cmpNew, true, unresolvedItems, removedItems);
                        }
                    }
                    else
                    {
                        ApplyToProject(pcd, resolveMap[lc.Guid], true, unresolvedItems, removedItems);
                    }
                }
            }
        }
Example #6
0
        private void UpdateFeatureSelections(ProjectComboData pcd)
        {
            TreeNode root = tv_FeatureView.Nodes[0];

            Dictionary <string, MFComponent> featList = new Dictionary <string, MFComponent>();

            foreach (MFComponent cmp in pcd.Proj.Features)
            {
                featList[cmp.Guid.ToLower()] = cmp;
            }

            Dictionary <TreeNode, bool> nodesToUpdate = new Dictionary <TreeNode, bool>();

            foreach (TreeNode tn in root.Nodes)
            {
                if (tn != null)
                {
                    MFComponent c = tn.Tag as MFComponent;

                    if (featList.ContainsKey(c.Guid.ToLower()))
                    {
                        if (!tn.Checked)
                        {
                            nodesToUpdate[tn] = true;
                        }
                    }
                    else
                    {
                        if (tn.Checked)
                        {
                            nodesToUpdate[tn] = false;
                        }
                    }
                }
            }

            System.Threading.Interlocked.Increment(ref m_CheckRefCount);
            foreach (TreeNode tn in nodesToUpdate.Keys)
            {
                tn.Checked = nodesToUpdate[tn];
            }
            System.Threading.Interlocked.Decrement(ref m_CheckRefCount);
        }
Example #7
0
        /// <summary>
        /// Apply user "check/uncheck" to all project nodes if "All Projects" is selected, otherwise
        /// just to the selected project.
        /// </summary>
        /// <param name="pcdAll"></param>
        /// <param name="compGuid"></param>
        /// <param name="fAdd"></param>
        private void ApplyToAllProjects(ProjectComboData pcd, MFComponent comp, bool fCheck)
        {
            ApplyToProject(pcd, comp, fCheck, null, null);

            if (pcd == m_pcdAll)
            {
                foreach (ProjectComboData pcd2 in cbProjectSelect_Library.Items)
                {
                    if (pcd2 != pcd)
                    {
                        // change the component to a bootloader component if it exists
                        if (pcd2.Proj.IsBootloaderProject())
                        {
                            Library lib = m_helper.FindLibrary(comp);

                            if (lib != null && lib.HasLibraryCategory)
                            {
                                LibraryCategory lc = m_helper.FindLibraryCategory(lib.LibraryCategory.Guid);

                                if (lc != null)
                                {
                                    foreach (Library li in m_helper.GetLibrariesOfType(lc))
                                    {
                                        if (li.IsBootloaderLibrary())
                                        {
                                            comp = new MFComponent(MFComponentType.Library, li.Name, li.Guid, li.ProjectPath, comp.Conditional);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        ApplyToProject(pcd2, comp, fCheck, null, null);
                    }
                }
            }
            else if (pcd.Name.ToLower() == "tinyclr")
            {
                ApplyToProject(m_pcdAll, comp, fCheck, null, null);
            }
        }
Example #8
0
        /// <summary>
        /// Find a feature node in the feature view tree from the given root node (recursive)
        /// </summary>
        /// <param name="feature"></param>
        /// <param name="root"></param>
        /// <returns></returns>
        TreeNode FindFeatureNode(MFComponent feature, TreeNode root)
        {
            ComponentTreeNode ctn = root.Tag as ComponentTreeNode;

            if (ctn != null && (string.Compare(ctn.Comp.Guid, feature.Guid, true) == 0))
            {
                return(root);
            }

            foreach (TreeNode tn in root.Nodes)
            {
                TreeNode found = FindFeatureNode(feature, tn);

                if (found != null)
                {
                    return(found);
                }
            }

            return(null);
        }
Example #9
0
        private void ApplyToProject(ProjectComboData pcd, MFComponent comp, bool fCheck, List <LibraryCategory> unresolvedItems, List <LibraryCategory> removedItems)
        {
            bool fActiveProj = (cbProjectSelect_Library.SelectedItem == pcd);

            bool fContainsLib = pcd.Proj.Libraries.Contains(comp);

            if (fCheck)
            {
                if (fContainsLib && pcd != m_pcdAll)
                {
                    return;
                }
                pcd.Proj.Libraries.Add(comp);
            }
            else
            {
                if (!fContainsLib && pcd != m_pcdAll)
                {
                    return;
                }
                pcd.Proj.RemoveLibrary(comp);
            }

            if (unresolvedItems == null || removedItems == null)
            {
                unresolvedItems = new List <LibraryCategory>();
                removedItems    = new List <LibraryCategory>();

                pcd.Proj.AnalyzeLibraries(m_helper, m_solution, unresolvedItems, removedItems);
            }

            if (fActiveProj && tv_LibraryView.Nodes.Count > 0)
            {
                if (fCheck)
                {
                    foreach (LibraryCategory lc in unresolvedItems)
                    {
                        if (tv_LibraryView.Nodes.Find(lc.Guid.ToLower(), true).Length == 0)
                        {
                            AddGenerateTemplateNode(pcd, lc);

                            Library sel = AutoSelectLibrary(pcd, lc);

                            TreeNode lcNode = tv_LibraryView.Nodes[0].Nodes.Add(lc.Guid.ToLower(), lc.Name);
                            lcNode.Tag = new MFComponent(MFComponentType.LibraryCategory, lc.Name, lc.Guid, lc.ProjectPath);

                            foreach (Library lib in m_helper.GetLibrariesOfType(lc, pcd.Proj, m_solution))
                            {
                                if (pcd.Proj.ValidateLibrary(lib, m_solution, m_solutionProc, m_helper))
                                {
                                    TreeNode tnLib = lcNode.Nodes.Add(lib.Guid.ToLower(), lib.Name);
                                    tnLib.Tag = new MFComponent(MFComponentType.Library, lib.Name, lib.Guid, lib.ProjectPath);

                                    if (sel == lib)
                                    {
                                        tnLib.Checked = true;
                                    }
                                }
                            }

                            lcNode.Expand();
                        }
                    }
                }
                else
                {
                    foreach (LibraryCategory lc in removedItems)
                    {
                        TreeNode[] nds = tv_LibraryView.Nodes.Find(lc.Guid.ToLower(), true);
                        if (nds.Length > 0)
                        {
                            nds[0].Remove();
                        }
                    }
                }
            }
        }
Example #10
0
 internal TemplateGenerationData(LibraryCategory lc, MFComponent cmp)
 {
     LibraryCat = lc;
     Comp       = cmp;
 }
Example #11
0
        private void tv_FeatureView_AfterCheck(object sender, TreeViewEventArgs e)
        {
            ProjectComboData pcd  = cbProjectSelect_Feature.SelectedItem as ProjectComboData;
            MFComponent      feat = e.Node.Tag as MFComponent;
            TreeNode         root = tv_FeatureView.Nodes[0];

            if (feat != null)
            {
                List <TreeNode> updateNodes = new List <TreeNode>();

                if (e.Node == root)
                {
                    foreach (TreeNode tn in root.Nodes)
                    {
                        updateNodes.Add(tn);
                    }
                }
                else
                {
                    updateNodes.Add(e.Node);
                }

                foreach (TreeNode tn in updateNodes)
                {
                    if (tn.Checked != e.Node.Checked || tn == e.Node)
                    {
                        if (tn.Checked != e.Node.Checked)
                        {
                            tn.Checked = e.Node.Checked;
                        }

                        if (pcd != null)
                        {
                            if (e.Node.Checked)
                            {
                                pcd.Proj.Features.Add(new MFComponent(MFComponentType.Feature, feat.Name, feat.Guid, feat.ProjectPath));
                            }
                            else
                            {
                                Feature f = m_helper.FindFeature(feat.Guid);

                                Dictionary <string, MFComponent> dependants = f.GetDependants(m_helper);

                                dependants[feat.Guid.ToLower()] = feat;

                                List <MFComponent> remFeatures = new List <MFComponent>();
                                foreach (MFComponent fCmp in pcd.Proj.Features)
                                {
                                    if (dependants.ContainsKey(fCmp.Guid.ToLower()))
                                    {
                                        remFeatures.Add(fCmp);
                                    }
                                }

                                foreach (MFComponent cmpFeat in remFeatures)
                                {
                                    pcd.Proj.Features.Remove(cmpFeat);
                                }
                            }
                        }
                    }
                }

                if (m_CheckRefCount == 0)
                {
                    pcd.Proj.AnalyzeFeatures(m_helper);

                    System.Threading.Interlocked.Increment(ref m_CheckRefCount);

                    UpdateFeatureSelections(pcd);

                    System.Threading.Interlocked.Decrement(ref m_CheckRefCount);
                }

                return;
            }
        }