ToString() public method

public ToString ( ) : string
return string
 static void Main(string[] args)
 {
     var p = new Point(3, 5);
     System.Console.WriteLine("original point: " + p.ToString());
     BadSwapPoint(p);
     System.Console.WriteLine("after bad swap: " + p.ToString());
     GoodSwapPoint(ref p);
     System.Console.WriteLine("after good swap: " + p.ToString());
     //GoodSwapPoint(ref localPoint);
 }
    static void FindAllPaths(Point currentPoint, string path)
    {
        for (int i = 0; i < direction.GetLength(0); i++)
        {
            int newRow = currentPoint.Row + direction[i, 0];
            int newCol = currentPoint.Col + direction[i, 1];

            if (InBouds(labyrinth, newRow, newCol))
            {
                if (IsEnd(new Point(newRow, newCol)))
                {
                    Console.WriteLine("Path found: " + path);
                    PrintLabyrinth(labyrinth);
                }
                if (IsFree(labyrinth, newRow, newCol))
                {
                    labyrinth[newRow, newCol] = "X";
                    path += currentPoint.ToString();

                    FindAllPaths(new Point(newRow, newCol), path);
                    labyrinth[newRow, newCol] = "-";
                }
            }
        }
    }
Beispiel #3
0
    static void Main()
    {
        // Point p = new Point(); // uma instância em Stack => IL initobj

        Point p = new Point(7,9); // uma instância em Stack => call Point::.ctor(int32, int32)

        Console.WriteLine(p.ToString());

        object o = p; // box

        Console.WriteLine(o.ToString());
        Console.WriteLine(o.GetHashCode());

        // ((Point) o).y = 11; // Não se pode modificar uma versão temporária unbox
        // <=>

        // ((Point) o).SetY(11);// O objecto o NÃO foi modificado

        Setter i = (Setter) o;
        i.SetY(11);

        /*
        Point p2 = (Point) o; // unbox
        p2.y = 11; // modificar o objecto em Stack
        o = p2; // o passa a referenciar um novo objecto resultante do boxing
        */

        Console.WriteLine(o.ToString());
        Console.WriteLine(o.GetHashCode());
    }
Beispiel #4
0
 public static void Main3()
 {
     // Create two Point instances on the stack. 
     Point p1 = new Point(10, 10);
     Point p2 = new Point(20, 20);
     // p1 does NOT get boxed to call ToString (a virtual method). 
     Console.WriteLine(p1.ToString());// "(10, 10)" 
     // p DOES get boxed to call GetType (a non-virtual method). 
     Console.WriteLine(p1.GetType());// "Point" 
     // p1 does NOT get boxed to call CompareTo. 
     // p2 does NOT get boxed because CompareTo(Point) is called. 
     Console.WriteLine(p1.CompareTo(p2));// "-1" 
     // p1 DOES get boxed, and the reference is placed in c. 
     IComparable c = p1;
     Console.WriteLine(c.GetType());// "Point" 
     // p1 does NOT get boxed to call CompareTo. 
     // Since CompareTo is not being passed a Point variable, 
     // CompareTo(Object) is called which requires a reference to 
     // a boxed Point. 
     // c does NOT get boxed because it already refers to a boxed Point. 
     Console.WriteLine(p1.CompareTo(c));// "0" 
     // c does NOT get boxed because it already refers to a boxed Point. 
     // p2 does get boxed because CompareTo(Object) is called. 
     Console.WriteLine(c.CompareTo(p2));// "-1" 
     // c is unboxed, and fields are copied into p2. 
     p2 = (Point)c;
     // Proves that the fields got copied into p2. 
     Console.WriteLine(p2.ToString());// "(10, 10)" 
 }
 public void Convert_to_a_string()
 {
     var p = new Point(1, 2);
     var p2 = new Point(1, 1);
     Assert.That(p.ToString(), Is.EqualTo("(1,2)"));
     Assert.That(p2.ToString(), Is.EqualTo("(1,1)"));
 }
Beispiel #6
0
 public static void Main()
 {
     Point p = new Point(7, 3);
     p.Print();
     Console.WriteLine(p.ToString()); // Redefinido em Point
     Console.WriteLine(p.GetType()); // box + call
     Console.WriteLine(p.GetHashCode()); // Herdado de Object
 }
Beispiel #7
0
        private void ObtenerPiedra()
        {
            var   k          = 0;
            Point?encontrada = null;
            var   a          = DateTime.Now;

            encontrada = piedraProvider.Obtener();
            var b = (DateTime.Now - a).Milliseconds;

            Consola.Text += " Tiempo: " + b + "///  encontradas " + (encontrada?.ToString() ?? "no") + "/// cantidad " + k + "\r\n";
        }
Beispiel #8
0
 public string Serialize()
 {
     if (_gui != null)
     {
         _position = _gui.Position;
         return(_position?.ToString());
     }
     else
     {
         return(_position?.ToString());
     }
 }
