Example #1
0
        private void SamplesStackPanel_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (e.OriginalSource != ((SampleControl)e.Source).ChannelBG_Copy)
            {
                return;
            }

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                Point  currentPosition = e.GetPosition(null);
                Vector dragVector      = startPosition - currentPosition;

                if (Math.Abs(dragVector.Length) > 5)
                {
                    SampleControl sampleControl = e.Source as SampleControl;
                    if (sampleControl != null)
                    {
                        DragData dragData = new DragData();
                        dragData.sampleControl      = sampleControl;
                        dragData.soundEffectControl = this;

                        DataObject dataObject = new DataObject("DragData", dragData);

                        try
                        {
                            DragDrop.DoDragDrop(sampleControl, dataObject, DragDropEffects.Move);
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
Example #2
0
        private void CreateSampleControl(SoundEffect soundEffect, Sample sample)
        {
            SampleControl sampleControl = new SampleControl(sample, soundEffect);

            SamplesStackPanel.Children.Add(sampleControl);
            sampleControl.Removed       += new EventHandler(sampleControl_Removed);
            sampleControl.LoadingSample += new EventHandler(sampleControl_LoadingSample);
        }
Example #3
0
        private void SamplesStackPanel_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            SampleControl sampleControl = e.Source as SampleControl;

            if (sampleControl != null)
            {
                startPosition = e.GetPosition(null);
            }
        }
Example #4
0
 void sampleControl_Removed(object sender, EventArgs e)
 {
     if (SoundEffect.Samples.Count > 1)
     {
         SoundEffect.Stop();
         SampleControl sampleControl = sender as SampleControl;
         SoundEffect.Samples.Remove(sampleControl.Sample);
         SamplesStackPanel.Children.Remove(sampleControl);
     }
 }
Example #5
0
        private void SamplesStackPanel_Drop(object sender, DragEventArgs e)
        {
            SampleControl dropsc = e.Source as SampleControl;
            DragData      scdrag = e.Data.GetData("DragData") as DragData;
            SampleControl sc     = scdrag.sampleControl;

            if (dropsc == null)
            {
                SamplesStackPanel.Children.Add(sc);
                SoundEffect.Samples.Add(sc.Sample);
            }
        }
Example #6
0
        private void SamplesStackPanel_DragOver(object sender, DragEventArgs e)
        {
            SampleControl dropsc = e.Source as SampleControl;
            DragData      scdrag = e.Data.GetData("DragData") as DragData;
            SampleControl sc     = scdrag.sampleControl;

            if (dropsc != null && dropsc != sc)
            {
                Int32 dropIndex = dropIndex = SamplesStackPanel.Children.IndexOf(dropsc);

                try
                {
                    scdrag.soundEffectControl.SamplesStackPanel.Children.Remove(sc);
                    scdrag.soundEffectControl.SoundEffect.Samples.Remove(sc.Sample);
                }
                catch (Exception ex)
                {
                    LoopStatus.Text = ex.Message;
                }

                SamplesStackPanel.Children.Insert(dropIndex, sc);
                SoundEffect.Samples.Insert(dropIndex, sc.Sample);
            }
        }
 private void CreateSampleControl(SoundEffect soundEffect, Sample sample)
 {
     SampleControl sampleControl = new SampleControl(sample, soundEffect);
     SamplesStackPanel.Children.Add(sampleControl);
     sampleControl.Removed += new EventHandler(sampleControl_Removed);
     sampleControl.LoadingSample += new EventHandler(sampleControl_LoadingSample);
 }