public void SetCurrentSkin(SkinInfo skin) { foreach (var item in _skins) { if (item.GetName().Equals(skin.GetName())) { // skin found, apply it SkinsListBox.SelectedIndex = SkinsListBox.FindString(item.GetName()); } } }
private bool RemoveSelectedSkin(SkinLink skin) { try { File.Delete(skin.Path); SkinsListBox.Items.RemoveAt(SkinsListBox.SelectedIndex); SkinsListBox.SelectedIndex = 0; SkinsListBox.Invalidate(); EnvironmentalVeriables.Skins.Remove(skin); return(true); } catch (Exception e) { MessageBox.Show("Can not remove selected skin!", "File error", MessageBoxButtons.OK, MessageBoxIcon.Error); logger.Log("Error", e.ToString()); return(false); } }
private Task PackFolderIntoSkin(string directory) { return(Task.Run(() => { lock (skinPackager) { AudiosurfSkin skin = skinPackager.CreateSkinFromFolder(directory); if (skin == null) { MessageBox.Show($"Error during packaging {directory} into audiosurf skin. Please, Check selected folder", "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBox.Show("Do you want to name new skin?", "new skin", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { new OpenNewSkinForm().ShowDialog(); skin.Name = EnvironmentalVeriables.TempSkinName; } else { string name = new DirectoryInfo(directory).Name; foreach (var skinName in EnvironmentalVeriables.Skins.Select(x => x.Name)) { if (name == skinName) { MessageBox.Show("Skin with same name already exist! Enter new name for this skin", "Naming Error", MessageBoxButtons.OK, MessageBoxIcon.Error); new OpenNewSkinForm().ShowDialog(); name = EnvironmentalVeriables.TempSkinName; break; } } skin.Name = name; } skinPackager.CompileTo(skin, "Skins"); var link = new SkinLink(@"Skins\" + skin.Name + SkinPackager.skinExtension, skin.Name); EnvironmentalVeriables.Skins.Add(link); SkinsListBox.Invoke(new Action(() => SkinsListBox.Items.Add(link))); DrawPreviewOfSkin(link); currentSkin = skin; } })); }
private void LoadSkins(string[] files, bool reload = false) { progressBar1.Invoke(new Action(() => progressBar1.Value = progressBar1.Minimum)); if (reload) { EnvironmentalVeriables.Skins.Clear(); SkinsListBox.Invoke(new Action(() => SkinsListBox.Items.Clear())); } var progBarPart = progressBar1.Maximum / files.Length; foreach (var path in files) { if (new FileInfo(path).Extension != ".askin") { continue; } AudiosurfSkin skin = skinPackager.Decompile(path); if (skin == null) { return; } var tempLink = new SkinLink(path, skin.Name); loadingSkinNameLabel.Invoke(new Action(() => loadingSkinNameLabel.Text = tempLink.Name)); progressBar1.Invoke(new Action(() => progressBar1.Value += progBarPart)); EnvironmentalVeriables.Skins.Add(tempLink); SkinsListBox.Invoke(new Action(() => SkinsListBox.Items.Add(tempLink))); } if (SkinsListBox.Items.Count == 0) { return; } progressBar1.Invoke(new Action(() => progressBar1.Value = progressBar1.Maximum)); SkinsListBox.SetProperty(() => SkinsListBox.SelectedIndex, 0); SkinsListBox.Invoke(new Action(() => SkinsListBox.Invalidate())); loadingSkinNameLabel.Invoke(new Action(() => loadingSkinNameLabel.Text = "Complete")); }