コード例 #1
0
ファイル: SliderBar.cs プロジェクト: summer-of-software/vtank
        ////////////////////////////////////////////////////////////////////////////
        private void SetValue(MouseEventArgs e)
        {
            Point p = new Point(e.Position.X, e.Position.Y);

            Value = (int)(100-((((float)Width - (float)p.X) / (float)Width) * (float)100)); ;
            Value = (int)MathHelper.Clamp(Value, 0.0f, 100.0f);
        }
コード例 #2
0
 void btn_MouseOver(object sender, MouseEventArgs e)
 {
     txt.Items.Add((sender == btn ? "Button" : "List") + ": Over");
       txt.ItemIndex = txt.Items.Count - 1;
 }
コード例 #3
0
 void btn_MouseUp(object sender, MouseEventArgs e)
 {
     txt.Items.Add((sender == btn ? "Button" : "List") + ": Up " + e.Button.ToString());
       txt.ItemIndex = txt.Items.Count - 1;
 }
コード例 #4
0
ファイル: TrackBar.cs プロジェクト: Kammikazy/Neoforce-Mono
    ////////////////////////////////////////////////////////////////////////////   

    ////////////////////////////////////////////////////////////////////////////        
    protected override void OnMousePress(MouseEventArgs e)
    {
      base.OnMouseDown(e);  
      
      if (e.Button == MouseButton.Left)
      {        
        int pos = e.Position.X;
          
        if (pos < btnSlider.Left)
        {
          Value -= pageSize;         
        }
        else if (pos >= btnSlider.Left + btnSlider.Width)
        {
          Value += pageSize;          
        } 
      }         
    }
コード例 #5
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
              int i = lastIndex;

              TrackItem((int)e.State.X - Root.AbsoluteLeft, (int)e.State.Y - Root.AbsoluteTop);

              if (ItemIndex >= 0 && (i == -1 || i != ItemIndex) && Items[ItemIndex].Items != null && Items[ItemIndex].Items.Count > 0 && ChildMenu != null)
              {
            HideSubMenu();
            lastIndex = ItemIndex;
            OnClick(e);
              }
              else if (ChildMenu != null && i != ItemIndex)
              {
             HideSubMenu();
             Focused = true;
              }
        }
コード例 #6
0
        ////////////////////////////////////////////////////////////////////////////     
        ////////////////////////////////////////////////////////////////////////////     
        void Input_MouseDown(object sender, MouseEventArgs e)
        {
            if (ReadOnly &&
              (e.Position.X >= AbsoluteLeft &&
               e.Position.X <= AbsoluteLeft + Width &&
               e.Position.Y >= AbsoluteTop &&
               e.Position.Y <= AbsoluteTop + Height)) return;

              if (lstCombo.Visible &&
             (e.Position.X < lstCombo.AbsoluteLeft ||
              e.Position.X > lstCombo.AbsoluteLeft + lstCombo.Width ||
              e.Position.Y < lstCombo.AbsoluteTop ||
              e.Position.Y > lstCombo.AbsoluteTop + lstCombo.Height) &&
             (e.Position.X < btnDown.AbsoluteLeft ||
              e.Position.X > btnDown.AbsoluteLeft + btnDown.Width ||
              e.Position.Y < btnDown.AbsoluteTop ||
              e.Position.Y > btnDown.AbsoluteTop + btnDown.Height))
              {
            //lstCombo.Visible = false;
            btnDown_Click(sender, e);
              }
        }
コード例 #7
0
		////////////////////////////////////////////////////////////////////////////         

		////////////////////////////////////////////////////////////////////////////     
		protected override void OnMouseDown(MouseEventArgs e)
		{
			base.OnMouseDown(e);

			if (tabPages.Count > 1)
			{
				Point p = new Point(e.State.X - Root.AbsoluteLeft, e.State.Y - Root.AbsoluteTop);
				for (int i = 0; i < tabPages.Count; i++)
				{
					Rectangle r = tabPages[i].HeaderRect;
					if (p.X >= r.Left && p.X <= r.Right && p.Y >= r.Top && p.Y <= r.Bottom)
					{
						SelectedIndex = i;
						break;
					}
				}
			}
		}
