Exemplo n.º 1
0
        public static bool NewKart(string newKartName)
        {
            if (Karts.Exists(k => k.Kart.KartName == newKartName))
            {
                return(false);
            }

            Karts.Add(new KartWrapper(new KartInfo(newKartName, null, false)));
            ChompShopAlerts.UpdateKartsLoaded();
            return(true);
        }
Exemplo n.º 2
0
        public static void CopyKart(KartWrapper kart)
        {
            int    nameCount = 1;
            string newName   = kart.Kart.KartName;

            while (Karts.Exists(k => k.Kart.KartName == newName + nameCount.ToString()))
            {
                nameCount++;
            }
            newName += nameCount.ToString();

            KartWrapper kartWrapper = new KartWrapper(kart, newName);

            Karts.Add(kartWrapper);
            ChompShopAlerts.UpdateKartsLoaded();
        }
Exemplo n.º 3
0
        private static void FinishedLoadingKarts(object sender, RunWorkerCompletedEventArgs args)
        {
            if (!args.Cancelled && args.Error == null)
            {
                //Load in the karts

                List <KartWrapper> wrappers = new List <KartWrapper>();

                List <KartInfo> karts = (List <KartInfo>)args.Result;

                foreach (KartInfo kart in karts)
                {
                    //Check to see if it exists
                    if (Karts.Exists(k => k.Kart.KartName == kart.KartName))
                    {
                        DialogResult result = MessageBox.Show("Kart \"" + kart.KartName + "\" already exists. Replace previous Kart with this Kart? Unsaved changes will be lost!",
                                                              "Name Conflict", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

                        if (result == DialogResult.Cancel)
                        {
                            //quit out of loading
                            wrappers.Clear();
                            break;
                        }
                        else if (result == DialogResult.No)
                        {
                            continue;
                        }
                        else //Yes
                        {
                            //Remove the kart from the list here
                            Karts.Remove(Karts.Single(k => k.Kart.KartName == kart.KartName));
                        }
                    }

                    wrappers.Add(new KartWrapper(kart));
                }

                if (wrappers.Count > 0)
                {
                    Karts.AddRange(wrappers);
                    ChompShopAlerts.UpdateKartsLoaded();
                }
            }

            Pitstop64.Services.ProgressService.StopDialog();
        }