public MetroForFly(
            System.Windows.Forms.Control fatherControl, // 父容器
            int flyWidth,
            int flyHeight,
            System.Drawing.Point locationPoint,    // 整体位置
            System.Windows.Forms.AnchorStyles anchorstyle
            )
        {
            // 包裹外层
            var panelSec = new HPanel
            {
                Size = new System.Drawing.Size(flyWidth, flyHeight),
                Location = locationPoint,
                Anchor = anchorstyle,
                BackColor = System.Drawing.Color.Transparent
            };
            Size = new System.Drawing.Size(flyWidth + 3 + 12, flyHeight + 3);
            Location = new System.Drawing.Point(-3, -3);
            BackColor = System.Drawing.Color.Transparent;
            Anchor = BaseAnchor.AnchorFill;
            AllowDrop = true;
            AutoScroll = true;
            MouseDown += MetroForFly_MouseDown;
            DragEnter += MetroForFly_DragEnter;

            // 加载实体层
            panelSec.Controls.Add(this);
            // 加载包裹外层
            fatherControl.Controls.Add(panelSec);
        }
 public Point GetCursorPosition()
 {
     var newPosition = new SysPoint();
     NativeMethods.GetCursorPos(ref newPosition);
     var screenspace = FromScreenPositionToScreenSpace(FromSysPoint(newPosition));
     return new Point((float)Math.Round(screenspace.X, 3), (float)Math.Round(screenspace.Y, 3));
 }
Exemple #3
1
 public void PointToSystemPoint()
 {
     var pt = new Point(2, 5);
     var actual = pt.ToSystemPoint();
     var expected = new System.Drawing.Point(2, 5);
     Assert.AreEqual(expected, actual);
 }
 // We take both the EditorForm's handle and its displayPanel handle, since messages
 // will sometimes be for the form, or the display panel.
 public MessageHandler( Panel displayPanel, EditorForm parent )
 {
     m_fakeFocus = false;
     m_displayPanel = displayPanel;
     m_parent = parent;
     m_mouseDownPosition = new System.Drawing.Point(0, 0); 
 }
        ///<summery>
        ///Finds global minimum and maximum in array or subarray.
        ///</summery>
        public static void CVMinMaxLoc(CVImage image,
            out double minVal,
            out double maxVal,
            out System.Drawing.Point minLocation,
            out System.Drawing.Point maxLocation,
            CVArr mask)
        {
            // Prepare out paramaters:
            __CvPoint min_loc = new __CvPoint();
            __CvPoint max_loc = new __CvPoint();
            double min_val = -1;
            double max_val = -1;

            //CvArr tempMask = 0;
            //if (mask != nullptr) {
            //    tempMask = mask->Array;
            //}
            //CVArr tempMask = mask.Array;

            minLocation = new System.Drawing.Point(0, 0);
            maxLocation = new System.Drawing.Point(0, 0);

            // Native call to openCV cvMinMaxLoc:
            PInvoke.cvMinMaxLoc(
                new __CvArrPtr(image),
                ref min_val, ref max_val,
                ref min_loc, ref max_loc, new __CvArrPtr(mask));

            minVal = min_val;
            maxVal = max_val;
            minLocation = new System.Drawing.Point(min_loc.x, min_loc.y);
            maxLocation = new System.Drawing.Point(max_loc.x, max_loc.y);
        }
        private void PN_Map_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.X / TileSize + 1 > map.MapSize.Width || e.Y / TileSize + 1 > map.MapSize.Height)
                return;

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                System.Drawing.Point click = new System.Drawing.Point(e.X / TileSize, e.Y / TileSize);
                LayerSelector layerdlg = new LayerSelector();
                layerdlg.ShowDialog();
                if (layerdlg.confirmed)
                {
                    if (layerdlg.layer > -1 && layerdlg.layer < 3)
                    {
                        ConfirmationTeleportation confirmationdlg = new ConfirmationTeleportation(premier, layer, click, layerdlg.layer, firstMap, map);
                        confirmationdlg.ShowDialog();
                        if (confirmationdlg.pEventAjouté)
                        {
                            ajouté = true;
                            this.Close();
                        }
                    }
                }
            }
        }
        public SelectTeleportationForm(Map map, System.Drawing.Point premier, int layer, Map firstMap, SpriteBatch Mapbatch)
        {
            InitializeComponent();
            utils = new XNAUtils();
            this.map = map;
            this.premier = premier;
            this.layer = layer;
            this.firstMap = firstMap;
            this.batch = Mapbatch;

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Size = Screen.PrimaryScreen.Bounds.Size;
            this.StartPosition = FormStartPosition.Manual;
            this.Location = new System.Drawing.Point(0, 0);

            PN_Map.Size = Screen.PrimaryScreen.Bounds.Size;
            PresentationParameters pp = new PresentationParameters()
            {
                BackBufferHeight = PN_Map.Height,
                BackBufferWidth = PN_Map.Width,
                DeviceWindowHandle = PN_Map.Handle,
                IsFullScreen = false
            };
            XNADevices.graphicsdevice.Reset(pp);
        }
        public void Execute(Point startClick, Point endClick)
        {
            var pt = new System.Drawing.Point((int) startClick.X, (int) startClick.Y);

            if (askForColor)
            {
                colorDlg.ShowDialog();
                fillColor = colorDlg.Color;
            }

            Animation animation = Animation.getInstance();
            if (animation.PointInCell(startClick))
            {
                //Already Exisiting Cell
                Cell c = animation.findCell(startClick);
                int frame = _viewModel.currentFrame;
                c.color[frame] = fillColor;

                //Trigers and update on the View
                _viewModel.Cells.Remove(c);
                _viewModel.Cells.Add(c);
            }
            else
            {

                var finder = new RegionFinder(_viewModel.Image, pt, _viewModel.Tolerance);
                finder.LineFound +=
                    line => _viewModel.Cells.Add(new Cell(line.Select(p => new Point(p.X, p.Y)).ToArray(), animation.numFrames(), _viewModel.currentFrame, fillColor));
                finder.Process();

                //Add to the Model
                animation.addCell(_viewModel.Cells.Last());

            }
        }
