Esempio n. 1
0
        private void UpdateAttachPhotoItem()
        {
            int number = Enumerable.Count <AlbumPhoto>(this._viewModel.PhotosVM.AlbumPhotos, (Func <AlbumPhoto, bool>)(p => p.IsSelected));

            this._albumPhotosSelected = number > 0;
            AttachmentPickerItemViewModel pickerItemViewModel = (AttachmentPickerItemViewModel)Enumerable.FirstOrDefault <AttachmentPickerItemViewModel>(this._viewModel.AttachmentTypes, (Func <AttachmentPickerItemViewModel, bool>)(at => at.AttachmentType.AttachmentType == AttachmentType.Photo));

            if (pickerItemViewModel == null)
            {
                return;
            }
            if (this._albumPhotosSelected)
            {
                if (this._savedText == "")
                {
                    this._savedText = pickerItemViewModel.Title;
                }
                pickerItemViewModel.Title         = UIStringFormatterHelper.FormatNumberOfSomething(number, CommonResources.AttachOnePhotoFrm, CommonResources.AttachTwoFourPhotosFrm, CommonResources.AttachFivePhotosFrm, true, null, false);
                pickerItemViewModel.IsHighlighted = true;
            }
            else
            {
                pickerItemViewModel.Title         = this._savedText;
                pickerItemViewModel.IsHighlighted = false;
            }
        }
Esempio n. 2
0
        private void Item_OnClicked(object sender, System.Windows.Input.GestureEventArgs e)
        {
            AttachmentPickerItemViewModel dataContext = (sender as FrameworkElement).DataContext as AttachmentPickerItemViewModel;

            if (dataContext == null)
            {
                return;
            }
            this.HandleAttachmentSelection(dataContext);
        }
        private void Item_OnClicked(object sender, System.Windows.Input.GestureEventArgs e)
        {
            AttachmentPickerItemViewModel dataContext = ((FrameworkElement)sender).DataContext as AttachmentPickerItemViewModel;

            if (dataContext == null)
            {
                return;
            }
            // ISSUE: reference to a compiler-generated field
            AttachmentSubItemSelectedEventHandler itemSelected = this.ItemSelected;

            if (itemSelected == null)
            {
                return;
            }
            AttachmentPickerItemViewModel picketItem = dataContext;

            itemSelected(picketItem);
        }
