diff --git a/src/RhinoInside.Revit.Loader/Loader.cs b/src/RhinoInside.Revit.Loader/Loader.cs index 864390746..95c0d70a4 100644 --- a/src/RhinoInside.Revit.Loader/Loader.cs +++ b/src/RhinoInside.Revit.Loader/Loader.cs @@ -59,79 +59,83 @@ static Distribution PickDistribution() #endif }; - var currentKey = Distribution.CurrentKey; - var available = distributions.Where(x => x.Available && (currentKey is null || x.RegistryKey == currentKey)).ToArray(); - - switch (available.Length) + var minVersion = distributions.OrderBy(x => x.MajorVersion).Select(x => x.MajorVersion).FirstOrDefault(); + if (minVersion > default(int)) { - case 0: - using - ( - var taskDialog = new TaskDialog("Install Rhino") - { - Id = $"{MethodBase.GetCurrentMethod().DeclaringType}.{MethodBase.GetCurrentMethod().Name}.InstallRhino", - MainIcon = TaskDialogIcon.TaskDialogIconWarning, - AllowCancellation = true, - MainInstruction = "Rhino is not available", - MainContent = "Rhino.Inside Revit requires Rhino 7 or 8 installed on the computer.", - CommonButtons = TaskDialogCommonButtons.Close - } - ) - { - taskDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Download Rhino…"); - if (taskDialog.Show() == TaskDialogResult.CommandLink1) + var currentKey = Distribution.CurrentKey; + var available = distributions.Where(x => x.Available && (currentKey is null || x.RegistryKey == currentKey)).ToArray(); + + switch (available.Length) + { + case 0: + using + ( + var taskDialog = new TaskDialog("Install Rhino") + { + Id = $"{MethodBase.GetCurrentMethod().DeclaringType}.{MethodBase.GetCurrentMethod().Name}.InstallRhino", + MainIcon = TaskDialogIcon.TaskDialogIconWarning, + AllowCancellation = true, + MainInstruction = "Rhino is not available", + MainContent = $"Rhino.Inside Revit requires Rhino {minVersion} or {minVersion + 1} installed on the computer.", + CommonButtons = TaskDialogCommonButtons.Close + } + ) { - try + taskDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "Download Rhino…"); + if (taskDialog.Show() == TaskDialogResult.CommandLink1) { - Process.Start(new ProcessStartInfo($@"https://www.rhino3d.com/download/rhino/") + try { - UseShellExecute = true, - WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) - }); + Process.Start(new ProcessStartInfo($@"https://www.rhino3d.com/download/rhino/") + { + UseShellExecute = true, + WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + }); + } + catch { } } - catch { } } - } - break; + break; - case 1: - return available[0]; + case 1: + return available[0]; - default: - using - ( - var taskDialog = new TaskDialog("Loading…") - { - Id = typeof(Distribution).FullName, - MainIcon = TaskDialogIcon.TaskDialogIconInformation, - TitleAutoPrefix = true, - AllowCancellation = false, - MainInstruction = "Looks like you have many supported Rhino versions installed.", - MainContent = "Please pick which one you want to use in this Revit session.", - //VerificationText = "Do not show again" - } - ) - { - for (int d = 0; d < 4 && d < Math.Min(available.Length, 4); d++) + default: + using + ( + var taskDialog = new TaskDialog("Loading…") + { + Id = typeof(Distribution).FullName, + MainIcon = TaskDialogIcon.TaskDialogIconInformation, + TitleAutoPrefix = true, + AllowCancellation = false, + MainInstruction = "Looks like you have many supported Rhino versions installed.", + MainContent = "Please pick which one you want to use in this Revit session.", + //VerificationText = "Do not show again" + } + ) { - var distribution = available[d]; - taskDialog.AddCommandLink - ( - TaskDialogCommandLinkId.CommandLink1 + d, - distribution.VersionInfo.FileDescription, - $"{distribution.ExeVersion()}" - ); - } + for (int d = 0; d < 4 && d < Math.Min(available.Length, 4); d++) + { + var distribution = available[d]; + taskDialog.AddCommandLink + ( + TaskDialogCommandLinkId.CommandLink1 + d, + distribution.VersionInfo.FileDescription, + $"{distribution.ExeVersion()}" + ); + } - taskDialog.DefaultButton = TaskDialogResult.CommandLink1; + taskDialog.DefaultButton = TaskDialogResult.CommandLink1; - var result = taskDialog.Show(); + var result = taskDialog.Show(); - if (TaskDialogResult.CommandLink1 <= result && result <= TaskDialogResult.CommandLink4) - return available[result - TaskDialogResult.CommandLink1]; - } - break; + if (TaskDialogResult.CommandLink1 <= result && result <= TaskDialogResult.CommandLink4) + return available[result - TaskDialogResult.CommandLink1]; + } + break; + } } return null;