コード例 #1
0
ファイル: ASMutablePosition.cs プロジェクト: fuchs-/CAT
    public void Move(int x, int y)
    {
        this.x += x;
        this.y += y;

        onPositionChanged.Invoke(this);
    }
コード例 #2
0
ファイル: PlayerModule.cs プロジェクト: waynejhou/LRCEditor
        public void Open(string filename)
        {
            CleanupPlayback();

            _waveSource =
                CodecFactory.Instance.GetCodec(filename)
                .ToSampleSource()
                .ToStereo()
                .ToWaveSource();
            _soundOut = new WasapiOut()
            {
                Latency = 100
            };
            _soundOut.Initialize(_waveSource);
            _soundOut.Volume = Math.Min(1.0f, Math.Max((float)volumeHandle / 100f, 0f));
            if (PlaybackStopped != null)
            {
                _soundOut.Stopped += PlaybackStopped;
            }

            PositionUpdateThread = new Thread(() => {
                while (true)
                {
                    PositionChangedEvent?.Invoke(this);
                    Thread.Sleep(10);
                }
            });
            PositionUpdateThread.Start();
        }
コード例 #3
0
ファイル: NodeEntry.cs プロジェクト: swipswaps/XLand
        private void Update()
        {
            if (!IsDragged)
            {
                return;
            }
            if (!Input.GetMouseButton(0))
            {
                IsDragged = false;
                return;
            }

            transform.position    = Input.mousePosition - m_MouseDisplacement;
            NodeInstance.position = transform.localPosition;
            if (PositionChangedEvent != null)
            {
                PositionChangedEvent.Invoke();
            }
        }
コード例 #4
0
 public void PositionChanged(Position newPosition, Position oldPosition)
 {
     PositionChangedEvent.Invoke(newPosition, oldPosition);
 }
コード例 #5
0
    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
        if ((WM)m.Msg == WM.MOUSEMOVE)
        {
            int y = ((int)m.LParam >> 16) & 0xffff;
            int x = (int)m.LParam & 0xffff;
            CurrentRowCol.X = x;
            CurrentRowCol.Y = y;
            MousePosition   = CharPositionFromPoint(x, y);
            Row             = LineFromPosition(MousePosition);
            CurrentWord     = GetWordFromPosition(MousePosition);
            Column          = GetColumn(MousePosition);
            PositionChangedEvent?.Invoke(this, EventArgs.Empty);
        }
        if ((WM)m.Msg == WM.NCHITTEST)
        {
            int   y     = ((int)m.LParam >> 16) & 0xffff;
            int   x     = (int)m.LParam & 0xffff;
            POINT point = new POINT(x, y);
            ScreenToClient(Handle, ref point);
            CurrentRowCol.X = point.X;
            CurrentRowCol.Y = point.Y;
            MousePosition   = CharPositionFromPoint(point.X, point.Y);
            Row             = LineFromPosition(MousePosition);
            CurrentWord     = GetWordFromPosition(MousePosition);
            Column          = GetColumn(MousePosition);
            PositionChangedEvent?.Invoke(this, EventArgs.Empty);
        }
        if ((WM)m.Msg == WM.KEYDOWN)
        {
            switch ((int)m.WParam)
            {
            case VK_DOWN:
            case VK_LEFT:
            case VK_RIGHT:
            case VK_UP:
            case VK_HOME:
            case VK_END:
            case VK_PRIOR:
            case VK_NEXT:
            {
                MousePosition = CurrentPosition;
                Row           = LineFromPosition(MousePosition);
                CurrentWord   = GetWordFromPosition(MousePosition);
                Column        = GetColumn(MousePosition);
                PositionChangedEvent?.Invoke(this, EventArgs.Empty);
            }
            break;
            }
        }

        if (!Selectable)
        {
            switch ((WM)m.Msg)
            {
            case WM.LBUTTONDOWN:
            case WM.RBUTTONDOWN:
            case WM.MBUTTONDOWN:
            case WM.LBUTTONUP:
            case WM.RBUTTONUP:
            case WM.MBUTTONUP:
                return;
            }
        }

        WM msg = (WM)m.Msg;

        if (m.Msg == 0x20a)
        {
            msg = WM.MOUSEHWHEEL;
        }
        if (msg == WM.MOUSEHWHEEL || msg == WM.VSCROLL || msg == WM.HSCROLL || msg == WM.KEYUP || msg == WM.MOUSEMOVE)
        {
            if (!scrolling)
            {
                if (Buddy != null && Buddy.IsHandleCreated)
                {
                    scrolling = true;
                    Buddy.FirstVisibleLine = FirstVisibleLine;
                    //SendMessage(Buddy.Handle, m.Msg, m.WParam.ToInt32(), m.LParam.ToInt32());
                    scrolling = false;
                }
            }
        }
    }
コード例 #6
0
 private void RaisePositionChangedEvent()
 {
     PositionChangedEvent?.Invoke();
 }
コード例 #7
0
        public void Open(string filename)
        {
            CleanupPlayback();
            SongName = System.IO.Path.GetFileName(filename);
            try
            {
                TagLib.File tf = TagLib.File.Create(filename);
                SongArt  = tf.Tag.Performers[0];
                SongName = tf.Tag.Title;
                if (tf.Tag.Pictures.Length > 0)
                {
                    SongImg = ByteToImg(tf.Tag.Pictures[0].Data.Data);
                }
                else
                {
                    Random rd    = new Random();
                    int    index = rd.Next(1, 6);
                    SongImg = ByteToImg(Properties.Resources.ResourceManager.GetObject("_" + index.ToString()) as byte[]);
                }
            }
            catch
            {
                SongName = Path.GetFileNameWithoutExtension(filename);
                SongArt  = "Unknown";
                Random rd    = new Random();
                int    index = rd.Next(1, 6);
                SongImg = ByteToImg(Properties.Resources.ResourceManager.GetObject("_" + index.ToString()) as byte[]);
            }
            try
            {
                _waveSource =
                    CodecFactory.Instance.GetCodec(filename)
                    .ToSampleSource()
                    .ToStereo()
                    .ToWaveSource();
                _soundOut = new WasapiOut()
                {
                    Latency = 100
                };
                _soundOut.Initialize(_waveSource);
                _soundOut.Volume = Math.Min(1.0f, Math.Max((float)volumeHandle / 100f, 0f));
            }
            catch (Exception ex)
            {
                MessageBoxResult MR = MessageBox.Show(ex.Message);
                Environment.Exit(0);
            }
            if (PlaybackStopped != null)
            {
                _soundOut.Stopped += PlaybackStopped;
            }

            PositionUpdateThread = new Thread(() => {
                while (true)
                {
                    PositionChangedEvent?.Invoke(Position);
                    Thread.Sleep(10);
                }
            });
            PositionUpdateThread.Start();
        }