示例#1
0
 // Function that sends a click to the server
 public void Click(RVIVector2 pos)
 {
     if (_client != null)
     {
         _client.Click(pos);
     }
 }
示例#2
0
        // OpenGL click control handler
        private void openGLControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point      p   = e.GetPosition(openGLControl);
            RVIVector2 pos = new RVIVector2(p.X / openGLControl.ActualWidth, 1f - (p.Y / openGLControl.ActualHeight));

            Click(pos);
        }
示例#3
0
        public void DrawRect(RVIVector2 pos, float w, float h)
        {
            Dispatcher.Invoke(new Action(() =>
            {
                if (string.IsNullOrWhiteSpace(_currentFrame))
                {
                    throw new NullReferenceException("Current frame is not set, cannot draw!");
                }
                double canvasW = canvas.Width;
                double canvasH = canvas.Height;

                RVIVector2 rasterizedPos = new RVIVector2((float)(pos.x * canvasW), (float)(canvasH - (pos.y * canvasH)));
                double rasterizedW       = w * canvasW;
                double rasterizedH       = h * canvasH;

                System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
                rect.Width  = rasterizedW;
                rect.Height = rasterizedH;
                rect.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(_currentColor.A, _currentColor.R, _currentColor.G, _currentColor.B));
                _frames[_currentFrame].Add(rect);
                Canvas.SetTop(rect, rasterizedPos.y - rasterizedH);
                Canvas.SetLeft(rect, rasterizedPos.x);
                _refresh = true;
            }));
        }
示例#4
0
        public void DrawLine(RVIVector2 posA, RVIVector2 posB)
        {
            Dispatcher.Invoke(new Action(() =>
            {
                if (string.IsNullOrWhiteSpace(_currentFrame))
                {
                    throw new NullReferenceException("Current frame is not set, cannot draw!");
                }
                double canvasW = canvas.Width;
                double canvasH = canvas.Height;

                RVIVector2 rasterizedA = new RVIVector2((float)(posA.x * canvasW), (float)(canvasH - (posA.y * canvasH)));
                RVIVector2 rasterizedB = new RVIVector2((float)(posB.x * canvasW), (float)(canvasH - (posB.y * canvasH)));

                Line line            = new Line();
                line.X1              = rasterizedA.x;
                line.X2              = rasterizedB.x;
                line.Y1              = rasterizedA.y;
                line.Y2              = rasterizedB.y;
                line.StrokeThickness = 1;
                line.Stroke          = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(_currentColor.A, _currentColor.R, _currentColor.G, _currentColor.B));
                _frames[_currentFrame].Add(line);
                _refresh = true;
            }));
        }
示例#5
0
 // Adds a rectangle shape to the current frame
 public void DrawRect(RVIVector2 pos, float width, float height)
 {
     if (_currentFrame != null)
     {
         RVIShape rect = RVIShape.CreateRect(new RVIRectangle(pos.x, pos.y, width, height), _currentColorRGBA);
         lock (_framesLock)
         {
             _frames[_currentFrame].Add(rect);
         }
     }
 }
示例#6
0
 // Adds a line shape to the current frame
 public void DrawLine(RVIVector2 posA, RVIVector2 posB)
 {
     if (_currentFrame != null)
     {
         RVIShape line = RVIShape.CreateLine(posA, posB, _currentColorRGBA);
         lock (_framesLock)
         {
             _frames[_currentFrame].Add(line);
         }
     }
 }
示例#7
0
 // Hack to fix an error that shifts text drawn by 1 bit for some reason
 private void DrawTextGL(OpenGL gl, string text, RVIVector2 position, float r, float g, float b, string fontName, float size)
 {
     // TL;DR -> Shift text by 1 bit to the right
     byte[] ascii = Encoding.ASCII.GetBytes(text);
     for (int i = 0; i < ascii.Length; i++)
     {
         ascii[i] += 1;
     }
     text = Encoding.ASCII.GetString(ascii);
     gl.DrawText((int)position.x, (int)position.y, r, g, b, fontName, size, text);
 }
示例#8
0
        private void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (_client == null)
            {
                return;
            }
            System.Windows.Point clickPos = e.GetPosition(canvas);
            RVIVector2           vPos     = new RVIVector2((float)(clickPos.X / canvas.Width), (float)((canvas.Height - clickPos.Y) / canvas.Height));

            _client.Click(vPos);
        }
示例#9
0
 public void Click(RVIVector2 pos)
 {
     throw new NotImplementedException();
 }