Exemplo n.º 1
0
 /// <summary>
 /// Returns the hash code for this instance.
 /// </summary>
 /// <returns>
 /// A 32-bit signed integer that is the hash code for this instance.
 /// </returns>
 /// <filterpriority>2</filterpriority>
 public override int GetHashCode()
 {
     unchecked
     {
         return((UpperLeft.GetHashCode() * 397) ^ LowerRight.GetHashCode());
     }
 }
Exemplo n.º 2
0
        public override void Write(BinaryWriter bw)
        {
            base.Write(bw);

            UpperLeft.Write(bw);
            LowerRight.Write(bw);
        }
Exemplo n.º 3
0
 public void MergeFrom(PathTimeObstacle other)
 {
     if (other == null)
     {
         return;
     }
     if (other.ObstacleId.Length != 0)
     {
         ObstacleId = other.ObstacleId;
     }
     if (other.bottomLeft_ != null)
     {
         if (bottomLeft_ == null)
         {
             bottomLeft_ = new global::Apollo.Planning.PathTimePoint();
         }
         BottomLeft.MergeFrom(other.BottomLeft);
     }
     if (other.upperLeft_ != null)
     {
         if (upperLeft_ == null)
         {
             upperLeft_ = new global::Apollo.Planning.PathTimePoint();
         }
         UpperLeft.MergeFrom(other.UpperLeft);
     }
     if (other.upperRight_ != null)
     {
         if (upperRight_ == null)
         {
             upperRight_ = new global::Apollo.Planning.PathTimePoint();
         }
         UpperRight.MergeFrom(other.UpperRight);
     }
     if (other.bottomRight_ != null)
     {
         if (bottomRight_ == null)
         {
             bottomRight_ = new global::Apollo.Planning.PathTimePoint();
         }
         BottomRight.MergeFrom(other.BottomRight);
     }
     if (other.TimeLower != 0D)
     {
         TimeLower = other.TimeLower;
     }
     if (other.TimeUpper != 0D)
     {
         TimeUpper = other.TimeUpper;
     }
     if (other.PathLower != 0D)
     {
         PathLower = other.PathLower;
     }
     if (other.PathUpper != 0D)
     {
         PathUpper = other.PathUpper;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Serializes the SGF point rectangle
 /// </summary>
 /// <returns>Serialized SGF point rectangle value representation</returns>
 public override string ToString()
 {
     if (UpperLeft == LowerRight)
     {
         //single point
         return(UpperLeft.ToString());
     }
     return($"{UpperLeft}:{LowerRight}");
 }
Exemplo n.º 5
0
        /// <summary>
        /// Remove the square from the playing field.
        /// </summary>
        public void Remove()
        {
            // if we get here we can remove the square:
            SquareCompleted?.Invoke(this, EventArgs.Empty);

            UpperRight.RemoveCell();
            LowerRight.RemoveCell();
            UpperLeft.RemoveCell();
            LowerLeft.RemoveCell();
        }
Exemplo n.º 6
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = List.GetHashCode();
         hashCode = (hashCode * 397) ^ UpperLeft.GetHashCode();
         hashCode = (hashCode * 397) ^ BottomRight.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 7
0
 private void SetColorTheme(ColorTheme theme, bool force)
 {
     if (force || this.currentTheme != theme)
     {
         this.currentTheme = theme;
         UpperLeft.SetColorTheme(theme);
         UpperRight.SetColorTheme(theme);
         LowerLeft.SetColorTheme(theme);
         LowerRight.SetColorTheme(theme);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Returns a rectangle enclosing the corner points of the current instance, rotated
 /// by the specified amount.
 /// </summary>
 public RectangleD Rotate(Angle angle)
 {
     if (angle.IsEmpty)
     {
         return(this);
     }
     // Rotate each corner point
     PointD[] Points = new PointD[] { UpperLeft.RotateAt(angle, Center),
                                      UpperRight.RotateAt(angle, Center),
                                      LowerRight.RotateAt(angle, Center),
                                      LowerLeft.RotateAt(angle, Center) };
     // Now return the smallest rectangle which encloses these points
     return(RectangleD.FromArray(Points));
 }
Exemplo n.º 9
0
        /// <summary>
        /// Returns a rectangle enclosing the corner points of the current instance, rotated
        /// by the specified amount around a specific point.
        /// </summary>
        /// <returns>A new <strong>RectangleD</strong> containing the rotated rectangle.</returns>
        /// <remarks><para>When a rectangle is rotated, the total width and height it occupies may be larger
        /// than the rectangle's own width and height.  This method calculates the smallest rectangle
        /// which encloses the rotated rectangle.</para>
        ///     <para>[TODO: Include before and after picture; this is confusing.]</para>
        /// </remarks>
        public RectangleD RotateAt(Angle _angle, PointD _center)
        {
            if (_angle.IsEmpty)
            {
                return(this);
            }
            // Rotate each corner point
            PointD[] points =
            {
                UpperLeft.RotateAt(_angle,  _center),
                UpperRight.RotateAt(_angle, _center),
                LowerRight.RotateAt(_angle, _center),
                LowerLeft.RotateAt(_angle,  _center)
            };

            // Now return the smallest rectangle which encloses these points
            return(FromArray(points));
        }
Exemplo n.º 10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ObstacleId.Length != 0)
            {
                hash ^= ObstacleId.GetHashCode();
            }
            if (bottomLeft_ != null)
            {
                hash ^= BottomLeft.GetHashCode();
            }
            if (upperLeft_ != null)
            {
                hash ^= UpperLeft.GetHashCode();
            }
            if (upperRight_ != null)
            {
                hash ^= UpperRight.GetHashCode();
            }
            if (bottomRight_ != null)
            {
                hash ^= BottomRight.GetHashCode();
            }
            if (TimeLower != 0D)
            {
                hash ^= TimeLower.GetHashCode();
            }
            if (TimeUpper != 0D)
            {
                hash ^= TimeUpper.GetHashCode();
            }
            if (PathLower != 0D)
            {
                hash ^= PathLower.GetHashCode();
            }
            if (PathUpper != 0D)
            {
                hash ^= PathUpper.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 11
0
 public RectangleD Divide(PointD position)
 {
     return(new RectangleD(UpperLeft.Divide(position), Size));
 }
Exemplo n.º 12
0
 public RectangleD Multiply(PointD position)
 {
     return(new RectangleD(UpperLeft.Multiply(position), Size));
 }
Exemplo n.º 13
0
 public RectangleD Subtract(PointD position)
 {
     return(new RectangleD(UpperLeft.Subtract(position), Size));
 }
Exemplo n.º 14
0
 public RectangleD Add(PointD position)
 {
     return(new RectangleD(UpperLeft.Add(position), Size));
 }
Exemplo n.º 15
0
 public RectangleD Translate(double offsetX, double offsetY)
 {
     return(new RectangleD(UpperLeft.Add(offsetX, offsetY), Size));
 }
Exemplo n.º 16
0
 public RectangleD Translate(PointD offset)
 {
     return(new RectangleD(UpperLeft.Add(offset), Size));
 }
Exemplo n.º 17
0
        private void ReSize(int x, int y)
        {
            //if (x==0 && y==0)
            //	return;


            this.SuspendLayout();

            int xx = Vertical.Left - x;
            int yy = Horizontal.Top - y;

            if (xx < 0)
            {
                xx = 0;
            }

            if (yy < 0)
            {
                yy = 0;
            }

            if (yy > this.Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth * 3)
            {
                yy = this.Height - Horizontal.Height - SystemInformation.VerticalScrollBarWidth * 3;
            }


            if (xx > this.Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth * 3)
            {
                xx = this.Width - Vertical.Width - SystemInformation.VerticalScrollBarWidth * 3;
            }

            if (xx != Vertical.Left)
            {
                Vertical.Left = xx;
            }

            if (yy != Horizontal.Top)
            {
                Horizontal.Top = yy;
            }


            int CenterY = (Horizontal.Top + Horizontal.Height / 2) - Center.Height / 2;
            int CenterX = (Vertical.Left + Vertical.Width / 2) - Center.Width / 2;

            Center.Location = new Point(CenterX, CenterY);
            this.ResumeLayout();
            this.Invalidate();

            try
            {
                if (UpperLeft != null)
                {
                    UpperLeft.Refresh();
                }
                if (UpperLeft != null)
                {
                    UpperLeft.Refresh();
                }
                if (UpperLeft != null)
                {
                    UpperLeft.Refresh();
                }
                if (UpperLeft != null)
                {
                    UpperLeft.Refresh();
                }
            }
            catch
            {
            }
            OnResizing();
            //DoResize();
            //this.Refresh ();
        }
Exemplo n.º 18
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // ignore new game requests if the ai is running
            if (aiThinking)
            {
                return;
            }

            HowTo.Visibility     = Visibility.Collapsed;
            HowToText.Visibility = Visibility.Collapsed;

            okToRotateQuadrant = false;
            okToClickDots      = false;

            UpperLeft.Reset();
            UpperRight.Reset();
            LowerLeft.Reset();
            LowerRight.Reset();

            masterBoard = new Board();

            if ((bool)playerBlackRadioButton.IsChecked)
            {
                playerColor = PieceColor.Black;

                if ((bool)aiEasyRadioButton.IsChecked)
                {
                    Debug.Assert(false, "Easy");
                    masterAI = new FixedDepthPlayer(PieceColor.White, 0);
                }
                else if ((bool)aiMediumRadioButton.IsChecked)
                {
                    Debug.Assert(false, "Med");
                    masterAI = new FixedDepthPlayer(PieceColor.White, 2);
                }
                else
                {
                    Debug.Assert(false, "Hard");
                    masterAI = new FixedTimePlayer(PieceColor.White, 5);
                }

                aiThinking = true;
                DoAiMove();
            }
            else
            {
                playerColor = PieceColor.White;
                if ((bool)aiEasyRadioButton.IsChecked)
                {
                    masterAI = new FixedDepthPlayer(PieceColor.Black, 0);
                }
                else if ((bool)aiMediumRadioButton.IsChecked)
                {
                    masterAI = new FixedDepthPlayer(PieceColor.Black, 2);
                }
                else
                {
                    masterAI = new FixedTimePlayer(PieceColor.Black, 5);
                }
                okToClickDots      = true;
                okToRotateQuadrant = false;
                BottomText.Text    = "Your move";
            }
        }
Exemplo n.º 19
0
 protected bool Equals(Range other)
 {
     return(List == other.List && UpperLeft.Equals(other.UpperLeft) && BottomRight.Equals(other.BottomRight));
 }
Exemplo n.º 20
0
        private void NewGameButton_Click(object sender, EventArgs e)
        {
            // ignore new game requests if the ai is running
            if (aiThinking)
            {
                return;
            }

            okToRotateQuadrant = false;
            okToClickDots      = false;

            UpperLeft.Reset();
            UpperRight.Reset();
            LowerLeft.Reset();
            LowerRight.Reset();

            PopupPanel.Visibility = System.Windows.Visibility.Collapsed;

            masterBoard = new Board();

            this.currentGameStyle = settings.GameStyleSetting;

            if (this.currentGameStyle == GameStyle.VsAi && settings.PlayerColorSetting == PieceColor.Black)
            {
                playerColor = PieceColor.Black;

                if (0 == settings.AiStrengthSetting)
                {
                    Debug.Assert(false, "Easy");
                    masterAI = new FixedDepthPlayer(PieceColor.White, 0);
                }
                else if (1 == settings.AiStrengthSetting)
                {
                    Debug.Assert(false, "Med");
                    masterAI = new FixedDepthPlayer(PieceColor.White, 2);
                }
                else
                {
                    Debug.Assert(false, "Hard");
                    masterAI = new FixedTimePlayer(PieceColor.White, 5);
                }

                aiThinking = true;
                DoAiMove();
            }
            else if (this.currentGameStyle == GameStyle.VsAi && settings.PlayerColorSetting == PieceColor.White)
            {
                playerColor = PieceColor.White;
                if (0 == settings.AiStrengthSetting)
                {
                    masterAI = new FixedDepthPlayer(PieceColor.Black, 0);
                }
                else if (1 == settings.AiStrengthSetting)
                {
                    masterAI = new FixedDepthPlayer(PieceColor.Black, 2);
                }
                else
                {
                    masterAI = new FixedTimePlayer(PieceColor.Black, 5);
                }
                okToClickDots      = true;
                okToRotateQuadrant = false;
                BottomText.Text    = "your move";
            }
            else if (this.currentGameStyle == GameStyle.VsHuman)
            {
                playerColor = PieceColor.White;

                okToClickDots      = true;
                okToRotateQuadrant = false;
                BottomText.Text    = "white's move";
            }
        }
Exemplo n.º 21
0
        private void AnimateMove(Move move)
        {
            if (move.xCoord <= 2 &&
                move.yCoord <= 2)
            {
                LowerLeft.ShowDotPlacement(move.xCoord % 3, move.yCoord % 3, move.pieceColor);
            }
            else if (move.xCoord <= 2 &&
                     move.yCoord > 2)
            {
                UpperLeft.ShowDotPlacement(move.xCoord % 3, move.yCoord % 3, move.pieceColor);
            }
            else if (move.xCoord > 2 &&
                     move.yCoord <= 2)
            {
                LowerRight.ShowDotPlacement(move.xCoord % 3, move.yCoord % 3, move.pieceColor);
            }
            else if (move.xCoord > 2 &&
                     move.yCoord > 2)
            {
                UpperRight.ShowDotPlacement(move.xCoord % 3, move.yCoord % 3, move.pieceColor);
            }

            // System.Threading.Thread.Sleep(1000);
            UpperLeft.ClearValue(Canvas.ZIndexProperty);
            UpperRight.ClearValue(Canvas.ZIndexProperty);
            LowerLeft.ClearValue(Canvas.ZIndexProperty);
            LowerRight.ClearValue(Canvas.ZIndexProperty);

            switch (move.rotation)
            {
            case Rotation.UpperLeftClockwise:
                UpperLeft.SetValue(Canvas.ZIndexProperty, 9);
                UpperLeft.ShowTwist(TwistDirection.Clockwise);
                break;

            case Rotation.UpperLeftAntiClockwise:
                UpperLeft.SetValue(Canvas.ZIndexProperty, 9);
                UpperLeft.ShowTwist(TwistDirection.AntiClockwise);
                break;

            case Rotation.UpperRightClockwise:
                UpperRight.SetValue(Canvas.ZIndexProperty, 9);
                UpperRight.ShowTwist(TwistDirection.Clockwise);
                break;

            case Rotation.UpperRightAntiClockwise:
                UpperRight.SetValue(Canvas.ZIndexProperty, 9);
                UpperRight.ShowTwist(TwistDirection.AntiClockwise);
                break;

            case Rotation.LowerLeftClockwise:
                LowerLeft.SetValue(Canvas.ZIndexProperty, 9);
                LowerLeft.ShowTwist(TwistDirection.Clockwise);
                break;

            case Rotation.LowerLeftAntiClockwise:
                LowerLeft.SetValue(Canvas.ZIndexProperty, 9);
                LowerLeft.ShowTwist(TwistDirection.AntiClockwise);
                break;

            case Rotation.LowerRightClockwise:
                LowerRight.SetValue(Canvas.ZIndexProperty, 9);
                LowerRight.ShowTwist(TwistDirection.Clockwise);
                break;

            case Rotation.LowerRightAntiClockwise:
                LowerRight.SetValue(Canvas.ZIndexProperty, 9);
                LowerRight.ShowTwist(TwistDirection.AntiClockwise);
                break;

            default:
                break;
            }
        }
Exemplo n.º 22
0
 public override int GetHashCode() =>
 UpperLeft.GetHashCode() + LowerRight.GetHashCode();
Exemplo n.º 23
0
        private void DoResize()
        {
            //			int OldWidth=Horizontal.Width ;
            //			int OldHeight=Vertical.Height;
            int NewHeight = this.Height;
            int NewWidth  = this.Width;

            if (NewHeight != 0 && NewWidth != 0)
            {
                this.SuspendLayout();
                //				Horizontal.Top = (int)(NewHeight*HorizontalPos);
                //				Vertical.Left =(int)(NewWidth*VerticalPos);
                //
                //				int CenterY=(Horizontal.Top+Horizontal.Height /2)-Center.Height/2;
                //				int CenterX=(Vertical.Left+Vertical.Width /2)-Center.Width /2;
                //
                //				Center.Location =new Point (CenterX,CenterY);


                //ReSize (0,0);
                ReSize2();
                OnResizing();

                if (Horizontal.Top < 15)
                {
                    Horizontal.Top = 0 - Horizontal.Height;
                    OnHideTop();
                }

                if (Vertical.Left < 15)
                {
                    Vertical.Left = 0 - Vertical.Width;
                    OnHideLeft();
                }


                Horizontal.Width = this.Width;
                Vertical.Height  = this.Height;
                Horizontal.SendToBack();
                Vertical.SendToBack();
                Horizontal.BackColor = SystemColors.Control;
                Vertical.BackColor   = SystemColors.Control;


                //this.SendToBack ();
                int RightLeft     = Vertical.Left + Vertical.Width;
                int RightLowerTop = Horizontal.Top + Horizontal.Height;
                int RightWidth    = this.Width - RightLeft;
                int LowerHeight   = this.Height - RightLowerTop;
                int UpperHeight   = Horizontal.Top;
                int LeftWidth     = Vertical.Left;

                if (LowerRight != null)
                {
                    LowerRight.BringToFront();
                    LowerRight.SetBounds(RightLeft, RightLowerTop, RightWidth, LowerHeight);
                }
                if (UpperRight != null)
                {
                    UpperRight.BringToFront();
                    UpperRight.SetBounds(RightLeft, 0, RightWidth, UpperHeight);
                }


                if (LowerLeft != null)
                {
                    LowerLeft.BringToFront();
                    LowerLeft.SetBounds(0, RightLowerTop, LeftWidth, LowerHeight);
                }
                if (UpperLeft != null)
                {
                    UpperLeft.BringToFront();
                    UpperLeft.SetBounds(0, 0, LeftWidth, UpperHeight);
                }
                this.ResumeLayout();                 //ggf
            }
        }
Exemplo n.º 24
0
 override public void AddToTable(ShipTable table)
 {
     table.shipCoords["MFD1"]["UpperLeft"]  = UpperLeft.ToTable();
     table.shipCoords["MFD1"]["Dimensions"] = Dimensions.ToTable();
 }