private void AddSize() { if (!IsNumeric.Match(widthInput.Text).Success || !IsNumeric.Match(heightInput.Text).Success) { return; } CropSize size = new CropSize( Convert.ToInt32(widthInput.Text), Convert.ToInt32(heightInput.Text)); if (!predefinedSizeList.Items.Contains(size)) { predefinedSizeList.Items.Add(size); List <CropSize> cropSize = new List <CropSize>(); foreach (CropSize item in predefinedSizeList.Items) { cropSize.Add(item); } predefinedSizeList.Items.Clear(); CropSize[] sizes = cropSize.ToArray(); Array.Sort(sizes); foreach (CropSize item in sizes) { predefinedSizeList.Items.Add(item); } } widthInput.Focus(); }
public void CompareTo_uses_Width() { int expected = -1; int height = 104; CropSize left = new CropSize(0, height); CropSize right = new CropSize(1, height); Assert.AreEqual(expected, left.CompareTo(right)); }
public void CompareTo_uses_Height() { int expected = -1; int width = 119; CropSize left = new CropSize(width, 0); CropSize right = new CropSize(width, 1); Assert.AreEqual(expected, left.CompareTo(right)); }
private void AddSize() { if (!isNumeric.Match(widthInput.Text).Success || !isNumeric.Match(heightInput.Text).Success) return; CropSize size = new CropSize( Convert.ToInt32(widthInput.Text), Convert.ToInt32(heightInput.Text)); if (!predefinedSizeList.Items.Contains(size)) { predefinedSizeList.Items.Add(size); List<CropSize> cropSize = new List<CropSize>(); foreach (CropSize item in predefinedSizeList.Items) cropSize.Add(item); predefinedSizeList.Items.Clear(); CropSize[] sizes = cropSize.ToArray(); Array.Sort(sizes); foreach (CropSize item in sizes) predefinedSizeList.Items.Add(item); } widthInput.Focus(); }
private void HandleMenuSizeCurrentClick(object sender, EventArgs e) { CropSize size = new CropSize(VisibleClientSize.Width, VisibleClientSize.Height); List<CropSize> list = new List<CropSize>(Configuration.Current.PredefinedSizes); if (list.Contains(size)) return; list.Add(size); CropSize[] cropSizes = list.ToArray(); //Array.Sort(cropSizes); Configuration.Current.PredefinedSizes = cropSizes; RefreshMenuItems(); }
public void Constructor_parameters_are_not_altered() { int width = 119; int height = 104; CropSize size = new CropSize(width, height); Assert.AreEqual(width, size.Width); Assert.AreEqual(height, size.Height); }
public void Two_CropSize_CompareTo() { int expected = 0; int width = 119; int height = 104; CropSize left = new CropSize(width, height); CropSize right = new CropSize(width, height); Assert.AreEqual(expected, left.CompareTo(right)); }
public void Two_CropSize_are_not_equal_if_Width_differs() { int height = 104; CropSize left = new CropSize(0, height); CropSize right = new CropSize(1, height); Assert.IsFalse(left.Equals(right)); Assert.IsFalse(left.Equals((object)right)); }
public void Two_CropSize_are_not_equal_if_Height_differs() { int width = 119; CropSize left = new CropSize(width, 0); CropSize right = new CropSize(width, 1); Assert.IsFalse(left.Equals(right)); Assert.IsFalse(left.Equals((object)right)); }
public void Two_CropSize_are_equal_if_Width_and_Height_match() { int width = 119; int height = 104; CropSize left = new CropSize(width, height); CropSize right = new CropSize(width, height); Assert.IsTrue(left.Equals(right)); Assert.IsTrue(left.Equals((object)right)); }
public void ToString_returns_width_x_height() { int width = 119; int height = 104; string expected = width + " x " + height; CropSize size = new CropSize(width, height); Assert.AreEqual(expected, size.ToString()); }
public void GetHashCode_uses_Width_and_Height() { int width = 119; int height = 104; int expected = width + 29 * height; CropSize size = new CropSize(width, height); Assert.AreEqual(expected, size.GetHashCode()); }
public void Evaluating_equals_returns_false_if_the_object_is_not_a_CropSize() { CropSize size = new CropSize(); object obj = new object(); Assert.IsFalse(size.Equals(obj)); }