Esempio n. 1
0
 // CONSTRUCTORS
 /// <summary>
 /// Constructor with parameters.
 /// </summary>
 /// <param name="pentagon">Current pentagon.</param>
 /// <param name="opacity">New opacity.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when pentagon is null.</exception>
 public ChangeOpacity(Models.Pentagon pentagon, double opacity)
 {
     if (pentagon != null)
     {
         this.pentagon  = pentagon;
         this.opacity   = opacity;
         this.prevState = pentagon.Opacity;
     }
     else
     {
         throw new System.ArgumentNullException("Pentagon is null");
     }
 }
 // CONSTRUCTORS
 /// <summary>
 /// Constructor with parameters.
 /// </summary>
 /// <param name="pentagon"></param>
 /// <param name="strokeThickness"></param>
 /// <exception cref="System.ArgumentNullException">Thrown when pentagon is null.</exception>
 public ChangeStrokeWidth(Models.Pentagon pentagon, double strokeThickness)
 {
     if (pentagon != null)
     {
         this.pentagon            = pentagon;
         this.strokeThickness     = strokeThickness;
         this.prevStrokeThickness = pentagon.StrokeThickness;
     }
     else
     {
         throw new System.ArgumentNullException("Pentagon is null");
     }
 }
 // CONSTRUCTORS
 /// <summary>
 /// Constructor with parameters.
 /// </summary>
 /// <param name="pentagon">Current pentagon.</param>
 /// <param name="color">New color.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when pentagon is null.</exception>
 public ChangeColor(Models.Pentagon pentagon, System.Windows.Media.Color color)
 {
     if (pentagon != null)
     {
         this.pentagon  = pentagon;
         this.color     = color;
         this.prevColor = pentagon.Color;
     }
     else
     {
         throw new System.ArgumentNullException("Pentagon is null");
     }
 }
 // CONSTRUCTORS
 /// <summary>
 /// Constructor with parameters.
 /// </summary>
 /// <param name="pentagon">Current pentagon.</param>
 /// <param name="points">New points.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when pentagon is null.</exception>
 /// <exception cref="System.ArgumentNullException">Thrown when points is null.</exception>
 public ChangeLocation(Models.Pentagon pentagon, System.Windows.Point[] points)
 {
     if (pentagon == null)
     {
         throw new System.ArgumentNullException("Pentagon is null");
     }
     if (points == null)
     {
         throw new System.ArgumentNullException("Points is null");
     }
     this.pentagon     = pentagon;
     this.points       = points;
     this.prevLocation = pentagon.Points;
 }
 /// <summary>
 /// Adds <see cref="Models.Pentagon"/>.
 /// </summary>
 public void Execute()
 {
     if (arrSortedIndices == null)
     {
         arrUnsortedVertices = canvas.Shapes.OfType <Models.Vertex>().ToArray();
         SortIndicesForVertices(arrUnsortedVertices);
     }
     System.Windows.Point[] arrPoints = arrUnsortedVertices.Select(vertex => vertex.Location).ToArray();
     System.Array.Sort(arrSortedIndices, arrPoints);
     pentagon = new Models.Pentagon
     {
         Points = arrPoints
     };
     canvas.RemoveAll(shape => shape is Models.Vertex);
     canvas.Add(pentagon);
 }
        // CONSTRUCTORS
        /// <summary>
        /// Constructor with 2 parameters
        /// </summary>
        /// <param name="baseCanvas">Basic canvas from which will be removed pentagon</param>
        /// <param name="target">Pentagon that will be removed</param>
        /// <exception cref="System.NullReferenceException">Pentagon or canvas doesn't exist!</exception>
        /// <exception cref="System.ArgumentException">Thrown when pentagon has not been found in canvas.</exception>
        public RemovePentagon(Canvas baseCanvas, Models.Pentagon target)
        {
            if (target == null)
            {
                throw new System.NullReferenceException("Pentagon doesn't exist!");
            }
            if (baseCanvas == null)
            {
                throw new System.NullReferenceException("Canvas doesn't exist!");
            }
            this.target           = target;
            this.baseCanvas       = baseCanvas;
            this.positionInCanvas = baseCanvas.IndexOf(target);

            if (positionInCanvas == -1)
            {
                throw new System.ArgumentException("Pentagon has not been found in canvas.");
            }
        }