Пример #1
0
        public DeckControl()
        {
            _mixerBackground = new Image();
            _mixerBackground.Height = 488;
            _mixerBackground.Width = 710;
            BitmapImage bmp = new BitmapImage();
            bmp.BeginInit();
            bmp.UriSource = new Uri("png/deck_background.png", UriKind.Relative);
            bmp.EndInit();
            _mixerBackground.Source = bmp;
            this.Children.Add(_mixerBackground);

            _recordController = new RecordController(RECORD_DIAMETER, RECORD_DIAMETER);
            _recordController.Margin = new Thickness(RECORD_MARGIN_LEFT, RECORD_MARGIN_TOP, 0, 0);
            _recordController.SetBackgroundImage(@"png/record.png");
            _recordController.Width = RECORD_DIAMETER;
            _recordController.Height = RECORD_DIAMETER;
            _recordController.TouchDown += new EventHandler<TouchEventArgs>(RecordTouchDown);
            _recordController.TouchUp += new EventHandler<TouchEventArgs>(RecordTouchUp);
            _recordController.TouchMove += new EventHandler<TouchEventArgs>(RecordTouchMove);
            _recordController.DragEnter += new System.Windows.DragEventHandler(RecordDragEnter);
            _recordController.DragLeave += new System.Windows.DragEventHandler(RecordDragLeave);
            _recordController.Drop += new System.Windows.DragEventHandler(RecordDrop);
            _recordController.AllowDrop = true;
            this.Children.Add(_recordController);

            _highPassKnob = new KnobControl(KNOB_DIAMETER, KNOB_DIAMETER);
            _highPassKnob.Margin = new Thickness(KNOB_MARGIN_LEFT, KNOB_MARGIN_TOP, 0, 0);
            _highPassKnob.SetBackgroundImage(@"png/dial_background.png");
            _highPassKnob.SetCenterImage(@"png/dial_knob.png");
            _highPassKnob.Width = KNOB_DIAMETER;
            _highPassKnob.Height = KNOB_DIAMETER;
            //_highPassKnob.TouchDown += new EventHandler<TouchEventArgs>(HPKnobTouchDown);
            //_highPassKnob.TouchUp += new EventHandler<TouchEventArgs>(HPKnobTouchUp);
            _highPassKnob.TouchMove += new EventHandler<TouchEventArgs>(HPKnobTouchMove);
            this.Children.Add(_highPassKnob);

            _lowPassKnob = new KnobControl(KNOB_DIAMETER, KNOB_DIAMETER);
            _lowPassKnob.Margin = new Thickness(KNOB_MARGIN_LEFT, KNOB_MARGIN_TOP + KNOB_DIAMETER * 1 + KNOB_PADDING * 1, 0, 0);
            _lowPassKnob.SetBackgroundImage(@"png/dial_background.png");
            _lowPassKnob.SetCenterImage(@"png/dial_knob.png");
            _lowPassKnob.Width = KNOB_DIAMETER;
            _lowPassKnob.Height = KNOB_DIAMETER;
            _lowPassKnob.TouchMove += new EventHandler<TouchEventArgs>(LPKnobTouchMove);
            this.Children.Add(_lowPassKnob);

            _reverbKnob = new KnobControl(KNOB_DIAMETER, KNOB_DIAMETER);
            _reverbKnob.Margin = new Thickness(KNOB_MARGIN_LEFT, KNOB_MARGIN_TOP + KNOB_DIAMETER * 2 + KNOB_PADDING * 2, 0, 0);
            _reverbKnob.SetBackgroundImage(@"png/dial_background.png");
            _reverbKnob.SetCenterImage(@"png/dial_knob.png");
            _reverbKnob.Width = KNOB_DIAMETER;
            _reverbKnob.Height = KNOB_DIAMETER;
            this.Children.Add(_reverbKnob);
            

            angle = 1;
            _recordMidPoint = new System.Windows.Point(_recordController.Width / 2 + _recordController.Margin.Left, _recordController.Height / 2 + _recordController.Margin.Top);
            rotate = new RotateTransform(1, _recordController.Width / 2, _recordController.Height / 2);
            transform = new TransformGroup();
            transform.Children.Add(rotate);

            dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1);
            dispatcherTimer.Start();

            system = new FMOD.System();
            FMOD.RESULT result = Factory.System_Create(ref system);
            system.init(8, INITFLAGS.NORMAL, (IntPtr)null);
            channel = new Channel(system);
            channel.Initialize(0);
            channel.SetHighPass(1.0f);
            _isPlaying = false;
        }