Esempio n. 4
0
        private void HandleAttachmentSelection(AttachmentPickerItemViewModel item)
        {
            if (item == null)
            {
                return;
            }
            if (this._subPickerUC != null)
            {
                this._subPickerUC.ItemSelected -= new AttachmentSubItemSelectedEventHandler(this.HandleAttachmentSelection);
            }
            AttachmentType attachmentType = item.AttachmentType.AttachmentType;

            switch (attachmentType)
            {
            case AttachmentType.Photo:
                if (!item.IsHighlighted)
                {
                    List <NamedAttachmentType> attachmentTypes = new List <NamedAttachmentType>((IEnumerable <NamedAttachmentType>)AttachmentTypes.AttachmentPhotoSubtypes);
                    if (this.OwnerId < 0L && this._adminLevel > 1)
                    {
                        attachmentTypes.Add(AttachmentTypes.PhotoCommunityType);
                    }
                    this.ShowAttachmentSubPickerFor(attachmentTypes);
                    break;
                }
                ((UIElement)this.borderLoading).Visibility = Visibility.Visible;
                ThreadPool.QueueUserWorkItem((WaitCallback)(state =>
                {
                    List <Stream> choosedPhotos = new List <Stream>();
                    List <Stream> previewsPhotos = new List <Stream>();
                    List <Size> sizes = new List <Size>();
                    this._viewModel.PhotosVM.SuppressEXIFFetch = true;
                    IEnumerator <AlbumPhoto> enumerator4 = ((IEnumerable <AlbumPhoto>)Enumerable.Where <AlbumPhoto>(this._viewModel.PhotosVM.AlbumPhotos, (Func <AlbumPhoto, bool>)(ap => ap.IsSelected))).GetEnumerator();
                    try
                    {
                        while (enumerator4.MoveNext())
                        {
                            AlbumPhoto current = enumerator4.Current;
                            Stream imageStream = current.ImageStream;
                            if (imageStream != null)
                            {
                                choosedPhotos.Add(imageStream);
                                previewsPhotos.Add(current.ThumbnailStream);
                                Size size = new Size();
                                sizes.Add(size);
                            }
                        }
                    }
                    finally
                    {
                        if (enumerator4 != null)
                        {
                            enumerator4.Dispose();
                        }
                    }
                    Execute.ExecuteOnUIThread((Action)(() =>
                    {
                        ParametersRepository.SetParameterForId("ChoosenPhotos", choosedPhotos);
                        ParametersRepository.SetParameterForId("ChoosenPhotosPreviews", previewsPhotos);
                        ParametersRepository.SetParameterForId("ChoosenPhotosSizes", sizes);
                        this._quickPhotoPickCallback();
                        ((UIElement)this.borderLoading).Visibility = Visibility.Collapsed;
                        this._ds.Hide();
                    }));
                }));
                break;

            case AttachmentType.Video:
                List <NamedAttachmentType> attachmentTypes1 = new List <NamedAttachmentType>((IEnumerable <NamedAttachmentType>)AttachmentTypes.AttachmentVideoSubtypes);
                if (this.OwnerId < 0L && this._adminLevel > 1)
                {
                    attachmentTypes1.Add(AttachmentTypes.VideoCommunityType);
                }
                this.ShowAttachmentSubPickerFor(attachmentTypes1);
                break;

            case AttachmentType.Audio:
                Navigator.Current.NavigateToAudio(1, 0, false, 0, 0, "");
                break;

            case AttachmentType.Document:
                Navigator.Current.NavigateToDocumentsPicker(this._viewModel.MaxCount);
                break;

            case AttachmentType.Location:
                Navigator.Current.NavigateToMap(true, 0.0, 0.0);
                break;

            case AttachmentType.PhotoFromPhone:
                Navigator.Current.NavigateToPhotoPickerPhotos(this._viewModel.MaxCount, false, false);
                break;

            case AttachmentType.VideoFromPhone:
                this._ds.Hide();
                FileOpenPicker fileOpenPicker1 = new FileOpenPicker();
                fileOpenPicker1.ContinuationData["FilePickedType"] = (int)attachmentType;
                List <string> .Enumerator enumerator1 = VKConstants.SupportedVideoExtensions.GetEnumerator();
                try
                {
                    while (enumerator1.MoveNext())
                    {
                        string current = enumerator1.Current;
                        fileOpenPicker1.FileTypeFilter.Add(current);
                    }
                }
                finally
                {
                    enumerator1.Dispose();
                }
                fileOpenPicker1.ContinuationData["Operation"] = "VideoFromPhone";
                fileOpenPicker1.PickSingleFileAndContinue();
                break;

            case AttachmentType.DocumentFromPhone:
                this._ds.Hide();
                FileOpenPicker fileOpenPicker2 = new FileOpenPicker();
                ((IDictionary <string, object>)fileOpenPicker2.ContinuationData)["FilePickedType"] = attachmentType;
                List <string> .Enumerator enumerator2 = VKConstants.SupportedDocExtensions.GetEnumerator();
                try
                {
                    while (enumerator2.MoveNext())
                    {
                        string current = enumerator2.Current;
                        fileOpenPicker2.FileTypeFilter.Add(current);
                    }
                }
                finally
                {
                    enumerator2.Dispose();
                }
                ((IDictionary <string, object>)fileOpenPicker2.ContinuationData)["Operation"] = "DocumentFromPhone";
                fileOpenPicker2.PickSingleFileAndContinue();
                break;

            case AttachmentType.PhotoMy:
                Navigator.Current.NavigateToPhotoAlbums(true, 0, false, 0);
                break;

            case AttachmentType.VideoMy:
                Navigator.Current.NavigateToVideo(true, 0, false, false);
                break;

            case AttachmentType.DocumentMy:
                Navigator.Current.NavigateToDocumentsPicker(this._viewModel.MaxCount);
                break;

            case AttachmentType.DocumentPhoto:
                this._ds.Hide();
                FileOpenPicker fileOpenPicker3 = new FileOpenPicker();
                ((IDictionary <string, object>)fileOpenPicker3.ContinuationData)["FilePickedType"] = attachmentType;
                List <string> .Enumerator enumerator3 = ((List <string>)VKConstants.SupportedDocLibraryExtensions).GetEnumerator();
                try
                {
                    while (enumerator3.MoveNext())
                    {
                        string current = enumerator3.Current;
                        fileOpenPicker3.FileTypeFilter.Add(current);
                    }
                }
                finally
                {
                    enumerator3.Dispose();
                }
                ((IDictionary <string, object>)fileOpenPicker3.ContinuationData)["Operation"] = "DocumentLibraryFromPhone";
                fileOpenPicker3.PickSingleFileAndContinue();
                break;

            case AttachmentType.Poll:
                Navigator.Current.NavigateToCreateEditPoll(this.OwnerId, 0, null);
                break;

            case AttachmentType.Timer:
                Navigator.Current.NavigateToPostSchedule(new DateTime?());
                break;

            case AttachmentType.PhotoCommunity:
                Navigator.Current.NavigateToPhotoAlbums(true, -this.OwnerId, true, this._adminLevel);
                break;

            case AttachmentType.VideoCommunity:
                Navigator.Current.NavigateToVideo(true, -this.OwnerId, true, false);
                break;

            case AttachmentType.Graffiti:
                if (this._conversationInfo == null)
                {
                    break;
                }
                this._ds.Hide();
                ParametersRepository.SetParameterForId("ConversationInfo", this._conversationInfo);
                Navigator.Current.NavigateToGraffitiDrawPage(this._conversationInfo.UserOrChatId, this._conversationInfo.IsChat, this._conversationInfo.Title);
                break;

            case AttachmentType.MoneyTransfer:
                Navigator.Current.NavigateToSendMoneyPage(this._conversationInfo.User.id, this._conversationInfo.User, 0, "");
                break;

            case AttachmentType.Gift:
                Navigator.Current.NavigateToGiftsCatalog(this._conversationInfo.UserOrChatId, this._conversationInfo.IsChat);
                break;
            }
        }
