Skip to content

Commit

Permalink
Merge pull request #1151 from mcneel/1.23
Browse files Browse the repository at this point in the history
Added a message when no Rhino is available.
  • Loading branch information
kike-garbo authored Jul 18, 2024
2 parents 4abdd8a + 5ebcbfd commit d29a327
Showing 1 changed file with 67 additions and 30 deletions.
97 changes: 67 additions & 30 deletions src/RhinoInside.Revit.Loader/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ Result IExternalApplication.OnStartup(UIControlledApplication controlledApplicat
catch { }
}

return _ExternalApplication?.OnStartup(controlledApplication) ?? Result.Failed;
return _ExternalApplication?.OnStartup(controlledApplication) ?? Result.Cancelled;
}

Result IExternalApplication.OnShutdown(UIControlledApplication controlledApplication)
{
return _ExternalApplication?.OnShutdown(controlledApplication) ?? Result.Failed;
return _ExternalApplication?.OnShutdown(controlledApplication) ?? Result.Cancelled;
}

static Distribution PickDistribution()
Expand All @@ -61,40 +61,77 @@ static Distribution PickDistribution()

var currentKey = Distribution.CurrentKey;
var available = distributions.Where(x => x.Available && (currentKey is null || x.RegistryKey == currentKey)).ToArray();
if (available.Length == 0) return distributions[0];
if (available.Length == 1) return available[0];

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"
}
)
switch (available.Length)
{
for (int d = 0; d < 4 && d < available.Length; d++)
{
var distribution = available[d];
taskDialog.AddCommandLink
case 0:
using
(
TaskDialogCommandLinkId.CommandLink1 + d,
distribution.VersionInfo.FileDescription,
$"{distribution.ExeVersion()}"
);
}
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)
{
try
{
Process.Start(new ProcessStartInfo($@"https://www.rhino3d.com/download/rhino/")
{
UseShellExecute = true,
WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
});
}
catch { }
}
}

break;

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 < available.Length; 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];
if (TaskDialogResult.CommandLink1 <= result && result <= TaskDialogResult.CommandLink4)
return available[result - TaskDialogResult.CommandLink1];
}
break;
}

return null;
Expand Down

0 comments on commit d29a327

Please sign in to comment.