Beispiel #9
0
    protected void OnPaint(object sender, PaintEventArgs e)
    {
        GraphicsUnit gUnit = GraphicsUnit.Pixel;

        Point renderingOrgPt = new Point(0, 0);
        renderingOrgPt.X = 100;
        renderingOrgPt.Y = 100;

        Graphics g = e.Graphics;

        g.PageUnit = gUnit;

        g.TranslateTransform(renderingOrgPt.X, renderingOrgPt.Y);
        g.DrawRectangle(new Pen(Color.Red, 1), 0, 0, 100, 100);

        this.Text = string.Format("PageUnit: {0}, Origin: {1}", gUnit, renderingOrgPt.ToString());
    }
Beispiel #10
0
    static void Main() 
    {
        Point p1 = new Point(1,2);      // создаем объект Point

        Point p2 = p1.Copy();           // создаем копию первого объекта 
       
        Point p3 = p1;                  // создаем ссылку на первый объект

        
        Say("{0}\n", Object.ReferenceEquals(p1, p2));   // если ссылки неравны
        
        Say("{0}\n", Object.Equals(p1, p2));            // если объекты равны
        
        Say("{0}\n", Object.ReferenceEquals(p1, p3));   // если ссылки равны
        
        Say("p1's value is: {0}\n", p1.ToString());     // печать объект в строчном виде: (1, 2)
    }
        public void DrawDirectEdge(Point p1, Point p2, Color c)
        {
            Console.WriteLine("DrawDirecEdge with p1 = {0}, p2 = {1}, color = {2}", p1.ToString(), p2.ToString(), c.ToString());
            //Graphics g = this.CreateGraphics();

            // стрелка
            Pen p = new Pen(c);
            //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            //g.ScaleTransform(
            p.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            p.CustomStartCap = new System.Drawing.Drawing2D.AdjustableArrowCap(8, 5, true);
            //p.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
            //p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

            g.DrawLine(p, p1.X, p1.Y, p2.X, p2.Y);

            //g.DrawLine(new Pen(c), p)
            //g.DrawLine(new Pen(c), p)
        }
