Exemplo n.º 1
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="numberOfwindows"></param>
    /// <param name="maxWidth"></param>
    /// <param name="maxHeight"></param>
    /// <returns></returns>
    /// <remarks>
    /// Possibilmente facciamo in modo che il <paramref name="maxHeight"/> e <paramref name="maxWidth"/> non siano piu' grandi
    /// della risoluzione del Desktop. :)
    /// </remarks>
    public static List<WindowDto> Randomize(int numberOfwindows,
      int maxWidth, int maxHeight,
      IScreenResolution resolution)
    {
      var result = new List<WindowDto>();

      for (int i = 1; i < numberOfwindows + 1; i++)
      {
        // Randomizziamo le dimensioni minime.
        var minWidthToRespect = rng.Next(maxWidth);
        var minHeightToRespect = rng.Next(maxHeight);

        var item = new WindowDto();

        item.ID = i;

        item.Width = rng.Next(minWidthToRespect, maxWidth);
        item.MinWidth = minWidthToRespect;
        item.Height = rng.Next(minHeightToRespect, maxHeight);
        item.MinHeight = minHeightToRespect;

        // Definisci il posizionamento.
        item.X = rng.Next(1, resolution.Width - item.Width);
        item.Y = rng.Next(1, resolution.Height - item.Height);

        // Aggiungi al risultato.
        result.Add(item);
      }

      return result;
    }
Exemplo n.º 2
0
        public void Setup()
        {
            mock       = new MockData();
            resolution = mock.CreateScreenResolution();

            sut = new CustomComponent();
            sut.SetScreenResolution(resolution);
        }
        public void SetScreenResolution(IScreenResolution resolution)
        {
            if (resolution == null)
            {
                throw new ArgumentNullException(nameof(resolution));
            }
            if (resolution.Width == default)
            {
                throw new ArgumentException(nameof(resolution.Width));
            }
            if (resolution.Height == default)
            {
                throw new ArgumentException(nameof(resolution.Height));
            }

            this.resolution = resolution;
        }
Exemplo n.º 4
0
 public List<WindowDto> CreateWindows(int numberOfWindows, int maxWidth, int maxHeight, IScreenResolution resolution)
 {
   return Randomize(numberOfWindows, maxWidth, maxHeight, resolution);
 }
Exemplo n.º 5
0
 public List<WindowDto> CreateWindows(int numberOfWindows, IScreenResolution resolution)
 {
   return Randomize(numberOfWindows, 300, 200, resolution);
 }
Exemplo n.º 6
0
 public List<WindowDto> CreateWindows(IScreenResolution resolution)
 {
   return Randomize(16, 300, 200, resolution);
 }