override public Element Optimize() { OptimizeChildren(); IWorkshopTree a = ParameterValues[0]; IWorkshopTree b = ParameterValues[1]; // Multiply number and number if (a is V_Number && b is V_Number) { return(((V_Number)ParameterValues[0]).Value * ((V_Number)ParameterValues[1]).Value); } // Multiply vector and number if ((a is V_Vector && b is V_Number) || (a is V_Number && b is V_Vector)) { V_Vector vector = a is V_Vector ? (V_Vector)a : (V_Vector)b; V_Number number = a is V_Number ? (V_Number)a : (V_Number)b; if (vector.ConstantSupported <Models.Vertex>()) { Models.Vertex vertex = (Models.Vertex)vector.GetConstant(); return(new V_Vector( vertex.X * number.Value, vertex.Y * number.Value, vertex.Z * number.Value )); } } return(this); }
// CONSTRUCTORS /// <summary> /// Constructor with parameters. /// </summary> /// <param name="vertex">Current vertex.</param> /// <param name="location">New location.</param> /// <exception cref="System.ArgumentNullException"> /// Thrown when vertex is null. /// </exception> public ChangeLocation(Models.Vertex vertex, System.Windows.Point location) { if (vertex != null) { this.vertex = vertex; this.location = location; this.prevLocation = vertex.Location; } else { throw new System.ArgumentNullException("Vertex is null."); } }
// CONSTRUCTORS /// <summary> /// Constructor with 3 parameters /// </summary> /// <param name="baseCanvas">Vertex in which will be added vertex</param> /// <param name="target">Added vertex</param> /// <param name="workCommandManger">program command manager</param> /// <exception cref="System.NullReferenceException">Pentagon, command manager or vertex doesn't exist!</exception> public AddVertex(Models.Canvas baseCanvas, Models.Vertex target, Models.UndoRedoManager workCommandManger) { if (baseCanvas == null) { throw new System.NullReferenceException("Canvas doesn't exist!"); } if (target == null) { throw new System.NullReferenceException("Vertex doesn't exist!"); } if (workCommandManger == null) { throw new System.NullReferenceException("Command manager doesn't exist!"); } this.baseCanvas = baseCanvas; this.target = target; this.workCommandManger = workCommandManger; }
// CONSTRUCTORS /// <summary> /// Constructor with parameters. /// </summary> /// <param name="canvas">Current canvas.</param> /// <param name="vertex">Current vertex.</param> /// <exception cref="System.ArgumentNullException"> /// Thrown when canvas is null. /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when vertex is null. /// </exception> /// <exception cref="System.ArgumentOutOfRangeException"> /// Thrown when vertex hasn`t been found in canvas. /// </exception> public RemoveVertex(Models.Canvas canvas, Models.Vertex vertex) { if (canvas == null) { throw new System.ArgumentNullException("Canvas is null."); } if (vertex == null) { throw new System.ArgumentNullException("Vertex is null."); } this.canvas = canvas; this.vertex = vertex; index = canvas.IndexOf(vertex); if (index == -1) { throw new System.ArgumentOutOfRangeException("Vertex hasn`t been found."); } }