ToString() public method

Converts this to a human readable string.

public ToString ( ) : string
return string
Exemplo n.º 1
0
 public void AddPoint(Point pt)
 {
     if(this.point_dict.ContainsKey(pt.ToString()))
     {
         MessageBox.Show("添加坐标失败:\n不能添加已在列表中的坐标!");
         return;
     }
     this.point_dict[pt.ToString()] = pt;
     this.lbxScatterPoints.Items.Add(pt.ToString());
 }
Exemplo n.º 2
0
        public void InitMap()
        {
            Graphics g = pictureBox1.CreateGraphics();
            int i = 0;
            foreach(Jour J in _list_Jour)
            {
                foreach(ActJour A in J.ListAct)
                {

                    if (A.Ext)
                    {
                        PictureBox PB = new PictureBox();
                        PB.Size = new System.Drawing.Size(20, 20);
                        PB.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
                        Point P = new Point(A.X+700 / 5, (1000 / 5) -A.Y);
                        PB.Location = P;
                        PB.Click += new System.EventHandler(this.PB_Click);
                        PB.Name = i.ToString();
                        PB.Image = ActImage(A, J);
                        PB.BackColor= Color.Transparent;
                        PB.Visible = true;
                        Lpb.Add(PB);
                        labelInfo.Text = P.ToString();
                        ListInfo.Add(InfoAct(A, J));
                        pictureBox1.Controls.Add(PB);
                        i++;
                    }
                }
            }
        }
Exemplo n.º 3
0
 void CanvasMouseUp(object sender, MouseEventArgs e)
 {
     this.Cursor = Cursors.Default;
     e_pt = e.Location;
     if ( s_pt != Point.Empty)
         MessageBox.Show("From "+s_pt.ToString()+"to "+e_pt.ToString());
 }
Exemplo n.º 4
0
        private void tileClick(object sender, EventArgs e)
        {
            Console.WriteLine("oldSelectedTile changed from {0} to {1}", oldSelectedTile.ToString(), selectedTile.ToString());
            oldSelectedTile = selectedTile;


            foreach (TileSelector t in tilesPanel.Controls)
            {
                if (t.Location == oldSelectedTile)
                {
                    t.Image.Dispose();
                    t.Load(tileDirectory + t.Tag);
                    Console.WriteLine("oldTile reloaded from {0}", tileDirectory + t.Tag);
                }
            }

            TileSelector tile = (TileSelector)sender;

            Console.WriteLine("selectedTile changed from {0} to {1}", selectedTile.ToString(), tile.Location.ToString());
            selectedTile = tile.Location;
            Bitmap temp = (Bitmap)tile.Image;

            for (int x = 0; x < temp.Width; x += 2)
            {
                for (int y = 0; y < temp.Height; y += 2)
                {
                    temp.SetPixel(x, y, System.Drawing.Color.Blue);
                }
            }

            tile.Image = temp;
            tile.Refresh();
        }
Exemplo n.º 5
0
        private void MainForm_MouseDown(object sender, MouseEventArgs e)
        {
            if (checkBoxAddPoint.Checked)
            {
                scene.DataPoints.Add(new PointD(e.X, e.Y));
                this.Invalidate();
                return;
            }

            mouse_start = e.Location;
            this.Text = mouse_start.ToString();
            capture = scene.HitTest(e.X, e.Y);
            switch (capture)
            {
                case 1:
                    point_start = scene.CurrentBezier.Point1;
                    break;

                case 2:
                    point_start = scene.CurrentBezier.Point2;
                    break;

                case 3:
                    point_start = scene.CurrentBezier.Point3;
                    break;

                case 4:
                    point_start = scene.CurrentBezier.Point4;
                    break;

                default:
                    break;
            }
        }
Exemplo n.º 6
0
        private void Map_MouseMove(object sender, MouseEventArgs e)
        {
            double zoom = this.Map.Zoom;

            MousPosition = new Point((int)((MousePosition.X - this.Location.X - 32) + zoom),
                                     (int)((MousePosition.Y - this.Location.Y - 110) + zoom));
            MouseCoords_lbl.Text = MousPosition.ToString();
        }
Exemplo n.º 7
0
        public override string ToString()
        {
            string str;

            str  = "Node: ";
            str += "g = " + g + "; h = " + h + "; f = " + f + "\n";
            str += position.ToString();
            return(str);
        }
Exemplo n.º 8
0
 private static void adjustLocation(XmlNode destNode, Point offset)
 {
     if (offset.ToString() != "0,0")
     {
         Point location = getLocationAttribute(destNode);
         location.X += offset.X;
         location.Y += offset.Y;
         setLocationAttribute(destNode, location);
     }
 }
Exemplo n.º 9
0
		/// <summary>
		/// Returns the <see cref="Piece"/> object at the specified co-ordinates.
		/// </summary>
		/// <param name="position">
		/// The position of the piece to get.
		/// </param>
		/// <exception cref="IndexOutOfRangeException">
		/// Thrown if the X and Y values in <i>position</i> are invalid.
		/// </exception>
		/// <returns>
		/// The <see cref="Piece"/> object at the requested position.
		/// </returns>
		public Player GetPiece(Point position)
		{
			if (position.X < 0 || position.X > (Board.Dimension) ||
				position.Y < 0 || position.Y > (Board.Dimension))
			{
				throw new IndexOutOfRangeException(
					"Point " + position.ToString() + " is out of range.");
			}

			int shiftOut = this.GetShiftOut(position.X, position.Y);
			return (Player)((this.pieces >> shiftOut) & 3L);
		}