Esempio n. 5
0
        private static List <AttachmentPickerItemViewModel> Convert(IEnumerable <NamedAttachmentType> attachmentTypes, bool excludeLocation)
        {
            List <AttachmentPickerItemViewModel> pickerItemViewModelList = new List <AttachmentPickerItemViewModel>();
            IEnumerator <NamedAttachmentType>    enumerator = attachmentTypes.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    NamedAttachmentType current = enumerator.Current;
                    if (!excludeLocation || current.AttachmentType != AttachmentType.Location)
                    {
                        AttachmentPickerItemViewModel pickerItemViewModel = new AttachmentPickerItemViewModel()
                        {
                            Title          = string.Concat(((string)((string)current.Name).Substring(0, 1)).ToUpper(), ((string)current.Name).Substring(1)),
                            AttachmentType = current
                        };
                        switch (current.AttachmentType)
                        {
                        case AttachmentType.Photo:
                            pickerItemViewModel.Icon            = "/Resources/AttachmentPicker/Types/Photo32px.png";
                            pickerItemViewModel.HighlightedIcon = "/Resources/Attach32px.png";
                            break;

                        case AttachmentType.Video:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Types/Video32px.png";
                            break;

                        case AttachmentType.Audio:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Types/Audio32px.png";
                            break;

                        case AttachmentType.Document:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Types/Document32px.png";
                            break;

                        case AttachmentType.Location:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Types/Location32px.png";
                            break;

                        case AttachmentType.PhotoFromPhone:
                        case AttachmentType.VideoFromPhone:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Locations/Gallery32px.png";
                            break;

                        case AttachmentType.PhotoMy:
                        case AttachmentType.VideoMy:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Locations/User32px.png";
                            break;

                        case AttachmentType.Poll:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Types/Poll32px.png";
                            break;

                        case AttachmentType.Timer:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Types/Timer32px.png";
                            break;

                        case AttachmentType.PhotoCommunity:
                        case AttachmentType.VideoCommunity:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Locations/Community32px.png";
                            break;

                        case AttachmentType.Graffiti:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Types/Graffiti32px.png";
                            break;

                        case AttachmentType.MoneyTransfer:
                            pickerItemViewModel.Icon = "/Resources/AttachmentPicker/Types/Money32px.png";
                            break;

                        case AttachmentType.Gift:
                            pickerItemViewModel.Icon = "/Resources/Gift32px.png";
                            break;
                        }
                        pickerItemViewModelList.Add(pickerItemViewModel);
                    }
                }
            }
            finally
            {
                if (enumerator != null)
                {
                    enumerator.Dispose();
                }
            }
            return(pickerItemViewModelList);
        }