C# (CSharp) Class MouseEventArgs, 0 Code Examples

C# (CSharp) MouseEventArgs - 30 examples found. These are the top rated real world C# (CSharp) examples of class MouseEventArgs from package 0 extracted from open source projects. You can rate examples to help us improve the quality of examples
Inheritance: EventArgs
Example #1
0
        private void bcpAdd_MouseDown(object sender, MouseEventArgs e)
        {
            moveAble = true;

            left = Cursor.Position.X;
            top = Cursor.Position.Y;
        }
Example #2
0
 private void ItemView_MouseMove(object sender, MouseEventArgs e)
 {
     int truex = e.X - 6;
     int truey = e.Y - 36;
     if (truex > 5 && truey > 3 && truex < 315 + 5 && truey < 318 + 3)
     {
         int temp = (truex - 8)*10/315 + (truey - 5)*10/318*10;
         if (temp != tar)
         {
             tar = temp;
             if (baseid + tar < UserProfile.InfoBag.BagCount && UserProfile.InfoBag.Items[baseid + tar].Type != 0)
             {
                 Image image = HItemBook.GetPreview(UserProfile.InfoBag.Items[baseid + tar].Type);
                 tooltip.Show(image, this, (tar%10)*315/10 + 42, (tar/10)*318/10 + 42);
             }
             else
             {
                 tooltip.Hide(this);
             }
             Invalidate(new Rectangle(6, 36, 324, 324));
         }
     }
     else
     {
         tar = -1;
         tooltip.Hide(this);
         Invalidate(new Rectangle(6, 36, 324, 324));
     }
 }
 protected override void OnMouseDown(MouseEventArgs e)
 {
     _startPoint = e.Location;
     _hscrolloffset = LayoutTarget.HorizontalScroll.Value;
     _vscrolloffset = LayoutTarget.VerticalScroll.Value;
     base.OnMouseDown(e);
 }
		protected override void OnMouseDown(MouseEventArgs e)
		{
			// get the index of the clicked item
			_rowIndexFromMouseDown = HitTest(e.X, e.Y).RowIndex;

			// basic mouse handling has right clicks show context menu without changing selection, so we handle it manually here
			if (e.Button == MouseButtons.Right)
				HandleRightMouseDown(e);

			// call the base class, so that the row gets selected, etc.
			base.OnMouseDown(e);

			if (_rowIndexFromMouseDown > -1)
			{
				// Remember the point where the mouse down occurred. 
				// The DragSize indicates the size that the mouse can move 
				// before a drag event should be started.                
				Size dragSize = SystemInformation.DragSize;

				// Create a rectangle using the DragSize, with the mouse position being
				// at the center of the rectangle.
				_dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width/2), e.Y - (dragSize.Height/2)), dragSize);
			}
			else
			{
				// Reset the rectangle if the mouse is not over an item in the ListBox.
				_dragBoxFromMouseDown = Rectangle.Empty;
			}
		}
Example #5
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            var pos = new int2(e.X / TileSize, e.Y / TileSize);

            if (InputMode == null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    CurrentTemplate = Templates.FirstOrDefault(t => t.Cells.ContainsKey(pos));
                    if (CurrentTemplate == null)
                        Templates.Add(CurrentTemplate = new Template { Cells = new Dictionary<int2, bool> { { pos, true } } });

                    Invalidate();
                }

                if (e.Button == MouseButtons.Right)
                {
                    Templates.RemoveAll(t => t.Cells.ContainsKey(pos));
                    CurrentTemplate = null;
                    Invalidate();
                }
            }
            else
            {
                TerrainTypes[pos.X, pos.Y] = int.Parse(InputMode);
                Invalidate();
            }
        }