Beispiel #12
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)
        {
            IInputArray img = _imageBox.DisplayedImage;

            using (InputArray iaImage = img.GetInputArray())
            {
                Size size = iaImage.GetSize();
                location.X = Math.Max(Math.Min(location.X, size.Width - 1), 0);
                location.Y = Math.Max(Math.Min(location.Y, size.Height - 1), 0);

                mousePositionTextbox.Text = location.ToString();

                if (_imageType == typeof(CvArray <>))
                {
                    using (Mat mat = iaImage.GetMat())
                    {
                        RenderIntensityForMat(mat, location);
                    }
                }
                else if (_imageType == typeof(Mat))
                {
                    Mat mat = img as Mat;
                    RenderIntensityForMat(mat, location);
                }
                else if (_imageType == typeof(UMat))
                {
                    UMat umat = img as UMat;
                    using (Mat mat = umat.GetMat(AccessType.Read))
                    {
                        RenderIntensityForMat(mat, location);
                    }
                }
                else
                {
                    colorIntensityTextbox.Text = String.Empty;
                }
            }
        }
 private void CastCatchLocation_Click(object sender, EventArgs e)
 {
     locationStartButton = helper.FindColor(startButtonGreen);
     if (locationStartButton == new Point())
     {
         MessageBox.Show("Start button could not be found.\nPlease make sure you are on the fishing start screen.\nIf you believe this may be an error, please submit an issue on github.", "Start button not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         locationStartButton = helper.getScreenLocationPoint(locationStartButton);
         if (steam)
         {
             locationTradeFishButton             = new Point(locationStartButton.X, locationStartButton.Y - 40);
             locationCloseShellDialogBox         = new Point(locationStartButton.X + 270, locationStartButton.Y - 350);
             locationCloseItGotAwayButton        = new Point(locationStartButton.X + 20, locationStartButton.Y - 130);
             locationTimerCaughtFish             = new Point(locationStartButton.X - 200, locationStartButton.Y - 70);
             locationJunkItem                    = new Point(locationStartButton.X + 40, locationStartButton.Y - 182);
             locationTopLeftWeightScreenshot     = new Point(locationStartButton.X - 25, locationStartButton.Y - 130);
             locationBottomRightWeightScreenshot = new Point(locationStartButton.X + 160, locationStartButton.Y - 50);
             location100Position                 = new Point(locationStartButton.X + 370, locationStartButton.Y - 81);
         }
         else
         {
             locationTradeFishButton             = new Point(locationStartButton.X, locationStartButton.Y - 15);
             locationCloseShellDialogBox         = new Point(locationStartButton.X + 265, locationStartButton.Y - 325);
             locationCloseItGotAwayButton        = new Point(locationStartButton.X + 30, locationStartButton.Y - 100);
             locationTimerCaughtFish             = new Point(locationStartButton.X - 200, locationStartButton.Y - 70);
             locationJunkItem                    = new Point(locationStartButton.X + 100, locationStartButton.Y - 155);
             locationTopLeftWeightScreenshot     = new Point(locationStartButton.X - 25, locationStartButton.Y - 130);
             locationBottomRightWeightScreenshot = new Point(locationStartButton.X + 160, locationStartButton.Y - 50);
             location100Position                 = new Point(locationStartButton.X + 373, locationStartButton.Y - 81);
         }
         castCatchLocationLbl.Text = "Cast/Catch Location:\n" + locationStartButton.ToString();
         autoBtn.Enabled           = true;
         cancelAutoModeBtn.Enabled = true;
         getTimesBtn.Enabled       = true;
     }
 }
Beispiel #14
0
            public override string ToString()
            {
                string from, to, tr, p;

                if (fromWhere != null)
                {
                    from = fromWhere.ToString();
                }
                else
                {
                    from = "null";
                }
                if (station != null)
                {
                    to = station.nameRus;
                }
                else
                {
                    to = "null";
                }
                if (myRoute != null)
                {
                    tr = myRoute.GetShortName();
                }
                else
                {
                    tr = "пешком";
                }
                if (prev != null)
                {
                    p = prev.ToString();
                }
                else
                {
                    p = "null";
                }
                return /*p+" -->> */ ("{{(" + totalTime.ToString() + ") " + to + " (" + tr + ")}} "); // from " + from + " to
            }
        public static void Go()
        {
            // Create two Point instances on the stack.
            Point p1 = new Point(10, 10);
            Point p2 = new Point(20, 20);

            // p1 does NOT get boxed to call ToString (a virtual method).
            Console.WriteLine(p1.ToString());   // "(10, 10)"

            // p DOES get boxed to call GetType (a non-virtual method).
            Console.WriteLine(p1.GetType());    // "Point"

            // p1 does NOT get boxed to call CompareTo.
            // p2 does NOT get boxed because CompareTo(Point) is called.
            Console.WriteLine(p1.CompareTo(p2)); // "-1"

            // p1 DOES get boxed, and the reference is placed in c.
            IComparable c = p1;

            Console.WriteLine(c.GetType());     // "Point"

            // p1 does NOT get boxed to call CompareTo.
            // Since CompareTo is not being passed a Point variable,
            // CompareTo(Object) is called which requires a reference to
            // a boxed Point.
            // c does NOT get boxed because it already refers to a boxed Point.
            Console.WriteLine(p1.CompareTo(c)); // "0"

            // c does NOT get boxed because it already refers to a boxed Point.
            // p2 does get boxed because CompareTo(Object) is called.
            Console.WriteLine(c.CompareTo(p2)); // "-1"

            // c is unboxed, and fields are copied into p2.
            p2 = (Point)c;

            // Proves that the fields got copied into p2.
            Console.WriteLine(p2.ToString());   // "(10, 10)"
        }
Beispiel #16
0
        private void Test_MouseHover(object sender, EventArgs e)
        {
            Point mousePt  = System.Windows.Forms.Cursor.Position;
            Point offsetPt = mousePt;


            offsetPt.Offset(this.Location.X * -1, this.Location.Y * -1);

            label1.Text = mousePt.ToString();
            label2.Text = offsetPt.ToString();

            if (this._testRect.Contains(mousePt))
            {
                label1.Text = "_testRect";
            }
            else if (IsInPolygon(_TestPoly.ToArray(), mousePt))
            {
                label1.Text = "_TestPoly";
            }
            else
            {
            }
        }
Beispiel #17
0
    void Inicialization()
    {
        PoolReference.TableScene["SkillsCanvas"].SetActive(true);
        while (PointExpText == null)
        {
            try
            {
                strengthNumText  = PoolReference.TableScene["strengthNumText"].GetComponent <Text>();
                intellectNumText = PoolReference.TableScene["intellectNumText"].GetComponent <Text>();
                speedNumText     = PoolReference.TableScene["speedNumText"].GetComponent <Text>();


                PointExpText      = PoolReference.TableScene["PointExpText"].GetComponent <Text>();
                PointExpText.text = Point.ToString();
            } catch (KeyNotFoundException)
            {
                MonoBehaviour.print("Inicialization в PlayerSkills не удалась. \nпроверьте ссылки в TableScene.\nПроверить addToPool на объектах.\n");

                break;
            }
        }
        PoolReference.TableScene["SkillsCanvas"].SetActive(false);
    }
Beispiel #18
0
        public void DrawPath(Point start, IList <IPathCommand> commands, double thickness, bool fill = false)
        {
            m_writer.WriteStartElement("path");
            m_writer.WriteAttributeString("start", start.ToString());
            m_writer.WriteAttributeString("thickness", thickness.ToString());
            m_writer.WriteAttributeString("fill", fill.ToString());

            using (MemoryStream dataStream = new MemoryStream())
            {
                System.IO.BinaryWriter dataWriter = new System.IO.BinaryWriter(dataStream);
                dataWriter.Write(commands.Count);
                foreach (IPathCommand pathCommand in commands)
                {
                    dataWriter.Write((int)pathCommand.Type);
                    pathCommand.Write(dataWriter);
                }
                dataWriter.Flush();

                m_writer.WriteValue(Convert.ToBase64String(dataStream.ToArray()));
            }

            m_writer.WriteEndElement();
        }
        public void GenerateLine()
        {
            Point cluster1Pos = MainData.GetGalaxyMap().Clusters.First(c => c.Id == ConnectionId1).Polygon.TransformToAncestor(MainData.Canvas).Transform(new Point(0, 0));
            Point cluster2Pos = MainData.GetGalaxyMap().Clusters.First(c => c.Id == ConnectionId2).Polygon.TransformToAncestor(MainData.Canvas).Transform(new Point(0, 0));

            Console.WriteLine("1: " + cluster1Pos.ToString());

            cluster1Pos = GetPoint(cluster1Pos, 55, Connection1Type);
            cluster2Pos = GetPoint(cluster2Pos, 55, Connection2Type);

            Line    = new Line();
            Line.X1 = cluster1Pos.X;
            Line.Y1 = cluster1Pos.Y;
            Line.X2 = cluster2Pos.X;
            Line.Y2 = cluster2Pos.Y;


            Line.Stroke          = Brushes.Orange;
            Line.StrokeThickness = 5;
            Line.Tag             = UId;

            MainData.AddChildToCanvas(CanvasElementType.CONNECTION, Line, UId.ToString());
        }
Beispiel #20
0
        private void oyunEkrani_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Y < 270)   /* Adam ve oku 0-270 Y koordinatı üzerinde hareket ettirmek için */
            {
                pbAdam.Top = e.Y;

                Point adamX = this.PointToClient(Cursor.Position); //Adamın koordinatlarını verir

                labelx.Text = adamX.ToString();
            }
            else
            {
            }


            if (okYaydaMi) //okun dışarı çıkmama kontrolü
            {
                if (e.Y < 270)
                {
                    pbOk.Top = e.Y;
                }
            }
        }
 public static bool Prefix(string action, Farmer who, Location tileLocation, bool __result, GameLocation __instance)
 {
     if (action == "Mailbox")
     {
         Logger.Log(Game1.player.name + " checked the mailbox at " + tileLocation.ToString() + "...");
         if (__instance is Farm)
         {
             Logger.Log("Mailbox was on the farm...");
             Point mailboxPosition = FarmState.getMailboxPosition(Game1.player);
             Logger.Log(Game1.player.name + "'s mailbox is at " + mailboxPosition.ToString());
             if (tileLocation.X != mailboxPosition.X || tileLocation.Y != mailboxPosition.Y)
             {
                 Logger.Log("Mailbox did not belong to " + Game1.player.name);
                 return(true);
             }
             Logger.Log("Mailbox belonged to " + Game1.player.name);
             __instance.mailbox();
             __result = true;
             return(false);
         }
     }
     return(true);
 }
