Пример #1
0
        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);
            }
        }
Пример #2
0
        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));
        }
Пример #3
0
        void onClick(object sender, EventArgs e)
        {
            Point mousep = System.Windows.Forms.Cursor.Position;

            mousep = picbox.PointToClient(mousep);
            cursor.Click(mousep);
            Refresh();
        }
Пример #4
0
        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);
        }
Пример #5
0
        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();
            }
        }
Пример #6
0
 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"));
     }
 }
Пример #7
0
 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;
     }
 }
Пример #8
0
        public Point getPoint()
        {
            Point p = mScreen.PointToClient(Control.MousePosition);

            //   Console.WriteLine("point:" + p);
            return(p);
        }
Пример #9
0
        public PointF GetCursor()
        {
            var p  = PictureBox.PointToClient(Cursor.Position);
            var pn = BackTransform(p);

            return(pn);
        }
Пример #10
0
        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));
        }
Пример #11
0
        //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;
                    }
                }
            }
        }
Пример #12
0
        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
            //
        }
Пример #14
0
        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;
        }
Пример #15
0
        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();
        }
Пример #16
0
 private bool mouseOverArea(PictureBox area)
 {
     if (area.ClientRectangle.Contains(area.PointToClient(Cursor.Position)))
     {
         return(true);
     }
     return(false);
 }
Пример #17
0
        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;
        }
Пример #18
0
        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;
        }
Пример #19
0
        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);
        }
Пример #20
0
        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;
        }
Пример #21
0
        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));
        }
Пример #22
0
        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;
        }
Пример #24
0
        /// <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采样图片框, 当前点坐标, 颜色);
        }
Пример #25
0
        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);
        }
Пример #26
0
        public void UpdateDrag()
        {
            if (isDrag)
            {
                var p = PictureBox.PointToClient(Cursor.Position);

                sx = origsx + ((p.X - startx) / zoom);
                sy = origsy + (-(p.Y - starty) / zoom);
            }
        }
Пример #27
0
        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;
        }
Пример #28
0
        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();
        }
Пример #29
0
        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);
            }
        }
Пример #30
0
        /// <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)));
        }