コード例 #1
0
        private void btnUploadPicture_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.Title  = "Open Picture";
            open.Filter = "jpg files (*.jpg)|*.jpg|All files (*.*)|*.*";

            if (open.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image = new Bitmap(open.OpenFile());
                Filename          = open.SafeFileName;
                PictureAdded?.Invoke(sender, e);
            }
            open.Dispose();
        }
コード例 #2
0
    public void AddRefPicture()
    {
        var script = UIController.Instance.ShowRefPicture();

        script.OnAccepted += (text) =>
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }
            PictureCanvas canvas = UIController.Instance.ShowPictureCanvas();
            pictures.Add(canvas);
            canvas.SetPicture(text);
            PictureAdded?.Invoke(canvas);
            script.Close();
        };
    }
コード例 #3
0
        public void test_rule_when_picture_size_match_spec(int width, int height, bool expect)
        {
            //Given
            var added = new PictureAdded(
                Guid.NewGuid(),
                Guid.NewGuid(),
                new Uri("https://google.com.tw").ToString(),
                height,
                width,
                1);

            _picture.Handle(added);
            //When
            //When
            var correct = _picture.HasCorrectSize();

            //Then
            Assert.Equal(expect, correct);
        }
コード例 #4
0
        public void test_resize_picture()
        {
            var added = new PictureAdded(
                Guid.NewGuid(),
                Guid.NewGuid(),
                new Uri("https://google.com.tw").ToString(),
                800,
                600,
                1);

            _picture.Handle(added);
            var resize = new PictureSize(801, 601);

            //When

            _picture.Handle(new PictureResized(Guid.NewGuid(), resize.Height, resize.Width));
            //Then
            Assert.Equal(resize.Width, _picture.Size.Width);
            Assert.Equal(resize.Height, _picture.Size.Height);
        }
コード例 #5
0
        public void test_new_picture()
        {
            //Given
            var added = new PictureAdded(
                Guid.NewGuid(),
                Guid.NewGuid(),
                new Uri("https://google.com.tw").ToString(),
                801,
                601,
                1);

            //When
            _picture.Handle(added);
            //Then
            Assert.Equal(added.PictureId, _picture.Id);
            Assert.Equal(added.Url, _picture.Location.ToString());
            Assert.Equal(added.Width, _picture.Size.Width);
            Assert.Equal(added.Height, _picture.Size.Height);
            Assert.Equal(added.Order, _picture.Order);
        }