Beispiel #22
0
 private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         Point pt = Cursor.Position;
         this.Text      = "Mouse Position: " + pt.ToString();
         this.CurWindow = new WindowInfo(WindowFromPoint(pt));
         label1.Text    = "Handle: " + this.CurWindow.Handle.ToString("X");
         label2.Text    = "Class: " + this.CurWindow.ClassName;
         label3.Text    = "Text: " + this.CurWindow.Text;
         label4.Text    = "Rectangle: " + this.CurWindow.Rect.ToString();
         if (this.LastWindow == null)
         {
             ControlPaint.DrawReversibleFrame(this.CurWindow.Rect, Color.Black, FrameStyle.Thick);
         }
         else if (!this.CurWindow.Handle.Equals(this.LastWindow.Handle))
         {
             ControlPaint.DrawReversibleFrame(this.LastWindow.Rect, Color.Black, FrameStyle.Thick);
             ControlPaint.DrawReversibleFrame(this.CurWindow.Rect, Color.Black, FrameStyle.Thick);
         }
         this.LastWindow = this.CurWindow;
     }
 }
Beispiel #23
0
    static void Main()
    {
        // Construct a Point object.
        var p1 = new Point(1, 2);

        // Make another Point object that is a copy of the first.
        var p2 = p1.Copy();

        // Make another variable that references the first Point object.
        var p3 = p1;

        // The line below displays false because p1 and p2 refer to two different objects.
        Console.WriteLine(Object.ReferenceEquals(p1, p2));

        // The line below displays true because p1 and p2 refer to two different objects that have the same value.
        Console.WriteLine(Object.Equals(p1, p2));

        // The line below displays true because p1 and p3 refer to one object.
        Console.WriteLine(Object.ReferenceEquals(p1, p3));

        // The line below displays: p1's value is: (1, 2)
        Console.WriteLine($"p1's value is: {p1.ToString()}");
    }
Beispiel #24
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            int clickedX = (int)(((double)e.X / (double)Width) * 8.0d);
            int clickedY = (int)(((double)e.Y / (double)Height) * 8.0d);

            Point clickedPoint = new Point(clickedX, clickedY);

            //Determine if this is the correct player
            if (Board[clickedY, clickedX].Colour != CheckerColour.Empty &&
                Board[clickedY, clickedX].Colour != currentTurn)
            {
                return;
            }

            //Determine if this is a move or checker selection
            List <Move> matches = possibleMoves.Where(m => m.Destination == clickedPoint).ToList <Move>();

            if (matches.Count > 0)
            {
                //Move the checker to the clicked square
                MoveChecker(matches[0]);
            }
            else if (Board[clickedY, clickedX].Colour != CheckerColour.Empty)
            {
                //Select the clicked checker
                selectedChecker.X = clickedX;
                selectedChecker.Y = clickedY;
                possibleMoves.Clear();

                Console.WriteLine("Selected Checker: {0}", selectedChecker.ToString());

                Move[] OpenSquares = Utils.GetOpenSquares(Board, selectedChecker);
                possibleMoves.AddRange(OpenSquares);

                this.Invalidate();
            }
        }
