public static string UploadFiletoFluro(HttpResponseMessage response, Elvanto.File file, string realm, string UploadURI) { byte[] downloadedfile = response.Content.ReadAsByteArrayAsync().Result; string filetype = ""; filetype = response.Content.Headers.ContentType.ToString(); Dictionary <string, object> postParameters = new Dictionary <string, object>(); SheetMusic sheet = new SheetMusic { title = file.title.Replace("/", " "), realms = new List <string>() }; sheet.realms.Add(realm); sheet.definition = "sheetMusic"; string jsonsheet = JsonConvert.SerializeObject(sheet); postParameters.Add("json", jsonsheet); postParameters.Add("?returnPopulated", true); postParameters.Add("file", new FormUpload.FileParameter(downloadedfile, FormUpload.GetFileName(file.content), filetype)); string userAgent = "Timothy's C# Migrator"; HttpWebResponse webResponse = FormUpload.MultipartFormDataPost(UploadURI, userAgent, postParameters, FluroAPIKey); StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()); string fullResponse = responseReader.ReadToEnd(); logger.Debug(fullResponse); webResponse.Close(); //need to parse the result and add it to the array Fluro.File.RootObject returnedfile = JsonConvert.DeserializeObject <Fluro.File.RootObject>(fullResponse); return(returnedfile._id); }
public async Task <IActionResult> DeleteConfirmed(int id) { var sheetMusicTutor = await _context.SheetMusicTutor.FindAsync(id); SheetMusic sm = await _context.SheetMusic.FirstOrDefaultAsync(s => s.SheetMusicId == sheetMusicTutor.SheetMusicId); sm.Amount += sheetMusicTutor.AmountLoaned; _context.SheetMusicTutor.Remove(sheetMusicTutor); await _context.SaveChangesAsync(); try { _context.Update(sm); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SheetMusicTutorExists(sheetMusicTutor.SheetMusicTutorId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, [Bind("SheetMusicId,Title,Composer,Amount")] SheetMusic sm) { SheetMusic sheetMusic = await _context.SheetMusic.FindAsync(id); sheetMusic.Amount = sm.Amount; if (id != sheetMusic.SheetMusicId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sheetMusic); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SheetMusicExists(sheetMusic.SheetMusicId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sheetMusic)); }
public static void Main(string[] argv) { if (argv.Length < 2) { Console.WriteLine("Usage: sheet input.mid output_prefix(_[page_number].png)"); return; } string filename = argv[0]; SheetMusic sheet = new SheetMusic(filename, null); int numpages = sheet.GetTotalPages(); string image_filename = argv[1]; for (int page = 1; page <= numpages; page++) { Bitmap bitmap = new Bitmap(SheetMusic.PageWidth + 40, SheetMusic.PageHeight + 40); Graphics g = Graphics.FromImage(bitmap); sheet.DoPrint(g, page); bitmap.Save(image_filename + "_" + page + ".png", System.Drawing.Imaging.ImageFormat.Png); g.Dispose(); bitmap.Dispose(); } }
private Clef clef; /** FAB: clef of this staff */ /** Create a new staff with the given list of music symbols, * and the given key signature. The clef is determined by * the clef of the first chord symbol. The track number is used * to determine whether to join this left/right vertical sides * with the staffs above and below. The SheetMusicOptions are used * to check whether to display measure numbers or not. */ public Staff(List <MusicSymbol> symbols, KeySignature key, MidiOptions options, int staffH, int tracknum, int totaltracks) { keysigWidth = SheetMusic.KeySignatureWidth(key); this.tracknum = tracknum; this.totaltracks = totaltracks; this.staffH = staffH; // FAB //showMeasures = (options.showMeasures && tracknum == 0); showMeasures = options.showMeasures; measureLength = options.time.Measure; clef = FindClef(symbols); clefsym = new ClefSymbol(clef, 0, false); keys = key.GetSymbols(clef); this.symbols = symbols; CalculateWidth(options.scrollVert); this.Height = CalculateHeight(); this.Height = staffH; CalculateStartEndTime(); FullJustify(); }
/// <summary> /// Draw the score sheetMusic on the panel pnlScrollView /// </summary> private void DrawScore() { if (sequence1 == null) { return; } Cursor = Cursors.WaitCursor; // set options options = new MidiOptions(sequence1) { scrollVert = ScrollVert, transpose = 0, key = -1, time = sequence1.Time, }; // Create object sheetMusic sheetmusic = new SheetMusic(sequence1, options, staffHeight) { Parent = pnlScrollView, }; Cursor = Cursors.Default; }
public frmNoteEdit(SheetMusic SM) { InitializeComponent(); sheetmusic = SM; sheetmusic.CurrentNoteChanged += new SheetMusic.CurrentNoteChangedEventHandler(sheetmusic_CurrentNoteChanged); sheetmusic.SelectionChanged += new SheetMusic.SelectionChangedEventHandler(sheetmusic_SelectionChanged); sheetmusic.CurrentTrackChanged += new SheetMusic.CurrentTrackChangedEventHandler(sheetmusic_TrackChanged); }
public async Task <IActionResult> Create([Bind("SheetMusicId,Title,Composer,Amount")] SheetMusic sheetMusic) { if (ModelState.IsValid) { _context.Add(sheetMusic); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sheetMusic)); }
public frmZoomDialog(SheetMusic fsheetmusic, float fzoom) { InitializeComponent(); updZoom.Value = 100; updZoom.Maximum = 400; updZoom.Minimum = 50; updZoom.Increment = 10; sheetmusic = fsheetmusic; newzoom = fzoom; updZoom.Value = Convert.ToDecimal(fzoom * 100); }
public async Task UploadSheetMusic(Composition composition, int roleId, byte[] file) { var sheetMusic = await Context.SheetMusics.FindAsync(composition.GroupId, composition.Id, roleId); if (sheetMusic == null) { sheetMusic = new SheetMusic { GroupId = composition.GroupId, CompositionId = composition.Id, RoleId = roleId }; Context.SheetMusics.Add(sheetMusic); } sheetMusic.File = file; await Context.SaveChangesAsync(); }
public static void Main(string[] argv) { if (argv.Length < 1) { Console.WriteLine("Usage: ExampleSheetMusicDLL filename.mid"); return; } string filename = argv[0]; Form form = new Form(); SheetMusic sheet = new SheetMusic(filename, null); sheet.Parent = form; form.Size = new Size(600, 400); form.AutoScroll = true; Application.Run(form); }
protected static void OnLearnComposition(Event e) { Sim sim = e.Actor as Sim; if (sim != null) { SheetMusic music = e.TargetObject as SheetMusic; if (music != null) { SheetMusic newMusic = music.Copy(false) as SheetMusic; if (newMusic != null) { Inventories.TryToMove(newMusic, sim); } } } }
public async Task <IActionResult> Create([Bind("SheetMusicTutorId,SheetMusicId,TutorId,AmountLoaned")] SheetMusicTutor sheetMusicTutor) { sheetMusicTutor.DateLoaned = DateTime.Now; SheetMusic sm = await _context.SheetMusic.FirstOrDefaultAsync(s => s.SheetMusicId == sheetMusicTutor.SheetMusicId); sm.Amount -= sheetMusicTutor.AmountLoaned; if (sm.Amount >= 0) { if (ModelState.IsValid) { _context.Update(sm); _context.Add(sheetMusicTutor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } else { ViewData["Error"] = "Not enough copies to loan. Can only loan out copies in stock."; } List <SheetMusic> sheetMusic = _context.SheetMusic.ToList(); List <SheetMusicViewModel> sms = sheetMusic.Select(s => new SheetMusicViewModel { id = s.SheetMusicId, name = s.Title + " (" + s.Composer + ") - Quantity: " + (sm.Amount += sheetMusicTutor.AmountLoaned) }).ToList(); ViewData["SheetMusic"] = new SelectList(sms, "id", "name"); List <Tutor> tutors = _context.Tutor.Include(a => a.Staff.Person).ToList(); List <TutorViewModel> t = tutors.Select(s => new TutorViewModel { id = s.TutorId, name = s.Staff.Person.FirstName + " " + s.Staff.Person.LastName }).ToList(); ViewData["Tutor"] = new SelectList(t, "id", "name"); return(View(sheetMusicTutor)); }
public async Task <IActionResult> Edit(int id, [Bind("SheetMusicTutorId,SheetMusicId,TutorId,AmountLoaned")] SheetMusicTutor smt) { SheetMusicTutor sheetMusicTutor = await _context.SheetMusicTutor.FirstOrDefaultAsync(s => s.SheetMusicTutorId == id); sheetMusicTutor.DateReturned = DateTime.Now; SheetMusic sm = await _context.SheetMusic.FirstOrDefaultAsync(s => s.SheetMusicId == sheetMusicTutor.SheetMusicId); sm.Amount += sheetMusicTutor.AmountLoaned; if (id != sheetMusicTutor.SheetMusicTutorId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sheetMusicTutor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SheetMusicTutorExists(sheetMusicTutor.SheetMusicTutorId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SheetMusicId"] = new SelectList(_context.SheetMusic, "SheetMusicId", "SheetMusicId", sheetMusicTutor.SheetMusicId); ViewData["TutorId"] = new SelectList(_context.Tutor, "TutorId", "TutorId", sheetMusicTutor.TutorId); return(View(sheetMusicTutor)); }
// GET: SheetMusicTutors/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var sheetMusicTutor = await _context.SheetMusicTutor.FindAsync(id); if (sheetMusicTutor == null) { return(NotFound()); } SheetMusic sm = await _context.SheetMusic.FirstOrDefaultAsync(s => s.SheetMusicId == sheetMusicTutor.SheetMusicId); var title = sm.Title; Tutor tutor = await _context.Tutor.Include(t => t.Staff.Person).FirstOrDefaultAsync(a => a.TutorId == sheetMusicTutor.TutorId); ViewData["SheetMusic"] = title; ViewData["name"] = tutor.Staff.Person.FirstName + " " + tutor.Staff.Person.LastName; return(View(sheetMusicTutor)); }
public static GameObject ReturnShoppingObject(RestockItem rItem, SimDescription actor, StoreSetRegister register) { GameObject o = null; bool keepLooping = true; switch (rItem.info.Type) { case ItemType.Herb: case ItemType.Ingredient: foreach (KeyValuePair <string, List <StoreItem> > kvp in Grocery.mItemDictionary) { foreach (StoreItem item in kvp.Value) { if (item.Name.Equals(rItem.info.Name)) { keepLooping = false; IngredientData data = (IngredientData)item.CustomData; if (rItem.info.Type == ItemType.Ingredient) { o = Ingredient.Create(data); } else { o = Herb.Create(data); //PlantableNonIngredientData data = (PlantableNonIngredientData)item.CustomData; //o = (GameObject)PlantableNonIngredient.Create(data); } break; } } if (!keepLooping) { break; } } break; case ItemType.Fish: o = Fish.CreateFishOfRandomWeight(rItem.info.FType); break; case ItemType.Craftable: break; case ItemType.Gem: case ItemType.Metal: o = (GameObject)RockGemMetalBase.Make(rItem.info.RockData, false); break; case ItemType.Nectar: NectarBottle bottle = (NectarBottle)GlobalFunctions.CreateObjectOutOfWorld("NectarBottle"); NectarBottleObjectInitParams nectarBottleObjectInitParams = bottle.CreateAncientBottle(rItem.info.NectarAge, rItem.info.Price); if (nectarBottleObjectInitParams != null) { bottle.mBottleInfo.FruitHash = nectarBottleObjectInitParams.FruitHash; bottle.mBottleInfo.Ingredients = nectarBottleObjectInitParams.Ingredients; bottle.mBottleInfo.Name = rItem.info.Name; //nectarBottleObjectInitParams.Name; bottle.mDateString = nectarBottleObjectInitParams.DateString; bottle.mBottleInfo.DateNum = nectarBottleObjectInitParams.DateNum; bottle.mBaseValue = rItem.info.Price; // nectarBottleObjectInitParams.BaseValue; bottle.ValueModifier = (int)(nectarBottleObjectInitParams.CurrentValue - rItem.info.Price); bottle.mBottleInfo.mCreator = nectarBottleObjectInitParams.Creator; bottle.mBottleInfo.NectarQuality = Sims3.Gameplay.Objects.Quality.Neutral; //NectarBottle.GetQuality((float)rItem.info.Price); bottle.mBottleInfo.MadeByLevel10Sim = nectarBottleObjectInitParams.MadeByLevel10Sim; bottle.UpdateVisualState(); } o = bottle; break; case ItemType.AlchemyPotion: foreach (AlchemyRecipe recipe in AlchemyRecipe.GetAllAwardPotionRecipes()) { if (rItem.info.Name.Equals(recipe.Name)) { string[] array = new string[] { recipe.Key }; AlchemyRecipe randomAwardPotionRecipe = AlchemyRecipe.GetRandomAwardPotionRecipe(); PotionShopConsignmentRegister.PotionShopConsignmentRegisterData potionShopConsignmentRegisterData = new PotionShopConsignmentRegister.PotionShopConsignmentRegisterData(); potionShopConsignmentRegisterData.mParameters = array; potionShopConsignmentRegisterData.mObjectName = randomAwardPotionRecipe.MedatorName; potionShopConsignmentRegisterData.mGuid = potionShopConsignmentRegisterData.mObjectName.GetHashCode(); potionShopConsignmentRegisterData.mSellerAge = CASAgeGenderFlags.None; potionShopConsignmentRegisterData.mWeight = 100f; potionShopConsignmentRegisterData.mSellPriceMinimum = 0.75f; potionShopConsignmentRegisterData.mSellPriceMaximum = 1.25f; potionShopConsignmentRegisterData.mDepreciationAgeMinimum = 0; potionShopConsignmentRegisterData.mDepreciationAgeMaximum = 5; potionShopConsignmentRegisterData.mLifespan = 3f; string text = string.Empty; if (!string.IsNullOrEmpty(randomAwardPotionRecipe.CustomClassName)) { text = randomAwardPotionRecipe.CustomClassName; } else { text = "Sims3.Gameplay.Objects.Alchemy.AlchemyPotion"; } potionShopConsignmentRegisterData.mScriptClass = text; potionShopConsignmentRegisterData.mIsRotatable = true; PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData potionShopConsignmentRegisterObjectData2 = PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData.Create(potionShopConsignmentRegisterData); potionShopConsignmentRegisterObjectData2.ShowTooltip = true; o = (GameObject)potionShopConsignmentRegisterObjectData2.mObject; break; } } break; case ItemType.Bug: Terrarium t = Terrarium.Create(rItem.info.BugType); if (t != null) { t.StartVfx(); } o = t; break; case ItemType.Food: int servingPrice = 25; if (register != null) { servingPrice = register.Info.ServingPrice; } IFoodContainer container = rItem.info.cookingProcess.Recipe.CreateFinishedFood(rItem.info.cookingProcess.Quantity, rItem.info.cookingProcess.Quality); if (rItem.info.cookingProcess.Quantity == Recipe.MealQuantity.Group) { ((ServingContainerGroup)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice * ((ServingContainerGroup)container).mNumServingsLeft); ((ServingContainerGroup)container).RemoveSpoilageAlarm(); } else { ((ServingContainerSingle)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice); ((ServingContainerSingle)container).RemoveSpoilageAlarm(); } o = (GameObject)container; break; case ItemType.Flowers: o = Wildflower.CreateWildflowerOfType(rItem.info.TypeOfWildFlower, Wildflower.WildflowerState.InVase); break; case ItemType.BookAlchemyRecipe_: case ItemType.BookComic_: case ItemType.BookFish_: case ItemType.BookGeneral_: case ItemType.BookRecipe_: case ItemType.BookSkill_: case ItemType.BookToddler_: case ItemType.SheetMusic_: case ItemType.AcademicTextBook_: foreach (KeyValuePair <string, List <StoreItem> > kvp in Bookstore.sItemDictionary) { foreach (StoreItem item in kvp.Value) { if (item.Name.Equals(rItem.info.Name)) { keepLooping = false; if (rItem.info.Type == ItemType.BookGeneral_) { o = (GameObject)BookGeneral.CreateOutOfWorld(item.CustomData as BookGeneralData); } if (rItem.info.Type == ItemType.BookSkill_) { o = (GameObject)BookSkill.CreateOutOfWorld(item.CustomData as BookSkillData); } if (rItem.info.Type == ItemType.BookRecipe_) { o = (GameObject)BookRecipe.CreateOutOfWorld(item.CustomData as BookRecipeData); } if (rItem.info.Type == ItemType.SheetMusic_) { o = (GameObject)SheetMusic.CreateOutOfWorld(item.CustomData as SheetMusicData); } if (rItem.info.Type == ItemType.BookToddler_) { o = (GameObject)BookToddler.CreateOutOfWorld(item.CustomData as BookToddlerData); } if (rItem.info.Type == ItemType.BookFish_) { o = (GameObject)BookFish.CreateOutOfWorld(item.CustomData as BookFishData); } if (rItem.info.Type == ItemType.BookAlchemyRecipe_) { o = (GameObject)BookAlchemyRecipe.CreateOutOfWorld(item.CustomData as BookAlchemyRecipeData); } if (rItem.info.Type == ItemType.AcademicTextBook_) { o = (GameObject)AcademicTextBook.CreateOutOfWorld(item.CustomData as AcademicTextBookData, actor); } if (rItem.info.Type == ItemType.BookComic_) { o = (GameObject)BookComic.CreateOutOfWorld(item.CustomData as BookComicData); } break; } } if (!keepLooping) { break; } } break; case ItemType.JamJar: JamJar jamJar = GlobalFunctions.CreateObjectOutOfWorld("canningJarJam", ProductVersion.Store) as JamJar; if (jamJar != null) { Type tInfo = jamJar.GetType(); BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; FieldInfo ingredientDataField = tInfo.GetField("mData", flags); FieldInfo ingredientKeyField = tInfo.GetField("mIngredientKey", flags); FieldInfo qualityField = tInfo.GetField("mQuality", flags); FieldInfo preservesField = tInfo.GetField("mIsPreserves", flags); MethodInfo materialStateMethod = tInfo.GetMethod("SetMaterialState", flags); ingredientDataField.SetValue(jamJar, rItem.info.IngData); ingredientKeyField.SetValue(jamJar, rItem.info.IngredientKey); qualityField.SetValue(jamJar, rItem.info.JamQuality); preservesField.SetValue(jamJar, rItem.info.JamIsPreserve); materialStateMethod.Invoke(jamJar, null); } o = (GameObject)jamJar; break; default: break; } return(o); }
private static void AddSongToFluro(Fluro.RootObject newsong, List <Elvanto.File> files) { List <string> chordchartids = new List <string>(); List <string> videoids = new List <string>(); // add files // first search to see if it already exists foreach (Elvanto.File file in files) { if (file.type == "Video") { if (file.content.Left(7) == "<iframe") { videoids.Add(FindVideoFromIFrame(file.content)); } else { videoids.Add(AddVideoToFluro(file.content)); } } else { // add new sheet //download existing file HttpClient dlclient = new HttpClient(); HttpResponseMessage response = new HttpResponseMessage(); if (file.content.Left(7) == "<iframe") { videoids.Add(FindVideoFromIFrame(file.content)); } else { response = dlclient.GetAsync(file.content).Result; if (response.IsSuccessStatusCode) { chordchartids.Add(Util.UploadFiletoFluro(response, file, FluroCreativeRealm, FluroFileUploadURI)); } } } } //Add SheetMusic to Song newsong.data.sheetMusic = new List <SheetMusic>(); foreach (string sheetid in chordchartids) { SheetMusic sheet = new SheetMusic { _id = sheetid }; newsong.data.sheetMusic.Add(sheet); } newsong.data.videos = new List <object>(); foreach (string videoid in videoids) { newsong.data.videos.Add(videoid); } newsong.realms = new List <Realm>(); Realm creative = new Realm { _id = FluroCreativeRealm }; newsong.realms.Add(creative); newsong.definition = "song"; Util.UploadToFluroReturnJson(FluroSongURI, "POST", JsonConvert.SerializeObject(newsong)); }
/** Create a new Chord Symbol from the given list of midi notes. * All the midi notes will have the same start time. Use the * key signature to get the white key and accidental symbol for * each note. Use the time signature to calculate the duration * of the notes. Use the clef when drawing the chord. */ public ChordSymbol(List <MidiNote> midinotes, KeySignature key, TimeSignature time, Clef c, SheetMusic sheet) { int len = midinotes.Count; int i; hastwostems = false; clef = c; sheetmusic = sheet; starttime = midinotes[0].StartTime; endtime = midinotes[0].EndTime; // Midi Notes of the chord notes = new List <MidiNote>(); for (i = 0; i < midinotes.Count; i++) { if (i > 1) { if (midinotes[i].Number < midinotes[i - 1].Number) { // FAB a corriger //throw new System.ArgumentException("Chord notes not in increasing order by number"); } } endtime = Math.Max(endtime, midinotes[i].EndTime); notes.Add(midinotes[i]); } // Note data of the chord notedata = CreateNoteData(midinotes, key, time); accidsymbols = CreateAccidSymbols(notedata, clef); /* Find out how many stems we need (1 or 2) */ NoteDuration dur1 = notedata[0].duration; NoteDuration dur2 = dur1; int change = -1; for (i = 0; i < notedata.Length; i++) { dur2 = notedata[i].duration; if (dur1 != dur2) { change = i; break; } } if (dur1 != dur2) { /* We have notes with different durations. So we will need * two stems. The first stem points down, and contains the * bottom note up to the note with the different duration. * * The second stem points up, and contains the note with the * different duration up to the top note. */ hastwostems = true; stem1 = new Stem(notedata[0].whitenote, notedata[change - 1].whitenote, dur1, Stem.Down, NotesOverlap(notedata, 0, change) ); stem2 = new Stem(notedata[change].whitenote, notedata[notedata.Length - 1].whitenote, dur2, Stem.Up, NotesOverlap(notedata, change, notedata.Length) ); } else { /* All notes have the same duration, so we only need one stem. */ int direction = StemDirection(notedata[0].whitenote, notedata[notedata.Length - 1].whitenote, clef); stem1 = new Stem(notedata[0].whitenote, notedata[notedata.Length - 1].whitenote, dur1, direction, NotesOverlap(notedata, 0, notedata.Length) ); stem2 = null; } /* For whole notes, no stem is drawn. */ if (dur1 == NoteDuration.Whole) { stem1 = null; } if (dur2 == NoteDuration.Whole) { stem2 = null; } width = MinWidth; // Lync MidiNotes & NotesData foreach (NoteData note in notedata) { for (i = 0; i < notes.Count; i++) { if (notes[i].Number == note.number) { note.midinoteindex = i; break; } } } }