Exemple #1
0
        private void scoreScrollViewer_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                // Get the current mouse position.
                mousePos = e.GetPosition(null);
                Vector diff = startPoint - mousePos;

                if (!playbackThread.IsBusy)
                {
                    if (e.LeftButton == MouseButtonState.Pressed &&
                        (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                         Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
                    {
                        ScrollViewer sv = (ScrollViewer)sender;
                        ScoreStaffs  ss = LayoutController.FindAncestor <ScoreStaffs>((DependencyObject)e.OriginalSource);
                        if (ss != null)
                        {
                            int        index    = scoreWrapPanel.Children.IndexOf(ss);
                            DataObject dragData = new DataObject("int", index);
                            DragDrop.DoDragDrop(ss, dragData, DragDropEffects.Move);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        private void fieldGrid_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                // Get the current mouse position.
                Point  mousePos = e.GetPosition(null);
                Vector diff     = startPoint - mousePos;

                if (e.LeftButton == MouseButtonState.Pressed &&
                    (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                     Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
                {
                    // Get the dragged ListViewItem.
                    Grid        grid = (Grid)sender;
                    ScoreStaffs ss   = LayoutController.FindAncestor <ScoreStaffs>((DependencyObject)e.OriginalSource);

                    // Initialize the drag & drop operation.
                    if (ss != null)
                    {
                        int        index    = Convert.ToInt32(ss.Name.Substring(ss.Name.LastIndexOf("s") + 1));
                        Genome     gen      = individuals[index];
                        DataObject dragData = new DataObject();
                        dragData.SetData("Object", gen);
                        dragData.SetData("String", KeySignatureAccidental + "|" + Tempo);
                        Octave[] octaves = { octave0, octave1 };
                        dragData.SetData("MusicNoteLib.Octave[]", octaves);
                        dragData.SetData("MusicNoteLib.DurationCFugue", Duration);
                        byte[] barIter = { barIteration0, barIteration1 };
                        dragData.SetData("byte[]", barIter);

                        DragDrop.DoDragDrop(ss, dragData, DragDropEffects.Copy);
                    }
                }
            }
            catch (Exception)
            {
            }
        }