Exemple #9
0
        public static ETransformType CheckTransformRect(Rectangle r, Point point)
        {
            Microsoft.Xna.Framework.Point p = new Microsoft.Xna.Framework.Point(point.X, point.Y);
            Rectangle rectTL = GetTransformRect(r, ETransformType.TopLeft);
            if (rectTL.Contains(p)) return ETransformType.TopLeft;
            Rectangle rectTR = GetTransformRect(r, ETransformType.TopRight);
            if (rectTR.Contains(p)) return ETransformType.TopRight;
            Rectangle rectBL = GetTransformRect(r, ETransformType.BottomLeft);
            if (rectBL.Contains(p)) return ETransformType.BottomLeft;
            Rectangle rectBR = GetTransformRect(r, ETransformType.BottomRight);
            if (rectBR.Contains(p)) return ETransformType.BottomRight;

            Rectangle rectT = GetTransformRect(r, ETransformType.Top);
            if (rectT.Contains(p)) return ETransformType.Top;
            Rectangle rectB = GetTransformRect(r, ETransformType.Bottom);
            if (rectB.Contains(p)) return ETransformType.Bottom;
            Rectangle rectL = GetTransformRect(r, ETransformType.Left);
            if (rectL.Contains(p)) return ETransformType.Left;
            Rectangle rectR = GetTransformRect(r, ETransformType.Right);
            if (rectR.Contains(p)) return ETransformType.Right;

            Rectangle rectM = GetTransformRect(r, ETransformType.Middle);
            if (rectM.Contains(p)) return ETransformType.Middle;
            Rectangle rectC = GetTransformRect(r, ETransformType.Center);
            if (rectC.Contains(p)) return ETransformType.Center;

            return ETransformType.None;
        }
        public override bool HandleTileEdit(TSPlayer player, TileEditType editType, BlockType blockType, DPoint location, int objectStyle)
        {
            if (this.IsDisposed)
            return false;
              if (base.HandleTileEdit(player, editType, blockType, location, objectStyle))
            return true;

              if (editType == TileEditType.PlaceTile)
            return this.HandleTilePlace(player, blockType, location, objectStyle);
              if (editType == TileEditType.TileKill || editType == TileEditType.TileKillNoItem)
            return this.HandleTileDestruction(player, location);
              if (editType == TileEditType.PlaceWire || editType == TileEditType.PlaceWireBlue || editType == TileEditType.PlaceWireGreen)
            return this.HandleWirePlace(player, location);

              #if DEBUG || Testrun
              if (editType == TileEditType.DestroyWire) {
            player.SendMessage(location.ToString(), Color.Aqua);

            if (!TerrariaUtils.Tiles[location].active())
              return false;

            ObjectMeasureData measureData = TerrariaUtils.Tiles.MeasureObject(location);
            player.SendInfoMessage(string.Format(
              "X: {0}, Y: {1}, FrameX: {2}, FrameY: {3}, Origin X: {4}, Origin Y: {5}, Active State: {6}",
              location.X, location.Y, TerrariaUtils.Tiles[location].frameX, TerrariaUtils.Tiles[location].frameY,
              measureData.OriginTileLocation.X, measureData.OriginTileLocation.Y,
              TerrariaUtils.Tiles.ObjectHasActiveState(measureData)
            ));
              }
              #endif

              return false;
        }
		public Vector2D GetCursorPosition()
		{
			var newPosition = new SysPoint();
			NativeMethods.GetCursorPos(ref newPosition);
			var screenSpace = FromScreenPositionToScreenSpace(FromSysPoint(newPosition));
			return new Vector2D((float)Math.Round(screenSpace.X, 3), (float)Math.Round(screenSpace.Y, 3));
		} //ncrunch: no coverage end
Exemple #12
0
 public void InitView(GroupBox gBox)
 {
     Location = new System.Drawing.Point(6, 18);
     Size = new System.Drawing.Size(296, 156);
     TabIndex = 0;
     gBox.Controls.Add(this);
 }
 public bool Protector_CheckProtected(TSPlayer player, DPoint tileLocation, bool fullAccessRequired) {
   try {
     return !ProtectorPlugin.LatestInstance.ProtectionManager.CheckBlockAccess(player, tileLocation, fullAccessRequired);
   } catch (Exception ex) {
     throw new CooperatingPluginException(null, ex);
   }
 }
		public int BufferHeight()
		{
			var height = VideoProvider.BufferHeight;
			var point = new System.Drawing.Point(0, height);

			return GlobalWin.DisplayManager.TransformPoint(point).Y - BorderHeight();
		}
Exemple #15
0
 /// <summary>
 /// Oblicza ścieżkę dla obiektu.
 /// </summary>
 /// <param name="start">Punkt początkowy ścieżki</param>
 /// <param name="goal">Puntk docelowy</param>
 /// <param name="objectRadius">Promień kuli, która jest w stanie objąć cały obiekt</param>
 /// <param name="controllable">Obiekt, dla którego obliczana jest ścieżka</param>
 /// <param name="gameObjects">Lista wszystkich obiektów na planszy</param>
 public void FindPath(Point start, Point goal, int objectRadius, IControllable controllable, IEnumerable<GameObject> gameObjects)
 {
     msg = "";
     DateTime dateTime = DateTime.Now;
     if(!radiuses.Contains(objectRadius))
     {
         curProcessed = ProcessMap(map, objectRadius, out curAvgDifficulty);
         lastRadius = objectRadius;
         lock (maps)
         {
             radiuses.Add(lastRadius);
             avgDifficulties.Add(curAvgDifficulty);
             maps.Add(curProcessed);
         }
     }
     else
     {
         lastRadius = objectRadius;
         curProcessed = maps[radiuses.IndexOf(objectRadius)];
         curAvgDifficulty = avgDifficulties[radiuses.IndexOf(objectRadius)];
     }
     msg += (DateTime.Now - dateTime).ToString() + "\r\n";
     Thread th = new Thread(new ParameterizedThreadStart(AStar));
     pathTime = DateTime.Now;
     th.Start(new AStarArg(start,goal,controllable, gameObjects));
     //AStar(start, goal, out path);
 }
    internal MouseCallbackEventArgs(IntPtr pRhinoView, int button, int x, int y)
    {
      //const int btnNone = 0;
      const int btnLeft = 1;
      const int btnRight = 2;
      const int btnMiddle = 3;
      const int btnX = 4;

      m_pRhinoView = pRhinoView;
      switch (button)
      {
        case btnLeft:
          m_button = System.Windows.Forms.MouseButtons.Left;
          break;
        case btnMiddle:
          m_button = System.Windows.Forms.MouseButtons.Middle;
          break;
        case btnRight:
          m_button = System.Windows.Forms.MouseButtons.Right;
          break;
        case btnX:
          m_button = System.Windows.Forms.MouseButtons.XButton1;
          break;
        default: // or btnNone
          m_button = System.Windows.Forms.MouseButtons.None;
          break;
      }
      m_point = new System.Drawing.Point(x, y);
    }
