/// <summary>
        /// Determines which version is greater, if left (-1) or right (+1). Returns 0 if unknown or equal
        /// </summary>
        public static int Compare(string leftId, string rightId, MinecraftVersions versions)
        {
            bool leftEquals  = false;
            bool rightEquals = false;

            for (int i = 0; i < versions.Versions.Length; i++)
            {
                leftEquals  = versions.Versions[i].ID.Equals(leftId);
                rightEquals = versions.Versions[i].ID.Equals(rightId);

                if (leftEquals && rightEquals)
                {
                    return(0);
                }

                if (leftEquals)
                {
                    return(-1);
                }

                if (rightEquals)
                {
                    return(1);
                }
            }

            return(0);
        }
예제 #2
0
        void CheckIfNewIsAvailable()
        {
            if (current == null || latest == null)
            {
                return;
            }

            var releaseComparision = MinecraftVersions.Compare(
                current.ID, latest.Release, selectJarPage.MinecraftVersions);

            var snapshotComparision = MinecraftVersions.Compare(
                current.ID, latest.Snapshot, selectJarPage.MinecraftVersions);

            if (releaseComparision > 0)
            {
                canUpgradeBlock.Text = Res.GetStr("higherVersionAvailable");
            }

            else if (snapshotComparision > 0)
            {
                canUpgradeBlock.Text = Res.GetStr("higherSnapshotAvailable");
            }

            else
            {
                canUpgradeBlock.Text = Res.GetStr("noHigherAvailable");
            }
        }
        async void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            MinecraftVersions = await MinecraftVersions.GetLatests();

            reloadVersions();

            onListUpdatedEventHandler(MinecraftVersions.Latest);
        }