public ObjectAnimator CreateNoteAnimation_FadeOnly(Position position) { const float TRANSPARENT = 0; const long DEFAULT_DURATION = 1000; DisplayMetrics screenDimensions = Generic.GetScreenDimentions(_currentActivity); //TODO: Add string positions as well. FretMetrics fretMetrics = GetFretMetrics(position.Fret); int Y_dest = fretMetrics.GetVerticalCenter() - _noteCircle.Height / 2; int X_dest = fretMetrics.GetHorizontalCenter() - _noteCircle.Width / 2; //Set initial location. _noteCircle.SetX(X_dest); _noteCircle.SetY(Y_dest); ObjectAnimator objAnimFadeOut = ObjectAnimator.OfFloat(_noteCircle, "Alpha", TRANSPARENT); objAnimFadeOut.SetDuration(DEFAULT_DURATION); objAnimFadeOut.AnimationEnd += (object sender, EventArgs e) => { OnNoteGone(this, new EventArgs()); }; return(objAnimFadeOut); }
/// <summary> /// Animates the note from the bottom to the top, and positions it depending on its fret position. /// </summary> /// <returns>Returns the animation of this NoteRepresentation.</returns> public ObjectAnimator CreateNoteAnimation() { const float TRANSPARENT = 0; DisplayMetrics screenDimensions = Generic.GetScreenDimentions(_currentActivity); FretMetrics fretMetrics = GetFretMetrics(_note.Position.Fret); //TODO: Add string positions as well. //Set initial location. _noteCircle.SetX(fretMetrics.GetHorizontalCenter() - _noteCircle.Width / 2); _noteCircle.SetY(screenDimensions.HeightPixels); int Y_dest = fretMetrics.GetVerticalCenter() - _noteCircle.Height / 2; ObjectAnimator objAnim = ObjectAnimator.OfFloat(_noteCircle, "Y", Y_dest); objAnim.SetDuration((long)_note.Duration); objAnim.StartDelay = (long)_note.Delay; objAnim.AnimationEnd += (object sender, EventArgs e) => { ObjectAnimator objAnimFadeOut = ObjectAnimator.OfFloat(_noteCircle, "Alpha", TRANSPARENT); objAnimFadeOut.SetDuration((long)_note.Duration); objAnimFadeOut.Start(); //Start capturing of note's sound input. OnNoteArraival(this, new OnNoteArraivalArgs(_note.Hertz)); objAnimFadeOut.AnimationEnd += (object sender2, EventArgs e2) => { //Note's sound input window closes. OnNoteGone(this, new EventArgs()); }; }; return(objAnim); /*PropertyViewAnimator pva = new PropertyViewAnimator(_noteCircle); * //Start * pva.Animate() * .SetDuration((int)(_note.Duration)) * .SetStartDelay((int)(_note.Delay)) * .Y(Y_dest_start) * .WithEndAction(new Runnable(() => { * //Start capturing of note's sound input. * //Raise StartNoteCapture event. * pva.Alpha(transparent).WithEndAction(new Runnable(() => { * //Note's sound input window closes. * //Raise EndNoteCapture event. * })); * })); * //Dilemma: * //Middle and End. * //But the animation does not happen here, it happens in AnimatorSet. * * return pva;*/ }
/// <summary> /// Gets the X, Y, Width, and Height of the fret which is represented on the screen by a view. /// </summary> /// <param name="fretNum">The number of the requested fret.</param> /// <returns>Returns the metrics of the requested fret.</returns> private FretMetrics GetFretMetrics(GuitarFret fretNum) { //Initialize a dummy fret. View fret = new View(_currentActivity); //Get the correct fret number. /*if (_currentActivity.Title == "TutorActivity") else if (_currentActivity.Title == "PlayerActivity") else if (_currentActivity.Title == "RecorderActivity")*/ switch (fretNum) { case GuitarFret.OpenString: fret = _currentActivity.FindViewById(Resource.Id.openString); break; case GuitarFret.Fret1: fret = _currentActivity.FindViewById(Resource.Id.fret1); break; case GuitarFret.Fret2: fret = _currentActivity.FindViewById(Resource.Id.fret2); break; case GuitarFret.Fret3: fret = _currentActivity.FindViewById(Resource.Id.fret3); break; case GuitarFret.Fret4: fret = _currentActivity.FindViewById(Resource.Id.fret4); break; case GuitarFret.Fret5: fret = _currentActivity.FindViewById(Resource.Id.fret5); break; case GuitarFret.Fret6: fret = _currentActivity.FindViewById(Resource.Id.fret6); break; } //Get the X & Y coordinates of the fret on the screen. int[] coordinates = new int[2]; fret.GetLocationInWindow(coordinates); //Summerize X, Y, Width, and Height. FretMetrics metrics = new FretMetrics( (int)fret.GetX(), //coordinates[0], (int)((TableRow)fret.Parent).GetY(), //coordinates[1], fret.MeasuredWidth, fret.MeasuredHeight); Log.Info("", fret.Tag.ToString()); Log.Info(fret.GetX().ToString(), fret.GetY().ToString()); Log.Info(coordinates[0].ToString(), coordinates[1].ToString()); Log.Info(fret.Width.ToString(), fret.Height.ToString()); Log.Info("Left", fret.Left.ToString()); Log.Info("Right", fret.Right.ToString()); Log.Info("Top", fret.Top.ToString()); Log.Info("Bottom", fret.Bottom.ToString()); return metrics; }
/// <summary> /// Gets the X, Y, Width, and Height of the fret which is represented on the screen by a view. /// </summary> /// <param name="fretNum">The number of the requested fret.</param> /// <returns>Returns the metrics of the requested fret.</returns> private FretMetrics GetFretMetrics(GuitarFret fretNum) { //Initialize a dummy fret. View fret = new View(_currentActivity); //Get the correct fret number. /*if (_currentActivity.Title == "TutorActivity") * * else if (_currentActivity.Title == "PlayerActivity") * * else if (_currentActivity.Title == "RecorderActivity")*/ switch (fretNum) { case GuitarFret.OpenString: fret = _currentActivity.FindViewById(Resource.Id.openString); break; case GuitarFret.Fret1: fret = _currentActivity.FindViewById(Resource.Id.fret1); break; case GuitarFret.Fret2: fret = _currentActivity.FindViewById(Resource.Id.fret2); break; case GuitarFret.Fret3: fret = _currentActivity.FindViewById(Resource.Id.fret3); break; case GuitarFret.Fret4: fret = _currentActivity.FindViewById(Resource.Id.fret4); break; case GuitarFret.Fret5: fret = _currentActivity.FindViewById(Resource.Id.fret5); break; case GuitarFret.Fret6: fret = _currentActivity.FindViewById(Resource.Id.fret6); break; } //Get the X & Y coordinates of the fret on the screen. int[] coordinates = new int[2]; fret.GetLocationInWindow(coordinates); //Summerize X, Y, Width, and Height. FretMetrics metrics = new FretMetrics( (int)fret.GetX(), //coordinates[0], (int)((TableRow)fret.Parent).GetY(), //coordinates[1], fret.MeasuredWidth, fret.MeasuredHeight); Log.Info("", fret.Tag.ToString()); Log.Info(fret.GetX().ToString(), fret.GetY().ToString()); Log.Info(coordinates[0].ToString(), coordinates[1].ToString()); Log.Info(fret.Width.ToString(), fret.Height.ToString()); Log.Info("Left", fret.Left.ToString()); Log.Info("Right", fret.Right.ToString()); Log.Info("Top", fret.Top.ToString()); Log.Info("Bottom", fret.Bottom.ToString()); return(metrics); }