Ejemplo n.º 1
0
        void btnSave_Click(object sender, RoutedEventArgs e)
        {
            List <common.Image> saveList = new List <common.Image>();

            foreach (object item in listImages.Items)
            {
                ImageItem content = (ImageItem)item;
                saveList.Add(content.ImageDataItem);
            }
            if (OriginalImageList != null)
            {
                foreach (common.Image oldItem in OriginalImageList)
                {
                    if (oldItem.ImageId > 0 && saveList.Count(i => i.ImageId == oldItem.ImageId) == 0)
                    {
                        oldItem.IsDeleted = true;
                        saveList.Add(oldItem);
                    }
                }
            }
            Globals.IsBusy = true;
            DataServiceHelper.SaveImageAsync(saveList, SaveComplete);
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
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();
        }