コード例 #1
0
        // This is the method defined for the MoveLeft event. Mark this event as private
        // if you will never override it. Otherwise mark it as protected virtual.

        /// <summary>
        /// Raises the <see cref="MoveLeft"/> event.
        /// </summary>
        protected virtual void OnMoveLeft(MovedLeftEventArgs e)
        {
            // Check to see if the event is handled anywhere (in simple terms).
            // This is where you send data to event handlers.
            // Send the object related to the event as first argument (in my case this control).
            // Send in e which is the event args passed in from onMouseMove with the moveAmountData.
            MoveLeft?.Invoke(this, e);
        }
コード例 #2
0
        // Use the Move event in conjunction with our own.
        protected override void OnMove(EventArgs e)
        {
            base.OnMove(e);

            // If this control has moved left.
            if (lastXPos > Location.X)
            {
                int moveAmount = lastXPos - Location.X;
                // Construct event args which are defined below.
                MovedLeftEventArgs eventArgs = new MovedLeftEventArgs(moveAmount);
                // Raise event and pass in our event args.
                // Event args will be available to any object that has
                // registered to the MoveLeft event.
                OnMoveLeft(eventArgs);
            }

            // When were done calculating, save the last x position to contrast
            // with the current position the next time the mouse move event is raised.
            lastXPos = Location.X;
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: mjsaiz/SamplesAndUtils
 private void specialControl_MoveLeft(object sender, MovedLeftEventArgs e)
 {
     // Add amount moved to total before displaying
     moveLeftAmount += e.MoveAmount;
     Text            = moveLeftAmount.ToString();
 }