Example #6
0
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            //lab12_1
            /*Point p = pictureBox1.Location;   // позиция левого верхнего угла pictureBox1
            Point p1 = this.Location;        // позиция левого верхнего угла формы
            // e.X и e.Y позиция курсора в pictureBox1
            int XX, YY;
            XX = e.X + p.X + p1.X; YY = e.Y + p.Y + p1.Y;
            toolTip1.ToolTipTitle = Convert.ToString(XX) + "; " + Convert.ToString(YY);
            toolTip1.SetToolTip(this.pictureBox1, " ");*/

            //lab12_2
            Point p = pictureBox1.Location;   // позиция левого верхнего угла pictureBox1
            Point p1 = this.Location;        // позиция левого верхнего угла формы
            // e.X и e.Y позиция курсора в pictureBox1
            int XX, YY;
            XX = e.X + p.X + p1.X; YY = e.Y + p.Y + p1.Y;
            /*Bitmap bmp = new Bitmap(1, 1);
            using (Graphics g = Graphics.FromImage(bmp))
            { g.CopyFromScreen(XX, YY, 0, 0, new Size(1, 1)); }
            Color color = bmp.GetPixel(0, 0);
            string SS;
            SS = Convert.ToString(color);
            toolTip1.ToolTipTitle = SS;*/

            toolTip1.ToolTipTitle = "x=" + Convert.ToString(XX) + "; " + "y=" + Convert.ToString(YY);
            toolTip1.SetToolTip(this.pictureBox1, " ");
        }
Example #7
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     Point screenPoint = PointToScreen(new Point(e.X, e.Y));
     Win32.HitTest ht = DoHitTest(e.X, e.Y);
     Win32.ReleaseCapture();
     Win32.SendMessage(Handle, Win32.WM_NCLBUTTONDOWN, (int)ht, (int)(screenPoint.Y << 16 | screenPoint.X));
 }
Example #8
0
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            int col = getCoord(e.X);
            int row = getCoord(e.Y);

            if (e.Button == MouseButtons.Left)
            {
                if (row >= 0 && col >= 0)
                {
                    if (board.isSafe(row, col) && !board.getHasQ(row, col))
                    {
                        board.setHasQ(row, col, true, hint);
                        this.Invalidate();

                        if (board.getNumQueens() == 8) 
                        {
                            System.Windows.Forms.MessageBox.Show("Congratulations! You did it!");
                        }
                    }
                    else
                    {
                        System.Media.SystemSounds.Beep.Play();
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (row >= 0 && col >= 0 && board.getHasQ(row, col))
                {
                    board.setHasQ(row, col, false, hint);
                    this.Invalidate();
                }
            }
        }
Example #9
0
        private void ProjectCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            int x = e.X;
            int y = e.Y;

            if (CurrentlySelected == null)
            {
                return;
            }

            //Move component to mouse position
            CurrentlySelected.Center = new Coordinate(
                    e.X - e.X % ProjectCanvas.GridRaster,
                    e.Y - e.Y % ProjectCanvas.GridRaster);

            //Align the component with the grid
            if (CurrentlySelected.Position.X % ProjectCanvas.GridRaster != 0)
            {
                CurrentlySelected.Position.X -= CurrentlySelected.Position.X % ProjectCanvas.GridRaster;
            }

            if(CurrentlySelected.Position.Y % ProjectCanvas.GridRaster != 0)
            {
                CurrentlySelected.Position.Y -= CurrentlySelected.Position.Y % ProjectCanvas.GridRaster;
            }
        }
Example #10
0
        private void lc(object sender, MouseEventArgs e)
        {
            c.Open();
            DataSet ds = new DataSet();
            string query = "select ID,pname,bill,pbill from pdetails where date=@bc ";
            OleDbCommand cmd = new OleDbCommand(query, c);
            cmd.Parameters.Add("@bc", OleDbType.Date).Value = dateTimePicker1.Value.Date;
            OleDbDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            /*ds.Tables.Add(dt);
            OleDbDataAdapter da = new OleDbDataAdapter();
            da.Fill(dt);*/
            dataGridView1.DataSource = dt.DefaultView;
            c.Close();
            try
            {
                c.Open();
                String str = @"SELECT SUM(pbill) FROM pdetails WHERE date=@bb;";

                OleDbCommand comm2 = new OleDbCommand(str, c);
                comm2.Parameters.Add("@bb", OleDbType.Date).Value = dateTimePicker1.Value.Date;
                bill = Convert.ToDouble(comm2.ExecuteScalar());

                label3.Text = bill.ToString() + "/-";
            }
            catch(Exception ex)
            {
                MessageBox.Show("selected date miss match");
                c.Close();
            }
                c.Close();
        }