Beispiel #25
0
        private void rubberEffectForm_MouseMove(object sender, MouseEventArgs e)
        {
            readPoi = this.PointToClient(Control.MousePosition);//基于工作区的坐标
            Graphics gw = this.CreateGraphics();

            if (useRubber)   //在橡皮筋模式内
            {
                gw.Clear(BackColor);
                int plct = poilst.Count;
                if (plct == 0)  // ==0: pass
                {
                }
                else if (plct == 1)
                {
                    gw.DrawLine(rubPen, poilst[0], readPoi);
                }
                else    //两点及以上
                {
                    for (int i = 0; i < plct; i++)
                    {
                        if (i == plct - 1)  //画到最后一点了
                        {
                            gw.DrawLine(rubPen, poilst[i], readPoi);
                            gw.DrawLine(rubPen, poilst[0], readPoi);
                        }
                        else
                        {
                            gw.DrawLine(rubPen, poilst[i], poilst[i + 1]);
                        }
                    }
                }
            }
            else
            {
            }
            intimePoiLbl.Text = readPoi.ToString();
        }
Beispiel #26
0
    public static void Main()
    {
        Ponto3D p1 = new Ponto3D(10, 10, 15);

        Print(p1); //conversão implícita para string

        Ponto3D p2 = Ponto3D.Origem();

        Print(p2);

        Ponto3D p3 = p2 - p1;

        Print(p3);

        Point p = (Point)p3;

        Print(p.ToString());

        int size;

        unsafe { size = sizeof(Ponto3D); }

        Print(size.ToString() + " bytes");
    }
Beispiel #27
0
        private void PictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            var bg = pictureBox1.BackgroundImage;

            SelectedPoint = e.Location;


            using (var gfx = pictureBox1.CreateGraphics())
            {
                gfx.Clear(Color.Black);
                if (bg != null)
                {
                    gfx.DrawImage(bg, pictureBox1.DisplayRectangle);
                }
                gfx.DrawRectangle(Pens.Red, e.X - 10, e.Y, 10, 10);
            }


            label1.Text = "Selected Point: " + SelectedPoint.ToString();

            var world = ServerContext.GlobalWorldMapTemplateCache.Values.ElementAt(comboBox2.SelectedIndex);

            if (world == null)
            {
                return;
            }

            using (var gfx = pictureBox1.CreateGraphics())
            {
                foreach (var portal in world.Portals)
                {
                    gfx.DrawString(portal.DisplayName, Font, Brushes.Yellow, new Point(portal.PointY, portal.PointX));
                    gfx.DrawRectangle(Pens.Cyan, portal.PointY - 10, portal.PointX, 10, 10);
                }
            }
        }
 /// <summary></summary>
 public override string ToString()
 {
     if (IsNone)
     {
         return("NONE");
     }
     if (IsPoint)
     {
         return(Point.ToString());
     }
     if (IsPoints)
     {
         return(Points.ToString());
     }
     if (IsLineSegment)
     {
         return(LineSegment.ToString());
     }
     if (IsLine)
     {
         return(Line.ToString());
     }
     return("UNKNOWN");
 }
Beispiel #29
0
    static void Main()
    {
        // Create the object.
        Point p = new Point(5, 98);

        // Test ToString with no formatting.
        Console.WriteLine("This is my point: " + p.ToString());

        // Use custom formatting style "x"
        Console.WriteLine("The point's x value is {0:x}", p);

        // Use custom formatting style "y"
        Console.WriteLine("The point's y value is {0:y}", p);

        try
        {
            // Use an invalid format; FormatException should be thrown here.
            Console.WriteLine("Invalid way to format a point: {0:XYZ}", p);
        }
        catch (FormatException e)
        {
            Console.WriteLine("The last line could not be displayed: {0}", e.Message);
        }
    }
    public GameObject CreateTile(Point p)
    {
        // Create the gameobject.
        GameObject newTile = Instantiate(tilePrefab, tilesContainer.transform);

        newTile.name = p.ToString();

        // Set the tile position for the script.
        HexagonTile tile = newTile.GetComponent <HexagonTile>();

        tile.TileX = p.X;
        tile.TileZ = p.Y;

        HexTemperature hexTemp = newTile.GetComponent <HexTemperature>();

        hexTemp.Pathing = HeatSearch;
        hexTemp.Field   = this;
        hexTemp.MyHex   = tile;

        tile.MyTemp = hexTemp;

        tiles[p] = newTile;
        return(newTile);
    }
Beispiel #31
0
        public void ToStringTest()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");
            Point p = new Point(4, 5);

            Assert.AreEqual("4,5", p.ToString());
            Point p2 = new Point(4.1, 5.1);

            Assert.AreEqual("4.1,5.1", p2.ToString());
            Point p3 = new Point(0, 0);

            Assert.AreEqual("0,0", p3.ToString());

            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de-de");
            Point p4 = new Point(4, 5);

            Assert.AreEqual("4;5", p4.ToString());
            Point p5 = new Point(4.1, 5.1);

            Assert.AreEqual("4,1;5,1", p5.ToString());
            Point p6 = new Point(0, 0);

            Assert.AreEqual("0;0", p6.ToString());
        }
