Пример #1
0
 /// <summary>
 /// Default Mouse Up Event Handler
 /// </summary>
 protected virtual void BaseGameForm_MouseUp(IGameControl sender, GameControlEventArgs args)
 {
 }
Пример #2
0
 /// <summary>
 /// Use this method to raise a base GameControl event. (typically called by the observer.)
 /// </summary>
 /// <param name="e">The event to raise</param>
 /// <param name="sender">The GameControl sending the event</param>
 /// <param name="args">The event arguments</param>
 public void RaiseEvent(BaseControlEvents e, IGameControl sender, GameControlEventArgs args)
 {
     switch (e)
     {
         case BaseControlEvents.ChangeFocus: ChangeFocus(sender, args); break;
         case BaseControlEvents.Click: Click(sender, args); break;
         case BaseControlEvents.Init: Init(sender, (GameControlTimedEventArgs)args); break;
         case BaseControlEvents.MouseDown: MouseDown(sender, args); break;
         case BaseControlEvents.MouseEnter: MouseEnter(sender, args); break;
         case BaseControlEvents.MouseLeave: MouseLeave(sender, args); break;
         case BaseControlEvents.MouseUp: MouseUp(sender, args); break;
         case BaseControlEvents.Render: Render(sender, (GameControlRenderEventArgs)args); break;
         case BaseControlEvents.Update: Update(sender, (GameControlTimedEventArgs)args); break;
     }
 }
Пример #3
0
 /// <summary>
 /// Default Change focus Event Handler
 /// </summary>
 protected virtual void BaseGameForm_ChangeFocus(IGameControl sender, GameControlEventArgs args)
 {
 }
Пример #4
0
        /// <summary>
        /// The slidebar should move (and the selected value change) on mousedown
        /// </summary>
        protected void Slider_MouseHeld(IGameControl sender, GameControlEventArgs args)
        {
            //Get mouse position
            Point mousepos = ParentForm.UI.CurrentMousePointer.PickedScreenCoordinate;
            int relativeX = mousepos.X - (int)GetAbsoluteLocation().X;
            int relativeY = mousepos.Y - (int)GetAbsoluteLocation().Y;
            float fraction = 0.0f;

            if (Alignment == SliderAlignment.Horizontal)
                fraction = (float)relativeX / (float)GrooveSource.Width;
            else if (Alignment == SliderAlignment.Vertical)
                fraction = (float)relativeY / (float)GrooveSource.Height;

            float rawvalue = (fraction * (MaxValue - MinValue)) + MinValue;
            if (StepMode == SliderStepMode.Smooth)
                Value = rawvalue;
            else if (StepMode == SliderStepMode.Snap) // If in snap mode, snap to nearest value.
            {
                float mod = rawvalue % Step;
                if (mod >= Step / 2)
                    Value = rawvalue + Step - mod;
                else
                    Value = rawvalue - mod;
            }

            if (Value < MinValue)
                Value = MinValue;
            if (Value > MaxValue)
                Value = MaxValue;
        }