当前位置: 首页>>代码示例>>C#>>正文


C# Converter.getCenterY方法代码示例

本文整理汇总了C#中Converter.getCenterY方法的典型用法代码示例。如果您正苦于以下问题:C# Converter.getCenterY方法的具体用法?C# Converter.getCenterY怎么用?C# Converter.getCenterY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Converter的用法示例。


在下文中一共展示了Converter.getCenterY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
//.........这里部分代码省略.........
开发者ID:Acemond,项目名称:PopNTouch,代码行数:101,代码来源:NoteBubbleAnimation.cs

示例2: previewDt_Tick

        /// <summary>
        /// Display the images of the notes from the melodyBubble
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void previewDt_Tick(object sender, EventArgs e)
        {
            ScatterViewItem bubble = SVItem;
            Point virtualBubbleCenter = new Point(bubble.ActualCenter.X, bubble.ActualCenter.Y);

            int width = (int)sessionVM.Grid.ActualWidth;
            int height = (int)sessionVM.Grid.ActualHeight;
            virtualBubbleCenter.X = virtualBubbleCenter.X * 1920.0 / width;
            virtualBubbleCenter.Y = virtualBubbleCenter.Y * 1080.0 / height;

            if (virtualBubbleCenter.X < 150.0) virtualBubbleCenter.X = 150.0;
            else if (virtualBubbleCenter.X >= 1830) virtualBubbleCenter.X = 1800;
            else virtualBubbleCenter.X = Math.Floor((virtualBubbleCenter.X + 30) / 60) * 60;

            //"Applatissement" de la portée
            int offset = GlobalVariables.ManipulationGrid.ElementAtOrDefault((int)((double)virtualBubbleCenter.X / 60.0));
            virtualBubbleCenter.Y += offset;

            PositionMelody = new Point(virtualBubbleCenter.X, virtualBubbleCenter.Y);

            previewNotesGrid.Items.Clear();

            //Y dans le cadre portée ?
            //Si oui, animation
            //pas de else
            if (virtualBubbleCenter.Y < 576 && virtualBubbleCenter.Y > 165)
            {
                if (virtualBubbleCenter.Y < 370)
                {
                    if (virtualBubbleCenter.Y >= 344) virtualBubbleCenter.Y = 344;
                    virtualBubbleCenter.Y = Math.Floor((virtualBubbleCenter.Y + 6.0) / 20.0) * 20.0 + 4.0;
                }
                else
                {
                    if (virtualBubbleCenter.Y <= 395) virtualBubbleCenter.Y = 395;
                    virtualBubbleCenter.Y = Math.Floor((virtualBubbleCenter.Y + 15.0) / 20.0) * 20.0 - 5.0;
                }

            List<NoteViewModel> ListOfNotes = melodyBubbleVM.melodyToListOfNote(PositionMelody);
            Converter cvrt = new Converter();

            double ratio = sessionVM.Grid.ActualWidth / 1920.0;

            for (int i = 0; i < ListOfNotes.Count; i++)
            {
                ScatterViewItem previewNote = new ScatterViewItem();
                FrameworkElementFactory notePreviewImage = new FrameworkElementFactory(typeof(Image));
                int offset2 = GlobalVariables.ManipulationGrid.ElementAtOrDefault(ListOfNotes[i].Note.Position + 2);
                double betweenStave = (350 - offset2) * ratio;
                bool up;

                previewNote.CanScale = false;
                previewNote.HorizontalAlignment = HorizontalAlignment.Center;
                previewNote.CanRotate = false;
                previewNote.HorizontalAlignment = HorizontalAlignment.Center;

                if (ListOfNotes[i].SVItem.Center.Y < betweenStave)
                {
                    up = true;
                    if (ListOfNotes[i].Note.Flat)
                        notePreviewImage.SetValue(Image.SourceProperty, new BitmapImage(new Uri(@"../../Resources/Images/UI_items/PreviewNotes/black/" + ListOfNotes[i].Note.Duration + "_bemol.png", UriKind.Relative)));
                    else if (ListOfNotes[i].Note.Sharp)
                        notePreviewImage.SetValue(Image.SourceProperty, new BitmapImage(new Uri(@"../../Resources/Images/UI_items/PreviewNotes/black/" + ListOfNotes[i].Note.Duration + "_diese.png", UriKind.Relative)));
                    else
                        notePreviewImage.SetValue(Image.SourceProperty, new BitmapImage(new Uri(@"../../Resources/Images/UI_items/PreviewNotes/black/" + ListOfNotes[i].Note.Duration + ".png", UriKind.Relative)));
                }
                else
                {
                    up = false;
                    if (ListOfNotes[i].Note.Flat)
                        notePreviewImage.SetValue(Image.SourceProperty, new BitmapImage(new Uri(@"../../Resources/Images/UI_items/PreviewNotes/white/" + ListOfNotes[i].Note.Duration + "_bemol.png", UriKind.Relative)));
                    else if (ListOfNotes[i].Note.Sharp)
                        notePreviewImage.SetValue(Image.SourceProperty, new BitmapImage(new Uri(@"../../Resources/Images/UI_items/PreviewNotes/white/" + ListOfNotes[i].Note.Duration + "_diese.png", UriKind.Relative)));
                    else
                        notePreviewImage.SetValue(Image.SourceProperty, new BitmapImage(new Uri(@"../../Resources/Images/UI_items/PreviewNotes/white/" + ListOfNotes[i].Note.Duration + ".png", UriKind.Relative)));
                }

                double Xpos = virtualBubbleCenter.X + melodyBubbleVM.MelodyBubble.Melody.Notes[i].Position * 60.0;
                double Ypos = cvrt.getCenterY(up, melodyBubbleVM.MelodyBubble.Melody.Notes[i]) + GlobalVariables.ManipulationGrid.ElementAtOrDefault(melodyBubbleVM.MelodyBubble.Melody.Notes[i].Position + 2) - offset;
                previewNote.Center = new Point(Xpos * ratio, Ypos * ratio);

                notePreviewImage.SetValue(Image.IsHitTestVisibleProperty, false);

                notePreviewImage.SetValue(Image.WidthProperty, (125.0 / 1920.0) * sessionVM.Grid.ActualWidth);
                notePreviewImage.SetValue(Image.HeightProperty, (260.0 / 1080.0) * sessionVM.Grid.ActualHeight);

                FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid));
                grid.AppendChild(notePreviewImage);

                ControlTemplate ct = new ControlTemplate(typeof(ScatterViewItem));
                ct.VisualTree = grid;

                Style notePreviewStyle = new Style(typeof(ScatterViewItem));
                notePreviewStyle.Setters.Add(new Setter(ScatterViewItem.TemplateProperty, ct));
                previewNote.Style = notePreviewStyle;
//.........这里部分代码省略.........
开发者ID:Acemond,项目名称:PopNTouch,代码行数:101,代码来源:MelodyBubbleAnimation.cs


注:本文中的Converter.getCenterY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。