Beispiel #32
0
        public void ShouldSerializeToWkt(double x, double y, double?z, string expectedWkt)
        {
            var wgs84Mock = new Mock <ICoordinateSystem>(MockBehavior.Loose);

            var coords = new List <double>(new double[] { x, y });

            if (z.HasValue)
            {
                coords.Add(z.Value);
            }

            var point = new Point()
            {
                pos = new pos(),
                CoordinateSystem = CommonServiceLocator.GetCoordinateSystemProvider().Wgs84
            };

            point.pos.Untyped.Value = string.Join(
                " ",
                coords.Select <double, string>(d => d.ToString(CultureInfo.InvariantCulture))
                );

            Assert.Equal <string>(expectedWkt, point.ToString());
        }
Beispiel #33
0
        //鼠标移动
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            Refresh(sender, e);
            pen = new Pen(nowColor);
            if (printing)
            {
                pointNow = new Point(e.X, e.Y);
                pointB   = pointNow;
                Console.WriteLine(pointA.ToString() + "     " + pointB.ToString());

                switch (function)
                {
                case "写字":
                    label1.Text = "添加水印";
                    break;

                case "画点":
                    label1.Text = "画点";
                    graphics.FillEllipse(new SolidBrush(nowColor), new Rectangle(pointB, fontSize));
                    break;

                case "橡皮":
                    graphics.FillEllipse(new SolidBrush(nowColor), new Rectangle(pointB, fontSize));
                    break;

                case "划线":
                    label1.Text = "划线"; break;

                case "矩形":
                    label1.Text = "矩形,\r\n上滑取消操作"; break;

                case "圆形":
                    label1.Text = "画圆"; break;
                }
            }
        }
 private void click(object sender, MouseEventArgs e)
 {
     loc = e.GetPosition(canvas);
     Console.WriteLine("Click" + loc.ToString());
     for (int i = 0; i < 20; i++)
     {
         for (int j = 0; j < 20; j++)
         {
             Rectangle r = rectangles[i, j];
             if ((loc.X > Canvas.GetLeft(r) && loc.X < Canvas.GetLeft(r) + 20) && (loc.Y > Canvas.GetTop(r) && loc.Y < Canvas.GetTop(r) + 20))
             {
                 //Console.WriteLine("True");
                 if (r.Fill == Brushes.White)
                 {
                     r.Fill = Brushes.Black;
                 }
                 else
                 {
                     r.Fill = Brushes.White;
                 }
             }
         }
     }
 }
        /// <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);
        }
Beispiel #36
0
 private void treeView_DragOver(object sender, DragEventArgs e)
 {
     try
     {
         Point currentPosition = e.GetPosition(m_Treeview);
         if (m_Test2.IsVisible)
         {
             Point l_vItemPos = m_Test2.PointToScreen(new Point(0d, 0d));
             m_Test2.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
             Size l_Size = m_Test2.DesiredSize;
             l_Size.Width  += l_vItemPos.X;
             l_Size.Height += l_vItemPos.Y;
             m_Test.Header  = l_vItemPos.ToString() + ",RB:" + l_Size.ToString() + "," + m_vCurrentMousePos.ToString();
         }
         if ((Math.Abs(currentPosition.X - m_vLastMouseDown.X) > 10.0) ||
             (Math.Abs(currentPosition.Y - m_vLastMouseDown.Y) > 10.0))
         {
             // Verify that this is a valid drop and then store the drop target
             m_vCurrentMousePos = System.Windows.Forms.Cursor.Position;
             TreeViewItem item = GetNearestContainer(e.OriginalSource as UIElement);
             if (m_DraggedTreeViewItem != item)
             {
                 e.Effects = DragDropEffects.Move;
             }
             else
             {
                 e.Effects = DragDropEffects.None;
                 //e.Effects = DragDropEffects.Scroll;
             }
         }
         e.Handled = true;
     }
     catch (Exception)
     {
     }
 }
Beispiel #37
0
        private void LayoutRoot_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PointCollection points = new PointCollection();

            foreach (Point p in poly.Points)
            {
                points.Add(p);
            }
            Point newPoint = e.GetPosition(poly);

            points.Add(newPoint);
            poly.Points = points;
            // placeholder
            Ellipse ph = new Ellipse
            {
                Fill   = new SolidColorBrush(Colors.Black),
                Width  = 4D,
                Height = 4D
            };
            TranslateTransform t = new TranslateTransform {
                X = newPoint.X - 2D, Y = newPoint.Y - 2D
            };

            ph.RenderTransform = t;
            cnv.Children.Add(ph);
            //
            TextBlock tb = new TextBlock
            {
                Foreground = new SolidColorBrush(Colors.Gray),
                FontSize   = 8
            };

            tb.Text            = newPoint.ToString();
            tb.RenderTransform = t;
            cnv.Children.Add(tb);
        }
