Esempio n. 1
0
        public void AddUpdateFile(VerifyFileJson verifyItem)
        {
            var buttons = GetHeaderSectionRows("Files");

            foreach (var button in buttons)
            {
                if (button.Tag == verifyItem)
                {
                    var v = (button as ButtonRow).RowLayout.Children.Last() as VerifyFileView;
                    v.Update(verifyItem);
                    Status.ReValidate();
                    return;
                }
            }

            AddIndex       = _addButton;
            AddIndexBefore = true;

            var view = new VerifyFileView(true);

            view.Update(verifyItem);

            var newButton = AddButtonViewRow(view, EditFile);

            newButton.Tag = verifyItem;
            Status.AddBusyView(newButton);
            Status.ReValidate();
        }
Esempio n. 2
0
        VerificationFilePage(AddVerificationPage verificationPage, VerifyFileJson verifyItem, OpenFile file = null) : base("VerificationFilePage")
        {
            _verificationPage = verificationPage;
            _item             = verifyItem ?? new VerifyFileJson();

            AddTitleRow("Title");
            AddHeaderRow("File");
            Status.AddBusyView(AddButtonRow("Select", Select));

            _link = AddEntryRow(null, "Link");
            _link.SetDetailViewIcon(Icons.RowLink);

            _verifyView = new VerifyFileView(false);
            AddViewRow(_verifyView);

            if (verifyItem != null)
            {
                _link.Edit.Text = verifyItem.link;
                _fileName       = verifyItem.name;
                _fileHash       = verifyItem.GetHash();
                _length         = verifyItem.length;
                _verifyView.Update(verifyItem);
            }

            Status.Add(_link.Edit, T("LinkStatus"), (view, entry, newText, oldText) =>
            {
                if (string.IsNullOrEmpty(newText))
                {
                    return(true);
                }

                return(newText.IsValdiUrl(true));
            });

            Status.Add(T("FileStatus"), (sv) =>
            {
                return(!string.IsNullOrEmpty(_fileName) && _fileHash != null && _length > 0);
            });

            AddFooterRow();

            AddSubmitRow("Submit", Submit);

            if (file != null)
            {
                UIApp.Run(() => HashFile(file));
            }
        }
Esempio n. 3
0
        public VerificationFilesPage(VerifyJson verify) : base("VerificationFilesPage")
        {
            AddTitleRow("Title");

            AddHeaderRow();

            foreach (var file in verify.files)
            {
                var view = new VerifyFileView(true);
                view.Update(file);

                var row = AddButtonViewRow(view, Verify);
                row.Tag = file;
            }

            AddFooterRow();
        }
Esempio n. 4
0
        async Task HashFile(OpenFile file)
        {
            IsBusy = true;
            Toast("Wait");

            _fileHash = null;
            _fileName = null;
            _length   = 0;

            await Task.Run(() =>
            {
                try
                {
                    (var hash, var length) = VerifyFileJson.GenerateHash(file.Stream);
                    if (hash != null)
                    {
                        _fileName = file.Name;
                        _fileHash = hash;
                        _length   = length;
                    }
                }
                catch (Exception ex)
                {
                    Log.IgnoreException(ex);
                }
            });

            if (_fileHash != null)
            {
                _verifyView.Update(new VerifyFileJson {
                    name = _fileName, hashtype = _fileHash.HashType.ToString().ToLower(), hash = Hex.ToString(_fileHash.RawData), length = _length, link = _link.Edit.Text
                });
            }

            IsBusy = false;
        }