本文整理汇总了C#中Converter.getOctave方法的典型用法代码示例。如果您正苦于以下问题:C# Converter.getOctave方法的具体用法?C# Converter.getOctave怎么用?C# Converter.getOctave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter.getOctave方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: moveCenter_Completed
/// <summary>
/// Event occured when the NoteBubble finished its move (to the right place)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void moveCenter_Completed(object sender, EventArgs e)
{
Converter converter = new Converter();
DisplayPreviewGrid(false);
noteBubbleVM.SVItem.Center = bubbleCenter;
for (int i = 0; i < sessionVM.NotesOnStave.Count && NothingAtThisPlace; i++)
{
if ((int)((virtualCenter.X - 120.0) / 60.0) == sessionVM.NotesOnStave[i].Note.Position
&& !sessionVM.NotesOnStave[i].Picked
&& converter.getOctave(virtualCenter.Y) == sessionVM.NotesOnStave[i].Note.Octave
&& converter.getPitch(virtualCenter.Y) == sessionVM.NotesOnStave[i].Note.Pitch
&& ((bubbleDroppedTopStave && sessionVM.Session.StaveTop.Notes.Contains(sessionVM.NotesOnStave[i].Note)) ||
(!bubbleDroppedTopStave && sessionVM.Session.StaveBottom.Notes.Contains(sessionVM.NotesOnStave[i].Note))))
{
if (noteBubbleVM.NoteBubble.Note.Duration == NoteValue.alteration)
{
NothingAtThisPlace = false;
noteVM = sessionVM.NotesOnStave[i];
}
else
{
sessionVM.NotesOnStave[i].Animation.BackToBubbleFormat(true);
NothingAtThisPlace = true;
}
}
else NothingAtThisPlace = true;
}
int positionNote = (int)((virtualCenter.X - 120.0) / 60.0);
double betweenStave = (350 - GlobalVariables.ManipulationGrid.ElementAtOrDefault(noteBubbleVM.NoteBubble.Note.Position + 2)) * (sessionVM.SessionSVI.ActualHeight / 1080);
bool isUp = (bubbleCenter.Y < betweenStave);
if (NothingAtThisPlace)
{
NoteViewModel noteViewModel = new NoteViewModel(bubbleCenter, noteBubbleVM.NoteBubble.Note, sessionVM.Notes, sessionVM);
if (!noteViewModel.Note.Sharp && !noteViewModel.Note.Flat)
{
if (isUp)
{
sessionVM.Session.StaveTop.CurrentInstrument.PlayNote(noteViewModel.Note);
sessionVM.Session.StaveTop.AddNote(noteViewModel.Note, positionNote);
}
else
{
sessionVM.Session.StaveBottom.CurrentInstrument.PlayNote(noteViewModel.Note);
sessionVM.Session.StaveBottom.AddNote(noteViewModel.Note, positionNote);
}
sessionVM.Bubbles.Items.Remove(noteBubbleVM.SVItem);
sessionVM.NbgVM.NoteBubbleVMs.Remove(noteBubbleVM);
sessionVM.Notes.Items.Add(noteViewModel.SVItem);
sessionVM.NotesOnStave.Add(noteViewModel);
}
}
else
{
//If the NoteBubbleViewModel is a (#) or (b)
if (noteBubbleVM.NoteBubble.Note.Sharp || noteBubbleVM.NoteBubble.Note.Flat)
{
bool changeline = false;
if (noteBubbleVM.NoteBubble.Note.Sharp)
changeline = noteVM.Note.UpSemiTone();
if (noteBubbleVM.NoteBubble.Note.Flat)
changeline = noteVM.Note.DownSemiTone();
double y = converter.getCenterY(isUp, noteVM.Note);
if (y < 80)
{
if (noteBubbleVM.NoteBubble.Note.Sharp)
noteVM.Note.DownSemiTone();
if (noteBubbleVM.NoteBubble.Note.Flat)
noteVM.Note.UpSemiTone();
canAnimate = true;
Animate();
}
else
{
y *= sessionVM.SessionSVI.ActualHeight / 1080.0;
sessionVM.NbgVM.NoteBubbleVMs.Remove(noteBubbleVM);
sessionVM.Bubbles.Items.Remove(noteBubbleVM.SVItem);
sessionVM.Notes.Items.Remove(noteVM.SVItem);
sessionVM.NotesOnStave.Remove(noteVM);
noteVM = new NoteViewModel(new Point(bubbleCenter.X, y), noteVM.Note, sessionVM.Notes, sessionVM);
if (isUp)
{
sessionVM.Session.StaveTop.RemoveNote(noteVM.Note);
sessionVM.Session.StaveTop.CurrentInstrument.PlayNote(noteVM.Note);
sessionVM.Session.StaveTop.AddNote(noteVM.Note, positionNote);
}
else
{
sessionVM.Session.StaveBottom.RemoveNote(noteVM.Note);
sessionVM.Session.StaveBottom.CurrentInstrument.PlayNote(noteVM.Note);
//.........这里部分代码省略.........
示例2: moveCenter_Completed
/// <summary>
/// Event occured when the note finished its move (to the right place)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void moveCenter_Completed(object sender, EventArgs e)
{
Converter converter = new Converter();
DisplayPreviewGrid(false);
for (int i = 0; i < sessionVM.NotesOnStave.Count && NothingAtThisPlace; i++)
{
//if (noteBubbleCenter.QuasiEquals(sessionVM.NotesOnStave[i].SVItem.Center) && !sessionVM.NotesOnStave[i].Picked)
if ((int)((virtualCenter.X - 120.0) / 60.0) == sessionVM.NotesOnStave[i].Note.Position
&& !sessionVM.NotesOnStave[i].Picked
&& converter.getOctave(virtualCenter.Y) == sessionVM.NotesOnStave[i].Note.Octave
&& converter.getPitch(virtualCenter.Y) == sessionVM.NotesOnStave[i].Note.Pitch
&& ((noteDroppedTopStave && sessionVM.Session.StaveTop.Notes.Contains(sessionVM.NotesOnStave[i].Note)) ||
(!noteDroppedTopStave && sessionVM.Session.StaveBottom.Notes.Contains(sessionVM.NotesOnStave[i].Note))))
{
//Invert comments if exception raises.
sessionVM.NotesOnStave[i].Animation.BackToBubbleFormat(true);
NothingAtThisPlace = true;
//NothingAtThisPlace = false;
}
else NothingAtThisPlace = true;
}
if (NothingAtThisPlace)
{
int positionNote = (int)((virtualCenter.X - 120.0) / 60.0);
double betweenStave = (350 - GlobalVariables.ManipulationGrid.ElementAtOrDefault(noteVM.Note.Position + 2)) * (sessionVM.SessionSVI.ActualHeight / 1080);
sessionVM.Session.StaveTop.RemoveNote(noteVM.Note);
sessionVM.Session.StaveBottom.RemoveNote(noteVM.Note);
bool isUp = (NoteCenter.Y < betweenStave);
noteVM.Note = new Note(converter.getOctave(virtualCenter.Y), noteVM.Note.Duration, converter.getPitch(virtualCenter.Y), positionNote, noteVM.Note.Sharp, noteVM.Note.Flat);
noteVM.SetStyle();
if (isUp)
{
sessionVM.Session.StaveTop.AddNote(noteVM.Note, positionNote);
sessionVM.Session.StaveTop.CurrentInstrument.PlayNote(noteVM.Note);
}
else
{
sessionVM.Session.StaveBottom.AddNote(noteVM.Note, positionNote);
sessionVM.Session.StaveBottom.CurrentInstrument.PlayNote(noteVM.Note);
}
}
else BackToBubbleFormat(false);
noteVM.Picked = false;
}
示例3: touchLeave
/// <summary>
/// Event occured when a Bubble is released
/// Magnetise the current bubble
/// Add the note in the right stave
/// Move the bubble to its final place
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void touchLeave(object sender, ContainerManipulationCompletedEventArgs e)
{
ScatterViewItem bubble = new ScatterViewItem();
bubble = e.Source as ScatterViewItem;
bubbleCenter = bubble.ActualCenter;
NothingAtThisPlace = true;
int width = (int)sessionVM.Grid.ActualWidth;
int height = (int)sessionVM.Grid.ActualHeight;
bubbleCenter.X = bubbleCenter.X * 1920.0 / width;
bubbleCenter.Y = bubbleCenter.Y * 1080.0 / height;
if (bubbleCenter.X < 150.0) bubbleCenter.X = 150.0;
else if (bubbleCenter.X >= 1830.0) bubbleCenter.X = 1800.0;
else bubbleCenter.X = Math.Floor((bubbleCenter.X + 30.0) / 60.0) * 60.0;
//"Applatissement" de la portée (MAJ : Switch -> Tableau !)
int offset = GlobalVariables.ManipulationGrid.ElementAtOrDefault((int)(bubbleCenter.X / 60.0));
bubbleCenter.Y += offset;
Converter converter = new Converter();
int positionNote = (int)(bubbleCenter.X - 120) / 60;
//Y dans le cadre portée ?
//Si oui, animation
//pas de else
if (bubbleCenter.Y < 576.0 && bubbleCenter.Y > 165.0)
{
if (bubbleCenter.Y < 370.0)
{
if (bubbleCenter.Y >= 344.0) bubbleCenter.Y = 344.0;
bubbleCenter.Y = Math.Floor((bubbleCenter.Y + 6.0) / 20.0) * 20.0 + 4.0;
bubbleDroppedTopStave = true;
}
else
{
if (bubbleCenter.Y <= 395) bubbleCenter.Y = 395;
bubbleCenter.Y = Math.Floor((bubbleCenter.Y + 15.0) / 20.0) * 20.0 - 5.0;
bubbleDroppedTopStave = false;
}
noteBubbleVM.NoteBubble.Note = new Note(converter.getOctave(bubbleCenter.Y), noteBubbleVM.NoteBubble.Note.Duration, converter.getPitch(bubbleCenter.Y), positionNote, noteBubbleVM.NoteBubble.Note.Sharp, noteBubbleVM.NoteBubble.Note.Flat);
virtualCenter = bubbleCenter;
bubbleCenter.Y -= offset;
bubbleCenter.X = bubbleCenter.X * width / 1920.0;
bubbleCenter.Y = bubbleCenter.Y * height / 1080.0;
#region STB
Storyboard stb = new Storyboard();
PointAnimation moveCenter = new PointAnimation();
moveCenter.From = bubble.ActualCenter;
moveCenter.To = bubbleCenter;
moveCenter.Duration = new Duration(TimeSpan.FromSeconds(0.15));
moveCenter.FillBehavior = FillBehavior.Stop;
stb.Children.Add(moveCenter);
Storyboard.SetTarget(moveCenter, bubble);
Storyboard.SetTargetProperty(moveCenter, new PropertyPath(ScatterViewItem.CenterProperty));
#endregion
bubble.Center = bubbleCenter;
moveCenter.Completed += new EventHandler(moveCenter_Completed);
stb.Begin(SVItem);
}
else
{
canAnimate = true;
Animate();
DisplayPreviewGrid(false);
}
}