コード例 #8
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////    
        private void AdjustPosition(ref MouseEventArgs e)
        {
            Rectangle screen = manager.Game.Window.ClientBounds;

              if (e.Position.X < 0) e.Position.X = 0;
              if (e.Position.Y < 0) e.Position.Y = 0;
              if (e.Position.X >= screen.Width) e.Position.X = screen.Width - 1;
              if (e.Position.Y >= screen.Height) e.Position.Y = screen.Height - 1;
        }
コード例 #9
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////
        private void BuildMouseEvent(MouseState state, MouseButton button, ref MouseEventArgs e)
        {
            e.State = state;
              e.Button = button;

              e.Position = new Point((int)(mouseState.X * manager.ScreenWidth), (int)(mouseState.Y * manager.ScreenHeight));
              AdjustPosition(ref e);

              e.Position = RecalcPosition(e.Position);
              e.State = new MouseState(e.State.LeftButton, e.State.MiddleButton, e.State.RightButton, e.State.XButton1, e.State.XButton2, e.Position.X, e.Position.Y, e.State.WheelDelta);

              Point pos = RecalcPosition(new Point((int)(mouseState.X * manager.ScreenWidth), (int)(mouseState.Y * manager.ScreenHeight)));
              e.Difference = new Point(e.Position.X - pos.X, e.Position.Y - pos.Y);
        }
コード例 #10
0
ファイル: TabControl.cs プロジェクト: Rfvgyhn/Neoforce
        /// <summary>
        /// Handles mouse down events for the tab control.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            // More than one tab page?
            if (tabPages.Count > 1)
            {
                // Convert mouse position to relative offset.
                Point p = new Point(e.State.X - Root.AbsoluteLeft, e.State.Y - Root.AbsoluteTop);

                // See if any of the tab page headers were clicked.
                for (int i = 0; i < tabPages.Count; i++)
                {
                    Rectangle r = tabPages[i].HeaderRect;

                    // Select page if mouse position is within header.
                    if (p.X >= r.Left && p.X <= r.Right && p.Y >= r.Top && p.Y <= r.Bottom)
                    {
                        SelectedIndex = i;
                        break;
                    }
                }
            }
        }
コード例 #11
0
ファイル: TabControl.cs プロジェクト: Rfvgyhn/Neoforce
        /// <summary>
        /// Handles mouse move events for the tab control.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            // More than one tab page control created?
            if (tabPages.Count > 1)
            {
                int index = hoveredIndex;

                // Get mouse position as a relative offset from the tab control.
                Point p = new Point(e.State.X - Root.AbsoluteLeft, e.State.Y - Root.AbsoluteTop);

                // Determine if the mouse is hovering any of the tab page headers.
                for (int i = 0; i < tabPages.Count; i++)
                {
                    Rectangle r = tabPages[i].HeaderRect;

                    // Mouse is within the current header region?
                    if (p.X >= r.Left && p.X <= r.Right && p.Y >= r.Top && p.Y <= r.Bottom && tabPages[i].Enabled)
                    {
                        index = i;
                        break;
                    }

                    else
                    {
                        index = -1;
                    }
                }

                // Update the hovered tab page header index?
                if (index != hoveredIndex)
                {
                    hoveredIndex = index;
                    Invalidate();
                }
            }
        }
コード例 #12
0
ファイル: SliderBar.cs プロジェクト: summer-of-software/vtank
 void slider_MouseUp(object sender, MouseEventArgs e)
 {
     bSliderDown = false;
 }
コード例 #13
0
ファイル: SliderBar.cs プロジェクト: summer-of-software/vtank
 void slider_MouseMove(object sender, MouseEventArgs e)
 {
     if (bSliderDown)
     {
         delta = p.X - e.Position.X;
         Value -= (int)(delta / 1.5);
     }
 }
コード例 #14
0
ファイル: SliderBar.cs プロジェクト: summer-of-software/vtank
 void slider_MouseDown(object sender, MouseEventArgs e)
 {
     bSliderDown = true;
     p = new Point(e.Position.X, e.Position.Y);
 }
