public void EmptyDocumentWithHeader()
        {
            var context  = new SerializationContext();
            var root     = new BaseObject();
            var document = new DocumentHeader()
            {
                ContentType  = root.GetType().Name,
                MajorVersion = 1,
                MinorVersion = 0
            };
            var writer = new Writer();

            Assert.IsTrue(Serializer.Serialize(writer, document, context));
            Assert.IsTrue(Serializer.Serialize(writer, root, context));

            var serialized = writer.ToString();

            Assert.NotNull(serialized);
            Assert.AreEqual("!Common.DocumentHeader{ContentType:\"BaseObject\",MajorVersion:1,MinorVersion:0}!Common.BaseObject{}", serialized);

            var reader  = new Reader(serialized);
            var readDoc = Serializer.Deserialize <DocumentHeader>(reader, context);

            Assert.NotNull(readDoc);
            var readRoot = Serializer.Deserialize <BaseObject>(reader, context);

            Assert.NotNull(readRoot);
        }
Beispiel #2
0
        public string modify([FromBody] DocumentHeader documentHeader)
        {
            IBlobService blobService  = new AzureBlobService();
            var          blobContents = blobService.getBlobContents(blobContainerConnString, blobContainerName, documentHeader.BlobItemName);
            var          tempGUID     = Guid.NewGuid().ToString();
            var          tempDocPath  = $"./local/{tempGUID}";

            System.IO.Directory.CreateDirectory(tempDocPath);
            System.IO.File.WriteAllBytes($"{tempDocPath}.docx", blobContents);

            var bookmarkReplacements = new Dictionary <string, string>();

            bookmarkReplacements.Add("Commentor_adresse", "Andevej 14");
            bookmarkReplacements.Add("Commentor_navn_header", "Anders And");
            bookmarkReplacements.Add("Commentor_navn_body", "Anders And");
            bookmarkReplacements.Add("Commentor_registreringsnummer", "1234 1234512345");
            bookmarkReplacements.Add("Commentor_dato", DateTime.Now.ToString("dd.MM.yyyy"));
            bookmarkReplacements.Add("Commentor_bodytext", documentHeader.BodyText);
            openDocument.ReplaceBookmarks($"{tempDocPath}.docx", $"{tempDocPath} - REPLACED.docx", bookmarkReplacements);

            var htmlSimpleInputBytes = System.IO.File.ReadAllBytes($"{tempDocPath} - REPLACED.docx");
            var serviceUser          = docProvider.GetUser("*****@*****.**");

            byte[] pdfHTMLSimpleDocBytes = docProvider.ConvertDocumentToPDF(htmlSimpleInputBytes, $"Temp/{Guid.NewGuid()}.docx", serviceUser.Id);
            System.IO.File.WriteAllBytes($"{tempDocPath} - REPLACED.pdf", pdfHTMLSimpleDocBytes);

            return(tempGUID);
        }
        internal static void UpdateDocumentById(Guid id, DocumentHeader newDocumentHeader)
        {
            try
            {
                using (AppDBContext db = new AppDBContext())
                {
                    var existingDocumentHeader = db.DocumentHeader.FirstOrDefault(x => x.ID == id);

                    if (!string.IsNullOrEmpty(newDocumentHeader.ClientName))
                    {
                        existingDocumentHeader.ClientName = newDocumentHeader.ClientName;
                        db.Logs.Add(PrepareDbLog($"Change {nameof(newDocumentHeader.ClientName)} from {existingDocumentHeader.ClientName} to {newDocumentHeader.ClientName}"));
                    }

                    if (newDocumentHeader.Date == DateTime.MinValue)
                    {
                        existingDocumentHeader.Date = newDocumentHeader.Date;
                        db.Logs.Add(PrepareDbLog($"Change {nameof(newDocumentHeader.Date)} from {existingDocumentHeader.Date} to {newDocumentHeader.Date}"));
                    }

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                FileLogger.AddLogExceptionToFile(ex.Message);
            }
        }
        public void AddNewOrder()
        {
            if (OrderList.Count > 0)
            {
                try
                {
                    using (var context = new AppDbContext())
                    {
                        DocumentHeader newHeader = new DocumentHeader(ClientId, SubTotalNet, SubTotalGross);

                        context.DocumentHeader.Add(newHeader);
                        context.SaveChanges();
                        foreach (var item in OrderList)
                        {
                            OrderModel newOrder = new OrderModel(newHeader.HeaderId, item.Name, item.ItemId, item.OrderQuantity, item.PriceNet, item.PriceGross);
                            context.Order.Add(newOrder);
                        }
                        context.SaveChanges();
                        this._dialog.ShowMessageAsync(this, "Uwaga", "Zamówienie złożono pomyślnie");
                        Logger.LogNewOrder(newHeader.Name, newHeader.HeaderId);
                        _shellViewModel.DownloadDockuments();
                        CleanNewOrder();
                    }
                }
                catch (Exception ex)
                {
                    this._dialog.ShowMessageAsync(this, "Uwaga", "Wystąpił błąd połączenia z bazą danych");
                    Logger.LogError(ex.Message);
                }
            }
            else
            {
                this._dialog.ShowMessageAsync(this, "Uwaga", "Nie wprowadzono żadnej pozycji");
            }
        }
Beispiel #5
0
        /// <summary>
        /// Attempts a forced replace or insert.
        /// If conflicts are detected, they are dropped, and the local version is again updated.
        /// Returns null if the method should be invoked again, otherwise the final version retrieved from the DB
        /// </summary>
        /// <typeparam name="T">Entity type</typeparam>
        /// <param name="store">DB to place the entity in</param>
        /// <param name="item">Entity to place. The _rev member may be updated in the process</param>
        /// <returns></returns>
        public static async Task <T> TryForceReplace <T>(DataBase store, T item) where T : Entity
        {
            //try
            {
                if (store == null)
                {
                    return(item);                       //during tests, db is not loaded
                }
                var serial = JsonConvert.SerializeObject(item,
                                                         Newtonsoft.Json.Formatting.None,
                                                         new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
                //store.Entities.Serializer.Serialize(item);
                //JsonConvert.SerializeObject(item);
                var header = await store.Documents.PutAsync(item._id, serial);

                //await store.Entities.PutAsync(item._id, item);
                if (!header.IsSuccess /*&& header.StatusCode == System.Net.HttpStatusCode.Conflict*/)
                {
                    var head = await store.Documents.HeadAsync(item._id);

                    if (head.IsSuccess)
                    {
                        item._rev = head.Rev;
                    }
                    return(null);
                }
                var echoRequest = new GetEntityRequest(header.Id);
                echoRequest.Conflicts = true;
                var echo = await store.Documents.GetAsync(header.Id);

                if (!echo.IsSuccess)
                {
                    return(null);
                }
                if (echo.Conflicts != null && echo.Conflicts.Length > 0)
                {
                    //we do have conflicts and don't quite know whether the new version is our version
                    var deleteHeaders = new DocumentHeader[echo.Conflicts.Length];
                    for (int i = 0; i < echo.Conflicts.Length; i++)
                    {
                        deleteHeaders[i] = new DocumentHeader(header.Id, echo.Conflicts[i]);
                    }
                    BulkRequest breq = new BulkRequest().Delete(deleteHeaders); //delete all conflicts
                    await store.Documents.BulkAsync(breq);                      //ignore result, but wait for it

                    item._rev = echo.Rev;                                       //replace again. we must win
                    return(await TryForceReplace(store, item));
                }
                return(JsonConvert.DeserializeObject <T>(echo.Content));                  //all good
            }
            //catch (Exception ex)
            //{

            //	throw;
            //}
        }
 private static string GetGifDescription(DocumentHeader documentHeader)
 {
     if (GifsPlayerUtils.ShouldShowSize())
     {
         return(documentHeader.Description);
     }
     return("GIF");
 }
        private void documentsList_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DocumentHeader selectedItem = this.documentsList.SelectedItem as DocumentHeader;

            this.documentsList.SelectedItem = null;
            if (selectedItem == null)
            {
                return;
            }
            if (!selectedItem.IsGif)
            {
                Navigator.Current.NavigateToWebUri(selectedItem.Document.url, true, false);
            }
            else
            {
                List <DocumentHeader> list1 = (List <DocumentHeader>)Enumerable.ToList <DocumentHeader>(Enumerable.Where <DocumentHeader>(this.ViewModel.DocumentsVM.Collection, (Func <DocumentHeader, bool>)(doc => doc.IsGif)));
                int num = -1;
                List <PhotoOrDocument> list = new List <PhotoOrDocument>();
                for (int index = 0; index < list1.Count; ++index)
                {
                    DocumentHeader documentHeader = list1[index];
                    if (documentHeader == selectedItem)
                    {
                        num = index;
                    }
                    list.Add(new PhotoOrDocument()
                    {
                        document = documentHeader.Document
                    });
                }
                if (num < 0)
                {
                    return;
                }
                InplaceGifViewerUC gifViewer = new InplaceGifViewerUC();
                Navigator.Current.NavigateToImageViewerPhotosOrGifs(num, list, false, false, null, null, false, (FrameworkElement)gifViewer, (Action <int>)(ind =>
                {
                    Doc document = list[ind].document;
                    if (document != null)
                    {
                        InplaceGifViewerViewModel gifViewerViewModel = new InplaceGifViewerViewModel(document, true, false, false);
                        gifViewerViewModel.Play(GifPlayStartType.manual);
                        gifViewer.VM = gifViewerViewModel;
                        ((UIElement)gifViewer).Visibility = Visibility.Visible;
                    }
                    else
                    {
                        InplaceGifViewerViewModel vm = gifViewer.VM;
                        if (vm != null)
                        {
                            vm.Stop();
                        }
                        ((UIElement)gifViewer).Visibility = Visibility.Collapsed;
                    }
                }), (Action <int, bool>)((i, b) => {}), false);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Creates an empty document, but don't write any data to the memory.
        /// </summary>
        /// <param name="documentSlice"></param>
        /// <param name="id"></param>
        public Document(Memory <byte> documentSlice, ushort id)
        {
            _documentSlice = documentSlice;
            var header = new DocumentHeader {
                DocumentId = id, ContentLength = 0, IsDeleted = false
            };

            Header = header;
        }
Beispiel #9
0
        /// <summary>
        /// Creates an empty document, but don't write any data to the memory.
        /// </summary>
        /// <param name="documentSlice"></param>
        /// <param name="id"></param>
        public Document(Memory <byte> documentSlice, ushort id)
        {
            _documentSlice = documentSlice;
            var header = new DocumentHeader();

            header.DocumentId    = id;
            header.ContentLength = 0;
            header.IsDeleted     = false;
            Header = header;
        }
Beispiel #10
0
        public void RemoveHeader()
        {
            DocumentHeader selectedHeader = (DocumentHeader)productsItemsGrid.SelectedItem;

            if (selectedHeader is null)
            {
                return;
            }
            DocumentDatabaseHelper.RemoveDocumentById(selectedHeader.ID);
        }
        private MediaListSectionViewModel GetDocumentsModel(Doc document, int count)
        {
            DocumentHeader documentHeader = new DocumentHeader(document, 0, false, 0L);

            return(new MediaListSectionViewModel(CommonResources.Profile_Docs, count, (MediaListItemViewModelBase) new GenericMediaListItemViewModel(document.ToString(), documentHeader.Name, documentHeader.GetSizeString(), "/Resources/Profile/ProfileDocuments.png", ProfileBlockType.docs), (Action)(() =>
            {
                this.PublishProfileBlockClickEvent(ProfileBlockType.docs);
                Navigator.Current.NavigateToDocuments(this._isGroup ? -this._profileData.Id : this._profileData.Id, this._profileData.AdminLevel > 1);
            })));
        }
Beispiel #12
0
        /// <summary>
        /// Construct the document header from the given memory slice.
        /// </summary>
        /// <param name="documentSlice"></param>
        public Document(Memory <byte>?documentSlice)
        {
            if (documentSlice == null)
            {
                throw new ArgumentNullException(nameof(documentSlice));
            }

            _documentSlice = (Memory <byte>)documentSlice;

            Header = MemoryMarshal.Read <DocumentHeader>(_documentSlice.Span);
        }
Beispiel #13
0
        public EditDocumentWindow(DocumentHeader selectedHeader)
        {
            InitializeComponent();
            ClientNameTextBox.Text = selectedHeader.ClientName;
            DateTextBox.Text       = selectedHeader.Date.ToString();
            NetPriceTextBox.Text   = selectedHeader.NetPrice.ToString();

            DataContext = new EditDocumentViewModel(null);

            ProductsItems.ItemsSource = DocumentDatabaseHelper.GetProductsByDocumentId(selectedHeader.ID);
        }
Beispiel #14
0
 public VoiceMessageAttachmentViewModel(Doc doc)
 {
     this._doc          = doc;
     this._docHeader    = new DocumentHeader(this._doc, 0, false, 0L);
     this._localFile    = MediaLRUCache.Instance.GetLocalFile(this.VideoUri);
     this._currentState = MediaLRUCache.Instance.HasLocalFile(this.VideoUri) ? VoiceMessageAttachmentViewModel.State.Downloaded : VoiceMessageAttachmentViewModel.State.NotStarted;
     if (!string.IsNullOrEmpty(this._localFile))
     {
         return;
     }
     this._localFile = Guid.NewGuid().ToString();
 }
        private void List_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DocumentHeader selectedItem = ((LongListSelector)sender).SelectedItem as DocumentHeader;

            if (selectedItem == null)
            {
                return;
            }
            this.list.SelectedItem = null;
            ParametersRepository.SetParameterForId("PickedDocument", selectedItem.Document);
            Navigator.Current.GoBack();
        }
Beispiel #16
0
        private void item_OnDeleteButtonClicked(object sender, RoutedEventArgs e)
        {
            if (sender == null)
            {
                return;
            }
            DocumentHeader menuItemDataContext = DocumentsPage.GetMenuItemDataContext(sender) as DocumentHeader;

            if (menuItemDataContext == null || MessageBox.Show(CommonResources.GenericConfirmation, UIStringFormatterHelper.FormatNumberOfSomething(1, CommonResources.Documents_DeleteOneFrm, CommonResources.Documents_DeleteTwoFourFrm, CommonResources.Documents_DeleteFiveFrm, true, null, false), MessageBoxButton.OKCancel) != MessageBoxResult.OK)
            {
                return;
            }
            this.ViewModel.DeleteDocument(menuItemDataContext);
        }
Beispiel #17
0
        public void EditHeader()
        {
            DocumentHeader selectedHeader = (DocumentHeader)productsItemsGrid.SelectedItem;

            if (selectedHeader is null)
            {
                return;
            }

            var editProductWindow = new EditDocumentWindow(selectedHeader);

            editProductWindow.Show();
            editProductWindow.Focus();
        }
Beispiel #18
0
        private void item_OnEditButtonClicked(object sender, RoutedEventArgs e)
        {
            if (sender == null)
            {
                return;
            }
            DocumentHeader menuItemDataContext = DocumentsPage.GetMenuItemDataContext(sender) as DocumentHeader;

            if (menuItemDataContext == null)
            {
                return;
            }
            Navigator.Current.NavigateToDocumentEditing(menuItemDataContext.Document.owner_id, menuItemDataContext.Document.id, menuItemDataContext.Document.title);
        }
Beispiel #19
0
        public void SetInsertHeader <TDocument>(TDocument document) where TDocument : Document
        {
            var userInfo    = GetCurrentUserInfo();
            var currentDate = DateTime.UtcNow;

            var header = new DocumentHeader
            {
                _tenant       = _tenantProvider.GetTenantId(),
                _created      = currentDate,
                _createUser   = userInfo.Item1,
                _createUserId = userInfo.Item2
            };

            document._header = header;
        }
 public void Initialize(List <Attachment> attachments, Doc doc1, Doc doc2)
 {
     this._attachments  = attachments;
     this._docHeader1   = new DocumentHeader(doc1, 0, false, 0L);
     this._docImageUri1 = this._docHeader1.ThumbnailUri.ConvertToUri();
     this.textBlockDescription1.Text = (this._docHeader1.IsGif ? DocImageAttachmentUC.GetGifDescription(this._docHeader1) : this._docHeader1.Description);
     if (doc2 == null)
     {
         return;
     }
     ((UIElement)this.gridDoc2).Visibility = Visibility.Visible;
     this._docHeader2   = new DocumentHeader(doc2, 0, false, 0L);
     this._docImageUri2 = this._docHeader2.ThumbnailUri.ConvertToUri();
     this.textBlockDescription2.Text = (this._docHeader2.IsGif ? DocImageAttachmentUC.GetGifDescription(this._docHeader2) : this._docHeader2.Description);
 }
Beispiel #21
0
        public void Handle(DocumentUploadedEvent message)
        {
            if (this._blockType != ProfileBlockType.docs || message.OwnerId.ToString() != this._id.Remove(this._id.IndexOf('_')).Remove(0, 3))
            {
                return;
            }
            DocumentHeader documentHeader = new DocumentHeader(message.Document, 0, false, 0L);

            this._id             = string.Format("doc{0}_{1}", message.Document.owner_id, message.Document.id);
            this.GenericTitle    = documentHeader.Name;
            this.GenericSubtitle = documentHeader.GetSizeString();
            // ISSUE: method reference
            this.NotifyPropertyChanged <string>(() => this.GenericTitle);
            // ISSUE: method reference
            this.NotifyPropertyChanged <string>(() => this.GenericSubtitle);
        }
Beispiel #22
0
        private void ParseTitleSubtitle()
        {
            if (this._attachment.type == "link" && this._attachment.link != null)
            {
                this._title       = !string.IsNullOrWhiteSpace(this._attachment.link.title) ? this._attachment.link.title : CommonResources.Link;
                this._subtitle    = GenericAttachmentItem.ParseDomain(this._attachment.link.url);
                this._navigateUri = this._attachment.link.url;
                this._iconSrc     = "/Resources/WallPost/AttachLink.png";
            }
            if (this._attachment.type == "note" && this._attachment.note != null)
            {
                this._title       = this._attachment.note.title ?? "";
                this._subtitle    = CommonResources.Note;
                this._navigateUri = string.Format("vk.com/note{0}_{1}", this._attachment.note.owner_id, this._attachment.note.nid);
                this._iconSrc     = "/Resources/WallPost/AttachNote.png";
            }
            if (this._attachment.type == "doc" && this._attachment.doc != null)
            {
                DocumentHeader documentHeader = new DocumentHeader(this._attachment.doc, 0, false, 0L);
                this._title       = documentHeader.Name;
                this._subtitle    = documentHeader.Description;
                this._navigateUri = documentHeader.Document.url;
                this._iconSrc     = "/Resources/WallPost/AttachDoc.png";
            }
            if (this._attachment.type == "page" && this._attachment.Page != null)
            {
                this._title       = this._attachment.Page.title ?? "";
                this._subtitle    = CommonResources.WikiPage;
                this._navigateUri = string.Format("https://vk.com/club{0}?w=page-{0}_{1}", this._attachment.Page.gid, this._attachment.Page.pid);
                this._iconSrc     = "/Resources/WallPost/AttachLink.png";
            }
            Product market = this._attachment.market;

            if (this._attachment.type == "market" && market != null)
            {
                this._title       = market.title;
                this._subtitle    = market.price.text;
                this._navigateUri = string.Format("http://m.vk.com/market{0}?w=product{1}_{2}", market.owner_id, market.owner_id, market.id);
                this._imageSrc    = market.thumb_photo;
            }
            ((UIElement)this._view).Tap += (new EventHandler <System.Windows.Input.GestureEventArgs>(this.View_OnTap));
            this._title    = this._title.Replace(Environment.NewLine, " ");
            this._subtitle = this._subtitle.Replace(Environment.NewLine, " ");
            MetroInMotion.SetTilt((DependencyObject)this._view, 1.5);
        }
        internal static void AddDocuments(DocumentViewModel documentViewModel)
        {
            List <Product> localProducts = new List <Product>();

            DocumentHeader documentHeader = new DocumentHeader()
            {
                ID           = Guid.NewGuid(),
                ClientName   = documentViewModel.ClientNameViewInput,
                Date         = documentViewModel.Date == DateTime.MinValue ? DateTime.Now : documentViewModel.Date,
                ClientNumber = documentViewModel.ClientNumberViewInput
            };

            for (int i = 0; i < documentViewModel.ProductsDataGrid.Items.Count; i++)
            {
                var productItem = (Product)documentViewModel.ProductsDataGrid.Items.GetItemAt(i);

                localProducts.Add(new Product
                {
                    Name       = productItem.Name,
                    ID         = Guid.NewGuid(),
                    DocumentId = documentHeader.ID,
                    Amount     = productItem.Amount,
                    GrossPrice = productItem.GrossPrice,
                    NetPrice   = productItem.NetPrice,
                });
            }

            documentHeader.GrossPrice = localProducts.Select(x => x.GrossPrice).Sum();
            documentHeader.NetPrice   = localProducts.Select(x => x.NetPrice).Sum();

            try
            {
                using (AppDBContext db = new AppDBContext())
                {
                    db.DocumentHeader.Add(documentHeader);
                    db.Product.AddRange(localProducts);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                FileLogger.AddLogExceptionToFile(ex.Message);
            }
        }
        private void GoToMessage_OnClicked(object sender, RoutedEventArgs e)
        {
            long   message_id  = 0;
            object dataContext = ((FrameworkElement)sender).DataContext;

            switch (this.pivot.SelectedIndex)
            {
            case 0:
                AlbumPhoto albumPhoto = dataContext as AlbumPhoto;
                message_id = albumPhoto != null ? albumPhoto.MessageId : 0L;
                break;

            case 1:
                VideoHeader videoHeader = dataContext as VideoHeader;
                message_id = videoHeader != null ? videoHeader.MessageId : 0L;
                break;

            case 2:
                AudioHeader audioHeader = dataContext as AudioHeader;
                message_id = audioHeader != null ? audioHeader.MessageId : 0L;
                break;

            case 3:
                DocumentHeader documentHeader = dataContext as DocumentHeader;
                message_id = documentHeader != null ? documentHeader.MessageId : 0L;
                break;

            case 4:
                LinkHeader linkHeader = dataContext as LinkHeader;
                message_id = linkHeader != null ? linkHeader.MessageId : 0L;
                break;
            }
            if (message_id == 0L)
            {
                return;
            }
            long peerId = this.ViewModel.PeerId;

            if (this.ViewModel.IsChat)
            {
                peerId -= 2000000000L;
            }
            Navigator.Current.NavigateToConversation(peerId, this.ViewModel.IsChat, false, "", message_id, false);
        }
Beispiel #25
0
        private void list_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ExtendedLongListSelector extendedLongListSelector = (ExtendedLongListSelector)sender;
            DocumentHeader           documentHeader           = extendedLongListSelector.SelectedItem as DocumentHeader;

            if (documentHeader != null)
            {
                extendedLongListSelector.SelectedItem = (null);
                if (!documentHeader.IsGif)
                {
                    Navigator.Current.NavigateToWebUri(documentHeader.Document.url, true, false);
                    return;
                }
                InplaceGifViewerUC     gifViewer = new InplaceGifViewerUC();
                List <PhotoOrDocument> documents = new List <PhotoOrDocument>();
                int num = 0;
                List <DocumentHeader> list = Enumerable.ToList <DocumentHeader>(this.ViewModel.Sections[this.pivot.SelectedIndex].Items.Collection);
                if (this._isSearchNow)
                {
                    ObservableCollection <Group <DocumentHeader> > groupedCollection = ((GenericCollectionViewModel2 <VKList <Doc>, DocumentHeader>)extendedLongListSelector.DataContext).GroupedCollection;
                    list = new List <DocumentHeader>();
                    if (groupedCollection.Count > 0)
                    {
                        list = Enumerable.ToList <DocumentHeader>(groupedCollection[0]);
                    }
                    if (groupedCollection.Count > 1)
                    {
                        list.AddRange(Enumerable.ToList <DocumentHeader>(groupedCollection[1]));
                    }
                }
                IEnumerable <DocumentHeader> arg_103_0 = list;
                Func <DocumentHeader, bool>  arg_103_1 = new Func <DocumentHeader, bool>((document) => { return(document.IsGif); });

                using (IEnumerator <DocumentHeader> enumerator = Enumerable.Where <DocumentHeader>(arg_103_0, arg_103_1).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        DocumentHeader current = enumerator.Current;
                        if (current == documentHeader)
                        {
                            num = documents.Count;
                        }
                        documents.Add(new PhotoOrDocument
                        {
                            document = current.Document
                        });
                    }
                }
                Action <int> action = delegate(int i)
                {
                    if (documents[i].document != null)
                    {
                        InplaceGifViewerViewModel inplaceGifViewerViewModel = new InplaceGifViewerViewModel(documents[i].document, true, false, false);
                        gifViewer.VM = inplaceGifViewerViewModel;
                        inplaceGifViewerViewModel.Play(GifPlayStartType.manual);
                        gifViewer.Visibility = Visibility.Visible;
                        return;
                    }
                    InplaceGifViewerViewModel expr_58 = gifViewer.VM;
                    if (expr_58 != null)
                    {
                        expr_58.Stop();
                    }
                    gifViewer.Visibility = Visibility.Collapsed;
                };
                INavigator             arg_1DA_0 = Navigator.Current;
                int                    arg_1DA_1 = num;
                List <PhotoOrDocument> arg_1DA_2 = documents;
                bool                   arg_1DA_3 = false;
                bool                   arg_1DA_4 = false;

                bool             arg_1DA_7 = false;
                FrameworkElement arg_1DA_8 = gifViewer;
                Action <int>     arg_1DA_9 = action;
                //Action<int, bool> arg_1DA_10 = new Action<int, bool>(DocumentsPage.<>c.<>9.<list_OnSelectionChanged>b__8_3));

                arg_1DA_0.NavigateToImageViewerPhotosOrGifs(arg_1DA_1, arg_1DA_2, arg_1DA_3, arg_1DA_4, null, this, arg_1DA_7, arg_1DA_8, arg_1DA_9, null, this.ViewModel.OwnerId == AppGlobalStateManager.Current.LoggedInUserId);
            }
        }
 internal PaymentDocument(DocumentHeader header) : base(header)
 {
 }
Beispiel #27
0
 internal MasterDataDocument(DocumentHeader header) : base(header)
 {
 }
 public MasterDataDocument(DocumentHeader header) : base(header) {}
        private async void HandleTap(DocumentHeader docHeader)
        {
            if (docHeader.IsGif)
            {
                if (this._tapHandled)
                {
                    return;
                }
                this._tapHandled = true;
                List <PhotoOrDocument> list = (List <PhotoOrDocument>)Enumerable.ToList <PhotoOrDocument>(Enumerable.Select <Attachment, PhotoOrDocument>(Enumerable.Where <Attachment>(Enumerable.ToList <Attachment>(Enumerable.OrderBy <Attachment, bool>(this._attachments, (Func <Attachment, bool>)(at =>
                {
                    if (at.doc == null)
                    {
                        return(false);
                    }
                    DocPreview preview = at.doc.preview;
                    return((preview != null ? preview.video :  null) == null);
                }))), (Func <Attachment, bool>)(at =>
                {
                    if (at.photo != null)
                    {
                        return(true);
                    }
                    if (at.doc != null)
                    {
                        return(at.doc.IsGif);
                    }
                    return(false);
                })), (Func <Attachment, PhotoOrDocument>)(a => new PhotoOrDocument()//todo: right?
                {
                    document = a.doc,
                    photo    = a.photo
                })));
                int index = list.IndexOf((PhotoOrDocument)Enumerable.FirstOrDefault <PhotoOrDocument>(list, (Func <PhotoOrDocument, bool>)(at =>
                {
                    if (at.document != null && at.document.owner_id == docHeader.Document.owner_id)
                    {
                        return(at.document.id == docHeader.Document.id);
                    }
                    return(false);
                })));
                InplaceGifViewerUC gifViewer = new InplaceGifViewerUC();
                await AnimationBehavior.ClearGifCacheAsync();

                Navigator.Current.NavigateToImageViewerPhotosOrGifs(index, list, false, false, null, null, false, (FrameworkElement)gifViewer, (Action <int>)(ind =>
                {
                    Doc document = list[ind].document;
                    if (document != null)
                    {
                        InplaceGifViewerViewModel gifViewerViewModel = new InplaceGifViewerViewModel(document, true, false, false);
                        gifViewerViewModel.Play(GifPlayStartType.manual);
                        gifViewer.VM = gifViewerViewModel;
                        ((UIElement)gifViewer).Visibility = Visibility.Visible;
                    }
                    else
                    {
                        InplaceGifViewerViewModel vm = gifViewer.VM;
                        if (vm != null)
                        {
                            vm.Stop();
                        }
                        ((UIElement)gifViewer).Visibility = Visibility.Collapsed;
                    }
                }), (Action <int, bool>)((i, b) => {}), false);
                this._tapHandled = false;
            }
            else
            {
                Navigator.Current.NavigateToWebUri(docHeader.Document.url, true, false);
            }
        }
Beispiel #30
0
 public PaymentDocument(DocumentHeader header) : base(header)
 {
 }