Exemple #17
0
        /// <summary>
        /// Creates the Region
        /// </summary>
        /// <param name="statLog"></param>
        /// <param name="cacheManager"></param>
        public Region(ref StatLog statLog, ref CacheManager cacheManager)
        {
            // Store the statLog
            _statLog = statLog;

            // Store the cache manager
            _cacheManager = cacheManager;

            //default options
            _options = new RegionOptions();
            _options.width = 1024;
            _options.height = 768;
            _options.left = 0;
            _options.top = 0;
            _options.uri = null;

            Location = new System.Drawing.Point(_options.left, _options.top);
            Size = new System.Drawing.Size(_options.width, _options.height);
            BackColor = System.Drawing.Color.Transparent;

            if (Settings.Default.DoubleBuffering)
            {
                SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
                SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            }

            // Create a new BlackList for us to use
            _blackList = new BlackList();
        }
        /// <summary>
        /// Constructor</summary>
		public DomNodeReplaceToolStrip()
        {
            // Define query tree, which defines the layout of the search toolstrip GUI
            m_rootNode = new DomNodeQueryRoot();
            QueryTree.AddLabel(m_rootNode, "Replace with");

			m_replaceTextInput = QueryTree.AddReplaceTextInput(m_rootNode, null, false);
            QueryTree.AddSeparator(m_rootNode);
            m_rootNode.RegisterReplaceButtonPress(QueryTree.AddButton(m_rootNode, "Replace"));

            // Entering text into the toolstrip will trigger a search, changing an option rebuilds the toolstrip GUI
            m_rootNode.ReplaceTextEntered += replaceSubStrip_ReplaceTextEntered;

            // 
            // Build toolStrip GUI by retrieving toolstrip item list from tree, and adding 
            // them to ToolStrip.Items
            // 
            SuspendLayout();
            List<ToolStripItem> toolStripItems = new List<ToolStripItem>();
            m_rootNode.GetToolStripItems(toolStripItems);
            Items.AddRange(toolStripItems.ToArray());

            // Initialize ToolStrip
            Location = new System.Drawing.Point(0, 0);
            Name = "Event Sequence Document Replace";
            Size = new System.Drawing.Size(292, 25);
            TabIndex = 0;
            Text = "Event Sequence Document Replace";
			GripStyle = ToolStripGripStyle.Hidden;

            // Done
			ResumeLayout(false);

			if (UIChanged != null) { }
		}
Exemple #19
0
 public MazeData()
 {
     Width = 0;
     Height = 0;
     startPoint = new System.Drawing.Point();
     endPoint = new System.Drawing.Point();
 }
        //should I only make automationElement and actionListener once?
        public static UIItem GetControl(Point point)
        {
            POINT point1 = new POINT(point.X, point.Y);
            IntPtr myIntPtr = WindowFromPoint(point1);

            AutomationElement automationElement = AutomationElement.FromHandle(myIntPtr);

            automationElement = GetChildControl(point, automationElement) ?? automationElement;

            TreeWalker walker = TreeWalker.ControlViewWalker;

            AutomationElement parentElement = walker.GetParent(automationElement);
            if (parentElement != null && parentElement.Current.LocalizedControlType == "button")
                automationElement = parentElement;

            int delNum;

            while(((string.IsNullOrEmpty(automationElement.Current.Name)
                        && string.IsNullOrEmpty(automationElement.Current.AutomationId))
                        || int.TryParse(automationElement.Current.AutomationId, out delNum)))
            {
                automationElement = walker.GetParent(automationElement);
            }

            ActionListener actionListener = new NullActionListener();
            return new UIItem(automationElement, actionListener);
        }
Exemple #21
0
        private void h_changePosition()
        {
            Size levelSize = Info.GetLevelSize();

            int yNewPosition = (int)(Position.Y + Math.Round(Math.Sin(Position.X / 20)));

            if (Position.X > (levelSize.Width - 100))
                direction = false;

            if (Position.X < 50)
                direction = true;

            if (direction)
            {
                if (Position.X < 150 || Position.X > levelSize.Width - 200)
                {
                    Position = new Point((int)(Position.X + MaxSpeed), yNewPosition + 3);
                }
                else
                {
                    Position = new Point((int)(Position.X + MaxSpeed), yNewPosition);
                }
            }
            else
            {
                if (Position.X < 150 || Position.X > levelSize.Width - 200)
                {
                    Position = new Point((int)(Position.X - MaxSpeed - 1), yNewPosition + 1);
                }
                else
                {
                    Position = new Point((int)(Position.X - MaxSpeed), yNewPosition);
                }
            }
        }
    private CircuitProcessingResult ProcessCircuit(TSPlayer triggerer, DPoint tileLocation, SignalType? overrideSignal = null, bool switchSender = true) {
      CircuitProcessor processor = new CircuitProcessor(this.PluginTrace, this, tileLocation);
      CircuitProcessingResult result = processor.ProcessCircuit(triggerer, overrideSignal, switchSender);

      this.NotifyPlayer(result);
      return result;
    }
