public override void Initialize()
        {
            SelectedPattern = null;
            if (Patterns.Count > 0)
            {
                return;
            }

            IsBusyLoading = true;
            Task.Factory.StartNew(() => _patternViewModelProvider.GetPatternsAsync().Result.Where(x => !x.IsInstaPrinterTemplate))
            .ContinueWith(t =>
            {
                t.Result.CopyTo(Patterns);
                IsBusyLoading = false;
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Пример #2
0
        private async void Print()
        {
            var result = await _patternVmProvider.GetPatternsAsync();

            TemplateViewModel instaTemplate = result.SingleOrDefault(x => x.IsInstaPrinterTemplate);
            Action <byte[]>   print         = null;

            if (!string.IsNullOrEmpty(_printerName))
            {
                print = (data) => _printer.Print(data, _printerName);
            }
            else
            {
                print = (data) => _printer.Print(data);
            }

            byte[] imageData = new byte[] { };
            Size   imageStreamSize;

            using (var stream = new MemoryStream(_checkedImage.Data))
            {
                var img = Image.FromStream(stream);
                imageStreamSize = img.Size;
            }

            if (instaTemplate != null)
            {
                imageData = _imageUtils.ProcessImages(new List <byte[]> {
                    _checkedImage.Data
                }, imageStreamSize,
                                                      _mappingEngine.Map <EntityTemplate>(instaTemplate));
            }

            else
            {
                //если раземер имени превышает допустимое значение то мы обрезаем его
                var imageName = _checkedImage.FullName.Length < 23 ? _checkedImage.FullName : (_checkedImage.UserName.Length < 23 ? _checkedImage.UserName : (_checkedImage.UserName.Substring(0, 20) + "..."));
                imageData = _imageUtils.GetCaptureForInstagramControl(_checkedImage.Data, imageName, DateTime.Now, _checkedImage.ProfilePictureData);
            }
            print(imageData);

            _navigator.NavigateForward <SelectActivityViewModel>(this, null);
        }