Ejemplo n.º 1
0
        private void btnSaveVariant_Click(Button sender)
        {
            VariantSaveWindow vsw = new VariantSaveWindow(variantCost, variant, (AKunit)spawner.Spawned);

            vsw.SaveVariant += new VariantSaveWindow.OnSaveVariant(vsw_SaveVariant);
            Controls.Add(vsw);
        }
Ejemplo n.º 2
0
        private void vsw_SaveVariant(VariantSaveWindow sender, string saveName, TextBlock variant)
        {
            BackgroundWorker bgwBuyVariant = new BackgroundWorker();

            bgwBuyVariant.DoWork             += new DoWorkEventHandler(bgwBuyVariant_DoWork);
            bgwBuyVariant.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgwBuyVariant_RunWorkerCompleted);

            string fullFileName = saveName + ".var";
            string saveDir      = string.Format("{0}\\Variants\\{1}", VirtualFileSystem.UserDirectoryPath,
                                                spawner.Spawned.Type.Name);

            if (!Directory.Exists(saveDir))
            {
                Directory.CreateDirectory(saveDir);
            }

            string[] variantsInDir = Directory.GetFiles(saveDir);

            bool alreadyExists = false;

            foreach (string fileName in variantsInDir)
            {
                if (fileName == fullFileName)
                {
                    alreadyExists = true;
                }
            }

            if (alreadyExists)
            {
                sender.txtInfo.Text = "File already exists";
                return;
            }

            bgwBuyVariant.RunWorkerAsync(new string[] { fullFileName, saveDir });

            sender.SetShouldDetach();
        }
        private void vsw_SaveVariant(VariantSaveWindow sender, string saveName, TextBlock variant)
        {
            BackgroundWorker bgwBuyVariant = new BackgroundWorker();
            bgwBuyVariant.DoWork += new DoWorkEventHandler(bgwBuyVariant_DoWork);
            bgwBuyVariant.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgwBuyVariant_RunWorkerCompleted);

            string fullFileName = saveName + ".var";
            string saveDir = string.Format("{0}\\Variants\\{1}", VirtualFileSystem.UserDirectoryPath,
                spawner.Spawned.Type.Name);

            if (!Directory.Exists(saveDir))
                Directory.CreateDirectory(saveDir);

            string[] variantsInDir = Directory.GetFiles(saveDir);

            bool alreadyExists = false;
            foreach (string fileName in variantsInDir)
            {
                if (fileName == fullFileName)
                    alreadyExists = true;
            }

            if (alreadyExists)
            {
                sender.txtInfo.Text = "File already exists";
                return;
            }

            bgwBuyVariant.RunWorkerAsync(new string[] { fullFileName, saveDir });

            sender.SetShouldDetach();
        }
 private void btnSaveVariant_Click(Button sender)
 {
     VariantSaveWindow vsw = new VariantSaveWindow(variantCost, variant, (AKunit)spawner.Spawned);
     vsw.SaveVariant += new VariantSaveWindow.OnSaveVariant(vsw_SaveVariant);
     Controls.Add(vsw);
 }