Example #11
0
 private void MainForm_MouseClick(object sender, MouseEventArgs e)
 {
     if (!this.timer.Enabled)
     {
         this.Start();
     }
 }
Example #12
0
 private void panel_Title_MouseDown(object sender, MouseEventArgs e)
 {
     int Tem_Y = 0;
     if (e.Button == MouseButtons.Left)//按下的是否为鼠标左键
     {
         Cla_FrmClass.FrmBackCheck();//检测各窗体是否连在一起
         Tem_Y = e.Y;
         FrmClass.FrmPoint = new Point(e.X, Tem_Y);//获取鼠标在窗体上的位置,用于磁性窗体
         FrmClass.CPoint = new Point(-e.X, -Tem_Y);//获取鼠标在屏幕上的位置,用于窗体的移动
         if (FrmClass.Example_List_AdhereTo)//如果与frm_ListBox窗体相连接
         {
             Cla_FrmClass.FrmDistanceJob(this, F_List);//计算窗体的距离差
             if (FrmClass.Example_Assistant_AdhereTo)//两个辅窗体是否连接在一起
             {
                 Cla_FrmClass.FrmDistanceJob(this, F_Libretto);//计算窗体的距离差
             }
         }
         if (FrmClass.Example_Libretto_AdhereTo)//如果与frm_Libretto窗体相连接
         {
             Cla_FrmClass.FrmDistanceJob(this, F_Libretto);//计算窗体的距离差
             if (FrmClass.Example_Assistant_AdhereTo)//两个辅窗体是否连接在一起
             {
                 Cla_FrmClass.FrmDistanceJob(this, F_List);//计算窗体的距离差
             }
         }
     }
 }
 public void UpdateLabel(object sender, MouseEventArgs e)
 {
     if(( e.X % 10 == 0 || e.Y % 10 == 0)
                         || ((e.Button & MouseButtons.Left) == MouseButtons.Left
                             && (e.Button & MouseButtons.Right) == MouseButtons.Right))
     display.Text = string.Format("X: {0}, Y: {1}, Button: {2}", e.X, e.Y, e.Button);
 }
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     Caja = new RectangleF((int)((e.X - MedCambiante.X) / (trackBar1.Value / 100.0f)),
         (int)((e.Y - MedCambiante.Y) / (trackBar1.Value / 100.0f)), 0, 0);
     label1.Text = "X= " + Caja.X;
     label2.Text = "Y= " + Caja.Y;
 }
    void mouseListner_MouseDown(object sender, MouseEventArgs e)
    {
        lastMouseDownPoint = e.Location;
        lastMouseDownSize = sizeChangeCtrl.Size;

        //動作を決定
        status = DAndDArea.None;
        if (getTop().Contains(e.Location))
        {
            status |= DAndDArea.Top;
        }
        if (getLeft().Contains(e.Location))
        {
            status |= DAndDArea.Left;
        }
        if (getBottom().Contains(e.Location))
        {
            status |= DAndDArea.Bottom;
        }
        if (getRight().Contains(e.Location))
        {
            status |= DAndDArea.Right;
        }

        if (status != DAndDArea.None)
        {
            mouseListner.Capture = true;
        }
    }
Example #16
0
        private void gridView1_MouseDown(object sender, MouseEventArgs e)
        {

            _HitInfo = gridView1.CalcHitInfo(new Point(e.X, e.Y));
            HealthInst = ((HealthInstitutionBE)gridView1.GetRow(_HitInfo.RowHandle));

        }
        private void SelectionForm_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
                return;

            _drawStart = e.Location;
        }