Exemple #23
0
 private void _MouseDown(object sender, MouseEventArgs e)
 {
     _isDown = true;
     _oldPoint = new System.Drawing.Point();
     _oldPoint = e.Location;
     _oldForm = this.Location;
 }
        private void add_anchor_window(System.Windows.Forms.Form form)
        {
            var application = this.Application;
            var parent_window = application.ActiveWindow;
            if (parent_window == null)
            {
                return;
            }
            if (application.ActiveDocument == null)
            {
                return;
            }

            object window_states = IVisio.VisWindowStates.visWSFloating | IVisio.VisWindowStates.visWSVisible;
            object window_types = IVisio.VisWinTypes.visAnchorBarAddon;

            var displacement = new System.Drawing.Point(50, 100);
            var window_rect = new System.Drawing.Rectangle(displacement, form.Size);
            string window_caption = form.Text;

            var the_anchor_window = VA.Application.UserInterfaceHelper.AddAnchorWindow(parent_window,
                                                                                       window_caption,
                                                                                       window_states,
                                                                                       window_types,
                                                                                       window_rect);

            if (the_anchor_window != null)
            {
                VA.Application.UserInterfaceHelper.AttachWindowsForm(the_anchor_window, form);
                form.Refresh();
            }
        }
 public BranchProcessData(DPoint branchingTileLocation, DPoint firstWireLocation, SignalType signal): this() {
   this.BranchingTileLocation = branchingTileLocation;
   this.FirstWireLocation = firstWireLocation;
   this.LastWireLocation = DPoint.Empty;
   this.Signal = signal;
   this.Direction = AdvancedCircuits.DirectionFromTileLocations(branchingTileLocation, firstWireLocation);
 }
 public bool IsTileInBetween(DPoint tileLocation) {
   switch (this.Direction) {
     case Direction.Left:
       return (
         (this.FirstWireLocation.Y == tileLocation.Y) &&
         (tileLocation.X >= this.LastWireLocation.X && tileLocation.X <= this.FirstWireLocation.X)
       );
     case Direction.Right:
       return (
         (this.FirstWireLocation.Y == tileLocation.Y) &&
         (tileLocation.X >= this.FirstWireLocation.X && tileLocation.X <= this.LastWireLocation.X)
       );
     case Direction.Up:
       return (
         (this.FirstWireLocation.X == tileLocation.X) &&
         (tileLocation.Y >= this.LastWireLocation.Y && tileLocation.Y <= this.FirstWireLocation.Y)
       );
     case Direction.Down:
       return (
         (this.FirstWireLocation.X == tileLocation.X) &&
         (tileLocation.Y >= this.FirstWireLocation.Y && tileLocation.Y <= this.LastWireLocation.Y)
       );
     case Direction.Unknown:
       return (this.FirstWireLocation == tileLocation);
     default:
       throw new InvalidOperationException();
   }
 }
Exemple #27
0
 public System.Drawing.Point GetIndexFromFrame(int frame)
 {
     System.Drawing.Point point = new System.Drawing.Point();
     point.Y = frame / framesX;
     point.X = frame - (point.Y * framesY);
     return point;
 }
 public OverTurnStonesPhase(CellState colorToTurn)
 {
     _placePos = new System.Drawing.Point(-1, -1);
     _turnPosList = new List<System.Drawing.Point>();
     _colorToTurn = colorToTurn;
     Init();
 }
        public void _resize() // Set the resize
        {
            double _form_ratio_width = (double)form.ClientSize.Width / (double)_formSize.Width;      // Ratio could be greater or less than 1
            double _form_ratio_height = (double)form.ClientSize.Height / (double)_formSize.Height;  // This one too
            var _controls = _get_all_controls(form);                                                //reenumerate the control collection
            int _pos = -1;                                                                          //do not change this value unless you know what you are doing

            // Do some math calculations
            foreach (Control control in _controls)
            {
                _pos += 1; // Increment by 1;
                System.Drawing.Size _controlSize = new System.Drawing.Size((int)(_arr_control_storage[_pos].Width * _form_ratio_width),
                    (int)(_arr_control_storage[_pos].Height * _form_ratio_height)); // Use for sizing

                System.Drawing.Point _controlposition = new System.Drawing.Point((int)
                (_arr_control_storage[_pos].X * _form_ratio_width), (int)(_arr_control_storage[_pos].Y * _form_ratio_height)); // Use for location

                // Set bounds
                control.Bounds = new System.Drawing.Rectangle(_controlposition, _controlSize); //Put together

                // Assuming you have a datagridview inside a form()
                // If you want to show the row header, replace the false statement of 
                // showRowHeader on top/public declaration to true;
                if (control.GetType() == typeof(DataGridView))
                    _dgv_Column_Adjust(((DataGridView)control), showRowHeader);


                //Font AutoSize
                control.Font = new System.Drawing.Font(form.Font.FontFamily,
                 (float)(((Convert.ToDouble(_fontsize) * _form_ratio_width) / 2) +
                  ((Convert.ToDouble(_fontsize) * _form_ratio_height) / 2)));

            }
        }
        private void ToggleButtonOn_Click(object sender, RoutedEventArgs e)
        {
            var isChecked = (bool)ToggleButtonOn.IsChecked;

            //m_brBotting.ToggleButtonOn = isChecked;

            if (isChecked)
            {
                var botAiType = (BotAiTypes)ComboBoxBotAi.SelectedIndex;
                var leaderPosition = int.Parse((string)ComboBoxLeaderCharacter.SelectionBoxItem);
                var nameBoxOffset = new System.Drawing.Point();
                var groupBoxOffset = new System.Drawing.Point();

                if (TextBoxNameBoxOffsetX.Text != null && TextBoxNameBoxOffsetX.Text.Length > 0)
                    nameBoxOffset.X = int.Parse(TextBoxNameBoxOffsetX.Text);
                if (TextBoxNameBoxOffsetY.Text != null && TextBoxNameBoxOffsetY.Text.Length > 0)
                    nameBoxOffset.Y = int.Parse(TextBoxNameBoxOffsetY.Text);

                if (TextBoxGroupBoxOffsetX.Text != null && TextBoxGroupBoxOffsetX.Text.Length > 0)
                    groupBoxOffset.X = int.Parse(TextBoxGroupBoxOffsetX.Text);
                if (TextBoxGroupBoxOffsetY.Text != null && TextBoxGroupBoxOffsetY.Text.Length > 0)
                    groupBoxOffset.Y = int.Parse(TextBoxGroupBoxOffsetY.Text);

                m_botSessionManager.StartSession(botAiType, leaderPosition, nameBoxOffset, groupBoxOffset);
            }
            else
            {
                m_botSessionManager.EndSession();
            }
        }
 public static extern IntPtr WindowFromPoint(System.Drawing.Point point);
