Пример #1
0
 internal static InlineMessage CreateVersionNotRegisteredState(Mainboard board, string version, bool multipleChoices, Hyperlink details)
 {
     if (multipleChoices)
     {
         if (IsLink(board.HelpUrl))
         {
             return(new InlineMessage(InlineSeverity.Error, "This mainboard was not installed correctly into .NET Micro Framework ", version, ". Check the ", Link("manufacturer-provided help", board.HelpUrl), " or contact the manufacturer. ", details));
         }
         else
         {
             return(new InlineMessage(InlineSeverity.Error, "This mainboard was not installed correctly into .NET Micro Framework ", version, ". Please contact the manufacturer. ", details));
         }
     }
     else
     {
         if (IsLink(board.HelpUrl))
         {
             return(new InlineMessage(InlineSeverity.Error, "This mainboard was not installed correctly. Check the ", Link("manufacturer-provided help", board.HelpUrl), " or contact the manufacturer. ", details));
         }
         else
         {
             return(new InlineMessage(InlineSeverity.Error, "This mainboard was not installed correctly. Please contact the manufacturer. ", details));
         }
     }
 }
Пример #2
0
        private static bool MeetsMinimumGadgeteerCoreVersion(Mainboard board, string selectedVersion)
        {
            Version minimumCoreVersion;

            if (!Version.TryParse(board.MinimumCoreVersion, out minimumCoreVersion))
            {
                return(false);
            }

            Version coreVersion;

            if (!CoreVersions.TryGetValue(selectedVersion, out coreVersion))
            {
                string path = Gadgeteer.GetAssembliesPath("v" + selectedVersion);
                if (path == null)
                {
                    coreVersion = new Version();
                }
                else
                {
                    path = Path.Combine(path, CoreAssemblyFileName);

                    try
                    {
                        FileVersionInfo coreInfo = FileVersionInfo.GetVersionInfo(path);
                        coreVersion = new Version(coreInfo.FileVersion);
                    }
                    catch { coreVersion = new Version(); }
                }

                CoreVersions[selectedVersion] = coreVersion;
            }

            return(coreVersion >= minimumCoreVersion);
        }
Пример #3
0
        private static void SelectVersionFor(Mainboard board, ref string selectedVersion, string projectType)
        {
            if (board.Type == Gadgeteer.LastUsedMainboardType)
            {
                string lastUsedVersion = Gadgeteer.GetLastUsedMicroFrameworkVersionForMainboard(board.Type);
                if (board.SupportedVersions.Contains(lastUsedVersion))
                {
                    selectedVersion = lastUsedVersion;
                    return;
                }
            }

            if (board.AvailableVersions.Length < 1)
            {
                selectedVersion = board.SupportedVersions.FirstOrDefault();
            }
            else
            {
                foreach (string availableVersion in board.AvailableVersions)
                {
                    if (MeetsProjectType(availableVersion, projectType) &&
                        MeetsMinimumGadgeteerCoreVersion(board, availableVersion))
                    {
                        selectedVersion = availableVersion;
                        return;
                    }
                }

                selectedVersion = board.AvailableVersions.FirstOrDefault();
            }
        }
Пример #4
0
        private static InlineMessage InlineStateForVersion(Mainboard board, string selectedVersion, string projectType)
        {
            bool multipleChoices = board.SupportedVersions.Length > 1;

            if (board.AvailableVersions.Contains(selectedVersion))
            {
                if (MeetsMinimumGadgeteerCoreVersion(board, selectedVersion))
                {
                    if (MeetsProjectType(selectedVersion, projectType))
                    {
                        return(CreateVersionInstalledState(board, selectedVersion, multipleChoices));
                    }
                    else
                    {
                        return(CreateProjectTypeMismatchState(selectedVersion, projectType, multipleChoices));
                    }
                }
                else
                {
                    return(CreateCoreRequiredState(board));
                }
            }
            else
            {
                return(CreateVersionNotInstalledState(board, selectedVersion, multipleChoices));
            }
        }