Example #18
0
        public override void mouseUp(ref MouseEventArgs e)
        {
            Console.WriteLine("call mouseUp " + _form1._mode);
            if (_form1._mode == EditMode.normal) return;
            if (_form1._mode == EditMode.drawing)
            {
                endDrawing();
                if (_width <= 0 || _height <= 0) endChoosing();
                _zoom.addZoomPoints();

                updateTextBox();
                _form1.richTextBox.Visible = true;
            }
            if (_form1._mode == EditMode.choose)
            {
                _zoom.updateZoomPoints();
            }
            else if (_form1._mode == EditMode.Zoom)
            {
                _zoom.updateZoomPoints();
                _form1._mode = EditMode.choose;
            }
            //MessageBox.Show("Error at MouseUp()!!");
            showZoomPoints();
        }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            clickPoint = Cursor.Position;
            this.Capture = true;

        }
Example #20
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (e.Button == MouseButtons.Left)
                SetVoxel(e.X, e.Y);
        }
Example #21
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None)
            {
                switch (DoHitTest(e.X, e.Y))
                {
                    case Win32.HitTest.HTTOP:
                    case Win32.HitTest.HTBOTTOM:
                        base.Cursor = Cursors.SizeNS;
                        break;

                    case Win32.HitTest.HTLEFT:
                    case Win32.HitTest.HTRIGHT:
                        base.Cursor = Cursors.SizeWE;
                        break;

                    case Win32.HitTest.HTTOPLEFT:
                    case Win32.HitTest.HTBOTTOMRIGHT:
                        base.Cursor = Cursors.SizeNWSE;
                        break;

                    case Win32.HitTest.HTTOPRIGHT:
                    case Win32.HitTest.HTBOTTOMLEFT:
                        base.Cursor = Cursors.SizeNESW;
                        break;

                    default:
                    case Win32.HitTest.HTCLIENT:
                        base.Cursor = base.DefaultCursor;
                        base.OnMouseMove(e);
                        break;
                }
            }
        }
        private void UcLineScanSelection_MouseClick(object sender, MouseEventArgs e)
        {
            if (this.StartPoint != Point.Empty && this.EndPoint != Point.Empty)
            {
                this.StartPoint = Point.Empty;
                this.EndPoint = Point.Empty;
            }

            if (this.StartPoint == Point.Empty)
                this.StartPoint = e.Location;
            else
                this.EndPoint = e.Location;

            if (this.StartPoint != Point.Empty && this.EndPoint != Point.Empty)
            {
                Points.Clear();

                int width = this.pictureBox.Width;

                if (this.SourceImage != null)
                    width = this.SourceImage.Width;

                for (int x = 0; x < width; x++)
                {
                    int y = this.CalcPoint(x);
                    
                    Points.Add(x, y);
                }

                this.pictureBox.Invalidate();
            }
        }
Example #23
0
 private void Ctrl_MouseClick(object sender, MouseEventArgs e)
 {
     if (sender == home_pnl)
     {
         Home_Admin hm = new Home_Admin();
         hm.giveMemberUserName(userName);
         hm.Show();
         this.Hide();
     }
     else if (sender == lock_pnl)
     {
         Home h = new Home();
         h.Show();
         this.Hide();
     }
     else if (sender == minimized_pnl)
     {
         right_option_timer.Stop();
         this.WindowState = FormWindowState.Minimized;
     }
     else if (sender == exit_pnl)
     {
         Application.Exit();
     }
 }
 private void btnMove_MouseMove(object sender, MouseEventArgs e)
 {
     if (MouseDown_TF)
     {
         this.Location = new Point(this.Location.X + (e.X - oldMouseLoc.X), this.Location.Y + (e.Y - oldMouseLoc.Y));
     }
 }
Example #25
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     bool over = ClientRectangle.Contains(e.X, e.Y);
     if (IsMouseOver != over)
         IsMouseOver = over;
 }
 private void Form1_MouseClick(object sender, MouseEventArgs e)
 {
     //mouse_x = e.X;
     //mouse_y = e.Y;
     //string str = "m_x: " + mouse_x + "   m_y:  " + mouse_y +  " ";
     //this.label2.Text = str;
 }