Exemple #32
0
 public void SetBottomRightBoxCoords(int pixelX, int pixelY)
 {
     this.boxBottomRight = new System.Drawing.Point(pixelX, pixelY);
 }
Exemple #33
0
 /// <summary>
 /// 设置输入法窗体的位置
 /// </summary>
 /// <param name="p">输入法窗体的位置</param>
 public void SetImmPos(System.Drawing.Point p)
 {
     SetImmPos(p.X, p.Y);
 }
 /// <summary>
 /// If the mouse is moving over the notify icon, the popup must be displayed.
 /// Note: There is no event on the notify icon to trap when the mouse leave, so a timer is used in conjunction
 /// with tracking the position of the mouse to test for when the popup window needs to be closed. See timer tick event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void targetNotifyIcon_MouseMove(object sender, MouseEventArgs e)
 {
     notifyIconMousePosition = System.Windows.Forms.Control.MousePosition; // Track the position of the mouse over the notify icon
     MouseMove();                                                          // The mouse is moving over the notify Icon, raise the event
     delayMouseLeaveEventTimer.Start();                                    // The timer counts down and closes the window, as the mouse moves over the icon, keep starting (resetting) this to stop it from closing the popup
 }
        public static int TransformPointY(int y)
        {
            var point = new System.Drawing.Point(0, y);

            return(GlobalWin.DisplayManager.TransformPoint(point).Y);
        }
        public static int TransformPointX(int x)
        {
            var point = new System.Drawing.Point(x, 0);

            return(GlobalWin.DisplayManager.TransformPoint(point).X);
        }
Exemple #37
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            if (!Focused) // check to see if the window is focused
            {
                return;
            }

            var input = Keyboard.GetState();

            // exit program
            if (input.IsKeyDown(Key.Escape))
            {
                Exit();
            }

            // camera parameters
            const float cameraSpeed = 3f;
            const float sensitivity = 0.2f;

            // panning
            if (input.IsKeyDown(Key.W))
            {
                _camera.Position += _camera.Up * cameraSpeed * (float)e.Time; // Up
            }
            if (input.IsKeyDown(Key.S))
            {
                _camera.Position -= _camera.Up * cameraSpeed * (float)e.Time; // Down
            }
            if (input.IsKeyDown(Key.A))
            {
                _camera.Position -= _camera.Right * cameraSpeed * (float)e.Time; // Left
            }
            if (input.IsKeyDown(Key.D))
            {
                _camera.Position += _camera.Right * cameraSpeed * (float)e.Time; // Right
            }
            // Get the mouse state
            var mouse = Mouse.GetState();

            var cursor       = Mouse.GetCursorState();
            var window       = Location;
            var CursorWindow = new System.Drawing.Point(cursor.X - window.X, cursor.Y - window.Y);  // cursor position relative to window
            var GuiActive    = ImGui.IsWindowFocused(ImGuiFocusedFlags.AnyWindow);

            if (_firstMove) // this bool variable is initially set to true
            {
                _lastPos   = new Vector2(mouse.X, mouse.Y);
                _firstMove = false;
            }
            else if (CursorWindow.X > (int)(0.25 * Width) + 8 &&  // Updating camera only if the mouse is inside the respective viewport
                     CursorWindow.X < Width + 8 &&                // with the left button pressed and if no GUI window is active.
                     CursorWindow.Y > 31 &&                       // Of indents: for (1000, 600) client size we have (1016, 639) actual size, where:
                     CursorWindow.Y < Height + 31 &&              // 8 - indent for resizing feature, 39 - 2 * 8 = 23 - main titlebar height
                     mouse.LeftButton == ButtonState.Pressed && !GuiActive)
            {
                // Calculate the offset of the mouse position
                var deltaX = mouse.X - _lastPos.X;
                var deltaY = mouse.Y - _lastPos.Y;

                // Apply the camera pitch and yaw (we clamp the pitch in the camera class)
                _camera.Yaw   += deltaX * sensitivity;
                _camera.Pitch -= deltaY * sensitivity; // reversed since y-coordinates range from bottom to top
            }

            // updating last mouse position
            _lastPos = new Vector2(mouse.X, mouse.Y);

            base.OnUpdateFrame(e);
        }
