Пример #1
0
 private void InternalClick(int identity, bool down)
 {
     if (!Utils.IsForegroundApplication())
     {
         return;
     }
     BstCursor.State state = this.LookupCursor(identity);
     if (state == null)
     {
         Logger.Warning("Cannot find cursor slot for identity {0}", (object)identity);
     }
     else
     {
         state.Clicked = down;
         if (!down)
         {
             state.Pointer.SetBitmap(state.PrimaryImage);
         }
         else
         {
             state.Pointer.SetBitmap(state.SecondaryImage);
         }
         this.InternalMove(identity, 0.0f, 0.0f, false);
     }
 }
Пример #2
0
        public void RaiseFocusChange()
        {
            bool flag = false;

            if (Utils.IsForegroundApplication())
            {
                flag = true;
            }
            for (int index = 0; index < 4; ++index)
            {
                BstCursor.State mCursor = this.mCursors[index];
                if (mCursor.Pointer != null)
                {
                    if (flag)
                    {
                        VMWindow.Instance.Focus();
                        mCursor.Pointer.Show();
                    }
                    else
                    {
                        mCursor.Pointer.Hide();
                    }
                }
            }
        }
Пример #3
0
 private void InternalMove(int identity, float x, float y, bool absolute)
 {
     if (!Utils.IsForegroundApplication())
     {
         return;
     }
     BstCursor.State state = this.LookupCursor(identity);
     if (state == null)
     {
         Logger.Warning("Cannot find cursor slot for identity {0}", (object)identity);
     }
     else
     {
         Rectangle scaledDisplayArea = LayoutManager.mScaledDisplayArea;
         state.Position.X += (int)x;
         if (state.Position.X < 0)
         {
             state.Position.X = 0;
         }
         else if (state.Position.X > scaledDisplayArea.Width)
         {
             state.Position.X = scaledDisplayArea.Width;
         }
         state.Position.Y += (int)y;
         if (state.Position.Y < 0)
         {
             state.Position.Y = 0;
         }
         else if (state.Position.Y > scaledDisplayArea.Height)
         {
             state.Position.Y = scaledDisplayArea.Height;
         }
         if (VMWindow.Instance.Visible)
         {
             Rectangle screen = VMWindow.Instance.RectangleToScreen(scaledDisplayArea);
             int       x1     = state.Position.X + screen.Left - state.Pointer.GetBitmap().Width / 2;
             int       y1     = state.Position.Y + screen.Top - state.Pointer.GetBitmap().Height / 2;
             state.Pointer.Update(x1, y1);
             state.Pointer.Show();
         }
         else
         {
             state.Pointer.Hide();
         }
         InputMapper.TouchPoint[] points = new InputMapper.TouchPoint[1];
         points[0].X    = (float)state.Position.X / (float)scaledDisplayArea.Width;
         points[0].Y    = (float)state.Position.Y / (float)scaledDisplayArea.Height;
         points[0].Down = state.Clicked;
         InputMapper.Instance.TouchHandlerImpl(points, state.SlotId * 4, false);
     }
 }
Пример #4
0
 public void GetNormalizedPosition(int identity, out float x, out float y)
 {
     BstCursor.State state = this.LookupCursor(identity);
     if (state == null)
     {
         x = 0.0f;
         y = 0.0f;
     }
     else
     {
         Rectangle scaledDisplayArea = LayoutManager.mScaledDisplayArea;
         x = (float)state.Position.X / (float)scaledDisplayArea.Width;
         y = (float)state.Position.Y / (float)scaledDisplayArea.Height;
     }
 }
Пример #5
0
 private void InternalDetach(int identity)
 {
     Logger.Info("Cursor.Detach({0})", (object)identity);
     BstCursor.State state = this.LookupCursor(identity);
     if (state == null)
     {
         Logger.Warning("Cannot find cursor slot for identity {0}", (object)identity);
     }
     else
     {
         state.Pointer.Close();
         state.Pointer    = (BstCursor.Pointer)null;
         state.Position.X = 0;
         state.Position.Y = 0;
         state.Clicked    = false;
     }
 }
Пример #6
0
 private void InternalAttach(int identity)
 {
     Logger.Info("Cursor.Attach({0})", (object)identity);
     BstCursor.State state = this.LookupCursor(identity);
     if (state == null)
     {
         Logger.Warning("Cannot find cursor slot for identity {0}", (object)identity);
     }
     else if (state.Pointer != null)
     {
         Logger.Warning("Cursor slot ID %d already has a pointer", (object)state.SlotId);
     }
     else
     {
         Logger.Info("Cursor using slot {0}", (object)state.SlotId);
         state.Position.X = 128;
         state.Position.Y = 128;
         state.Clicked    = false;
         state.Pointer    = new BstCursor.Pointer();
         state.Pointer.SetBitmap(state.PrimaryImage);
         this.InternalMove(identity, 0.0f, 0.0f, false);
         VMWindow.Instance.Focus();
     }
 }