private void CalculateData()
        {
            string d = null;

            if (DocumentSize.Current.Height >= DocumentSize.ExpandedMinimumHeight)
            {
                var margin = Math.Sqrt(DocumentSize.Current.Width) - 4;
                d = ShortViewOfJson.GetContentDataWithMargin(inner.DataAsJson, (int)margin);
            }
            Execute.OnTheUI(() => Data = d);
        }
Esempio n. 2
0
        private void ProduceTrimmedDocumentView()
        {
            if (DocumentSize.Current.DisplayStyle == DocumentDisplayStyle.IdOnly)
            {
                return;
            }

            var widthInCharacters = (int)(DocumentSize.Current.Width / CharacterWidth);
            var heightInLines     = (int)(DocumentSize.Current.Height / LineHeight);

            Task.Factory.StartNew(() => ShortViewOfJson.GetContentTrimmedToDimensions(inner.DataAsJson, widthInCharacters, heightInLines))
            .ContinueOnSuccessInTheUIThread(v => TrimmedDocumentView = v);
        }
        public ViewableDocument(JsonDocument inner)
        {
            this.inner = inner;

            Id           = inner.Metadata.IfPresent <string>("@id");
            LastModified = inner.LastModified ?? DateTime.MinValue;
            if (LastModified.Kind == DateTimeKind.Utc)
            {
                LastModified = LastModified.ToLocalTime();
            }
            ClrType        = inner.Metadata.IfPresent <string>(Constants.RavenClrType);
            CollectionType = DetermineCollectionType(inner.Metadata);

            disposable = Observable.FromEventPattern <EventHandler, EventArgs>(e => DocumentSize.Current.SizeChanged += e, e => DocumentSize.Current.SizeChanged -= e)
                         .Throttle(TimeSpan.FromSeconds(0.5))
                         .Subscribe(_ => CalculateData());

            CalculateData();
            ToolTipText = ShortViewOfJson.GetContentDataWithMargin(inner.DataAsJson, 10);
        }