public Present Evaluate(Present[] paramList) { D.Assert(paramList.Length == 2); MapRectangle value = ((MapRectangleParameter)paramList[0]).value; Size value2 = ((SizeParameter)paramList[1]).value; MapRectangle mapRectangle = value.Transform(imageTransformer.getDestLatLonToSourceTransformer()) .GrowFraction(0.05); Present present = warpedBoundsFuture.Realize("WarpImageVerb.Evaluate-bounds"); if (present is BoundsPresent) { MapRectangle boundingBox = ((BoundsPresent)present).GetRenderRegion().GetBoundingBox(); if (!boundingBox.intersects(value)) { return(new BeyondImageBounds()); } } Present present2 = sourceMapSupplier.Curry(new ParamDict(new object[] { TermName.ImageBounds, new MapRectangleParameter(mapRectangle) })).Realize("WarpImageVerb.Evaluate"); if (present2 is PresentFailureCode) { return(present2); } ImageRef imageRef = (ImageRef)present2; GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(value2, "WarpImageVerb"); imageTransformer.doTransformImage(imageRef.image, mapRectangle, gDIBigLockedImage, value); imageRef.Dispose(); return(new ImageRef(new ImageRefCounted(gDIBigLockedImage))); }
public override Present Realize(string refCredit) { Monitor.Enter(this); Present result; try { if (activeAsyncRef != null) { result = activeAsyncRef.Duplicate(refCredit); } else { D.Assert(!realizing); realizing = true; activeAsyncRef = (AsyncRef)future.Realize("ODSPF"); AsyncRef asyncRef = (AsyncRef)activeAsyncRef.Duplicate(refCredit); prioritizer.Realizing(this); activeAsyncRef.AddCallback(AsyncCompleteCallback); result = asyncRef; } } finally { Monitor.Exit(this); } return(result); }
private void HandleUpdate() { if (!needUpdate) { return; } needUpdate = false; Monitor.Enter(this); try { if (previewInterest != null) { previewInterest.Dispose(); previewInterest = null; waitingForCI = null; } if (_legend != null) { try { IFuture renderedLegendFuture = _legend.GetRenderedLegendFuture(displayableSource, (FutureFeatures)5); if (previewFuture != renderedLegendFuture) { previewFuture = renderedLegendFuture; AsyncRef asyncRef = (AsyncRef)renderedLegendFuture.Realize("LegendOptionsPanel.UpdatePreviewPanel"); if (asyncRef.present == null) { waitingForCI = new CallbackIgnorinator(this); asyncRef.AddCallback(waitingForCI.Callback); asyncRef.SetInterest(524296); previewInterest = new InterestList(); previewInterest.Add(asyncRef); previewInterest.Activate(); UpdatePreviewImage(null); } else { if (asyncRef.present is ImageRef) { UpdatePreviewImage((ImageRef)asyncRef.present); } } } } catch (Legend.RenderFailedException) { } } } finally { Monitor.Exit(this); } }
public override Present Realize(string refCredit) { Present present = documentFuture.Realize(refCredit); if (!(present is SourceDocument)) { return(PresentFailureCode.FailedCast(present, "FetchDocumentFuture")); } SourceDocument sourceDocument = (SourceDocument)present; string filesystemAbsolutePath = sourceDocument.localDocument.GetFilesystemAbsolutePath(); Present[] paramList = new Present[] { new StringParameter(filesystemAbsolutePath), new IntParameter(sourceDocument.localDocument.GetPageNumber()) }; string text = Path.GetExtension(filesystemAbsolutePath).ToLower(); if (text[0] == '.') { text = text.Substring(1); } Verb verb = null; string a = null; if (knownExtensions.ContainsKey(text)) { a = knownExtensions[text]; } if (a == "FoxIt") { verb = new FoxitOpenVerb(); } else { if (a == "WPF") { verb = new WPFOpenVerb(); } else { if (a == "GDI") { verb = new GDIOpenVerb(); } } } if (verb == null) { return(new PresentFailureCode(new UnknownImageTypeException("Unknown file type " + text))); } return(verb.Evaluate(paramList)); }
public void RequestRenderRegion(IFuture asynchronousImageBoundsFuture) { if (this.renderRegion == null) { AsyncRef asyncRef = (AsyncRef)asynchronousImageBoundsFuture.Realize("LatentRegionHolder.RequestRenderRegion"); asyncRef.AddCallback(new AsyncRecord.CompleteCallback(this.ImageBoundsAvailable)); new PersistentInterest(asyncRef); } }
public RenderRegion GetRenderRegionSynchronously(IFuture synchronousImageBoundsFuture) { Present present = synchronousImageBoundsFuture.Realize("LatentRegionHolder.GetRenderRegionSynchronously"); this.StoreRenderRegion(present); if (this.renderRegion == null) { throw new Exception("Render region request failed, gasp: " + present.ToString()); } return this.renderRegion; }
public string GetRendererCredit() { IFuture accessFuture = this.GetAccessFuture(AccessMethod.RendererCredit, FutureFeatures.Cached, new IFuture[0]); Present present = accessFuture.Realize("UnwarpedMapTileSource.GetRendererCredit"); if (present is StringParameter) { return(((StringParameter)present).value); } return(null); }
public RenderRegion GetRenderRegionSynchronously(IFuture synchronousImageBoundsFuture) { Present present = synchronousImageBoundsFuture.Realize("LatentRegionHolder.GetRenderRegionSynchronously"); this.StoreRenderRegion(present); if (this.renderRegion == null) { throw new Exception("Render region request failed, gasp: " + present.ToString()); } return(this.renderRegion); }
internal string GetDocumentFilename() { Present present = localDocumentFuture.Realize("UnwarpedMapTileSource.GetDocumentFilename"); if (present is SourceDocument) { return(((SourceDocument)present).localDocument.GetFilesystemAbsolutePath()); } throw new Exception("Unable to fetch document"); }
public override Present Realize(string refCredit) { Present present = antialiasedFuture.Realize(refCredit); if (transparencyOptions.Effectless()) { return(present); } Present present2 = exactColorFuture.Realize(refCredit); return(Evaluate(new[] { present, present2 })); }
private Present FetchClippedImage() { if (debug_lastZoom != address.ZoomLevel) { debug_lastZoom = address.ZoomLevel; D.Sayf(0, "{0} start zoom level {1}", new object[] { Clocker.theClock.stamp(), address.ZoomLevel }); } IFuture future = applier.clippedImageFuture.Curry(new ParamDict(new object[] { TermName.TileAddress, address })); return(future.Realize("ImageRef.FetchClippedImage")); }
internal void DoWork() { D.Assert(_present == null); Present presentValue; try { presentValue = _future.Realize("AsyncRecord.DoWork"); } catch (Exception ex) { presentValue = new PresentFailureCode(ex); } Notify(presentValue); }
public override Present Realize(string refCredit) { Present present = asyncFuture.Realize(refCredit); if (present is AsyncRef) { AsyncRef asyncRef = (AsyncRef)present; asyncRef.AddCallback(PresentReadyCallback); asyncRef.SetInterest(interestValue); AsyncRef asyncRef2 = (AsyncRef)asyncRef.Duplicate(refCredit + "2"); new PersistentInterest(asyncRef); asyncReadyEvent.WaitOne(); return(asyncRef2.present); } return(present); }
public Present Get(IFuture future, string refCredit) { string text = this.makeCachePathname(future, "fresh."); string text2 = this.makeCachePathname(future, "stale."); Monitor.Enter(this); try { long num; Present present = this.Fetch(text, out num); if (present != null) { D.Sayf(10, "fresh hit! {0}", new object[] { "fresh." }); Present result = present; return(result); } present = this.Fetch(text2, out num); if (present != null) { File.Move(text2, text); this.IncrementFreshCount(num); D.Sayf(10, "stale hit! {0} {1}", new object[] { "stale.", num }); Present result = present; return(result); } } finally { Monitor.Exit(this); } Present result2 = future.Realize(refCredit); this.ScheduleDeferredWrite(result2, text, future.ToString()); D.Sayf(10, "miss", new object[0]); return(result2); }
public Present Evaluate(Present[] paramList) { D.Assert(paramList.Length == 0); if (userRegion != null) { return(new BoundsPresent(userRegion)); } Present present = delayedStaticBoundsFuture.Realize("UserBoundsRefVerb.Evaluate"); if (present is BoundsPresent) { return(present); } if (present is PresentFailureCode) { return(new PresentFailureCode((PresentFailureCode)present, "BoundsPresent.Evaluate")); } return(new PresentFailureCode(string.Format("Unrecognized Present type {0} in BoundsPresent.Evaluate", present.GetType()))); }
public void Process() { try { present = future.Realize("CacheRecord.Process"); } catch (Exception ex) { present = new PresentFailureCode(ex); } D.Assert(present != null); Monitor.Enter(this); try { wait.Set(); wait.Close(); wait = null; } finally { Monitor.Exit(this); } }
public Present Get(IFuture future, string refCredit) { string text = this.makeCachePathname(future, "fresh."); string text2 = this.makeCachePathname(future, "stale."); Monitor.Enter(this); try { long num; Present present = this.Fetch(text, out num); if (present != null) { D.Sayf(10, "fresh hit! {0}", new object[] { "fresh." }); Present result = present; return result; } present = this.Fetch(text2, out num); if (present != null) { File.Move(text2, text); this.IncrementFreshCount(num); D.Sayf(10, "stale hit! {0} {1}", new object[] { "stale.", num }); Present result = present; return result; } } finally { Monitor.Exit(this); } Present result2 = future.Realize(refCredit); this.ScheduleDeferredWrite(result2, text, future.ToString()); D.Sayf(10, "miss", new object[0]); return result2; }
public Present Evaluate(Present[] paramList) { D.Assert(paramList.Length == 4); MapRectangleParameter parameter = (MapRectangleParameter)paramList[0]; SizeParameter parameter2 = (SizeParameter)paramList[1]; Present present = paramList[2]; Present present2 = paramList[3]; double num = Math.Min(parameter.value.LonExtent, parameter.value.LatExtent); int num2 = Math.Max(parameter2.value.Width, parameter2.value.Height); if ((num > 1.0) && (num2 <= 0x400)) { IFuture future = this.prototype.Curry(new ParamDict(new object[] { TermName.ImageBounds, new MapRectangleParameter(this.unitRectangle), TermName.OutputSize, new SizeParameter(this.memoizedSize), TermName.UseDocumentTransparency, present, TermName.ExactColors, present2 })); StrongHash hash = new StrongHash(); future.AccumulateRobustHash(hash); D.Sayf(0, "Future {0} hashes to {1}", new object[] { RobustHashTools.DebugString(future), hash.ToString() }); Present present3 = future.Realize("sourceImageDownsampler-memo"); if (present3 is ImageRef) { try { ImageRef ref2 = (ImageRef)present3; GDIBigLockedImage image = new GDIBigLockedImage(parameter2.value, "sourceImageDownsampler-downsample"); lock (ref2.image) { lock (image) { Graphics graphics = image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheGraphics(); MapRectangle region = parameter.value.Intersect(this.unitRectangle); if (!region.IsEmpty()) { RectangleF srcRect = this.SelectSubRectangle(this.unitRectangle, region, this.memoizedSize); RectangleF destRect = this.SelectSubRectangle(parameter.value, region, parameter2.value); Image image2 = ref2.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage(); graphics.InterpolationMode = InterpolationMode.HighQualityBilinear; graphics.DrawImage(image2, destRect, srcRect, GraphicsUnit.Pixel); } graphics.Dispose(); return(new ImageRef(new ImageRefCounted(image))); } } } catch (ArgumentException) { return(new PresentFailureCode("Image processing overflow")); } catch (OverflowException) { return(new PresentFailureCode("Image processing overflow")); } catch (Exception exception) { return(new PresentFailureCode(exception)); } finally { present3.Dispose(); } } return(present3); } return(this.prototype.Curry(new ParamDict(new object[] { TermName.ImageBounds, parameter, TermName.OutputSize, parameter2, TermName.UseDocumentTransparency, present, TermName.ExactColors, present2 })).Realize("sourceImageDownsampler-passthru")); }