Exemplo n.º 10
0
        public void EndSelect(GraphApp app, GraphAppGUI appGUI, Point p, bool shiftHeld)
        {
            Console.WriteLine("Selection end: " + p.ToString());
            Started = false;

            endPoint = p;
            Rectangle selectionRect = getSelectionRectangle(startPoint, endPoint);

            GraphPanel gp = appGUI.CurrentGraphPanel;
            if (!shiftHeld)
            {
                gp.Deselect();
            }
            List<ISelectable> selectables = gp.Selectables;

            int selectTotal = 0;

            foreach (ISelectable s in selectables)
            {
                if (s.Intersects(selectionRect))
                {
                    bool filterPass = false;
                    foreach (SelectionFilter filter in filters)
                    {
                        if (filter.PassesFilter(s.GetItem()))
                        {
                            filterPass = true;
                        }
                    }

                    if (!filterPass)
                    {
                        continue;
                    }
                    gp.Select(s);
                    s.Select();
                    selectTotal++;
                    Console.WriteLine("Selected " + s.ToString());
                }
            }

            if (selectTotal == 0)
            {
                Console.WriteLine("Selected nothing");
                gp.Deselect();
            }

            gp.Refresh();
        }
Exemplo n.º 11
0
    void MapIt(Intcode.State initialState, Point currentLoc, ref HashSet <Point> cells, ref Point oxygenCell, int depth)
    {
        foreach (Movement m in Enum.GetValues(typeof(Movement)))
        {
            log($"{currentLoc.ToString()}: moving {m}", depth);

            var tempState = Intcode.State.Clone(initialState);
            tempState.input = (IntType)m;
            var newLoc = move(m, currentLoc);
            if (cells.Contains(newLoc))
            {
                // we've been here before
                continue;
            }

            bool processedCurrent = false;
            while (!processedCurrent && Intcode.Step(tempState))
            {
                var output = tempState.PopOutput();
                if (output.HasValue)
                {
                    switch ((Response)output.Value)
                    {
                    case Response.Moved:
                        //  log($"Moved to {newLoc.ToString()}", depth);
                        break;

                    case Response.Wall:
                        log($"{newLoc.ToString()}: Wall", depth);
                        processedCurrent = true;
                        break;

                    case Response.MovedAndFound:
                        log($"{newLoc.ToString()}: found big O", depth);
                        oxygenCell = newLoc;
                        break;
                    }
                    if (!processedCurrent)
                    {
                        log($"{newLoc.ToString()}: Spreading it out here, boss", depth);
                        cells.Add(newLoc);
                        MapIt(tempState, newLoc, ref cells, ref oxygenCell, depth + 1);
                        processedCurrent = true;
                    }
                }
            }
        }
    }
Exemplo n.º 12
0
        public void EdgeConstructorTest()
        {
            //Arrange
            Vertex v1 = new Vertex(100, new Point(100, 100));
            Vertex v2 = new Vertex(200, new Point(200, 200));
            int cost = 500;
            Point stringPosition = new Point(300,300);

            //Act
            Edge target = new Edge(v1, v2, cost, stringPosition);

            //Assert
            Assert.AreEqual(target.V1.Name, v1.Name);
            Assert.AreEqual(target.V2.Name, v2.Name);
            Assert.AreEqual(target.Cost, cost);
            Assert.AreEqual(target.StringPosition.ToString(), stringPosition.ToString());
        }
Exemplo n.º 13
0
        private void courtBox_MouseDown(object sender, MouseEventArgs e)
        {
            const int imageBorder = 6;
            const float xSize = 1199;
            const float ySize = 716;

            MouseButtons currButton = e.Button;
            Point loc = new Point(e.X, e.Y);

            /* We need to get the location of the click in "ESPN" coordinates.  That is, the top left corner is (0,0)
             * and the bottom right corner is (940, 500). */
            loc.X = (int)((loc.X - imageBorder) / xSize * 940);
            loc.Y = (int)((loc.Y - imageBorder) / ySize * 500);

            Console.WriteLine("Click registered:");
            Console.WriteLine("\t" + loc.ToString());
            Console.WriteLine("\t" + currButton.ToString());
        }
        private bool LineIntersectsLine(
            System.Drawing.Point l1p1,
            System.Drawing.Point l1p2,
            System.Drawing.Point l2p1,
            System.Drawing.Point l2p2)
        {
            try
            {
                Int64 d = (l1p2.X - l1p1.X) * (l2p2.Y - l2p1.Y) - (l1p2.Y - l1p1.Y) * (l2p2.X - l2p1.X);
                if (d == 0)
                {
                    return(false);
                }

                Int64 q = (l1p1.Y - l2p1.Y) * (l2p2.X - l2p1.X) - (l1p1.X - l2p1.X) * (l2p2.Y - l2p1.Y);
                Int64 r = q / d;

                Int64 q1 = (Int64)(l1p1.Y - l2p1.Y) * (Int64)(l1p2.X - l1p1.X);
                Int64 q2 = (Int64)(l1p1.X - l2p1.X) * (Int64)(l1p2.Y - l1p1.Y);

                q = q1 - q2;
                Int64 s = q / d;

                if (r < 0 || r > 1 || s < 0 || s > 1)
                {
                    return(false);
                }

                return(true);
            }
            catch (OverflowException err)
            {
                Debug.Print("----------------------------------");
                Debug.Print(err.Message);
                Debug.Print(l1p1.ToString());
                Debug.Print(l1p2.ToString());
                Debug.Print(l2p1.ToString());
                Debug.Print(l2p2.ToString());
                return(false);
            }
        }
