Beispiel #1
0
        void bt_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (changingVersion)
            {
                MessageBox.ShowDialog("Warning", "The version is currently being changed/downloaded! Cannot change now!");
            }
            else
            {
                ChangeMCVersion cv = new ChangeMCVersion();
                if (cv.ShowDialog() == true)
                {
                    this.changingVersion = true;
                    TinyMinecraftVersion prevVer = this.Version;
                    this.Version = cv.version;
                    try
                    {
                        Task.Factory.StartNew(delegate
                        {
                            if (!File.Exists(cv.version.FullVersion.BinaryPath))
                            {

                                Download dl = cv.version.FullVersion.ScheduleJarDownload();
                                PluginAPI.PluginManager.onVersionDownload(dl);
                                DownloadPackage dp = new DownloadPackage("Libraries", true);
                                dp.ShouldContinue = true;
                                cv.version.FullVersion.Libraries.ForEach(l => { if (!File.Exists(l.Extractpath)) { l.ScheduleExtract(dp); } });
                                if (dp.getDownloads().Count > 0)
                                    DownloadManager.ScheduleDownload(dp);

                                dl.WaitForComplete();
                                CopyJar();
                                App.InvokeAction(delegate
                                {
                                    (App.mainWindow.listBox_instanceInfo.Items[0] as Label).Content = (this.Version == null ? "no version" : this.Version.Key);
                                    App.mainWindow.UpdateInstances();
                                });
                                this.changingVersion = false;

                            }
                            else
                            {
                                CopyJar();
                                App.InvokeAction(delegate
                                {
                                    (App.mainWindow.listBox_instanceInfo.Items[0] as Label).Content = (this.Version == null ? "no version" : this.Version.Key);
                                    App.mainWindow.UpdateInstances();
                                });
                                this.changingVersion = false;
                            }
                        });
                    }
                    catch (Exception ex)
                    {

                        MCM.Utils.MessageBox.ShowDialog("Error", "The selected version could not be changed because: " + ex.Message);
                        this.Version = prevVer;
                        (App.mainWindow.listBox_instanceInfo.Items[0] as Label).Content = (this.Version == null ? "no version" : this.Version.Key);
                        App.mainWindow.UpdateInstances();
                        this.changingVersion = false;
                    }
                }
                PluginManager.onChangeVersion(this);
            }
        }
 void bt_Click(object sender, RoutedEventArgs e)
 {
     ChangeMCVersion cmv = new ChangeMCVersion();
     if (cmv.ShowDialog() == true)
     {
         Instance instance = GetSelectedInstance();
         for (int i = 0; i < InstanceManager.instances.Count; i++)
         {
             if (InstanceManager.instances[i] == instance)
             {
                 InstanceManager.instances[i].Version = cmv.version.FullVersion;
                 (treeView_instances.SelectedItem as TreeViewItem).Header = "Minecraft version " + cmv.version.Key;
                 (treeView_instances.SelectedItem as TreeViewItem).Tag = cmv.version.FullVersion;
                 treeView_instances_SelectedItemChanged(null, null);
                 break;
             }
         }
     }
 }