Beispiel #38
0
        /// <summary>
        /// Displays the current mouse position to the console.
        /// </summary>
        private static void DisplayCurrentMousePosition()
        {
            Point p             = default;
            int   printedLength = 0;//The current amount of buffer chars that are used.

            Console.CursorVisible = false;
            while (true)
            {
                Point current = MouseMover.GetMousePosition();
                if (current != p)
                {
                    p = current;
                    string toPrint   = p.ToString();
                    int    newLength = toPrint.Length;
                    Console.CursorLeft = 0;
                    Console.Write(toPrint);
                    for (int i = newLength; i < printedLength; i++)
                    {
                        Console.Write(' ');
                    }
                    printedLength = newLength;
                }
            }
        }
Beispiel #39
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();
        }
Beispiel #40
0
 public void ToStringTest()
 {
     Point p = new Point(0, 0);
     Assert.Equal(string.Format(CultureInfo.CurrentCulture, "{{X={0},Y={1}}}", p.X, p.Y), p.ToString());
 }
Beispiel #41
0
 public void PointToStringAndFromString()
 {
     var p = new Point(2.23f, 3.45f);
     string pointString = p.ToString();
     Assert.AreEqual(p, new Point(pointString));
     Assert.Throws<Point.InvalidNumberOfComponents>(() => new Point("0.0"));
 }
Beispiel #42
0
        /// <summary>
        /// Add a monster with a random patrol. Needs the mapgenerator of the level in question
        /// </summary>
        /// <param name="monster"></param>
        /// <param name="mapGen"></param>
        private bool AddMonsterFarFromLocation(Monster monster, Point location, int level, MapGenerator mapGen)
        {
            //Offset location

            int maxLoops = 50;
            int loops = 0;

            Point toPlaceLoc = new Point(location);

            int distance = 40;

            do
            {
                toPlaceLoc = new Point(location.x + (int)Gaussian.BoxMuller(distance, 5), location.y + (int)Gaussian.BoxMuller(distance, 5));

                loops++;
                distance--;

            } while (!Game.Dungeon.AddMonster(monster, level, toPlaceLoc) && loops < maxLoops);

            if (loops == maxLoops)
            {
                LogFile.Log.LogEntryDebug("Failed to place: " + monster.Representation + " far from to: " + location + " reverting to random placement", LogDebugLevel.Medium);

                loops = 0;

                do
                {
                    toPlaceLoc = Game.Dungeon.RandomWalkablePointInLevel(level);
                    loops++;

                } while (!Game.Dungeon.AddMonster(monster, level, toPlaceLoc) && loops < maxLoops);

                LogFile.Log.LogEntryDebug("Failed to place: " + monster.Representation + " giving up", LogDebugLevel.High);
                return false;
            }

            LogFile.Log.LogEntryDebug("Item " + monster.Representation + " placed at: " + location.ToString(), LogDebugLevel.High);

            return true;
        }
Beispiel #43
0
 public static string GetName(Point p)
 {
     return p.ToString();
 }
Beispiel #44
0
 Chunk InstantiateChunk(Chunk corridorChunk, Chunk chamberChunk, double chamberProbability, Point currentPoint)
 {
     Debug.Log ("-------Instantiating Chunk!------");
     Chunk c = null;
     if (random.NextDouble() < chamberProbability) {
         c = Instantiate(chamberChunk) as Chunk;
     } else {
         c = Instantiate(corridorChunk) as Chunk;
     }
     c.name = currentPoint.ToString();
     return c;
 }
Beispiel #45
0
        public void ToString (int px, int py, string str)
        {
            var p = new Point(px, py);

            p.ToString().Should().Be(str);
        }
Beispiel #46
0
    static void Main(string[] args)
    {
        string[] inputs;
        inputs = Console.ReadLine().Split(' ');
        int W = int.Parse(inputs[0]); // number of columns.
        int H = int.Parse(inputs[1]); // number of rows.
        var map = new List<string[]>();
        for (int i = 0; i < H; i++)
        {
            string LINE = Console.ReadLine(); // represents a line in the grid and contains W integers. Each integer represents one room of a given type.
            map.Add(LINE.Split(' '));
        }
        int EX = int.Parse(Console.ReadLine()); // the coordinate along the X axis of the exit (not useful for this first mission, but must be read).

        //var tree = buildTree(map);

        // game loop
        while (true)
        {
            inputs = Console.ReadLine().Split(' ');
            int XI = int.Parse(inputs[0]);
            int YI = int.Parse(inputs[1]);
            string POS = inputs[2];

            var type = int.Parse(map[YI][XI]);
            var direction = nextStepOf(type, POS);

            var expectedPosition = new Point(XI, YI) + direction;
            Console.WriteLine(expectedPosition.ToString());
        }
    }
Beispiel #47
0
    private void parseTypeC()
    {
        string[] coins = msg.Split(':', '#');
        string[] position = coins[1].Split(',');
        string lifeTime = coins[2];
        int value = int.Parse(coins[3]);

        Point p = new Point(int.Parse(position[0]), int.Parse(position[1]));
        gameInstance.addCoin(p, int.Parse(lifeTime));

        Debug.Log("Coin appears at " + p.ToString() + ". It will be there for " + lifeTime.ToString() + " time. Coin value is " + value);
    }