Exemple #38
0
        /// <summary>
        /// NCC to find template
        /// </summary>
        private void NCCExecute()
        {
            try
            {
                Trace.TraceInformation("NCC matching start");
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                Mat dst = destination.Clone();

                /// convert to gray image
                Mat grayImage = new Mat();
                CvInvoke.CvtColor(dst, grayImage, ColorConversion.Rgb2Gray);

                /// use the sobel filter on the source image which returns the gradients in the X (Gx) and Y (Gy) direction.
                Mat gx = new Mat();
                Mat gy = new Mat();
                CvInvoke.Sobel(grayImage, gx, DepthType.Cv64F, 1, 0);
                CvInvoke.Sobel(grayImage, gy, DepthType.Cv64F, 0, 1);

                /// compute the magnitude and direction
                Mat magnitude = new Mat();
                Mat direction = new Mat();
                CvInvoke.CartToPolar(gx, gy, magnitude, direction);

                /// template matching
                var _gx        = gx.ToImage <Gray, double>();
                var _gy        = gy.ToImage <Gray, double>();
                var _magnitude = magnitude.ToImage <Gray, double>();

                long   totalLength = contoursLength;
                double nMinScore   = minScore / totalLength; // normalized min score
                double nGreediness = (1 - greediness * minScore) / (1 - greediness) / totalLength;

                double partialScore = 0;
                double resultScore  = 0;
                int    resultX      = 0;
                int    resultY      = 0;
                for (int i = 0, h = grayImage.Height; i < h; i++)
                {
                    for (int j = 0, w = grayImage.Width; j < w; j++)
                    {
                        double sum = 0;
                        long   num = 0;
                        for (int m = 0, rank = contoursRelative.Size; m < rank; m++)
                        {
                            for (int n = 0, length = contoursRelative[m].Size; n < length; n++)
                            {
                                num += 1;
                                int curX = j + contoursRelative[m][n].X;
                                int curY = i + contoursRelative[m][n].Y;
                                if (curX < 0 || curY < 0 || curX > grayImage.Width - 1 || curY > grayImage.Height - 1)
                                {
                                    continue;
                                }

                                double sdx = _gx.Data[curY, curX, 0];
                                double sdy = _gy.Data[curY, curX, 0];
                                double tdx = contoursInfo[m][n].DerivativeX;
                                double tdy = contoursInfo[m][n].DerivativeY;

                                if ((sdy != 0 || sdx != 0) && (tdx != 0 || tdy != 0))
                                {
                                    double nMagnitude = _magnitude.Data[curY, curX, 0];
                                    if (nMagnitude != 0)
                                    {
                                        sum += (sdx * tdx + sdy * tdy) * contoursInfo[m][n].MagnitudeN / nMagnitude;
                                    }
                                }
                                partialScore = sum / num;
#if FAST
                                if (partialScore < minScore)
#else
                                if (partialScore < Math.Min((minScore - 1) + (nGreediness * num), nMinScore * num))
#endif
                                { break; }
                            }
                        }
                        if (partialScore > resultScore)
                        {
                            resultScore = partialScore;
                            resultX     = j;
                            resultY     = i;
                            Trace.TraceInformation($"Current Score : {resultScore}");
                        }
                    }
                }

                Trace.TraceInformation($"Score : {resultScore}");

                /// overlay display origin image, edge(green) and origin point(red)
                /// NOTE: origin point is the first edge point
                var point = new System.Drawing.Point(resultX, resultY);
                Trace.TraceInformation($"Point : {point}");
                CvInvoke.DrawContours(dst, contoursRelative, -1, new Bgr(System.Drawing.Color.Green).MCvScalar, 5, offset: point);
                CvInvoke.Circle(dst, point, 2, new Bgr(System.Drawing.Color.Red).MCvScalar, -1);
                grayImage.Dispose();
                Destination.Dispose();
                Destination = dst;

                Trace.TraceInformation($"NCC matching end. time: {(double)stopwatch.ElapsedTicks * 1000 / Stopwatch.Frequency} ms");
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
                Trace.TraceError(ex.StackTrace);
            }
        }
Exemple #39
0
        /// <summary>
        /// Create a template
        /// </summary>
        private void TemplateExecute()
        {
            try
            {
                contoursRelative = new VectorOfVectorOfPoint();
                contoursInfo     = new List <PointInfo[]>();
                contoursLength   = 0;

                /// clone origin image
                Mat src = template.Clone();

                /// convert to gray image
                Mat grayImage = new Mat();
                CvInvoke.CvtColor(src, grayImage, ColorConversion.Rgb2Gray);

                /// using the canny algorithm to get edges
                Mat output    = new Mat();
                Mat hierarchy = new Mat();
                VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
                CvInvoke.Canny(grayImage, output, 100, 800);
                CvInvoke.FindContours(output, contours, hierarchy, RetrType.External, ChainApproxMethod.ChainApproxNone);

                /// use the sobel filter on the template image which returns the gradients in the X (Gx) and Y (Gy) direction.
                Mat gx = new Mat();
                Mat gy = new Mat();
                CvInvoke.Sobel(grayImage, gx, DepthType.Cv64F, 1, 0);
                CvInvoke.Sobel(grayImage, gy, DepthType.Cv64F, 0, 1);

                /// compute the magnitude and direction
                Mat magnitude = new Mat();
                Mat direction = new Mat();
                CvInvoke.CartToPolar(gx, gy, magnitude, direction);

                /// save edge info
                var _gx        = gx.ToImage <Gray, double>();
                var _gy        = gy.ToImage <Gray, double>();
                var _magnitude = magnitude.ToImage <Gray, double>();

                double    magnitudeTemp = 0;
                PointInfo pointInfo     = new PointInfo();
                int       originx       = contours[0][0].X;
                int       originy       = contours[0][0].Y;
                for (int i = 0, m = contours.Size; i < m; i++)
                {
                    int n = contours[i].Size;
                    contoursLength += n;
                    contoursInfo.Add(new PointInfo[n]);
                    System.Drawing.Point[] points = new System.Drawing.Point[n];

                    for (int j = 0; j < n; j++)
                    {
                        int x = contours[i][j].X;
                        int y = contours[i][j].Y;
                        points[j].X           = x - originx;
                        points[j].Y           = y - originy;
                        pointInfo.DerivativeX = _gx.Data[y, x, 0];
                        pointInfo.DerivativeY = _gy.Data[y, x, 0];
                        magnitudeTemp         = _magnitude.Data[y, x, 0];
                        pointInfo.Magnitude   = magnitudeTemp;
                        if (magnitudeTemp != 0)
                        {
                            pointInfo.MagnitudeN = 1 / magnitudeTemp;
                        }
                        contoursInfo[i][j] = pointInfo;
                    }
                    contoursRelative.Push(new VectorOfPoint(points));
                }

                /// overlay display origin image, edge(green) and origin point(red)
                /// NOTE: origin point is the first edge point
                CvInvoke.DrawContours(src, contours, -1, new Bgr(System.Drawing.Color.Green).MCvScalar, 5);
                var point = new System.Drawing.Point(contours[0][0].X, contours[0][0].Y);
                CvInvoke.Circle(src, point, 2, new Bgr(System.Drawing.Color.Red).MCvScalar, -1);
                gx.Dispose();
                _gx.Dispose();
                gy.Dispose();
                _gy.Dispose();
                magnitude.Dispose();
                _magnitude.Dispose();
                direction.Dispose();
                Template.Dispose();
                Template = src;
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
                Trace.TraceError(ex.StackTrace);
            }
        }
Exemple #40
0
 public POINT(System.Drawing.Point pt) : this(pt.X, pt.Y)
 {
 }
