Ejemplo n.º 1
0
        public frmSelection(WidgetType type)
        {
            InitializeComponent();

            (selectionPanel as Control).KeyDown += new KeyEventHandler(this.onKeyDown);
            (selectionPanel as Control).Select();
            (selectionPanel as Control).MouseWheel += new MouseEventHandler(this.onMouseWheel);
            (zoomedImageBox as Control).MouseWheel += new MouseEventHandler(this.onMouseWheel);

            _fileToLoad += type.ToString() + ".json";

            if (File.Exists(_fileToLoad))
            {
                string file = File.ReadAllText(_fileToLoad);
                _images = JsonConvert.DeserializeObject<List<ImageTestData>>(file);

                foreach (ImageTestData item in _images)
                {
                    _widgetCount += item.WidgetAreaList.Count;
                }

                _index = _images.Count - 1;
                _currentImage = _images[_images.Count - 1];
                _images.RemoveAt(_images.Count - 1);

                _loadedFromJSON = true;
            }
            else
            {
                _images = new List<ImageTestData>();
            }

            _imagePaths = Directory.GetFiles("testimages\\").ToList<string>();

            lblType.Text = type.ToString();
        }
Ejemplo n.º 2
0
        private void LoadNextImage()
        {
            _index++;

            _firstClickedPoint = new Point(-1, -1);
            lblFirstPoint.Text = "First point not selected";
            btnClearFirstPoint.Visible = false;

            if (!_loadedFromJSON)
            {
                if (_currentImage != null)
                {
                    if (_primaryColour != Color.Empty)
                    {
                        _currentImage.PrimaryColourRed = Convert.ToInt32(_primaryColour.R);
                        _currentImage.PrimaryColourBlue = Convert.ToInt32(_primaryColour.B);
                        _currentImage.PrimaryColourGreen = Convert.ToInt32(_primaryColour.G);
                    }
                    else
                    {
                        _currentImage.PrimaryColourRed = -1;
                        _currentImage.PrimaryColourGreen = -1;
                        _currentImage.PrimaryColourBlue = -1;
                    }

                    _images.Add(_currentImage);
                }

                _currentImage = new ImageTestData();
                _currentImage.WidgetAreaList = new List<WidgetArea>();
            }
            else
            {
                _loadedFromJSON = false;
            }

            if (_index > _imagePaths.Count - 1)
            {
                MessageBox.Show("No more images");
                return;
            }

            try
            {
                _image = new Bitmap(_imagePaths[_index]);
                zoomedImageBox.BackgroundImage = _image;
                zoomedImageBox.Width = zoomedImageBox.BackgroundImage.Width;
                zoomedImageBox.Height = zoomedImageBox.BackgroundImage.Height;
                zoomedImageBox.Location = new Point(100, 10);
                _currentImage.FilePath = _imagePaths[_index];
            }
            catch (Exception)
            {

            }

            lblCurrentImageIndex.Text = (_index + 1).ToString();

            _primaryColour = Color.Empty;
            _backgroundColour = Color.Empty;

            UpdateLabels();
        }