Beispiel #48
0
    private void parseTypeL()
    {
        string[] life = msg.Split(':', '#');
        string[] position = life[1].Split(',');
        string lifeTime = life[2];

        Point p = new Point(int.Parse(position[0]), int.Parse(position[1]));
        gameInstance.addLifePack(p, int.Parse(lifeTime));

        Debug.Log("Life pack appears at " + p.ToString() + ". It will be there for " + lifeTime.ToString() + " time.");
    }
Beispiel #49
0
 public void PointToString()
 {
     var p = new Point(3, 4);
     Assert.AreEqual("(3, 4)", p.ToString());
 }
Beispiel #50
0
	private string PrintResultTable(ICoordinateSystem fromCoordSys, ICoordinateSystem toCoordSys, Point fromPnt, Point toPnt, Point refPnt, Point backPnt, string header)
	{
		string table = "<table style=\"border: 1px solid #000; margin: 10px;\">";
		table += "<tr><td colspan=\"2\"><h3>" + header + "</h3></td></tr>";
		table += "<tr><td width=\"130px\" valign=\"top\">Input coordsys:</td><td>" + fromCoordSys.WKT + "</td></tr>";
		table += "<tr><td valign=\"top\">Output coordsys:</td><td>" + toCoordSys.WKT + "</td></tr>";
		table += "<tr><td>Input coordinate:</td><td>" + fromPnt.ToString() + "</td></tr>";
		table += "<tr><td>Ouput coordinate:</td><td>" + toPnt.ToString() + "</td></tr>";
		table += "<tr><td>Expected coordinate:</td><td>" + refPnt.ToString() + "</td></tr>";
		table += "<tr><td>Difference:</td><td>" + (refPnt-toPnt).ToString() + "</td></tr>";
		table += "<tr><td>Reverse transform:</td><td>" + backPnt.ToString() + "</td></tr>";
		table += "<tr><td>Difference:</td><td>" + (backPnt - fromPnt).ToString() + "</td></tr>";
		table += "</table>";
		return table;
	}
Beispiel #51
0
 public override void DrawEllipse(Point Center, double R)
 {
     Console.WriteLine(" : center=" + Center.ToString() + " , R=" + R);
 }
Beispiel #52
0
        public void TestRoverEncountersObstacleMovingNegatively()
        {
            var obstructionPoint = new Point { X = 2, Y = 2 };
            var planetWithObstacles = new Planet(50, new Point[] { obstructionPoint });
            var rover = new Rover(new Point { X = 3, Y = 2 }, 'W', stateFactory, planetWithObstacles);
            rover.MoveForward();

            Assert.That(rover.IsObstructed, Is.EqualTo(true));
            Assert.That(rover.Obstruction.ToString(), Is.EqualTo(obstructionPoint.ToString()));
            Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("3,2"));
        }
Beispiel #53
0
    /// <summary>
    /// Prints out the map data to the console
    /// </summary>
    private void _printMap()
    {
#if false
        Debug.Log("Start = " + m_startPoint.ToString());
        Debug.Log("Exit = " + m_exitPoint.ToString());
        Debug.Log("Shop = " + m_shopPoint.ToString());
        Debug.Log("Is Actually exit = " + m_worldMapData[m_exitPoint.x, m_exitPoint.y].RoomType);

        for (int i = 0; i < m_worldMaxXSize; i++)
        {
            for (int j = 0; j < m_worldMaxYSize; j++)
            {
                Point currentPoint = new Point(i, j);
                RoomData currentRoom = m_worldMapData[i, j];
                Debug.Log("Position = " + currentPoint.ToString());
                Debug.Log("Current Room: NorthDoor = " + currentRoom.IsNorthDoorActive + "| East Door = " + currentRoom.IsEastDoorActive +
                    "| South Door = " + currentRoom.IsSouthDoorActive + "| West Door = " + currentRoom.IsWestDoorActive);
            }
        } 
#endif
    }
Beispiel #54
0
        /// <summary>
        /// Tries to add an item close to a location, puts it anywhere if that's not possible
        /// </summary>
        /// <param name="item"></param>
        /// <param name="level"></param>
        /// <param name="location"></param>
        private bool AddItemCloseToLocation(Item item, int level, Point location)
        {
            //Offset location

            int maxLoops = 50;
            int loops = 0;

            Point toPlaceLoc = new Point(location);

            do
            {
                toPlaceLoc = new Point(location.x + (int)Gaussian.BoxMuller(2, 2), location.y + (int)Gaussian.BoxMuller(2, 2));
                loops++;

            } while (!Game.Dungeon.AddItem(item, level, toPlaceLoc) && loops < maxLoops);

            if (loops == maxLoops)
            {
                LogFile.Log.LogEntryDebug("Failed to place: " + item.Representation + " close to: " + location + " reverting to random placement", LogDebugLevel.Medium);

                loops = 0;

                do
                {
                    toPlaceLoc = Game.Dungeon.RandomWalkablePointInLevel(level);
                    loops++;

                } while (!Game.Dungeon.AddItem(item, level, toPlaceLoc) && loops < maxLoops);

                LogFile.Log.LogEntryDebug("Failed to place: " + item.Representation + " giving up", LogDebugLevel.High);
                return false;
            }

            LogFile.Log.LogEntryDebug("Item " + item.Representation + " placed at: " + location.ToString(), LogDebugLevel.High);

            return true;
        }