Example #27
0
 private void Picture_MouseDown(object sender, MouseEventArgs e)
 {
     isRightClicked = e.Button == MouseButtons.Right;
     try
     {
         if ((PaintingManager.CurrentTool is TwoPointTool) && !PaintingManager.CurrentTool.InUse)
         {
             ((TwoPointTool)PaintingManager.CurrentTool).StartPainting(e.Location);
             PaintingManager.File.IsModified = true;
         }
         InstantTool currentTool = PaintingManager.CurrentTool as InstantTool;
         if (currentTool != null)
         {
             currentTool.Paint(PaintingManager.Page.Picture, e.Location.X, e.Location.Y,
                 isRightClicked? PaintingManager.CurrentTool.SecondaryColor: PaintingManager.CurrentTool.PrimaryColor,
                               PaintingManager.Page.Picture.GetPixel(e.Location.X, e.Location.Y));
         }
         MultiPointTool multiPointTool = PaintingManager.CurrentTool as MultiPointTool;
         if (multiPointTool != null)
         {
             multiPointTool.InUse = true;
             multiPointTool.PointsToDraw.Add(e.Location);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message + exception.StackTrace, "Error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
Example #28
0
        private void ColorNode_MouseDown(object sender, MouseEventArgs e)
        {
            var colorNode = new Node("Color");
            colorNode.Location = new Point(200, 50);
            var redChannel = new NodeSliderItem("R", 64.0f, 16.0f, 0, 1.0f, 0.0f, false, false);
            var greenChannel = new NodeSliderItem("G", 64.0f, 16.0f, 0, 1.0f, 0.0f, false, false);
            var blueChannel = new NodeSliderItem("B", 64.0f, 16.0f, 0, 1.0f, 0.0f, false, false);
            var colorItem = new NodeColorItem("Color", Color.Black, false, true);

            EventHandler<NodeItemEventArgs> channelChangedDelegate = delegate(object s, NodeItemEventArgs args)
            {
                var red = redChannel.Value;
                var green = blueChannel.Value;
                var blue = greenChannel.Value;
                colorItem.Color = Color.FromArgb((int)Math.Round(red * 255), (int)Math.Round(green * 255), (int)Math.Round(blue * 255));
            };
            redChannel.ValueChanged += channelChangedDelegate;
            greenChannel.ValueChanged += channelChangedDelegate;
            blueChannel.ValueChanged += channelChangedDelegate;

            colorNode.AddItem(redChannel);
            colorNode.AddItem(greenChannel);
            colorNode.AddItem(blueChannel);

            colorItem.Clicked += new EventHandler<NodeItemEventArgs>(OnColClicked);
            colorNode.AddItem(colorItem);

            this.DoDragDrop(colorNode, DragDropEffects.Copy);
        }
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (e.Button == MouseButtons.Right)
                ShowTabPageContextMenu(new Point(e.X, e.Y));
        }
	private void listPresetDateRanges_MouseClick(object sender,MouseEventArgs e) {
		int selectedI=listPresetDateRanges.IndexFromPoint(e.Location);
		switch((ChartViewDates)selectedI) {
			case ChartViewDates.All:
				DateStart=DateTime.MinValue;
				DateEnd=DateTime.MinValue;//interpreted as empty.  We want to show all future dates.
				break;
			case ChartViewDates.Today:
				DateStart=DateTime.Today;
				DateEnd=DateTime.Today;
				break;
			case ChartViewDates.Yesterday:
				DateStart=DateTime.Today.AddDays(-1);
				DateEnd=DateTime.Today.AddDays(-1);
				break;
			case ChartViewDates.ThisYear:
				DateStart=new DateTime(DateTime.Today.Year,1,1);
				DateEnd=new DateTime(DateTime.Today.Year,12,31);
				break;
			case ChartViewDates.LastYear:
				DateStart=new DateTime(DateTime.Today.Year-1,1,1);
				DateEnd=new DateTime(DateTime.Today.Year-1,12,31);
				break;
		}
		FillDateTextBoxesHelper();
	}