コード例 #15
0
        ////////////////////////////////////////////////////////////////////////////       
        protected override void OnMouseScroll(MouseEventArgs e)
        {
            if (!ClientArea.Enabled)
            return;

            // If current control doesn't scroll, scroll the parent control
            if (sbVert.Range - sbVert.PageSize < 1)
            {
            Control c = this;

            while (c != null)
            {
                var p = c.Parent as Container;

                if (p != null && p.Enabled)
                {
                    p.OnMouseScroll(e);

                    break;
                }

                c = c.Parent;
            }

            return;
            }

            if (e.ScrollDirection == MouseScrollDirection.Down)
            sbVert.ScrollDown(ScrollAlot);
            else
            sbVert.ScrollUp(ScrollAlot);

            base.OnMouseScroll(e);
        }
コード例 #16
0
        ////////////////////////////////////////////////////////////////////////////    
        private void BuildMouseEvent(MouseState state, MouseButton button, MouseScrollDirection direction, ref MouseEventArgs e)
        {
            BuildMouseEvent(state, button, ref e);

            e.ScrollDirection = direction;
        }
コード例 #17
0
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////     
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

              if (ReadOnly && e.Button == MouseButton.Left)
              {
            btnDown_Click(this, new MouseEventArgs());
              }
        }
コード例 #18
0
        ////////////////////////////////////////////////////////////////////////////        
        ////////////////////////////////////////////////////////////////////////////
        private void UpdateButtons(MouseState state, GameTime gameTime)
        {
            #if (!XBOX && !XBOX_FAKE)

              MouseEventArgs e = new MouseEventArgs();

              foreach (InputMouseButton btn in mouseButtons)
              {
            ButtonState bs; // = ButtonState.Released;

            if (btn.Button == MouseButton.Left) bs = state.LeftButton;
            else if (btn.Button == MouseButton.Right) bs = state.RightButton;
            else if (btn.Button == MouseButton.Middle) bs = state.MiddleButton;
            else if (btn.Button == MouseButton.XButton1) bs = state.XButton1;
            else if (btn.Button == MouseButton.XButton2) bs = state.XButton2;
            else continue;

            bool pressed = (bs.Down);
            if (pressed)
            {
              double ms = gameTime.ElapsedGameTime.TotalMilliseconds;
              if (pressed) btn.Countdown -= ms;
            }

            if ((pressed) && (!btn.Pressed))
            {
              btn.Pressed = true;
              BuildMouseEvent(state, btn.Button, ref e);

              if (MouseDown != null) MouseDown.Invoke(this, e);
              if (MousePress != null) MousePress.Invoke(this, e);
            }
            else if ((!pressed) && (btn.Pressed))
            {
              btn.Pressed = false;
              btn.Countdown = RepeatDelay;
              BuildMouseEvent(state, btn.Button, ref e);

              if (MouseUp != null) MouseUp.Invoke(this, e);
            }
            else if (btn.Pressed && btn.Countdown < 0)
            {
              e.Button = btn.Button;
              btn.Countdown = RepeatRate;
              BuildMouseEvent(state, btn.Button, ref e);

              if (MousePress != null) MousePress.Invoke(this, e);
            }
              }

              #endif
        }
コード例 #19
0
        ////////////////////////////////////////////////////////////////////////////
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (HotTrack)
            {
                TrackItem(e.Position.X, e.Position.Y);
            }
        }
コード例 #20
0
        ////////////////////////////////////////////////////////////////////////////
        private void UpdateMouse(MouseState state, GameTime gameTime)
        {
            #if (!XBOX && !XBOX_FAKE)

              if ((state.X != mouseState.X) || (state.Y != mouseState.Y))
              {
            MouseEventArgs e = new MouseEventArgs();

            MouseButton btn = MouseButton.None;
            if (state.LeftButton.Down) btn = MouseButton.Left;
            else if (state.RightButton.Down) btn = MouseButton.Right;
            else if (state.MiddleButton.Down) btn = MouseButton.Middle;
            else if (state.XButton1.Down) btn = MouseButton.XButton1;
            else if (state.XButton2.Down) btn = MouseButton.XButton2;

            BuildMouseEvent(state, btn, ref e);
            if (MouseMove != null)
            {
              MouseMove.Invoke(this, e);
            }
              }

              // Mouse wheel position changed
              if (state.WheelDelta != mouseState.WheelDelta)
              {
              MouseEventArgs e = new MouseEventArgs();
              MouseScrollDirection direction = state.WheelDelta < mouseState.WheelDelta ? MouseScrollDirection.Down : MouseScrollDirection.Up;

              BuildMouseEvent(state, MouseButton.None, direction, ref e);

              if (MouseScroll != null)
              {
              MouseScroll.Invoke(this, e);
              }
              }

              UpdateButtons(state, gameTime);

              mouseState = state;

              #endif
        }
