private void Box_MouseWheel(object sender, MouseEventArgs e) { lock (lock1) { float zold = zoom; if (e.Delta > 0) { zoom *= 1.2f; } else { zoom *= 0.8f; } if (zoom < 0.01) { zoom = 0.01f; } if (zoom > 1000) { zoom = 1000f; } var pos = Box.PointToClient(Cursor.Position); sx = -(pos.X / zold - sx - pos.X / zoom); sy = -(pos.Y / zold - sy - pos.Y / zoom); } }
public PointF GetPos() { var pos = box.PointToClient(Cursor.Position); var posx = (pos.X / zoom - sx); var posy = (-pos.Y / zoom - sy); return(new PointF(posx, posy)); }
void onClick(object sender, EventArgs e) { Point mousep = System.Windows.Forms.Cursor.Position; mousep = picbox.PointToClient(mousep); cursor.Click(mousep); Refresh(); }
public static Point GetPointOfCursor(this PictureBox pictureBox) { var ratioX = (double)pictureBox.Image.Width / pictureBox.Width; var ratioY = (double)pictureBox.Image.Height / pictureBox.Height; var result = new Point( (int)(pictureBox.PointToClient(Cursor.Position).X *ratioX), (int)(pictureBox.PointToClient(Cursor.Position).Y *ratioY)); return(result); }
private void picKeyboard_DoubleClick(object sender, EventArgs e) { mMouseDownPos = mCtrl.PointToClient(Cursor.Position); var channel = mMouseDownPos.Y / ChannelHeight; if (InstName.X <= mMouseDownPos.X && channel < 16) { var fm = new InstList(mSender, channel); fm.ShowDialog(); } }
public void trackCursor(bool LMBisDown) { if (!LMBisDown) { Point loc = gameWindow.PointToClient(Cursor.Position); drawnObjects[0].Add(new Sprite(loc, @".\\ImageResources\\SwordCursor.png")); } if (LMBisDown) { Point loc = gameWindow.PointToClient(Cursor.Position); drawnObjects[0].Add(new Sprite(loc, @".\\ImageResources\\SwordCursorAlt.png")); } }
void framecontrol_DragOver(object sender, DragEventArgs e) { if (!e.Data.GetDataPresent(typeof(int))) { e.Effect = DragDropEffects.None; } else { PictureBox pb = (PictureBox)sender; Point p = pb.PointToClient(new Point(e.X, e.Y)); int toFrame = p.X / (pb.Size.Width / mFrames); string[] images = mData.getFrame(mState, toFrame); if (images == null) { e.Effect = DragDropEffects.Copy; return; } for (int i = images.Length - 1; i >= 0; --i) { if (images[i] != null) { e.Effect = DragDropEffects.None; return; } } e.Effect = DragDropEffects.Copy; } }
public Point getPoint() { Point p = mScreen.PointToClient(Control.MousePosition); // Console.WriteLine("point:" + p); return(p); }
public PointF GetCursor() { var p = PictureBox.PointToClient(Cursor.Position); var pn = BackTransform(p); return(pn); }
private Color GetMousePickedColor() { Point mousePos = PictureBox.PointToClient(Cursor.Position); int x = (int)(((float)(mousePos.X) / (float)(PictureBox.Width)) * (float)PictureBox.Image.Width); int y = (int)(((float)(mousePos.Y) / (float)(PictureBox.Height)) * (float)PictureBox.Image.Height); if (x < 0) { return(Color.Transparent); } if (y < 0) { return(Color.Transparent); } if (x >= PictureBox.Image.Width) { return(Color.Transparent); } if (y >= PictureBox.Image.Height) { return(Color.Transparent); } return(bitmap.GetPixel(x, y)); }
//event for mouseclick on lighting units to display information about the wanted unit //also functions as a second method of checking the checkboxes when choosing addresses private void Form1_MouseClick(object sender, MouseEventArgs e) { l.Location = new Point(0, _buttons[2].Location.Y - _buttonHeight * 2); l.AutoSize = true; Point LocalMousePosition = SimulationRoom.PointToClient(Cursor.Position); foreach (var VARIABLE in light) { if (VARIABLE.x <= LocalMousePosition.X + 10 && VARIABLE.x >= LocalMousePosition.X - 10 && VARIABLE.y <= LocalMousePosition.Y + 10 && VARIABLE.y >= LocalMousePosition.Y - 10) { l.Text = "Current Ligting Unit: " + VARIABLE.Address; LightingUnit Current = DALIController.FindUnitWithAddress(VARIABLE.Address); InfoScreen.ChangeCurrentLightingUnit(Current); if (CheckBoxes[VARIABLE.Address].Checked == false) { CheckBoxes[VARIABLE.Address].Checked = true; } else if (CheckBoxes[VARIABLE.Address].Checked == true) { CheckBoxes[VARIABLE.Address].Checked = false; } } } }
private void перевернутьToolStripMenuItem_Click(object sender, EventArgs e) { Point pos = PictureBox.PointToClient(Control.MousePosition); if (_partStart != -1 && _partEnd != -1 && ((pos.X >= _partStart && pos.X <= _partEnd) || (pos.X <= _partStart && pos.X >= _partEnd))) { int startWav = (_partStart >= _partEnd ? _partEnd : _partStart); int endWav = (_partStart >= _partEnd ? _partStart : _partEnd); startWav = getPosInWavBuffer(startWav); endWav = getPosInWavBuffer(endWav); if (endWav >= _bytes.Length) { endWav = _bytes.Length - 1; } _bytes = AudioUtils.ReverseWave(_bytes, startWav, endWav); _audioFrame.Process(ref _bytes, true); updateWave(); } else { _bytes = AudioUtils.ReverseWave(ref _bytes); _audioFrame.Process(ref _bytes, true); updateWave(); } _partStart = _partEnd = -1; }
public ServerSocket() { // // Required for Windows Form Designer support // InitializeComponent(); pictureBox1.Width = Panel_ImageHolder.Width; pictureBox1.Height = Panel_ImageHolder.Height; //opeque black in the controller panel panel_controllers.BackColor = Color.FromArgb(190, 0, 0, 0); btn_Play.FlatAppearance.MouseOverBackColor = btn_Play.BackColor; btn_Play.BackColorChanged += (s, e) => { btn_Play.FlatAppearance.MouseOverBackColor = btn_Play.BackColor; }; var pos = this.PointToScreen(panel_controllers.Location); pos = pictureBox1.PointToClient(pos); panel_controllers.Parent = pictureBox1; panel_controllers.Location = pos; //*************** SOCKET CODES ************ // tbAux.SelectionChanged += tbAux_SelectionChanged; // // TODO: Add any constructor code after InitializeComponent call // }
public static void MakePicTransparent(PictureBox pciture, PictureBox pictureBox, Form form) { var pos = form.PointToScreen(pciture.Location); pos = pictureBox.PointToClient(pos); pciture.Parent = pictureBox; pciture.Location = pos; }
internal void 设置伪彩色频点(Point 坐标, Color 颜色) { Point 当前点坐标 = 谱线图片框右.PointToClient(坐标); if (当前点坐标.X < 画线区域框.X || 当前点坐标.Y < 画线区域框.Y || 当前点坐标.X > 画线区域框.Width + 画线区域框.X || 当前点坐标.Y > 画线区域框.Height + 画线区域框.Y) { return; } float 横向间隔 = (float)画线区域框.Width / (RAW数据.数据[0, 0].幅值.Length - 1); int n = 0; Point 框内坐标 = new Point(当前点坐标.X - 画线区域框.X, 当前点坐标.Y - 画线区域框.Y); if (框内坐标.X > 横向间隔 / 2) { n = (int)(((float)框内坐标.X - 横向间隔 / 2) / 横向间隔) + 1; } if (颜色 == Color.Red) { 红频点 = n; } else if (颜色 == Color.Green) { 绿频点 = n; } else { 蓝频点 = n; } g谱线位图.FillRectangle(new SolidBrush(背景色), new Rectangle(0, 0, 谱线图片框大小.Width, 画线区域框.Y)); if (红频点 >= 0) { g谱线位图.DrawLine(new Pen(Color.Red), new PointF(红频点 * 横向间隔 + 画线区域框.X, 画线区域框.Y - 1), new PointF(红频点 * 横向间隔 + 画线区域框.X, 0)); } if (绿频点 >= 0) { g谱线位图.DrawLine(new Pen(Color.Green), new PointF(绿频点 * 横向间隔 + 画线区域框.X, 画线区域框.Y - 1), new PointF(绿频点 * 横向间隔 + 画线区域框.X, 0)); } if (蓝频点 >= 0) { g谱线位图.DrawLine(new Pen(Color.Blue), new PointF(蓝频点 * 横向间隔 + 画线区域框.X, 画线区域框.Y - 1), new PointF(蓝频点 * 横向间隔 + 画线区域框.X, 0)); } //Pen 笔 = new Pen(颜色); //g谱线位图.DrawLine(笔, new PointF(n * 横向间隔 + 画线区域框.X, 画线区域框.Y - 1), new PointF(n * 横向间隔 + 画线区域框.X, 0)); 谱线图片框右.Refresh(); }
private bool mouseOverArea(PictureBox area) { if (area.ClientRectangle.Contains(area.PointToClient(Cursor.Position))) { return(true); } return(false); }
public static void MakeButtonTransparent(Button button, PictureBox pictureBox, Form form) { var pos = form.PointToScreen(button.Location); pos = pictureBox.PointToClient(pos); button.Parent = pictureBox; button.Location = pos; }
public static void MakeTransparent(Label label, PictureBox pictureBox, Form form) { var pos = form.PointToScreen(label.Location); pos = pictureBox.PointToClient(pos); label.Parent = pictureBox; label.Location = pos; }
private void TransparentChange(PictureBox PictureBoxName, Label LabelName, int alpha, Color color) { var pos = this.PointToScreen(LabelName.Location); pos = PictureBoxName.PointToClient(pos); LabelName.Parent = PictureBoxName; LabelName.Location = pos; LabelName.BackColor = Color.FromArgb(alpha, color); }
private void bindPictureBoxAndLabel(PictureBox pictureBox, Label label) { var pos = PointToScreen(label.Location); pos = pictureBox.PointToClient(pos); label.Parent = pictureBox; label.Location = pos; label.BackColor = Color.Transparent; }
void framecontrol_DragDrop(object sender, DragEventArgs e) { mFromFrame = (int)e.Data.GetData(typeof(int)); PictureBox pb = (PictureBox)sender; Point p = pb.PointToClient(new Point(e.X, e.Y)); mToFrame = p.X / (pb.Size.Width / mFrames); copyMoveMenu.Show(new Point(e.X, e.Y)); }
void removeBG(PictureBox pb, PictureBox pb2) { var pos = this.PointToScreen(pb2.Location); pos = pb.PointToClient(pos); pb2.Parent = pb; pb2.Location = pos; pb2.BackColor = Color.Transparent; }
public void TachNen(Label t, PictureBox p) { var a = this.PointToScreen(t.Location); a = p.PointToClient(a); t.Parent = p; t.Location = a; t.BackColor = Color.Transparent; }
/// <summary> /// 鼠标点击高光谱采样图片时,会把该点的光谱曲线固定在右边的谱线框中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 采样图片框_MouseClick(object sender, MouseEventArgs e) { Point 当前点坐标 = 采样图片框左.PointToClient(Cursor.Position); if (当前点坐标.X < 0 || 当前点坐标.Y < 0 || 当前点坐标.X > RAW数据.灰度图.Width || 当前点坐标.Y > RAW数据.灰度图.Height) { return; } if (e.Button != MouseButtons.Left) { return; } 点击采样点列表.Add(当前点坐标); Color 颜色 = 颜色8[(点击采样点列表.Count - 1) % 颜色8.Length]; 画光谱曲线(RAW数据.数据[当前点坐标.Y, 当前点坐标.X].幅值, Math.Max(RAW数据.最大值, RAW数据.数据[当前点坐标.Y, 当前点坐标.X].最大幅值), g谱线位图, 画线区域框, 颜色); 画点击采样点(g采样图片框, 当前点坐标, 颜色); }
private Label MakeItTrans(Label l, PictureBox p) { var pos = this.PointToScreen(l.Location); pos = p.PointToClient(pos); l.Parent = p; l.Location = pos; l.BackColor = Color.Transparent; return(l); }
public void UpdateDrag() { if (isDrag) { var p = PictureBox.PointToClient(Cursor.Position); sx = origsx + ((p.X - startx) / zoom); sy = origsy + (-(p.Y - starty) / zoom); } }
private void SetTransparentText(Label label, string text) { var pos = PointToScreen(label.Location); pos = pictureBox.PointToClient(pos); label.Parent = pictureBox; label.Location = pos; label.BackColor = Color.Transparent; label.Visible = true; label.Text = text; }
void startPlay() { //start play and start timer to draw play position\ _player = new MediaPlayer(this.Parent); // start lay from the position of the mouse Point loc = PictureBox.PointToClient(Control.MousePosition); int wavPos = getPosInWavBuffer(loc.X); _player.Play(_bytes, wavPos); _timer.Start(); }
private void btn_Paint(object sender, PaintEventArgs e) { PictureBox pic = (sender as PictureBox); Point p = pic.PointToClient(Control.MousePosition); if (pic.ClientRectangle.Contains(p.X, p.Y)) { using (SolidBrush brush = new SolidBrush(Color.FromArgb(100, Color.YellowGreen))) e.Graphics.FillRectangle(brush, pic.ClientRectangle); } }
/// <summary> /// カーソルがどのフィールドの上にいるかを計算します。 /// </summary> /// <returns></returns> public Coordinate CursorPosition(PictureBox pictureBox) { var fieldWidth = ((pictureBox.Width <= 0) ? 1 : pictureBox.Width) / Calc.Field.Width; var fieldHeight = ((pictureBox.Height <= 0) ? 1 : pictureBox.Height) / Calc.Field.Height; System.Drawing.Point systemCursorPosition = System.Windows.Forms.Cursor.Position; System.Drawing.Point pictureBoxCursorPosition = pictureBox.PointToClient(systemCursorPosition); return(new System.Drawing.Point( x: pictureBoxCursorPosition.X / ((fieldWidth <= 0) ? 1 : fieldWidth), y: pictureBoxCursorPosition.Y / ((fieldHeight <= 0) ? 1 : fieldHeight))); }