예제 #1
0
        private void RefreshImageList()
        {
            ImageListItems.Clear();
            for (var i = 0; i < models.Images.NumImages; ++i)
            {
                var item = new ImageItemViewModel(models.Images, i);
                ImageListItems.Add(item);
            }

            OnPropertyChanged(nameof(ImageListItems));
        }
예제 #2
0
        private void RefreshImageList()
        {
            SelectedImageListItem = null;

            ImageListItems.Clear();
            for (var i = 0; i < models.Images.NumImages; ++i)
            {
                var item = new ImageListBoxItem(models.Images.GetFilename(i), models.Images.GetFileFormat(i), i, models.Images);
                ImageListItems.Add(item);
            }

            OnPropertyChanged(nameof(ImageListItems));
            OnPropertyChanged(nameof(SelectedImageListItem));
        }
예제 #3
0
        private void RefreshImageList()
        {
            SelectedImageListItem = null;

            ImageListItems.Clear();
            for (var i = 0; i < models.Images.NumImages; ++i)
            {
                var item = new ImageListBoxItem(models.Images.Images[i].Filename, models.Images.Images[i].OriginalFormat.ToString(), i, models.Images);
                ImageListItems.Add(item);
            }

            OnPropertyChanged(nameof(ImageListItems));
            OnPropertyChanged(nameof(SelectedImageListItem));
        }
예제 #4
0
        public void Drop(IDropInfo dropInfo)
        {
            if (dropInfo.Data is ImageListBoxItem)
            {
                // move images
                var idx1 = ImageListItems.IndexOf(dropInfo.Data as ImageListBoxItem);
                var idx2 = dropInfo.InsertIndex;
                if (idx1 < 0 || idx2 < 0)
                {
                    return;
                }
                // did the order change?
                if (idx1 == idx2)
                {
                    return;
                }

                // move image want the final position of the moved image
                if (idx1 < idx2)
                {
                    idx2--;
                }

                // put item from idx1 into the position it was dragged to
                models.Images.MoveImage(idx1, idx2);
            }
            else if (dropInfo.Data is DataObject)
            {
                var obj   = dropInfo.Data as System.Windows.DataObject;
                var items = obj.GetFileDropList();
                if (items == null)
                {
                    return;
                }

                int desiredPosition = dropInfo.InsertIndex;

                foreach (var file in items)
                {
                    if (windowViewModel.ImportImage(file))
                    {
                        // put inserted image into correct position
                        models.Images.MoveImage(models.Images.NumImages - 1, desiredPosition++);
                    }
                }
            }
        }
예제 #5
0
        public async void Drop(IDropInfo dropInfo)
        {
            if (dropInfo.Data is ImageItemViewModel vm)
            {
                // move images
                var idx1 = ImageListItems.IndexOf(vm);
                var idx2 = dropInfo.InsertIndex;
                if (idx1 < 0 || idx2 < 0)
                {
                    return;
                }
                // did the order change?
                if (idx1 == idx2)
                {
                    return;
                }

                // move image want the final position of the moved image
                if (idx1 < idx2)
                {
                    idx2--;
                }

                // put item from idx1 into the position it was dragged to
                models.Images.MoveImage(idx1, idx2);
            }
            else if (dropInfo.Data is DataObject obj)
            {
                var items = obj.GetFileDropList();

                int desiredPosition = dropInfo.InsertIndex;

                foreach (var file in items)
                {
                    await import.ImportImageAsync(file);

                    // put inserted image into correct position
                    models.Images.MoveImage(models.Images.NumImages - 1, desiredPosition++);
                }
            }
        }