コード例 #1
0
        private void _addSoundSourceToolStripButton_Click(object sender, EventArgs e)
        {
            if (_openFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
            {
                var source = new ALSource();
                var buffer = new ALBuffer();
                buffer.LoadWavFile(_openFileDialog.FileName);
                source.Buffer = buffer;
                source.Position = new Vector3(50, 50, 50);
                source.Looping = true;

                _sources.Add(source);
                InvalidateViews();
            }
        }
コード例 #2
0
        private void HandleMouseDown(Vector2 ms, Func<Vector3, Vector2> extract)
        {
            var sourceImage = _mainImageList.Images["source"];

            var tlOfs = new Vector2(-sourceImage.Width / 2f, -sourceImage.Height / 2f);
            var brOfs = -tlOfs;

            // Opposite order to Draw()
            foreach (var source in _sources.Reverse<ALSource>())
            {
                var pos = extract(source.Position);
                var tl = pos + tlOfs;
                var br = pos + brOfs;

                if (Contains(tl, br, ms))
                {
                    _repeatToolStripButton.Image = source.Looping ?
                        _mainImageList.Images["repeat_on"] :
                        _mainImageList.Images["repeat_off"];

                    _isMouseDown = true;
                    _selectedSource = source;
                    _listenerSelected = false;
                    InvalidateViews();
                    return;
                }
            }

            // Variable name haxxorz
            {
                var pos = extract(_listener.Position);
                var tl = pos + tlOfs;
                var br = pos + brOfs;

                if (Contains(tl, br, ms))
                {
                    _isMouseDown = true;
                    _selectedSource = null;
                    _listenerSelected = true;
                    InvalidateViews();
                    return;
                }
            }
        }