Пример #5
0
        internal static InlineMessage InlineStateFor(Mainboard board, ref string selectedVersion, string projectType)
        {
            if (board == null)
            {
                return(null);
            }

            if (board.HasDefinitionErrors)
            {
                return(CreateInvalidXmlState(board));
            }

            if (board.SupportedVersions.Length < 1)
            {
                return(CreateInvalidXmlState(board));
            }

            if (board.SupportedVersions.Length == 1)
            {
                selectedVersion = board.SupportedVersions[0];
            }
            else if (selectedVersion == null)
            {
                SelectVersionFor(board, ref selectedVersion, projectType);
            }

            return(InlineStateForVersion(board, selectedVersion, projectType));
        }
Пример #6
0
        private void OnBoardFound(Mainboard board)
        {
            _mainboards.Add(board);

            if (SelectedMainboard == null && board.Type == _lastUsedMainboardType)
            {
                SelectedMainboard = board;
            }
        }
Пример #7
0
 private static InlineMessage CreateVersionNotInstalledState(Mainboard board, string version, bool multipleChoices)
 {
     if (multipleChoices)
     {
         return(new InlineMessage(InlineSeverity.Error, "This .NET Micro Framework version is not installed. You can download it at ", Link("http://netmf.codeplex.com/", "http://netmf.codeplex.com/releases/"), "."));
     }
     else
     {
         return(new InlineMessage(InlineSeverity.Error, "This mainboard supports .NET Micro Framework ", version, " only, which is not installed. You can download it at ", Link("http://netmf.codeplex.com/", "http://netmf.codeplex.com/releases/"), "."));
     }
 }
Пример #8
0
 private static InlineMessage CreateInvalidXmlState(Mainboard board)
 {
     if (IsLink(board.HelpUrl))
     {
         return(new InlineMessage(InlineSeverity.Error, "This mainboard’s software has errors preventing it from being used by .NET Gadgeteer. Check the ", Link("manufacturer-provided help", board.HelpUrl), " or contact the manufacturer."));
     }
     else
     {
         return(new InlineMessage(InlineSeverity.Error, "This mainboard’s software has errors preventing it from being used by .NET Gadgeteer. Please contact the manufacturer."));
     }
 }
Пример #9
0
        private bool?MeetsAssemblyRegistration(Mainboard board, string selectedVersion)
        {
            if (_registeredAssemblies == null)
            {
                return(null);
            }

            List <string> assemblies;

            if (!_registeredAssemblies.TryGetValue("v" + selectedVersion, out assemblies))
            {
                return(_registeredAssembliesEnumerated ? true : (bool?)null);
            }

            return(board.Assemblies.Where(a => a.Version == selectedVersion).All(a => assemblies.BinarySearch(a.Name, StringComparer.OrdinalIgnoreCase) >= 0));
        }
Пример #10
0
 private static InlineMessage CreateVersionInstalledState(Mainboard board, string version, bool multipleChoices)
 {
     if (multipleChoices)
     {
         return(null); // go ahead without warning
     }
     else
     {
         if (IsLink(board.HelpUrl))
         {
             return(new InlineMessage(InlineSeverity.Information, "The project will target .NET Micro Framework ", version, ". If you expect a different version, check the ", Link("manufacturer-provided help", board.HelpUrl), " or contact the manufacturer."));
         }
         else
         {
             return(new InlineMessage(InlineSeverity.Information, "The project will target .NET Micro Framework ", version, ". If you expect a different version, contact the manufacturer."));
         }
     }
 }
Пример #11
0
 private static InlineMessage CreateCoreRequiredState(Mainboard board)
 {
     return(new InlineMessage(InlineSeverity.Error, "This mainboard requires .NET Gadgeteer Core version ", board.MinimumCoreVersion, " or newer. Download the latest version at ", Link("http://gadgeteer.codeplex.com/", "http://gadgeteer.codeplex.com/releases"), "."));
 }