Exemple #41
0
        private void MessageReceiveCallback(IAsyncResult result)
        {
            EndPoint remote = new IPEndPoint(0, 0);
            string   pos    = "";

            // autoEvent.WaitOne();
            try
            {
                if (server.GetConnected())
                {
                    // get received message.
                    pos = Encoding.UTF8.GetString(recBuffer);

                    // clicked?
                    if (pos.StartsWith("click"))
                    {
                        this.LeftClick();

                        // long click = double click
                    }
                    else if (pos.StartsWith("d.click"))
                    {
                        this.LeftClick();
                        this.LeftClick();
                    }
                    else if (pos.StartsWith("r.click"))
                    {
                        this.RightClick();
                    }
                    else if (pos.StartsWith("trascina"))
                    {
                        this.trascina();
                    }
                    else if (pos.StartsWith("SU"))
                    {
                        this.SU(Convert.ToInt32(pos.Substring(2, 2)) + 30);
                        //  Console.WriteLine(Convert.ToInt32(pos.Substring(2, 2)));
                    }
                    else if (pos.StartsWith("GIU"))
                    {
                        this.GIU(Convert.ToInt32(pos.Substring(3, 3)) - 30);
                        //Console.WriteLine(Convert.ToInt32(pos.Substring(3, 3)));
                    }
                    else
                    {
                        string x = pos.Substring(0, pos.IndexOf(","));
                        // calculate delta
                        int deltaX;
                        int deltaY;
                        int.TryParse(x, out deltaX);
                        int.TryParse(pos.Substring(pos.IndexOf(",") + 1,
                                                   pos.IndexOf("\0") + -pos.IndexOf(",")), out deltaY);
                        // Console.WriteLine(deltaY+"//////////////////");
                        int scaleY;
                        int.TryParse(server.coordinateCLient.Substring(server.coordinateCLient.IndexOf(",") + 1, (server.coordinateCLient.IndexOf("\0") - server.coordinateCLient.IndexOf(","))), out scaleY);
                        int scaleX;
                        int.TryParse(server.coordinateCLient.Substring(0, server.coordinateCLient.IndexOf(",")), out scaleX);
                        int coordX = (Screen.PrimaryScreen.Bounds.Width * deltaX) / scaleX;
                        int coordY = (Screen.PrimaryScreen.Bounds.Height * deltaY) / scaleY;
                        //  Console.WriteLine("nuove coordinate" + coordX + " " + coordY + " " + (Screen.PrimaryScreen.Bounds.Height * deltaY) + " " + scaleY);
                        // set new point
                        System.Drawing.Point pt = System.Windows.Forms.Cursor.Position;
                        System.Windows.Forms.Cursor.Position = new System.Drawing.Point(coordX, coordY);
                    }
                }
                // End and "begin" for next package
                this.receiveSocket.EndReceiveFrom(result, ref remote);
            }
            catch (SocketException e)
            {
                Console.Write("i close the socket");
                // chiudo il socket per la ricezione.
                if (receiveSocket != null)
                {
                    receiveSocket.Close(); receiveSocket = null;
                }

                server.terminatecurrentsocketMouse = true;
            }
            catch (Exception)
            {
                Console.Write(pos);
                // chiudo il socket per la ricezione.
                if (receiveSocket != null)
                {
                    receiveSocket.Close(); receiveSocket = null;
                }
                server.terminatecurrentsocketMouse = true;
            }
            server.MouseUDPreceiveDone.Set();
        }
 private double Distance(Point p1, Point p2) => Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2);
Exemple #43
0
        private void Open_Selector(object sender, RoutedEventArgs e)
        {
            string SelectorString = ModelItem.GetValue <string>("Selector");
            int    maxresult      = 1;

            if (string.IsNullOrEmpty(SelectorString))
            {
                SelectorString = "[{Selector: 'Windows'}]";
            }
            var selector   = new Interfaces.Selector.Selector(SelectorString);
            var pluginname = selector.First().Selector;
            var selectors  = new Interfaces.Selector.SelectorWindow(pluginname, selector, maxresult);

            if (selectors.ShowDialog() == true)
            {
                ModelItem.Properties["Selector"].SetValue(new InArgument <string>()
                {
                    Expression = new Literal <string>(selectors.vm.json)
                });
                var Plugin = Interfaces.Plugins.recordPlugins.Where(x => x.Name == pluginname).First();
                var _base  = Plugin.GetElementsWithSelector(selector, null, 10);
                if (_base == null && _base.Length == 0)
                {
                    return;
                }
                var ele = _base[0];
                if (ele != null && !(ele is UIElement))
                {
                    var automation = AutomationUtil.getAutomation();
                    var p          = new System.Drawing.Point(ele.Rectangle.X + 10, ele.Rectangle.Y + 10);
                    if (p.X > 0 && p.Y > 0)
                    {
                        var _temp = automation.FromPoint(p);
                        if (_temp != null)
                        {
                            ele = new UIElement(_temp);
                        }
                    }
                }
                if (ele is UIElement ui)
                {
                    var window = ui.GetWindow();
                    if (window == null)
                    {
                        return;
                    }
                    if (!string.IsNullOrEmpty(window.Name))
                    {
                        ModelItem.Properties["DisplayName"].SetValue(window.Name);
                    }
                    if (window.Properties.BoundingRectangle.IsSupported)
                    {
                        var bound = window.BoundingRectangle;
                        ModelItem.Properties["X"].SetValue(new InArgument <int>()
                        {
                            Expression = new Literal <int>(bound.X)
                        });
                        ModelItem.Properties["Y"].SetValue(new InArgument <int>()
                        {
                            Expression = new Literal <int>(bound.Y)
                        });
                        ModelItem.Properties["Width"].SetValue(new InArgument <int>()
                        {
                            Expression = new Literal <int>(bound.Width)
                        });
                        ModelItem.Properties["Height"].SetValue(new InArgument <int>()
                        {
                            Expression = new Literal <int>(bound.Height)
                        });
                    }
                }
            }
        }
Exemple #44
0
 internal static extern IntPtr WindowFromPoint(System.Drawing.Point pt);
Exemple #45
0
 public bool Contains(System.Drawing.Point pt)
 {
     throw null;
 }
