Skip to content

Commit

Permalink
Updated requirements message.
Browse files Browse the repository at this point in the history
  • Loading branch information
kike-garbo committed Aug 27, 2024
1 parent ccadbce commit a7c44d1
Showing 1 changed file with 64 additions and 60 deletions.
124 changes: 64 additions & 60 deletions src/RhinoInside.Revit.Loader/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a7c44d1

Please sign in to comment.