Example #1
0
        private void buttonReplace_Click(object sender, EventArgs e)
        {
            if (_library == null)
            {
                return;
            }
            if (_library.FileName == null)
            {
                return;
            }
            if (PreviewListView.SelectedIndices.Count == 0)
            {
                return;
            }

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.ShowDialog();

            if (ofd.FileName == "")
            {
                return;
            }

            Bitmap newBmp = new Bitmap(ofd.FileName);

            ImageList.Images.Clear();
            _indexList.Clear();
            _library.ReplaceImage(PreviewListView.SelectedIndices[0], newBmp, 0, 0);
            PreviewListView.VirtualListSize = _library.Images.Count;

            try
            {
                PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true);
                ImageBox.Image = _library.Images[PreviewListView.SelectedIndices[0]].Image;
            }
            catch (Exception)
            {
                return;
            }
        }