Exemple #1
0
        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();
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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();
        }
Exemple #5
0
        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();
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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));
        }
Exemple #8
0
        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));
        }
Exemple #9
0
        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));
        }
Exemple #10
0
        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));
        }
Exemple #11
0
        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());
        }
Exemple #12
0
        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());
        }
Exemple #13
0
        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));
        }