コード例 #21
0
		////////////////////////////////////////////////////////////////////////////     

		////////////////////////////////////////////////////////////////////////////     
		protected override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove(e);
			if (tabPages.Count > 1)
			{
				int index = hoveredIndex;
				Point p = new Point(e.State.X - Root.AbsoluteLeft, e.State.Y - Root.AbsoluteTop);
				for (int i = 0; i < tabPages.Count; i++)
				{
					Rectangle r = tabPages[i].HeaderRect;
					if (p.X >= r.Left && p.X <= r.Right && p.Y >= r.Top && p.Y <= r.Bottom && tabPages[i].Enabled)
					{
						index = i;
						break;
					}
					else
					{
						index = -1;
					}
				}
				if (index != hoveredIndex)
				{
					hoveredIndex = index;
					Invalidate();
				}
			}
		}
コード例 #22
0
    ////////////////////////////////////////////////////////////////////////////     

    ////////////////////////////////////////////////////////////////////////////
    void ArrowPress(object sender, MouseEventArgs e)
    {
      if (e.Button == MouseButton.Left)
      {
        if (sender == btnMinus)
        {
            ScrollUp();
        }
        else if (sender == btnPlus)
        {
            ScrollDown();
        }       
      }
    }
コード例 #23
0
 ////////////////////////////////////////////////////////////////////////////   
 ////////////////////////////////////////////////////////////////////////////   
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
 }
コード例 #24
0
 ////////////////////////////////////////////////////////////////////////////        
 
 ////////////////////////////////////////////////////////////////////////////        
 protected override void OnMouseUp(MouseEventArgs e)
 {
   btnSlider.Passive = false;  
   base.OnMouseUp(e);       
 }
コード例 #25
0
        ////////////////////////////////////////////////////////////////////////////   
        ////////////////////////////////////////////////////////////////////////////   
        protected override void OnMouseOut(MouseEventArgs e)
        {
            base.OnMouseOut(e);

              OnMouseMove(e);
        }
コード例 #26
0
    ////////////////////////////////////////////////////////////////////////////        
    
    ////////////////////////////////////////////////////////////////////////////        
    protected override void OnMouseDown(MouseEventArgs e)
    {      
      base.OnMouseDown(e);            
      
      btnSlider.Passive = true;            
      
      if (e.Button == MouseButton.Left)
      {
        if (orientation == Orientation.Horizontal)
        {
          int pos = e.Position.X;
          
          if (pos < btnSlider.Left)
          {
              ScrollUp(true);      
          }
          else if (pos >= btnSlider.Left + btnSlider.Width)
          {
              ScrollDown(true);
          } 
        }
        else
        {
          int pos = e.Position.Y;

          if (pos < btnSlider.Top)
          {
              ScrollUp(true);
          }
          else if (pos >= btnSlider.Top + btnSlider.Height)
          {
              ScrollDown(true);
          }       
        }                               
      }  
    }
コード例 #27
0
 void btn_MousePress(object sender, MouseEventArgs e)
 {
     //  txt.Items.Add((sender == btn ? "Button" : "List") + ": Press");
     //  txt.ItemIndex = txt.Items.Count - 1;
 }
コード例 #28
0
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 private void btn_MousePress(object sender, MouseEventArgs e)
 {
     Focused = true;
       if (sender == btnUp) ShiftIndex(true);
       else if (sender == btnDown) ShiftIndex(false);
 }
コード例 #29
0
 void lst_MouseScroll(object sender, MouseEventArgs e)
 {
     txt.Items.Add((sender == btn ? "Button" : "List") + ": Scroll");
     txt.ItemIndex = txt.Items.Count - 1;
 }
コード例 #30
0
ファイル: SliderBar.cs プロジェクト: summer-of-software/vtank
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     bMouseDown = false;
 }