Пример #1
0
        private void ListImageCompleted(List<common.Image> imageList)
        {
            Globals.IsBusy = false;
            listImages.Items.Clear();
            OriginalImageList = new List<common.Image>();
            foreach (common.Image item in imageList)
            {
                OriginalImageList.Add(item);
                ImageItem imageItem = new ImageItem(item);
                imageItem.btnDelete.Click += new RoutedEventHandler(btnDelete_Click);
                imageItem.btnDelete.Visibility = this.IsReadOnly ? Visibility.Collapsed : Visibility.Visible;
                listImages.Items.Add(imageItem);
            }

            if (OriginalImageList.Count > 0)
            {
                listImages.Visibility = System.Windows.Visibility.Visible;
                btnSave.IsEnabled = true;
            }
            else
            {
                listImages.Visibility = System.Windows.Visibility.Collapsed;
                btnSave.IsEnabled = false;
            }
        }
Пример #2
0
        void btnUploadOK_Click(object sender, RoutedEventArgs e)
        {
            listImages.Visibility = System.Windows.Visibility.Visible;
            btnSave.IsEnabled = true;

            List<ImageItem> list = new List<ImageItem>();
            foreach (object item in listImages.Items)
            {
                list.Add((ImageItem)item);
            }

            common.Image newImage = new common.Image();
            newImage.IsChanged = true;
            newImage.FileName = txtFileName.Text;
            newImage.ImageContent = _byteArray;
            newImage.ImageSmallContent = _byteArraySmall;
            newImage.CreatedBy = newImage.UpdatedBy = Globals.UserLogin.UserName;
            newImage.DisplayIndex = list != null && list.Count > 0 ? (list.Max(i => i.ImageDataItem.DisplayIndex) + 1) : 1;
            newImage.ImageTypeId = (int) this.ImageType;
            newImage.ItemId = this.ItemId;

            ImageItem imageItem = new ImageItem(newImage);
            imageItem.btnDelete.Click += new RoutedEventHandler(btnDelete_Click);
            imageItem.btnDelete.Visibility = this.IsReadOnly ? Visibility.Collapsed : Visibility.Visible;
            listImages.Items.Add(imageItem);

            uiPopupUpload.Close();
        }