Exemplo n.º 15
0
        public void Init(Form1 mainForm, CoronaJointure joint)
        {
            this.MainForm = mainForm;
            this.cJoint = joint;
            modePanel = "NEW";

            if (this.cJoint.type.Equals("WHEEL")) {
                this.objA = cJoint.coronaObjA;
                obj1Tb.Text = objA.DisplayObject.Name;
                this.objB = cJoint.coronaObjB;
                obj2Tb.Text = objB.DisplayObject.Name;

                this.axisDistance = cJoint.axisDistance;
                axisDistanceTb.Text = axisDistance.ToString();

                this.setAnchorPoint(cJoint.AnchorPointA);

                motorSpeedNup.Value = Convert.ToInt32(cJoint.motorSpeed);

                motorForceNup.Value = Convert.ToInt32( cJoint.maxMotorTorque);

                modePanel = "MODIFY";
            }
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            int bufSize = 256;
            StringBuilder sb = new StringBuilder(bufSize);

            Rectangle rect = new Rectangle(0, 0, 100, 100);

            if (SetNHW32())
            {
                {
                    for (;;)
                    {
                        int i = 1;
                        int j = 0;
                        Point cursorPoint = new Point();
                        GetCursorPos(ref cursorPoint);
                        BL_SetFlag32((uint)GetWordFlag.enable, IntPtr.Zero, cursorPoint.X, cursorPoint.Y);
                        Thread.Sleep(1000);
                        BL_GetText32(sb, bufSize, ref rect);
                        System.Console.WriteLine(sb.ToString() + " " + rect.ToString() + " " + cursorPoint.ToString());
                    }
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Set the mouse position over the image. 
        /// It also set the color intensity of the pixel on the image where is mouse is at
        /// </summary>
        /// <param name="location">The location of the mouse on the image</param>
        public void SetMousePositionOnImage(Point location)
        {
            mousePositionTextbox.Text = location.ToString();

             IImage img = _imageBox.DisplayedImage;
             Size size = img.Size;
             location.X = Math.Min(location.X, size.Width - 1);
             location.Y = Math.Min(location.Y, size.Height - 1);

             MCvScalar scalar = CvInvoke.cvGet2D(img.Ptr, location.Y, location.X);
             _buffer[0] = scalar.v0; _buffer[1] = scalar.v1; _buffer[2] = scalar.v2; _buffer[3] = scalar.v3;

             StringBuilder sb = new StringBuilder(String.Format("[{0}", _buffer[0]));
             for (int i = 1; i < img.NumberOfChannels; i++)
            sb.AppendFormat(",{0}", _buffer[i]);
             sb.Append("]");

             colorIntensityTextbox.Text = sb.ToString();
        }
Exemplo n.º 18
0
        public void mouseMove(object sender, MouseEventArgs evt)
        {
            if (this.map.cells != null)
            {
                Point mouse = new Point(evt.X, evt.Y);
                mouse.X = (mouse.X - (int)this.startX);
                mouse.Y = (mouse.Y - (int)this.startY);

                foreach (Cell cell in this.map.cells)
                {
                    Point cellLocation = new Point((int)((cell.x * this.squareSize) + this.startX), (int)((cell.y * this.squareSize) + this.startY));
                    //int wall = 0;
                    bool hit = false;

                    int column = (int)Math.Truncate(((double)mouse.X + (this.squareSize * .99)) / this.squareSize);
                    int row = (int)Math.Truncate(((double)mouse.Y + (this.squareSize * .99)) / this.squareSize);

                    Point mouseInCell = new Point((((column - 1) * this.squareSize) - mouse.X) * -1, (((row - 1) * this.squareSize) - mouse.Y) * -1);
                    Point[] middleWalls = new Point[] { new Point(this.squareSize / 2, 0), new Point(this.squareSize, this.squareSize / 2), new Point(this.squareSize / 2, this.squareSize), new Point(0, this.squareSize / 2)};

                    int difference = this.squareSize *2;
                    int chosenWall = 3;

                    /*for (int wall = 0; wall < middleWalls.Length; wall++)
                    {
                        if ((Math.Abs(mouseInCell.X - middleWalls[wall].X) + Math.Abs(mouseInCell.Y - middleWalls[wall].Y)) < difference)
                        {
                            difference = (Math.Abs(mouseInCell.X - middleWalls[wall].X) + Math.Abs(mouseInCell.Y - middleWalls[wall].Y));
                            chosenWall = wall;
                            this.view.setPosition(difference.ToString() + "   ");
                        }
                    }*/

                    if (mouseInCell.Y <= 25 & mouseInCell.X < 75 && mouseInCell.X > 25) chosenWall = 0;
                    else if (mouseInCell.Y >= 75 & mouseInCell.X < 75 && mouseInCell.X > 25) chosenWall = 2;
                    else if (mouseInCell.X >= 75) chosenWall = 1;
                    else chosenWall = 3;

                    this.view.setPosition(column.ToString() + " " + row.ToString() + " " + mouseInCell.ToString());
                    //this.view.setPosition(chosenWall.ToString());
                    this.setFocusCell(new Point(column, row), chosenWall);
                    /*List<int> possible = new List<int>();
                    possible[0] = this.squareSize;// x proximity to mouse
                    possible[1] = this.squareSize;// y proximity to mouse
                    possible[2] = 0;// cell x
                    possible[3] = 0;// cell y
                    possible[4] = 0;// wall*/

                    /*for (wall = 0; wall < 4; wall++)
                    {
                        if (Math.Abs(mouse.X - (cellLocation.X + (this.wallEnd[wall].X / 2))) <= (this.squareSize / 2) && Math.Abs(mouse.Y - (cellLocation.Y + (this.wallEnd[wall].Y / 4))) <= (this.squareSize / 2))
                        {
                            this.setFocusCell(new Point(cell.column, cell.row), wall);
                            //this.view.refresh();
                            hit = true;
                            //this.view.setPosition((mouse.ToString() + new Point((int)cellLocation.X + this.wallEnd[wall].X, (int)(cellLocation.Y + this.wallEnd[wall].Y)).ToString()));
                            this.view.setPosition();
                            //break;
                        }
                    }*/
                    /*if (hit)
                    {
                        break;

                    }*/
                }

                this.view.refresh();
            }
        }
Exemplo n.º 19
0
        void OnMouseMove(Point position)
        {
            Debug.WriteLine(position.ToString());
            if (_lastMousePosition.IsEmpty)
            {
                _lastMousePosition = position;
            }
            else
            {
                double distance = Math.Sqrt(Math.Pow(position.X - _lastMousePosition.X, 2) + Math.Pow(position.Y - _lastMousePosition.Y, 2));
                if (distance > 3)
                    Cancel();

                _lastMousePosition = position;
            }
        }
Exemplo n.º 20
0
        internal static void Save()
        {
            XmlTextWriter XMLobj;

            try
            {
                if (!System.IO.Directory.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\Cryptotext Editor"))
                {
                    System.IO.Directory.CreateDirectory(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\Cryptotext Editor");
                }

                XMLobj = new XmlTextWriter(settingsPath, System.Text.Encoding.UTF8);
            }
            catch (UnauthorizedAccessException)
            {
                return;
            }

            XMLobj.Formatting = Formatting.Indented;

            XMLobj.WriteStartDocument();

            XMLobj.WriteStartElement("Settings");
            XMLobj.WriteAttributeString("program", "Cryptotext Editor");

            XMLobj.WriteStartElement("EditorSize");

            XMLobj.WriteAttributeString("Width", EditorSize.Width.ToString());
            XMLobj.WriteAttributeString("Height", EditorSize.Height.ToString());
            XMLobj.WriteValue(EditorSize.ToString());
            XMLobj.WriteEndElement();

            XMLobj.WriteStartElement("CurrentFilePath");
            XMLobj.WriteValue(CurrentFilePath);
            XMLobj.WriteEndElement();

            XMLobj.WriteStartElement("CurrentFileSaved");
            XMLobj.WriteValue(CurrentFileSaved.ToString());
            XMLobj.WriteEndElement();

            XMLobj.WriteStartElement("WordWrap");
            XMLobj.WriteValue(WordWrap.ToString());
            XMLobj.WriteEndElement();

            XMLobj.WriteStartElement("DetectUrls");
            XMLobj.WriteValue(DetectUrls.ToString());
            XMLobj.WriteEndElement();

            XMLobj.WriteStartElement("AutoSave");
            XMLobj.WriteValue(AutoSave.ToString());
            XMLobj.WriteEndElement();

            XMLobj.WriteStartElement("LastOpenedFile");
            XMLobj.WriteValue(LastOpenedFile);
            XMLobj.WriteEndElement();

            XMLobj.WriteStartElement("editorLocation");
            XMLobj.WriteAttributeString("x", editorLocation.X.ToString());
            XMLobj.WriteAttributeString("y", editorLocation.Y.ToString());
            XMLobj.WriteValue(editorLocation.ToString());
            XMLobj.WriteEndElement();

            XMLobj.WriteStartElement("editorLangPath");
            XMLobj.WriteValue(editorLangPath);
            XMLobj.WriteEndElement();

            XMLobj.WriteStartElement("editorToolBox");
            XMLobj.WriteValue(editorToolBox.ToString());
            XMLobj.WriteEndElement();

            XMLobj.WriteEndElement();

            XMLobj.WriteEndDocument();
            XMLobj.Close();
        }
        /// <summary>
        /// Get position of tap on the screen
        /// </summary>
        /// <param name="x">x value of tap (on pin device)</param>
        /// <param name="y">y value of tap (on pin device)</param>
        /// <param name="vr">touched view range</param>
        /// <returns>position on the screen</returns>
        public Point GetTapPositionOnScreen(double x, double y, BrailleIOViewRange vr)
        {
            Point p = GetTapPositionInContent(x, y, vr);
            if (vr != null && p != null)
            {
                double zoom = vr.GetZoom();
                if (zoom != 0)
                {
                    int x_old = p.X;
                    int y_old = p.Y;
                    p = new Point((int)Math.Round(x_old / zoom), (int)Math.Round(y_old / zoom));

                    if (ScreenObserver != null && ScreenObserver.ScreenPos is Rectangle)
                    {
                        Rectangle sp = (Rectangle)ScreenObserver.ScreenPos;
                        p.X += sp.X;
                        p.Y += sp.Y;
                    }
                    System.Diagnostics.Debug.WriteLine("tap screen position: " + p.ToString());
                }
            }
            return p;
        }
Exemplo n.º 22
0
 private int GetSelectedHandle(Point p)
 {
     int index = -1;
     for (int i = 1; i < 9; i++)
     {
         if (GetHandleRect(i).Contains(p))
         {
             index = i;
             break;
         }
     }
     if (this.area.Contains(p)) index = 0;
     System.Diagnostics.Trace.WriteLine(area.ToString());
     System.Diagnostics.Trace.WriteLine(p.ToString());
     System.Diagnostics.Trace.WriteLine(index.ToString());
     return index;
 }
 private void PaintLastCoordinate(Graphics g, Color color, Point point, int x, int y)
 {
     g.DrawString(point.ToString(), new Font(FontFamily.GenericSansSerif, 12), new SolidBrush(color), x, y);
 }
Exemplo n.º 24
0
        public Point PointToScreen(Point point)
        {
            if (!Functions.ClientToScreen(window.Handle, ref point))
                throw new InvalidOperationException(String.Format(
                    "Could not convert point {0} from screen to client coordinates. Windows error: {1}",
                    point.ToString(), Marshal.GetLastWin32Error()));

            return point;
        }
Exemplo n.º 25
0
        private void imagem_MouseUp(object sender, MouseEventArgs e)
        {
            if (box)
            {
                box = false;
                p2 = e.Location;
                if (p2.X - p1.X < 0) return;
                if (p2.Y - p1.Y < 0) return;
                if (p1 == p2)
                {

                    Rectangle rtest;
                    Point pt1, pt2;
                    int i = 0;
                    foreach (Box boxp in lista_box)
                    {
                        pt1 = boxp.P1;
                        pt2 = boxp.P2;
                        rtest = new Rectangle(pt1.X, pt1.Y, pt2.X - pt1.X, pt2.Y - pt1.Y);

                        if(rtest.Contains(p1))
                        {
                             lista.SelectedIndex = i;
                        }
                        i++;
                    }
                    return;
                }

                imagem.Invalidate();

                lista_box.Add(new Box(p1, p2));

                lista.Items.Add(p1.ToString() + " - " + p2.ToString());

                lista.SelectedIndex = lista_box.Count - 1;
            }
        }
        public void MoveProduct(PlacedProduct selectedProduct, List<PlacedProduct> placedProducts, Vector deltaVector, int panelWidth, int panelHeight)
        {
            //A variable to keep track of collision
            bool collision = false;
            

            //The new location that the product is going towards
            Point newLocationPoint = new Point(
                (int)(selectedProduct.Location.X + deltaVector.X),
                (int)(selectedProduct.Location.Y + deltaVector.Y)   );

            


            //Checkes the borders
            foreach (Polygon wall in selectedProduct.PolyBorder(panelWidth, panelHeight))
            {
                PolygonCollisionController.PolygonCollisionResult result =
                    PolygonCollisionController.PolygonCollision(selectedProduct.Poly, wall, deltaVector);

                if (result.WillIntersect)
                {
                    collision = true;
                    break;
                }
            }


            //Loops through each item and determines if it collides with any of them
            foreach (PlacedProduct collisionTarget in placedProducts)
            {
                if (collision)
                { break; }
                if (selectedProduct.Product.Collidable == false) //If the selected product is not collidable. For example an 'Energy Socket'. Break out the loop and place it.
                { break; }
                if (collisionTarget.Product.Collidable == false) //If the target is not collidable. For example an 'Energy Socket'. Skip this loop and go to the next target.
                { continue; }

                PolygonCollisionController.PolygonCollisionResult result =
                    PolygonCollisionController.PolygonCollision(selectedProduct.Poly, collisionTarget.Poly, deltaVector);

                if (result.WillIntersect)
                {
                    collision = true;
                    break;
                }
            }

            //Failsafe check at the end
            if (!collision)
            { /*selectedProduct.MoveTo(newLocationPoint); */}
            else
            {
                MessageBox.Show("Fail");
            }
            MessageBox.Show(newLocationPoint.ToString());

        }
Exemplo n.º 27
0
 private void SetCursorAsHome()
 {
     pHome = new Point(Cursor.Position.X - wRect.Left, Cursor.Position.Y - wRect.Top);
     logger.Debug("Setting home as : " + pHome.ToString());
 }
Exemplo n.º 28
0
        private void BindDonnees()
        {
            Zone z = (Zone)cbZone.SelectedItem;
            if (z != null)
            {
                RecZone = z.RecZone;
                RecNom = z.RecNom;
                PopCurseur = z.PopCurseur;
                tbRecZone.Text = z.RecZone.ToString();
                tbRecNom.Text = z.RecNom.ToString();
                tbPopCurseur.Text = z.PopCurseur.ToString();
                tbDescription.Text = z.Description;
                tbNoParagraphe.Text = z.NoParagraphe;

                //Construction zones connexes
                lbZonesConnexes.Items.Clear();
                foreach (string zc in z.NomsZonesConnexes)
                {
                    lbZonesConnexes.Items.Add(zc);
                }

                //Construction zones disponibles
                lbZonesDispo.Items.Clear();
                List<string> zonesDispo = new List<string>();
                foreach (Zone zc in ZonesChargees)
                {
                    if (!zc.Nom.Equals(z.Nom) && !z.NomsZonesConnexes.Contains(zc.Nom))
                    {
                        lbZonesDispo.Items.Add(zc.Nom);
                    }
                }
            }
            else
            {
                PopCurseur = new Point(-50, -50);
                tbPopCurseur.Text = PopCurseur.ToString();
            }
        }
Exemplo n.º 29
0
        private void b_adjust_bot_Click(object sender, EventArgs e)
        {
            Point found_point = divideAndConquerSearch(0, 500);

            if(found_point == FAIL_POINT)
            {
                writeToLog(module_name, "Could not adjust Bot!");
                return;
            }

            Point to_match = new Point(607, 585);

            Point adjust_point_p = new Point(found_point.X - to_match.X, found_point.Y - to_match.Y);

            if (Tools.adjust_bot_point == adjust_point_p)
            {
                writeToLog(module_name, "Bot was correctly adjusted.");
            }
            else
            {
                MyXML xml = new MyXML(config_path);
                xml.write(adjust_point_x, adjust_point_p.X.ToString());
                xml.write(adjust_point_y, adjust_point_p.Y.ToString());
                Tools.adjust_bot_point = adjust_point_p;

                writeToLog(module_name, "Bot correctly adjusted from " + Tools.adjust_bot_point.ToString() + " to " + adjust_point_p.ToString() + ".");
            }

            BackgroundWorker bgw = new BackgroundWorker();
            bgw.DoWork += new DoWorkEventHandler(AsyncAdjustPixelColors);
            bgw.RunWorkerAsync();
        }
Exemplo n.º 30
0
        void received()
        {
            String s=serialPort1.ReadExisting();
            this.Text = s;
            if (s[0] == 'w') {
                string[] t = s.Split(',');
                aw = Int32.Parse(t[1]);
                ah = Int32.Parse(t[2]);

            }
            Properties.Settings ms = Properties.Settings.Default;
            if (s == "b1") {
                SendKeys.SendWait(ms.b1);//home
            }
            else if (s == "b2")
            {
                SendKeys.SendWait(ms.b2);//end
            }
            else if (s == "b3" )
            {
                SendKeys.SendWait(ms.b3);//back
            }
            else if (s == "l2")
            {
                if (clickMode)  clickMode = false;
                else SendKeys.SendWait(ms.l2);//down
            }
            else if (s == "b4" )
            {
                SendKeys.SendWait(ms.b4);//right
                //この辺で画像送信
            }
            else if(s == "l1"){
                if (clickMode) clickMode = false;
                else SendKeys.SendWait(ms.l1);//up
            }
            else if (s == "m1")
            {
               SendKeys.SendWait(ms.m1);//+F5
            }
            else if (s == "m2")
            {
                SendKeys.SendWait(ms.m2);//ESC
            }

            else if (s == "s1" && shakeEnable)
            {
                SendKeys.SendWait(ms.l2);
                shakeEnable = false;
                timer1.Enabled = true;
            }
            else if (s[0] == 'v')
            {
                if (!clickMode)
                {

                    //Cursor.Hide();
                    //ポインタを動かす
                    string[] t = s.Split(',');
                    //t[0]:v1, t[1]:a, t[2]:x, t[3]:y ,
                    int a = Int32.Parse(t[1]);
                    double ax = double.Parse(t[2]);
                    double ay = double.Parse(t[3]);

                    if (a == 0 || a == 2)
                    {

                        pictureBox1.Visible = true;
                        //this.Visible = true;
                    }
                    else if (a == 1)
                    {
                        pictureBox1.Visible = false;

                        //this.Visible = false;
                    }
                    p = new Point((int)(ax * w / aw), (int)(ay * h / ah));
                    //pictureBox1.Location = p;
                    this.Location = new Point(p.X - 25, p.Y - 25);
                    this.Text = p.ToString();
                    //this.TopMost = true;
                    Cursor.Position = new Point((int)w, (int)h / 2);
                }
                else
                {
                    //ポインタを動かす
                    string[] t = s.Split(',');
                    //t[0]:v1, t[1]:a, t[2]:x, t[3]:y ,
                    int a = Int32.Parse(t[1]);
                    double ax = double.Parse(t[2]);
                    double ay = double.Parse(t[3]);

                    p = new Point((int)(ax * w / aw), (int)(ay * h / ah));
                    Cursor.Position = p;
                }

            }
            else if (s[0] == 'c')
            {
                if (clickMode)
                {
                    //crick
                    INPUT[] input = new INPUT[2];

                    if (s == "c2")
                    {
                        input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
                        input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
                    }
                    else if (s == "c1")
                    {
                        input[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
                        input[1].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
                    }

                    SendInput(2, input, Marshal.SizeOf(input[0]));//効かないときがある

                    //clickMode = false;
                }
                else
                {
                    clickMode = true;
                    this.Location = new Point(-100,-100);
                }
            }
        }
Exemplo n.º 31
0
        private void tsbtnLocalization_Click(object sender, EventArgs e)
        {
            if (this.current_fingerprint == null)
                return;
            FormLocalizationSetting fls = new FormLocalizationSetting();
            if (this.current_dbpath != null)
                fls.DBpath = this.current_dbpath;
            if (fls.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                FileStream fs = new FileStream(fls.DBpath, FileMode.Open, FileAccess.Read, FileShare.Read);
                FingerprintDataBase fdb = (FingerprintDataBase)formatter.Deserialize(fs);
                fs.Close();
                FingerprintDataBase.Match_Strategy match_strategy = fls.MatchStrategy;
                double[] args = fls.Args;
                PointF loc = (new FingerprintDataBase(fdb.loc_fingerprint_dict, fdb.map)).MatchLocation(this.current_fingerprint[this.FingerprintName], match_strategy, args);
                this.current_dbpath = fls.DBpath;

                Point pt_real = new Point();
                foreach (Transmitter trans in this.viz_rps.Map.Transmitters)
                    pt_real = trans.Location;
                lbxLocResult.Items.Add("真实\t" + pt_real.ToString());
                lbxLocResult.Items.Add("估计\t" + loc.ToString());
                double err_pxl = new MathUtils.MathUtility().point_dist(pt_real, loc);
                lbxLocResult.Items.Add("误差(p)\t" + err_pxl.ToString("0.00"));
                lbxLocResult.Items.Add("误差(m)\t" + (err_pxl * this.viz_rps.Map.MeterPixelRatio).ToString("0.00"));
                lbxLocResult.Items.Add("--------------");
                lbxLocResult.SelectedIndex = lbxLocResult.Items.Count - 1;
            }
        }
Exemplo n.º 32
0
        private static Point GetCenterMass(Image<Bgr, Byte> img)
        {
            //ImageViewer viewer = new ImageViewer();
            //crunch down thresholds to find red-based blobs
            //viewer.Image = img;
            //viewer.ShowDialog();
            splitImage = img.Split();
            blue = splitImage[0].Copy();
            green = splitImage[1].Copy();
            red = splitImage[2].Copy();

            //make the lowest levels bright
            //blue._ThresholdBinary(new Gray(blueMin), new Gray(255));
            // green._ThresholdBinary(new Gray(greenMin), new Gray(255));

            //make the highest levels bright
            red = red.Sub(blue.ThresholdBinary(new Gray(blueMax), new Gray(255)));
            red = red.Sub(green.ThresholdBinary(new Gray(greenMax), new Gray(255)));
            red._ThresholdBinary(new Gray(redMin), new Gray(255));

            //build up mask
            // gray = red.And(blue).And(green);
            gray = red.Copy();

            //do auto threshold if active
            if (AUTO_ADJUST_THRESHOLD)
            {

                //find optimal redThreshold
                bool found = false;
                int currentRed = redMax;//start in middle to hopefully minimize search time
                while (!found)
                {
                    if (gray.GetSum().Intensity / (img.Width * img.Height) > maxRedPercent)
                    {
                        currentRed += 1;
                    }
                    else if (gray.GetSum().Intensity / (img.Width * img.Height) < minRedPercent)
                    {
                        currentRed -= 1;
                    }
                    else
                    {
                        found = true;
                        break;
                    }

                    if (currentRed > redMax || currentRed < redMin)//out of bounds, so no red found!
                    {
                        found = true;
                        System.Console.WriteLine("Current Red Percent out of bound: " + currentRed);
                        return new Point(Int32.MinValue, Int32.MinValue);
                    }

                    System.Console.WriteLine("Setting red to " + redMin);
                    red = splitImage[2].Copy();
                    red = red.Sub(blue.ThresholdBinary(new Gray(blueMax), new Gray(255)));
                    red = red.Sub(green.ThresholdBinary(new Gray(greenMax), new Gray(255)));
                    red._ThresholdBinary(new Gray(redMin), new Gray(255));

                    //build up mask
                    // gray = red.And(blue).And(green);
                    gray = red.Copy();

                   // viewer.Image = gray;
                }
            }

            MCvMoments moments = gray.GetMoments(true);
            MCvPoint2D64f momentGravity = moments.GravityCenter;

            Point center = new Point((int)momentGravity.x - img.Width / 2, (int)momentGravity.y - img.Height / 2);

            System.Console.WriteLine("Center at " + center.ToString());
            System.Console.WriteLine("Intesity: " + gray.GetSum().Intensity + ", " + (gray.GetSum().Intensity / (img.Height * img.Width)));

               // viewer.Image = gray;

            //viewer.ShowDialog();
            return center;
        }
Exemplo n.º 33
0
		private void CheckPieces(Point source, Point destination)
		{
			if (source.Equals(destination) == true)
			{
				throw new InvalidMoveException(ErrorIdenticalPiece);
			}

			if (this.IsOuterPiece(source) == false || this.IsOuterPiece(destination) == false)
			{
				throw new InvalidMoveException(ErrorInternalPiece);
			}

			if (this.CanCurrentPlayerUseSource(source) == false)
			{
				throw new InvalidMoveException(
					 string.Format(ErrorInvalidSourcePiece, this.currentPlayer.ToString(), source.ToString()));
			}

			if (source.X != destination.X && source.Y != destination.Y)
			{
				throw new InvalidMoveException(
					 string.Format(ErrorInvalidDestinationPosition, this.currentPlayer.ToString(), destination.ToString()));
			}

			var endPoint = this.GetEndPoint(source, destination);

			if (endPoint != 0 && endPoint != (Dimension - 1))
			{
				throw new InvalidMoveException(
					 string.Format(ErrorInvalidDestinationPosition, this.currentPlayer.ToString(), destination.ToString()));
			}
		}
Exemplo n.º 34
0
        public int versatility; // sum of distances to all map keys. lower values = more versatile

        public override string ToString()
        {
            return(srcIndex.ToString());
        }
Exemplo n.º 35
0
        private void UpdateActions()
        {
            List <ActionItem> actions = new List <ActionItem>();

            for (int i = 0; i < _clickManagerCopy.ActionsCount; i++)
            {
                if (_clickManagerCopy.RegistrationClicks.ContainsKey(i) ||
                    _clickManagerCopy.TaxiOrderingClicks.ContainsKey(i) ||
                    _clickManagerCopy.DataCleaningClicks.ContainsKey(i))
                {
                    ActionItem actionItem;
                    if (_clickManagerCopy.RegistrationClicks.ContainsKey(i))
                    {
                        Click click            = _clickManagerCopy.RegistrationClicks[i];
                        Point relativePosition =
                            new Point(
                                (int)(_width * click.Position.X),
                                (int)(_height * click.Position.Y));
                        actionItem = new ActionItem
                        {
                            Number      = i + 1,
                            Delay       = click.Delay,
                            Description = click.Description,
                            Position    = relativePosition.ToString()
                        };
                    }
                    else if (_clickManagerCopy.TaxiOrderingClicks
                             .ContainsKey(i))
                    {
                        Click click            = _clickManagerCopy.TaxiOrderingClicks[i];
                        Point relativePosition =
                            new Point(
                                (int)(_width * click.Position.X),
                                (int)(_height * click.Position.Y));
                        actionItem = new ActionItem
                        {
                            Number      = i + 1,
                            Delay       = click.Delay,
                            Description = click.Description,
                            Position    = relativePosition.ToString()
                        };
                    }
                    else
                    {
                        Click click            = _clickManagerCopy.DataCleaningClicks[i];
                        Point relativePosition =
                            new Point(
                                (int)(_width * click.Position.X),
                                (int)(_height * click.Position.Y));
                        actionItem = new ActionItem
                        {
                            Number      = i + 1,
                            Delay       = click.Delay,
                            Description = click.Description,
                            Position    = relativePosition.ToString()
                        };
                    }

                    actions.Add(actionItem);
                }
                else if (_clickManagerCopy.KeyboardInputs.ContainsKey(i))
                {
                    actions.Add(new ActionItem
                    {
                        Number      = i + 1,
                        Delay       = _clickManagerCopy.KeyboardInputs[i].Delay,
                        Description = _clickManagerCopy.KeyboardInputs[i]
                                      .Description,
                    });
                }
                else if (_clickManagerCopy.EnterPresses.ContainsKey(i))
                {
                    actions.Add(new ActionItem
                    {
                        Number      = i + 1,
                        Delay       = _clickManagerCopy.EnterPresses[i].Delay,
                        Description = _clickManagerCopy.EnterPresses[i]
                                      .Description,
                    });
                }
            }

            Actions = actions;
        }
Exemplo n.º 36
0
 public int GetItemIndexFromPoint(Point p)
 {
     //do something get index fron point
     if (itemList == null)
     {
         InitToolBar();
     }
     int length = itemList.Length;
     System.Diagnostics.Debug.WriteLine("Item length:" + length.ToString());
     System.Diagnostics.Debug.WriteLine("Point:" + p.ToString());
     for (int i = 0; i < length; i++)
     {
         if (itemList[i] != null)
             System.Diagnostics.Debug.WriteLine("itemList[i]:" + itemList[i].RECT.ToString());
         if (itemList[i] != null && itemList[i].RECT.Contains(p))
         {
             return i;
         }
     }
     System.Diagnostics.Debug.WriteLine("return -1");
     return -1;
 }
Exemplo n.º 37
0
        /// <summary>
        /// Provides a default implementation for performing dst = F(dst, src) or F(src) over some rectangle 
        /// of interest. May be slightly faster than calling the other multi-parameter Apply method, as less 
        /// variables are used in the implementation, thus inducing less register pressure.
        /// </summary>
        /// <param name="dst">The Surface to write pixels to, and from which pixels are read and used as the lhs parameter for calling the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>.</param>
        /// <param name="dstOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the dst Surface.</param>
        /// <param name="src">The Surface to read pixels from for the rhs parameter given to the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>b>.</param></param>
        /// <param name="srcOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the src Surface.</param>
        /// <param name="roiSize">The size of the rectangles-of-interest for all Surfaces.</param>
        public void ApplyBase(Surface dst, Point dstOffset, Surface src, Point srcOffset, Size roiSize)
        {
            // Create bounding rectangles for each Surface
            Rectangle dstRect = new Rectangle(dstOffset, roiSize);

            if (dstRect.Width == 0 || dstRect.Height == 0)
            {
                return;
            }

            Rectangle srcRect = new Rectangle(srcOffset, roiSize);

            if (srcRect.Width == 0 || srcRect.Height == 0)
            {
                return;
            }

            // Clip those rectangles to those Surface's bounding rectangles
            Rectangle dstClip = Rectangle.Intersect(dstRect, dst.Bounds);
            Rectangle srcClip = Rectangle.Intersect(srcRect, src.Bounds);

            // If any of those Rectangles actually got clipped, then throw an exception
            if (dstRect != dstClip)
            {
                throw new ArgumentOutOfRangeException
                (
                    "roiSize",
                    "Destination roi out of bounds" +
                    ", dst.Size=" + dst.Size.ToString() +
                    ", dst.Bounds=" + dst.Bounds.ToString() +
                    ", dstOffset=" + dstOffset.ToString() +
                    ", src.Size=" + src.Size.ToString() +
                    ", srcOffset=" + srcOffset.ToString() +
                    ", roiSize=" + roiSize.ToString() +
                    ", dstRect=" + dstRect.ToString() +
                    ", dstClip=" + dstClip.ToString() +
                    ", srcRect=" + srcRect.ToString() +
                    ", srcClip=" + srcClip.ToString()
                );
            }

            if (srcRect != srcClip)
            {
                throw new ArgumentOutOfRangeException("roiSize", "Source roi out of bounds");
            }

            // Cache the width and height properties
            int width = roiSize.Width;
            int height = roiSize.Height;

            // Do the work.
            unsafe
            {
                for (int row = 0; row < roiSize.Height; ++row)
                {
                    ColorBgra *dstPtr = dst.GetPointAddress(dstOffset.X, dstOffset.Y + row);
                    ColorBgra *srcPtr = src.GetPointAddress(srcOffset.X, srcOffset.Y + row);
                    Apply(dstPtr, srcPtr, width);
                }
            }
        }
 /// <summary>
 /// Get position of tap within the content
 /// </summary>
 /// <param name="x">x value of tap (on pin device)</param>
 /// <param name="y">y value of tap (on pin device)</param>
 /// <param name="vr">touched view range</param>
 /// <returns>position within content</returns>
 public Point GetTapPositionInContent(double x, double y, BrailleIOViewRange vr)
 {
     Point p = new Point();
     if (vr != null)
     {
         double contentX = x - vr.OffsetPosition.X - vr.Padding.Left - vr.Margin.Left - vr.Border.Left;
         double contentY = y - vr.OffsetPosition.Y - vr.Padding.Top - vr.Margin.Top - vr.Border.Top;
         p = new Point((int)Math.Round(contentX), (int)Math.Round(contentY));
         System.Diagnostics.Debug.WriteLine("tap content position: " + p.ToString());
     }
     return p;
 }