Equals() public method

public Equals ( Point value ) : bool
value Point
return bool
Ejemplo n.º 1
0
		public void Equals ()
		{
			Point p = new Point (4, 5);
			Assert.IsTrue (p.Equals (new Point (4, 5)));
			Assert.IsFalse (p.Equals (new Point (5, 4)));
			Assert.IsFalse (p.Equals (new object()));
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Process mouse up without activated tool.
        /// </summary>
        /// <param name="e">Mouse button event args.</param>
        private void _OnMouseUpWithoutTool(MouseButtonEventArgs e)
        {
            // Get the x and y coordinates of the mouse pointer.
            System.Windows.Point position   = e.GetPosition(_mapControl.map);
            MapPoint             pointOnMap = _mapControl.map.ScreenToMap(position);

            if (e.RightButton == MouseButtonState.Released && e.ChangedButton == MouseButton.Right)
            {
                _mapSelectionManager.FinishSelectByFrame(pointOnMap);
            }
            else
            {
                if (e.LeftButton == MouseButtonState.Released && e.ChangedButton == MouseButton.Left &&
                    position.Equals(ClickedCoords) && !_mapSelectionManager.SelectionWasMade &&
                    // do not clear selection in case of clicked item == edited item
                    _clickedGraphic == null)
                {
                    // Do not react on mouse click in case of geocoding in progress
                    if (_mapControl.IsGeocodingInProgressCallback != null && !_mapControl.IsGeocodingInProgressCallback())
                    {
                        _mapSelectionManager.SelectedItems.Clear();

                        if (position.Equals(ClickedCoords) && !_mapSelectionManager.SelectionWasMade && _mapControl.IsInEditedMode &&
                            e.LeftButton == MouseButtonState.Released && e.ChangedButton == MouseButton.Left)
                        {
                            _CallEndEditDelegate(false);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
		private void Compare (Point p)
		{
			Point p2 = p;
			Assert.IsFalse (p.Equals (null), "Equals(null)");
			Assert.IsTrue (p.Equals ((object) p), "Equals(object)");
			Assert.IsTrue (p.Equals (p), "Equals(Point)");
			Assert.IsTrue (p == p2, "==");
			Assert.IsFalse (p != p2, "!=");
		}
Ejemplo n.º 4
0
		public void NaN ()
		{
			Point p = new Point (Double.NaN, Double.NaN);
			Assert.IsTrue (Double.IsNaN (p.X), "X");
			Assert.IsTrue (Double.IsNaN (p.Y), "Y");
			Assert.AreEqual ("NaN,NaN", p.ToString (), "ToString");

			// special reserved case
			Point p2 = p;
			Assert.IsFalse (p.Equals ((object) p2), "Equals(object)");
			Assert.IsFalse (p.Equals (p2), "Equals(Point)");
			Assert.IsFalse (p == p2, "==");
			Assert.IsTrue (p != p2, "!=");
		}
Ejemplo n.º 5
0
        public bool checkHitCurve(String Data, gPath p)
        {
            bool tf = true;

            String[] tmpStr    = Data.Split(',');
            double[] tmpDouStr = new double[tmpStr.Length];
            for (int i = 0; i < tmpStr.Length; i++)
            {
                tmpDouStr[i] = Convert.ToDouble(tmpStr[i]);
            }
            System.Windows.Point tmpPoint0 = new System.Windows.Point(tmpDouStr[0], tmpDouStr[1]);
            System.Windows.Point tmpPoint1 = new System.Windows.Point(tmpDouStr[2], tmpDouStr[3]);
            System.Windows.Point tmpPoint2 = new System.Windows.Point(tmpDouStr[4], tmpDouStr[5]);
            System.Windows.Point tmpPoint3 = new System.Windows.Point(tmpDouStr[6], tmpDouStr[7]);

            if (!tmpPoint0.Equals(p.controlBtn1))
            {
                tf = false;
            }
            if (!tmpPoint1.Equals(p.controlBtn2))
            {
                tf = false;
            }
            if (!tmpPoint2.Equals(p.controlBtn3))
            {
                tf = false;
            }
            if (!tmpPoint3.Equals(p.controlBtn4))
            {
                tf = false;
            }
            return(tf);
        }
Ejemplo n.º 6
0
 private void UIElement_OnMouseWheelImage(object sender, MouseWheelEventArgs e)
 {
     if (sender is Image image)
     {
         if (image.Name == "SourceImage")
         {
             _startSource = e.GetPosition((IInputElement)e.Source);
             if (e.Delta > 0)
             {
                 if (_selectedPointSource.Equals(new Point()))
                 {
                     _selectedPointSource = _startSource;
                 }
                 _startSource      = _selectedPointSource;
                 _zoomValueImage1 += 0.2;
             }
             else
             {
                 if (_zoomValueImage1 <= 1)
                 {
                     _selectedPointSource = new Point();
                     _zoomValueImage1     = 1;
                     return;
                 }
                 _zoomValueImage1 -= 0.2;
             }
             ScaleTransform scale = new ScaleTransform(_zoomValueImage1, _zoomValueImage1, _startSource.X, _startSource.Y);
             image.RenderTransform = scale;
         }
         else if (image.Name == "ProcessedImage")
         {
             _startProcessed = e.GetPosition((IInputElement)e.Source);
             if (e.Delta > 0)
             {
                 if (_selectedPointProcessed.Equals(new Point()))
                 {
                     _selectedPointProcessed = _startProcessed;
                 }
                 _startProcessed   = _selectedPointProcessed;
                 _zoomValueImage2 += 0.2;
             }
             else
             {
                 if (_zoomValueImage2 <= 1)
                 {
                     _selectedPointProcessed = new Point();
                     _zoomValueImage2        = 1;
                     return;
                 }
                 _zoomValueImage2 -= 0.2;
             }
             ScaleTransform scale = new ScaleTransform(_zoomValueImage2, _zoomValueImage2, _startProcessed.X, _startProcessed.Y);
             image.RenderTransform = scale;
         }
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// React on mouse up event.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Mouse button event args.</param>
        private void _MapMouseUp(object sender, MouseButtonEventArgs e)
        {
            // Get the x and y coordinates of the mouse pointer.
            System.Windows.Point position   = e.GetPosition(_mapControl.map);
            MapPoint             pointOnMap = _mapControl.map.ScreenToMap(position);

            if (_tools.CurrentTool != null)
            {
                if (e.ChangedButton == MouseButton.Left)
                {
                    _tools.CurrentTool.OnMouseUp(MouseButton.Left,
                                                 Keyboard.Modifiers, pointOnMap.X, pointOnMap.Y);
                }

                if (position.Equals(ClickedCoords) && !_mapSelectionManager.SelectionWasMade && _mapControl.IsInEditedMode &&
                    _clickedGraphic == null &&
                    e.LeftButton == MouseButtonState.Released && e.ChangedButton == MouseButton.Left)
                {
                    // Do not react on mouse click in case of geocoding in progress.
                    if ((_mapControl.IsGeocodingInProgressCallback != null && !_mapControl.IsGeocodingInProgressCallback()) ||
                        (_mapControl.IsGeocodingInProgressCallback == null))
                    {
                        _CallEndEditDelegate(true);
                    }
                }
            }
            else
            {
                _OnMouseUpWithoutTool(e);
            }

            // Change cursor to open hand if need to change cursor from grabbed hand to open.
            if (_mapControl.map.Cursor == _grabbedHandCursor && e.LeftButton == MouseButtonState.Released && e.ChangedButton == MouseButton.Left)
            {
                Mouse.OverrideCursor = null;
                if (!(_mapControl.CurrentTool is EditingTool))
                {
                    // If tool is used - return tool cursor. Otherwise - open hand.
                    if (_mapControl.CurrentTool != null)
                    {
                        _mapControl.map.Cursor = _mapControl.CurrentTool.Cursor;
                    }
                    else
                    {
                        _mapControl.map.Cursor = _openHandCursor;
                    }
                }
                else
                {
                    _mapControl.map.Cursor = _openHandCursor;
                }
            }

            _clickedGraphic = null;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// React on mouse double click.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Mouse button event args.</param>
        private void _MapMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            System.Windows.Point position = e.GetPosition(_mapControl.map);

            bool isGraphicEdited = !(_clickedGraphic is EditMarkerGraphicObject) &&
                                   !(_clickedGraphic is CandidateGraphicObject);

            // Workaround:
            // due notundersandable map messages(1 graphic mouse up on 3 graphic mouse down) in case of
            // mouse down on graphic, pan, mouse up, doubleclick,
            // need to check selection. if selected element differ from doubleclicked - deny editing
            DataGraphicObject dataGraphic = _clickedGraphic as DataGraphicObject;
            bool isSelected = true;

            if (dataGraphic != null && !_mapSelectionManager.SelectedItems.Contains(dataGraphic.Data))
            {
                isSelected = false;
            }

            if (_clickedGraphic != null && isGraphicEdited && !_mapControl.IsInEditedMode &&
                position.Equals(ClickedCoords) && isSelected)
            {
                if (dataGraphic != null && dataGraphic.Data != _mapControl.EditedObject)
                {
                    if (dataGraphic.Data is IGeocodable)
                    {
                        _mapSelectionManager.SelectionChangedFromMap = true;
                        _mapControl.StartEditGeocodableCallback(dataGraphic.Data);
                        _mapSelectionManager.SelectionChangedFromMap = false;
                    }
                    else if (dataGraphic.Data is Zone || dataGraphic.Data is Barrier)
                    {
                        _mapSelectionManager.SelectionChangedFromMap = true;
                        _mapControl.StartEditRegionCallback(dataGraphic.Data);
                        _mapSelectionManager.SelectionChangedFromMap = false;
                    }

                    _mapSelectionManager.SelectionWasMade = true;
                    e.Handled = true;
                }
            }
        }
Ejemplo n.º 9
0
        // This method performs the Point operations
        public void PerformOperation(object sender, RoutedEventArgs e)
        {
            var li = sender as RadioButton;

            // Strings used to display the results
            string syntaxString, resultType, operationString;

            // The local variables point1, point2, vector2, etc are defined in each
            // case block for readability reasons. Each variable is contained within
            // the scope of each case statement.
            switch (li?.Name)
            {
            //begin switch

            case "rb1":
            {
                // Translates a Point by a Vector using the overloaded + operator.
                // Returns a Point.
                var point1  = new System.Windows.Point(10, 5);
                var vector1 = new Vector(20, 30);

                var pointResult = point1 + vector1;
                // pointResult is equal to (30, 35)

                // Note: Adding a Point to a Point is not a legal operation

                // Displaying Results
                syntaxString    = "pointResult = point1 + vector1;";
                resultType      = "Point";
                operationString = "Adding a Point and Vector";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb2":
            {
                // Translates a Point by a Vector using the static Add method.
                // Returns a Point.
                var point1  = new System.Windows.Point(10, 5);
                var vector1 = new Vector(20, 30);

                var pointResult = System.Windows.Point.Add(point1, vector1);
                // pointResult is equal to (30, 35)

                // Displaying Results
                syntaxString    = "pointResult = Point.Add(point1, vector1);";
                resultType      = "Point";
                operationString = "Adding a Point and Vector";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb3":
            {
                // Subtracts a Vector from a Point using the overloaded - operator.
                // Returns a Point.
                var point1  = new System.Windows.Point(10, 5);
                var vector1 = new Vector(20, 30);

                var pointResult = point1 - vector1;
                // pointResult is equal to (-10, -25)

                // Displaying Results
                syntaxString    = "pointResult = point1 - vector1;";
                resultType      = "Point";
                operationString = "Subtracting a Vector from a Point";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb4":
            {
                // Subtracts a Vector from a Point using the static Subtract method.
                // Returns a Point.
                var point1  = new System.Windows.Point(10, 5);
                var vector1 = new Vector(20, 30);

                var pointResult = System.Windows.Point.Subtract(point1, vector1);
                // pointResult is equal to (-10, -25)

                // Displaying Results
                syntaxString    = "pointResult = Point.Subtract(point1, vector1);";
                resultType      = "Point";
                operationString = "Subtracting a Vector from a Point";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb5":
            {
                // Subtracts a Point from a Point using the overloaded - operator.
                // Returns a Vector.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var vectorResult = point1 - point2;
                // vectorResult is equal to (-5, -35)

                // Displaying Results
                syntaxString    = "vectorResult = point1 - point2;";
                resultType      = "Vector";
                operationString = "Subtracting a Point from a Point";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb6":
            {
                // Subtracts a Point from a Point using the static Subtract method.
                // Returns a Vector.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var vectorResult = System.Windows.Point.Subtract(point1, point2);
                // vectorResult is equal to (-5, -35)

                // Displaying Results
                syntaxString    = "vectorResult = Point.Subtract(point1, point2);";
                resultType      = "Vector";
                operationString = "Subtracting a Point from a Point";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb7":
            {
                // Offsets the X and Y values of a Point.
                var point1 = new System.Windows.Point(10, 5);

                point1.Offset(20, 30);
                // point1 is equal to (30, 35)

                // Note: This operation is equivalent to adding a point
                // to vector with the corresponding X,Y values.

                // Displaying Results
                syntaxString    = "point1.Offset(20,30);";
                resultType      = "Point";
                operationString = "Offsetting a Point";
                ShowResults(point1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb8":
            {
                // Multiplies a Point by a Matrix.
                // Returns a Point.
                var point1  = new System.Windows.Point(10, 5);
                var matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                var pointResult = point1 * matrix1;
                // pointResult is equal to (780, 940)

                // Displaying Results
                resultType      = "Point";
                syntaxString    = "pointResult = point1 * matrix1;";
                operationString = "Multiplying a Point by a Matrix";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb9":
            {
                // Multiplies a Point by a Matrix.
                // Returns a Point.
                var point1  = new System.Windows.Point(10, 5);
                var matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                var pointResult = System.Windows.Point.Multiply(point1, matrix1);
                // pointResult is equal to (780, 940)

                // Displaying Results
                resultType      = "Point";
                syntaxString    = "pointResult = Point.Multiply(point1, matrix1);";
                operationString = "Multiplying a Point by a Matrix";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb10":
            {
                // Checks if two Points are equal using the overloaded equality operator.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var areEqual = (point1 == point2);
                // areEqual is False

                // Displaying Results
                syntaxString    = "areEqual = (point1 == point2);";
                resultType      = "Boolean";
                operationString = "Checking if two points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }


            case "rb11":
            {
                // Checks if two Points are equal using the static Equals method.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var areEqual = System.Windows.Point.Equals(point1, point2);
                // areEqual is False

                // Displaying Results
                syntaxString    = "areEqual = Point.Equals(point1, point2);";
                resultType      = "Boolean";
                operationString = "Checking if two points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb12":
            {
                // Compares an Object and a Point for equality using the non-static Equals method.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var areEqual = point1.Equals(point2);
                // areEqual is False


                // Displaying Results
                syntaxString    = "areEqual = point1.Equals(point2);";
                resultType      = "Boolean";
                operationString = "Checking if two points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb13":
            {
                // Compares an Object and a Vector for equality using the non-static Equals method.
                var vector1 = new Vector(20, 30);
                var vector2 = new Vector(45, 70);

                var areEqual = vector1.Equals(vector2);
                // areEqual is False


                // Displaying Results
                syntaxString    = "areEqual = vector1.Equals(vector2);";
                resultType      = "Boolean";
                operationString = "Checking if two vectors are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb14":
            {
                // Converts a string representation of a point into a Point structure

                var pointResult = System.Windows.Point.Parse("1,3");
                // pointResult is equal to (1, 3)

                // Displaying Results
                syntaxString    = "pointResult = Point.Parse(\"1,3\");";
                resultType      = "Matrix";
                operationString = "Converts a string into a Point structure.";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb15":
            {
                // Gets a string representation of a Point structure
                var point1 = new System.Windows.Point(10, 5);

                var pointString = point1.ToString();
                // pointString is equal to 10,5

                // Displaying Results
                syntaxString    = "pointString = point1.ToString();";
                resultType      = "String";
                operationString = "Getting the string representation of a Point";
                ShowResults(pointString, syntaxString, resultType, operationString);
                break;
            }

            case "rb16":
            {
                // Gets the hashcode of a Point structure

                var point1 = new System.Windows.Point(10, 5);

                var pointHashCode = point1.GetHashCode();

                // Displaying Results
                syntaxString    = "pointHashCode = point1.GetHashCode();";
                resultType      = "int";
                operationString = "Getting the hashcode of Point";
                ShowResults(pointHashCode.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb17":
            {
                // Explicitly converts a Point structure into a Size structure
                // Returns a Size.

                var point1 = new System.Windows.Point(10, 5);

                var size1 = (Size)point1;
                // size1 has a width of 10 and a height of 5

                // Displaying Results
                syntaxString    = "size1 = (Size)point1;";
                resultType      = "Size";
                operationString = "Expliciting casting a Point into a Size";
                ShowResults(size1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb18":
            {
                // Explicitly converts a Point structure into a Vector structure
                // Returns a Vector.

                var point1 = new System.Windows.Point(10, 5);

                var vector1 = (Vector)point1;
                // vector1 is equal to (10,5)

                // Displaying Results
                syntaxString    = "vector1 = (Vector)point1;";
                resultType      = "Vector";
                operationString = "Expliciting casting a Point into a Vector";
                ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            // task example.  Not accessed through radio buttons
            case "rb20":
            {
                // Checks if two Points are not equal using the overloaded inequality operator.

                // Declaring point1 and initializing x,y values
                var point1 = new System.Windows.Point(10, 5);

                // Declaring point2 without initializing x,y values
                var point2 = new System.Windows.Point
                {
                    X = 15,
                    Y = 40
                };

                // Boolean to hold the result of the comparison

                // assigning values to point2

                // checking for inequality
                var areNotEqual = (point1 != point2);

                // areNotEqual is True

                // Displaying Results
                syntaxString    = "areNotEqual = (point1 != point2);";
                resultType      = "Boolean";
                operationString = "Checking if two points are not equal";
                ShowResults(areNotEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }
            } //end switch
        }
Ejemplo n.º 10
0
 /// <summary>Compares two <see cref="T:System.Windows.Point" /> structures for equality.</summary>
 /// <returns>true if both <see cref="T:System.Windows.Point" /> structures contain the same <see cref="P:System.Windows.Point.X" /> and <see cref="P:System.Windows.Point.Y" /> values; otherwise, false.</returns>
 /// <param name="value">The point to compare to this instance.</param>
 public bool Equals(Point value)
 {
     return(Point.Equals(this, value));
 }
Ejemplo n.º 11
0
		public static bool Equals (Point point1, Point point2)
		{
			return point1.Equals (point2);
		}
Ejemplo n.º 12
0
        public static Mesh ChunksToMesh(ILogger log, List<Chunk> chunks, int texturePixelWidth, int texturePixelHeight)
        {
            Mesh mesh = new Mesh();
            int numVertices = 0;
            foreach (Chunk chunk in chunks) {
                numVertices += chunk.vertices.Count;
            }
            mesh.TriangleIndices = new Int32Collection();
            mesh.Positions = new Point3DCollection(numVertices);
            mesh.Normals = new Vector3DCollection(numVertices);
            mesh.vertexWeights = new List<VertexWeight>();
            var uvCoords = new Point[numVertices];
            Point uninitPoint = new Point(-10000, -10000);
            for (int uv = 0; uv < uvCoords.Length; ++uv)
            {
                uvCoords[uv] = uninitPoint;
            }
            int vstart = 0;
            foreach (var chunk in chunks) {
                if ((chunk.gifTag0.prim & 0x07) != 4) {
                    Debug.Fail("Can only deal with tri strips");
                }

                foreach (var vertex in chunk.vertices) {
                    var point = new Point3D(vertex.x / 16.0, vertex.y / 16.0, vertex.z / 16.0);
                    mesh.Positions.Add(point);
                }
                foreach (var normal in chunk.normals) {
                    mesh.Normals.Add(new Vector3D(normal.x / 127.0, normal.y / 127.0, normal.z / 127.0));
                }
                foreach (VertexWeight vw in chunk.vertexWeights) {
                    VertexWeight vwAdjusted = vw;
                    vwAdjusted.startVertex += vstart;
                    if (vwAdjusted.endVertex >= chunk.vertices.Count) {
                        vwAdjusted.endVertex = chunk.vertices.Count - 1;
                    }
                    vwAdjusted.endVertex += vstart;
                    if (vw.startVertex <= (chunk.vertices.Count-1)) {
                        mesh.vertexWeights.Add(vwAdjusted);
                    }
                }
                int[] vstrip = new int[chunk.gifTag0.nloop];
                int regsPerVertex = chunk.gifTag0.nreg;
                int numVlocs = chunk.vlocs.Count;
                int numVertsInChunk = chunk.vertices.Count;
                for (int vlocIndx = 2; vlocIndx < numVlocs; ++vlocIndx) {
                    int v = vlocIndx - 2;
                    int stripIdx2 = (chunk.vlocs[vlocIndx].v2 & 0x1FF) / regsPerVertex;
                    int stripIdx3 = (chunk.vlocs[vlocIndx].v3 & 0x1FF) / regsPerVertex;
                    if (stripIdx3 < vstrip.Length && stripIdx2 < vstrip.Length) {
                        vstrip[stripIdx3] = vstrip[stripIdx2] & 0x1FF;

                        bool skip2 = (chunk.vlocs[vlocIndx].v3 & 0x8000) == 0x8000;
                        if (skip2) {
                            vstrip[stripIdx3] |= 0x8000;
                        }
                    }
                    int stripIdx = (chunk.vlocs[vlocIndx].v1 & 0x1FF) / regsPerVertex;
                    bool skip = (chunk.vlocs[vlocIndx].v1 & 0x8000) == 0x8000;

                    if (v < numVertsInChunk && stripIdx < vstrip.Length) {
                        vstrip[stripIdx] = skip ? (v | 0x8000) : v;
                    }
                }
                int numExtraVlocs = chunk.extraVlocs[0];
                for (int extraVloc = 0; extraVloc < numExtraVlocs; ++extraVloc) {
                    int idx = extraVloc * 4 + 4;
                    int stripIndxSrc = (chunk.extraVlocs[idx] & 0x1FF) / regsPerVertex;
                    int stripIndxDest = (chunk.extraVlocs[idx + 1] & 0x1FF) / regsPerVertex; ;
                    vstrip[stripIndxDest] = (chunk.extraVlocs[idx + 1] & 0x8000) | (vstrip[stripIndxSrc] & 0x1FF);

                    stripIndxSrc = (chunk.extraVlocs[idx + 2] & 0x1FF) / regsPerVertex;
                    stripIndxDest = (chunk.extraVlocs[idx + 3] & 0x1FF) / regsPerVertex; ;
                    vstrip[stripIndxDest] = (chunk.extraVlocs[idx + 3] & 0x8000) | (vstrip[stripIndxSrc] & 0x1FF);
                }
                int triIdx = 0;
                for (int i = 2; i < vstrip.Length; ++i) {
                    int vidx1 = vstart + (vstrip[i - 2] & 0xFF);
                    int vidx2 = vstart + (vstrip[i - 1] & 0xFF);
                    int vidx3 = vstart + (vstrip[i] & 0xFF);

                    int uv1 = i - 2;
                    int uv2 = i - 1;
                    int uv3 = i;

                    // Flip the faces (indices 1 and 2) to keep the winding rule consistent.
                    if ((triIdx & 1) == 1) {
                        int temp = uv1;
                        uv1 = uv2;
                        uv2 = temp;

                        temp = vidx1;
                        vidx1 = vidx2;
                        vidx2 = temp;
                    }

                    if ((vstrip[i] & 0x8000) == 0) {
                        // WPF really has S,T coords rather than u,v
                        double udiv = texturePixelWidth * 16.0;
                        double vdiv = texturePixelHeight * 16.0;

                        var p1 = new Point(chunk.uvs[uv1].u / udiv, chunk.uvs[uv1].v / vdiv);
                        var p2 = new Point(chunk.uvs[uv2].u / udiv, chunk.uvs[uv2].v / vdiv);
                        var p3 = new Point(chunk.uvs[uv3].u / udiv, chunk.uvs[uv3].v / vdiv);

                        p1 = TileST(p1);
                        p2 = TileST(p2);
                        p3 = TileST(p3);

                        if (!uninitPoint.Equals(uvCoords[vidx1]) && !p1.Equals(uvCoords[vidx1]))
                        {
                            // There is more than 1 uv assigment to this vertex, so we need to duplicate it.
                            int originalVIdx = vidx1;
                            vidx1 = vstart + numVertsInChunk;
                            numVertsInChunk++;
                            mesh.Positions.Add(mesh.Positions.ElementAt(originalVIdx));
                            mesh.Normals.Add(mesh.Normals.ElementAt(originalVIdx));
                            Array.Resize(ref uvCoords, uvCoords.Length+1);
                            uvCoords[uvCoords.Length - 1] = uninitPoint;
                            var weight = FindVertexWeight(chunk.vertexWeights, originalVIdx - vstart);
                            if (weight.boneWeight1 > 0)
                            {
                                var vw = weight;
                                vw.startVertex = vidx1;
                                vw.endVertex = vidx1;
                                mesh.vertexWeights.Add(vw);
                            }
                        }
                        if (!uninitPoint.Equals(uvCoords[vidx2]) && !p2.Equals(uvCoords[vidx2]))
                        {
                            // There is more than 1 uv assigment to this vertex, so we need to duplicate it.
                            int originalVIdx = vidx2;
                            vidx2 = vstart + numVertsInChunk;
                            numVertsInChunk++;
                            mesh.Positions.Add(mesh.Positions.ElementAt(originalVIdx));
                            mesh.Normals.Add(mesh.Normals.ElementAt(originalVIdx));
                            Array.Resize(ref uvCoords, uvCoords.Length + 1);
                            uvCoords[uvCoords.Length - 1] = uninitPoint;
                            var weight = FindVertexWeight(chunk.vertexWeights, originalVIdx - vstart);
                            if (weight.boneWeight1 > 0)
                            {
                                var vw = weight;
                                vw.startVertex = vidx2;
                                vw.endVertex = vidx2;
                                mesh.vertexWeights.Add(vw);
                            }
                        }
                        if (!uninitPoint.Equals(uvCoords[vidx3]) && !p3.Equals(uvCoords[vidx3]))
                        {
                            // There is more than 1 uv assigment to this vertex, so we need to duplicate it.
                            int originalVIdx = vidx3;
                            vidx3 = vstart + numVertsInChunk;
                            numVertsInChunk++;
                            mesh.Positions.Add(mesh.Positions.ElementAt(originalVIdx));
                            mesh.Normals.Add(mesh.Normals.ElementAt(originalVIdx));
                            Array.Resize(ref uvCoords, uvCoords.Length + 1);
                            uvCoords[uvCoords.Length - 1] = uninitPoint;
                            var weight = FindVertexWeight(chunk.vertexWeights, originalVIdx - vstart);
                            if (weight.boneWeight1 > 0)
                            {
                                var vw = weight;
                                vw.startVertex = vidx3;
                                vw.endVertex = vidx3;
                                mesh.vertexWeights.Add(vw);
                            }
                        }

                        uvCoords[vidx1] = p1;
                        uvCoords[vidx2] = p2;
                        uvCoords[vidx3] = p3;

                        // Double sided hack. Should fix this with normals really
                        mesh.TriangleIndices.Add(vidx1);
                        mesh.TriangleIndices.Add(vidx2);
                        mesh.TriangleIndices.Add(vidx3);

                        mesh.TriangleIndices.Add(vidx2);
                        mesh.TriangleIndices.Add(vidx1);
                        mesh.TriangleIndices.Add(vidx3);
                    }
                    ++triIdx;
                }
                vstart += numVertsInChunk;
            }
            mesh.TextureCoordinates = new PointCollection(uvCoords);
            return mesh;
        }
Ejemplo n.º 13
0
        private static void AnimateLabel4Spline(List<DataPoint> pointCollection, Storyboard storyBoard)
        {
             // Animate Marker
            foreach (DataPoint dataPoint in pointCollection)
            {
                if ((Boolean)dataPoint.LabelEnabled)
                {
                    FrameworkElement labelVisual = dataPoint.LabelVisual;

                    if (labelVisual != null)
                    {
                        (((labelVisual as Border).Child as Canvas).Children[0] as TextBlock).Text = dataPoint.TextParser(dataPoint.LabelText);
                       
                        Point oldLabelPosition = new Point((Double)labelVisual.GetValue(Canvas.LeftProperty), (Double)labelVisual.GetValue(Canvas.TopProperty));

                        Double newMarkerXPos = 0, newMarkerYPos = 0;
                        Point newLabelPosition = SetLabelPosition4LineDataPoint(dataPoint, ref newMarkerXPos, ref newMarkerYPos);

                        //// Set the labels to its old position
                        //labelVisual.SetValue(Canvas.LeftProperty, oldLabelPosition.X);
                        //labelVisual.SetValue(Canvas.TopProperty, oldLabelPosition.Y);

                        labelVisual.Visibility = Visibility.Visible;

                        if (!oldLabelPosition.Equals(newLabelPosition))
                        {   
                            // Animation for (Canvas.Top) property
                            DoubleAnimation da = new DoubleAnimation()
                            {
                                From = oldLabelPosition.X,
                                To = newLabelPosition.X,
                                Duration = new Duration(new TimeSpan(0, 0, 1)),
                                SpeedRatio = 2
                            };

                            Storyboard.SetTarget(da, labelVisual);
                            Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Left)"));
                            Storyboard.SetTargetName(da, (String)labelVisual.GetValue(FrameworkElement.NameProperty));

                            storyBoard.Children.Add(da);

                            // Animation for (Canvas.Top) property
                            da = new DoubleAnimation()
                            {
                                From = oldLabelPosition.Y,
                                To = newLabelPosition.Y,
                                Duration = new Duration(new TimeSpan(0, 0, 1)),
                                SpeedRatio = 2
                            };

                            Storyboard.SetTarget(da, labelVisual);
                            Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Top)"));
                            Storyboard.SetTargetName(da, (String)labelVisual.GetValue(FrameworkElement.NameProperty));

                            storyBoard.Children.Add(da);
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private static void AnimateMarkers4Spline(List<DataPoint> pointCollection, Storyboard storyBoard)
        {   
            // Animate Marker
            foreach (DataPoint dataPoint in pointCollection)
            {
                dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);

                if ((Boolean)dataPoint.MarkerEnabled)
                {
                    #region Attach Animation with Marker

                    FrameworkElement marker = dataPoint.Marker.Visual;

                    if (marker != null)
                    {
                        Point newMarkerPosition = dataPoint.Marker.CalculateActualPosition(dataPoint._visualPosition.X, dataPoint._visualPosition.Y, new Point(0.5, 0.5));
                        Point oldMarkerPosition = new Point((Double)marker.GetValue(Canvas.LeftProperty), (Double)marker.GetValue(Canvas.TopProperty));

                        dataPoint.Marker.Visual.Visibility = Visibility.Visible;

                        if (!oldMarkerPosition.Equals(newMarkerPosition))
                        {
                            // Animation for (Canvas.Top) property
                            DoubleAnimation da = new DoubleAnimation()
                            {
                                From = oldMarkerPosition.X,
                                To = newMarkerPosition.X,
                                Duration = new Duration(new TimeSpan(0, 0, 1)),
                                SpeedRatio = 2
                            };

                            Storyboard.SetTarget(da, marker);
                            Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Left)"));
                            Storyboard.SetTargetName(da, (String)marker.GetValue(FrameworkElement.NameProperty));

                            storyBoard.Children.Add(da);

                            // Animation for (Canvas.Top) property
                            da = new DoubleAnimation()
                            {
                                From = oldMarkerPosition.Y,
                                To = newMarkerPosition.Y,
                                Duration = new Duration(new TimeSpan(0, 0, 1)),
                                SpeedRatio = 2
                            };

                            Storyboard.SetTarget(da, marker);
                            Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Top)"));
                            Storyboard.SetTargetName(da, (String)marker.GetValue(FrameworkElement.NameProperty));

                            storyBoard.Children.Add(da);
                        }
                    }

                    #endregion

                }

            }
        }
Ejemplo n.º 15
0
 public static bool Equals(Point point1, Point point2)
 {
     return(point1.Equals(point2));
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Finds the extension point.
        /// </summary>
        public void FindExtensionPoint()
        {
            if (controlledCases.Count >= 25)
            {
                ExtensionPoint = null;
                return;
            }

            // Etendre à la case ayant le plus de minerai (i.e une case de desert)
            Point HG = new Point (position.X, position.Y);
            Point BD = new Point (position.X, position.Y);

            int portee = 0;
            // premier carré (3x3)
            if (controlledCases.Count < 9)
            {
                portee = 1;
            }
            // deuxième carré (4x4)
            else if (controlledCases.Count < 16)
            {
                portee = 2;
            }
            // troisième carré (5x5)
            else if (controlledCases.Count < 25)
            {
                portee = 3;
            }

            if (position.X - portee > 0)
                HG.X -= portee;
            if (position.Y - portee > 0)
                HG.Y -= portee;
            if (position.X + portee < map.Size.X)
                BD.X += portee;
            if (position.Y + portee < map.Size.Y)
                BD.Y += portee;

            // Trouver le point idéal
            List<Point> listCases = new List<Point>();

            for (int i = (int)HG.X; i <= BD.X; i++)
            {
                for (int j = (int)HG.Y; j <= BD.Y; j++)
                {
                    listCases.Add(new Point(i, j));
                }
            }

            Point toBeAdded = new Point();
            if (listCases.Exists(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.FruitSquareDecorator && !controlledCases.Contains(point)))
            {
                toBeAdded = listCases.Find(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.FruitSquareDecorator && !controlledCases.Contains(point));
            }
            else if (listCases.Exists(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.IronSquareDecorator && !controlledCases.Contains(point)))
            {
                toBeAdded = listCases.Find(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.IronSquareDecorator && !controlledCases.Contains(point));
            }
            else if (listCases.Exists(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.Field && !controlledCases.Contains(point)))
            {
                toBeAdded = listCases.Find(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.Field && !controlledCases.Contains(point));
            }
            else if (listCases.Exists(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.Desert && !controlledCases.Contains(point)))
            {
                toBeAdded = listCases.Find(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.Desert && !controlledCases.Contains(point));
            }
            else if (listCases.Exists(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.Mountain && !controlledCases.Contains(point)))
            {
                toBeAdded = listCases.Find(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.Mountain && !controlledCases.Contains(point));
            }
            else if (listCases.Exists(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.Water && !controlledCases.Contains(point)))
            {
                toBeAdded = listCases.Find(point => map.SquareMatrix[(int)point.X, (int)point.Y] is World.Square.Water && !controlledCases.Contains(point));
            }

            if (toBeAdded.Equals(new Point(0, 0)))
            {
                ExtensionPoint = null;
            }
            else
            {
                ExtensionPoint = toBeAdded;
                player.CitiesToBeExtended.Enqueue(this);
            }
        }
Ejemplo n.º 17
0
        // This method performs the Point operations
        public void PerformOperation(object sender, RoutedEventArgs e)
        {
            RadioButton li = sender as RadioButton;

            // Strings used to display the results
            String syntaxString, resultType, operationString;

            // The local variables point1, point2, vector2, etc are defined in each
            // case block for readability reasons. Each variable is contained within
            // the scope of each case statement.
            switch (li.Name)
            {   //begin switch

                case "rb1":
                    {
                        // Translates a Point by a Vector using the overloaded + operator.
                        // Returns a Point.
                        Point point1 = new Point(10, 5);
                        Vector vector1 = new Vector(20, 30);
                        Point pointResult = new Point();

                        pointResult = point1 + vector1;
                        // pointResult is equal to (30, 35)

                        // Note: Adding a Point to a Point is not a legal operation

                        // Displaying Results
                        syntaxString = "pointResult = point1 + vector1;";
                        resultType = "Point";
                        operationString = "Adding a Point and Vector";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb2":
                    {
                        // Translates a Point by a Vector using the static Add method.
                        // Returns a Point.
                        Point point1 = new Point(10, 5);
                        Vector vector1 = new Vector(20, 30);
                        Point pointResult = new Point();

                        pointResult = Point.Add(point1, vector1);
                        // pointResult is equal to (30, 35)

                        // Displaying Results
                        syntaxString = "pointResult = Point.Add(point1, vector1);";
                        resultType = "Point";
                        operationString = "Adding a Point and Vector";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb3":
                    {
                        // Subtracts a Vector from a Point using the overloaded - operator.
                        // Returns a Point.
                        Point point1 = new Point(10, 5);
                        Vector vector1 = new Vector(20, 30);
                        Point pointResult = new Point();

                        pointResult = point1 - vector1;
                        // pointResult is equal to (-10, -25)

                        // Displaying Results
                        syntaxString = "pointResult = point1 - vector1;";
                        resultType = "Point";
                        operationString = "Subtracting a Vector from a Point";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb4":
                    {
                        // Subtracts a Vector from a Point using the static Subtract method.
                        // Returns a Point.
                        Point point1 = new Point(10, 5);
                        Vector vector1 = new Vector(20, 30);
                        Point pointResult = new Point();

                        pointResult = Point.Subtract(point1, vector1);
                        // pointResult is equal to (-10, -25)

                        // Displaying Results
                        syntaxString = "pointResult = Point.Subtract(point1, vector1);";
                        resultType = "Point";
                        operationString = "Subtracting a Vector from a Point";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb5":
                    {
                        // Subtracts a Point from a Point using the overloaded - operator.
                        // Returns a Vector.
                        Point point1 = new Point(10, 5);
                        Point point2 = new Point(15, 40);
                        Vector vectorResult = new Vector();

                        vectorResult = point1 - point2;
                        // vectorResult is equal to (-5, -35)

                        // Displaying Results
                        syntaxString = "vectorResult = point1 - point2;";
                        resultType = "Vector";
                        operationString = "Subtracting a Point from a Point";
                        ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb6":
                    {
                        // Subtracts a Point from a Point using the static Subtract method.
                        // Returns a Vector.
                        Point point1 = new Point(10, 5);
                        Point point2 = new Point(15, 40);
                        Vector vectorResult = new Vector();

                        vectorResult = Point.Subtract(point1, point2);
                        // vectorResult is equal to (-5, -35)

                        // Displaying Results
                        syntaxString = "vectorResult = Point.Subtract(point1, point2);";
                        resultType = "Vector";
                        operationString = "Subtracting a Point from a Point";
                        ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb7":
                    {
                        // Offsets the X and Y values of a Point.
                        Point point1 = new Point(10, 5);

                        point1.Offset(20, 30);
                        // point1 is equal to (30, 35)

                        // Note: This operation is equivalent to adding a point
                        // to vector with the corresponding X,Y values.

                        // Displaying Results
                        syntaxString = "point1.Offset(20,30);";
                        resultType = "Point";
                        operationString = "Offsetting a Point";
                        ShowResults(point1.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb8":
                    {
                        // Multiplies a Point by a Matrix.
                        // Returns a Point.
                        Point point1 = new Point(10, 5);
                        Point pointResult = new Point();
                        Matrix matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                        pointResult = point1 * matrix1;
                        // pointResult is equal to (780, 940)

                        // Displaying Results
                        resultType = "Point";
                        syntaxString = "pointResult = point1 * matrix1;";
                        operationString = "Multiplying a Point by a Matrix";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb9":
                    {
                        // Multiplies a Point by a Matrix.
                        // Returns a Point.
                        Point point1 = new Point(10, 5);
                        Point pointResult = new Point();
                        Matrix matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                        pointResult = Point.Multiply(point1, matrix1);
                        // pointResult is equal to (780, 940)

                        // Displaying Results
                        resultType = "Point";
                        syntaxString = "pointResult = Point.Multiply(point1, matrix1);";
                        operationString = "Multiplying a Point by a Matrix";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb10":
                    {
                        // Checks if two Points are equal using the overloaded equality operator.
                        Point point1 = new Point(10, 5);
                        Point point2 = new Point(15, 40);
                        Boolean areEqual;

                        areEqual = (point1 == point2);
                        // areEqual is False

                        // Displaying Results
                        syntaxString = "areEqual = (point1 == point2);";
                        resultType = "Boolean";
                        operationString = "Checking if two points are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb11":
                    {
                        // Checks if two Points are equal using the static Equals method.
                        Point point1 = new Point(10, 5);
                        Point point2 = new Point(15, 40);
                        Boolean areEqual;

                        areEqual = Point.Equals(point1, point2);
                        // areEqual is False

                        // Displaying Results
                        syntaxString = "areEqual = Point.Equals(point1, point2);";
                        resultType = "Boolean";
                        operationString = "Checking if two points are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb12":
                    {
                        // Compares an Object and a Point for equality using the non-static Equals method.
                        Point point1 = new Point(10, 5);
                        Point point2 = new Point(15, 40);
                        Boolean areEqual;

                        areEqual = point1.Equals(point2);
                        // areEqual is False

                        // Displaying Results
                        syntaxString = "areEqual = point1.Equals(point2);";
                        resultType = "Boolean";
                        operationString = "Checking if two points are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb13":
                    {
                        // Compares an Object and a Vector for equality using the non-static Equals method.
                        Vector vector1 = new Vector(20, 30);
                        Vector vector2 = new Vector(45, 70);
                        Boolean areEqual;

                        areEqual = vector1.Equals(vector2);
                        // areEqual is False

                        // Displaying Results
                        syntaxString = "areEqual = vector1.Equals(vector2);";
                        resultType = "Boolean";
                        operationString = "Checking if two vectors are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb14":
                    {
                        // Converts a string representation of a point into a Point structure
                        Point pointResult = new Point();

                        pointResult = Point.Parse("1,3");
                        // pointResult is equal to (1, 3)

                        // Displaying Results
                        syntaxString = "pointResult = Point.Parse(\"1,3\");";
                        resultType = "Matrix";
                        operationString = "Converts a string into a Point structure.";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb15":
                    {
                        // Gets a string representation of a Point structure
                        Point point1 = new Point(10, 5);
                        String pointString;

                        pointString = point1.ToString();
                        // pointString is equal to 10,5

                        // Displaying Results
                        syntaxString = "pointString = point1.ToString();";
                        resultType = "String";
                        operationString = "Getting the string representation of a Point";
                        ShowResults(pointString.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb16":
                    {
                        // Gets the hashcode of a Point structure

                        Point point1 = new Point(10, 5);
                        int pointHashCode;

                        pointHashCode = point1.GetHashCode();

                        // Displaying Results
                        syntaxString = "pointHashCode = point1.GetHashCode();";
                        resultType = "int";
                        operationString = "Getting the hashcode of Point";
                        ShowResults(pointHashCode.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb17":
                    {
                        // Explicitly converts a Point structure into a Size structure
                        // Returns a Size.

                        Point point1 = new Point(10, 5);
                        Size size1 = new Size();

                        size1 = (Size)point1;
                        // size1 has a width of 10 and a height of 5

                        // Displaying Results
                        syntaxString = "size1 = (Size)point1;";
                        resultType = "Size";
                        operationString = "Expliciting casting a Point into a Size";
                        ShowResults(size1.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb18":
                    {
                        // Explicitly converts a Point structure into a Vector structure
                        // Returns a Vector.

                        Point point1 = new Point(10, 5);
                        Vector vector1 = new Vector();

                        vector1 = (Vector)point1;
                        // vector1 is equal to (10,5)

                        // Displaying Results
                        syntaxString = "vector1 = (Vector)point1;";
                        resultType = "Vector";
                        operationString = "Expliciting casting a Point into a Vector";
                        ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                // task example.  Not accessed through radio buttons
                case "rb20":
                    {
                        // Checks if two Points are not equal using the overloaded inequality operator.

                        // Declaring point1 and initializing x,y values
                        Point point1 = new Point(10, 5);

                        // Declaring point2 without initializing x,y values
                        Point point2 = new Point();

                        // Boolean to hold the result of the comparison
                        Boolean areNotEqual;

                        // assigning values to point2
                        point2.X = 15;
                        point2.Y = 40;

                        // checking for inequality
                        areNotEqual = (point1 != point2);

                        // areNotEqual is True

                        // Displaying Results
                        syntaxString = "areNotEqual = (point1 != point2);";
                        resultType = "Boolean";
                        operationString = "Checking if two points are not equal";
                        ShowResults(areNotEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                default:
                    break;

            } //end switch
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Writes the attribute.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="value">The value.</param>
 /// <param name="defaultValue">The default value.</param>
 protected void WriteAttribute(string name, Point value, Point defaultValue)
 {
     if (this.settings.WriteDefaultValues || !value.Equals(defaultValue)) {
         this.writer.WriteAttributeString(name, value.Format());
     }
 }
Ejemplo n.º 19
0
        public void TimerTick(object sender, EventArgs e)
        {
            if (m_kinect.currentPlayer == 0) return;
            Line line = new Line();
            if (!m_calibarting)
            {
                line.Stroke = System.Windows.Media.Brushes.Red;
                m_prevPoint = m_point;
                line.X1 = m_prevPoint.X;
                line.Y1 = m_prevPoint.Y;
            }

            m_point = new Point(m_kinect.currentX, m_kinect.currentY);
            m_point = mapping(m_point);

            if (!m_calibarting)
            {
                line.X2 = m_point.X;
                line.Y2 = m_point.Y;
                line.HorizontalAlignment = HorizontalAlignment.Left;
                line.VerticalAlignment = VerticalAlignment.Top;
                line.StrokeThickness = 3;
            }
            UpdateDebug();

            if (!m_point.Equals(m_prevPoint))
            {
                m_grid.Children.Add(line);
            }

            this.sendMessage();
        }
Ejemplo n.º 20
0
 // Selection and temp point should follow ones on CamersImage
 // and change corresponding camera3dpoint in real time
 // Undoing from this level
 private void OnSelectedPointChangedSecond(object sender, Point point)
 {
     if (point.X < 0)
     {
         _camImageFirst.SelectedPoint = point;
         _butRemovePoint.IsEnabled = false;
         _butAcceptPoint.IsEnabled = true;
         _isPointsSelected = false;
         return;
     }
     foreach (var point3d in Points3D)
     {
         if (point.Equals(point3d.Cam2Point))
         {
             _camImageFirst.SelectedPoint = point3d.Cam1Point;
             _butRemovePoint.IsEnabled = true;
             _curCamPoint = point3d;
             _isPointsSelected = true;
             return;
         }
     }
     CheckIfValidPointsChoosen();
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Update the scroll offset of the HTML container and invalidate visual to re-render.
 /// </summary>
 private void UpdateScrollOffsets()
 {
     var newScrollOffset = new Point(-_horizontalScrollBar.Value, -_verticalScrollBar.Value);
     if (!newScrollOffset.Equals(_htmlContainer.ScrollOffset))
     {
         var oldValue = _htmlContainer.ScrollOffset;
         _htmlContainer.ScrollOffset = newScrollOffset;
         InvalidateVisual();
     }
 }