Exemple #46
0
        public void OnUserAction(Interfaces.IRecordPlugin sender, Interfaces.IRecordEvent e)
        {
            StopRecordPlugins();
            AutomationHelper.syncContext.Post(o =>
            {
                Interfaces.GenericTools.Restore(Interfaces.GenericTools.MainWindow);
                foreach (var p in Interfaces.Plugins.recordPlugins)
                {
                    if (p.Name != sender.Name)
                    {
                        if (p.ParseUserAction(ref e))
                        {
                            continue;
                        }
                    }
                }
                e.Selector.RemoveRange(2, e.Selector.Count - 2);
                ModelItem.Properties["Selector"].SetValue(new InArgument <string>()
                {
                    Expression = new Literal <string>(e.Selector.ToString())
                });
                var ele = e.Element;
                if (ele != null && !(ele is UIElement))
                {
                    var automation = AutomationUtil.getAutomation();
                    var p          = new System.Drawing.Point(ele.Rectangle.X + 10, ele.Rectangle.Y + 10);
                    if (p.X > 0 && p.Y > 0)
                    {
                        var _temp = automation.FromPoint(p);
                        if (_temp != null)
                        {
                            ele = new UIElement(_temp);
                        }
                    }
                }

                if (ele is UIElement ui)
                {
                    var window = ui.GetWindow();
                    if (window == null)
                    {
                        return;
                    }
                    if (!string.IsNullOrEmpty(window.Name))
                    {
                        ModelItem.Properties["DisplayName"].SetValue(window.Name);
                    }
                    if (window.Properties.BoundingRectangle.IsSupported)
                    {
                        var bound = window.BoundingRectangle;
                        ModelItem.Properties["X"].SetValue(new InArgument <int>()
                        {
                            Expression = new Literal <int>(bound.X)
                        });
                        ModelItem.Properties["Y"].SetValue(new InArgument <int>()
                        {
                            Expression = new Literal <int>(bound.Y)
                        });
                        ModelItem.Properties["Width"].SetValue(new InArgument <int>()
                        {
                            Expression = new Literal <int>(bound.Width)
                        });
                        ModelItem.Properties["Height"].SetValue(new InArgument <int>()
                        {
                            Expression = new Literal <int>(bound.Height)
                        });
                    }
                }
            }, null);
        }
Exemple #47
0
 public Size(System.Drawing.Point pt)
 {
     throw null;
 }
Exemple #48
0
 public Rectangle(System.Drawing.Point location, System.Drawing.Size size)
 {
     throw null;
 }
Exemple #49
0
 internal SearchResult(double maximumSimilarity, System.Drawing.Point maximumPoint)
 {
     MaximumSimilarity = maximumSimilarity;
     MatchedPoint      = maximumPoint;
 }
Exemple #50
0
 public void Offset(System.Drawing.Point pos)
 {
 }
Exemple #51
0
 Color IRenderSurface.GetPixelSafe(Point position)
 {
     return(GetPixelSafe(position));
 }
Exemple #52
0
 public Color GetPixelSafe888(Point position)
 {
     return(IsValidPosition(position) ?
            GetPixelFast888(position) :
            default(Color));
 }
Exemple #53
0
 public static Point ToWpf(this System.Drawing.Point p)
 {
     return(new Point(p.X, p.Y));
 }
Exemple #54
0
        public AppNav(int key, bool isColor)
        {
            switch (key)
            {
            case 3:
            {
                Controls.Add(new Nav(@"NaxMin")
                    {
                        Location = new System.Drawing.Point(0, 0)
                    });
                Controls.Add(new Nav(@"NavMax")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width, 0)
                    });
                Controls.Add(new NavCsm(@"NavOff")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width * 2, 0)
                    });
            }
            break;

            case 5:
            {
                Controls.Add(new Nav(@"NavTray")
                    {
                        Location = new System.Drawing.Point(0, 0)
                    });
                Controls.Add(new Nav(@"NavTop")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width, 0)
                    });
                Controls.Add(new Nav(@"NaxMin")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width * 2, 0)
                    });
                Controls.Add(new Nav(@"NavMax")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width * 3, 0)
                    });
                Controls.Add(new NavCsm(@"NavOff")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width * 4, 0)
                    });
            }
            break;

            case 7:
            {
                Controls.Add(new NavBarCmDrag {
                        Location = new System.Drawing.Point(0, 0)
                    });
                Controls.Add(new Nav(@"NavBack")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width, 0)
                    });
                Controls.Add(new Nav(@"NavTray")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width * 2, 0)
                    });
                Controls.Add(new Nav(@"NavTop")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width * 3, 0)
                    });
                Controls.Add(new Nav(@"NaxMin")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width * 4, 0)
                    });
                Controls.Add(new Nav(@"NavMax")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width * 5, 0)
                    });
                Controls.Add(new NavCsm(@"NavOff")
                    {
                        Location = new System.Drawing.Point(Helper.NavSize.Width * 6, 0)
                    });
            }
            break;
            }
            if (isColor)
            {
                BackColor = System.Drawing.Color.YellowGreen;
            }
            Anchor   = System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top;
            Size     = new System.Drawing.Size(Helper.NavSize.Width * key, Helper.NavSize.Height);
            Location = new System.Drawing.Point(Helper.Ui.Width - Helper.NavSize.Width * key, 0);
        }
Exemple #55
0
 void IRenderSurface.PlotPixelSafe(Point position, Color color)
 {
     PlotPixelSafe(position, color);
 }
 public bool IsOutlineVisible(System.Drawing.Point point, System.Drawing.Pen pen)
 {
 }
 public bool IsOutlineVisible(System.Drawing.Point pt, System.Drawing.Pen pen, System.Drawing.Graphics graphics)
 {
 }
 public void AddLine(System.Drawing.Point pt1, System.Drawing.Point pt2)
 {
 }
        public static int BorderWidth()
        {
            var point = new System.Drawing.Point(0, 0);

            return(GlobalWin.DisplayManager.TransformPoint(point).X);
        }
Exemple #60
0
 public void SetTopLeftBoxCoords(int pixelX, int pixelY)
 {
     this.boxTopLeft = new System.Drawing.Point(pixelX, pixelY);
 }