Beispiel #1
0
        private int addVersionDisplay()
        {
            int boxLeft        = Console.WindowWidth / 2 + 1,
                boxTop         = 3;
            const int boxRight = -1,
                      boxH     = 5;

            if (ChangePlan.IsAnyAvailable(registry, mod.identifier))
            {
                List <CkanModule> avail  = registry.AllAvailable(mod.identifier);
                CkanModule        inst   = registry.GetInstalledVersion(mod.identifier);
                CkanModule        latest = registry.LatestAvailable(mod.identifier, null);
                bool installed           = registry.IsInstalled(mod.identifier, false);
                bool latestIsInstalled   = inst?.Equals(latest) ?? false;
                List <CkanModule> others = avail;

                others.Remove(inst);
                others.Remove(latest);

                if (installed)
                {
                    DateTime?instTime = InstalledOn(mod.identifier);

                    if (latestIsInstalled)
                    {
                        addVersionBox(
                            boxLeft, boxTop, boxRight, boxTop + boxH - 1,
                            () => $"Latest/Installed {instTime?.ToString("d") ?? "manually"}",
                            () => ConsoleTheme.Current.ActiveFrameFg,
                            true,
                            new List <CkanModule>()
                        {
                            inst
                        }
                            );
                        boxTop += boxH;
                    }
                    else
                    {
                        addVersionBox(
                            boxLeft, boxTop, boxRight, boxTop + boxH - 1,
                            () => "Latest Version",
                            () => ConsoleTheme.Current.AlertFrameFg,
                            false,
                            new List <CkanModule>()
                        {
                            latest
                        }
                            );
                        boxTop += boxH;

                        addVersionBox(
                            boxLeft, boxTop, boxRight, boxTop + boxH - 1,
                            () => $"Installed {instTime?.ToString("d") ?? "manually"}",
                            () => ConsoleTheme.Current.ActiveFrameFg,
                            true,
                            new List <CkanModule>()
                        {
                            inst
                        }
                            );
                        boxTop += boxH;
                    }
                }
                else
                {
                    addVersionBox(
                        boxLeft, boxTop, boxRight, boxTop + boxH - 1,
                        () => "Latest Version",
                        () => ConsoleTheme.Current.NormalFrameFg,
                        false,
                        new List <CkanModule>()
                    {
                        latest
                    }
                        );
                    boxTop += boxH;
                }

                if (others.Count > 0)
                {
                    addVersionBox(
                        boxLeft, boxTop, boxRight, boxTop + boxH - 1,
                        () => "Other Versions",
                        () => ConsoleTheme.Current.NormalFrameFg,
                        false,
                        others
                        );
                    boxTop += boxH;
                }
            }
            else
            {
                DateTime?instTime = InstalledOn(mod.identifier);
                // Mod is no longer indexed, but we can generate a display
                // of the old info about it from when we installed it
                addVersionBox(
                    boxLeft, boxTop, boxRight, boxTop + boxH - 1,
                    () => $"UNAVAILABLE/Installed {instTime?.ToString("d") ?? "manually"}",
                    () => ConsoleTheme.Current.AlertFrameFg,
                    true,
                    new List <CkanModule>()
                {
                    mod
                }
                    );
                boxTop += boxH;
            }

            return(boxTop - 1);
        }