Esempio n. 1
0
		public Present Evaluate(Present[] paramList)
		{
			MapRectangle mapRectangle = null;
			int i = 0;
			while (i < paramList.Length)
			{
				Present present = paramList[i];
				Present result;
				if (present is PresentFailureCode)
				{
					result = new PresentFailureCode((PresentFailureCode)present, "CompositeBoundsVerb");
				}
				else
				{
					if (present is BoundsPresent)
					{
						((BoundsPresent)present).GetRenderRegion().AccumulateBoundingBox(ref mapRectangle);
						i++;
						continue;
					}
					result = new PresentFailureCode(new Exception("Unexpected result of child computation in CompositeBoundsVerb"));
				}
				return result;
			}
			if (mapRectangle == null)
			{
				return new PresentFailureCode("No valid sourcemaps in input.");
			}
			RenderRegion renderRegion = new RenderRegion(mapRectangle, new DirtyEvent());
			return new BoundsPresent(renderRegion);
		}
Esempio n. 2
0
        public Present Evaluate(Present[] paramList)
        {
            MapRectangle mapRectangle = null;
            int          i            = 0;

            while (i < paramList.Length)
            {
                Present present = paramList[i];
                Present result;
                if (present is PresentFailureCode)
                {
                    result = new PresentFailureCode((PresentFailureCode)present, "CompositeBoundsVerb");
                }
                else
                {
                    if (present is BoundsPresent)
                    {
                        ((BoundsPresent)present).GetRenderRegion().AccumulateBoundingBox(ref mapRectangle);
                        i++;
                        continue;
                    }
                    result = new PresentFailureCode(new Exception("Unexpected result of child computation in CompositeBoundsVerb"));
                }
                return(result);
            }
            if (mapRectangle == null)
            {
                return(new PresentFailureCode("No valid sourcemaps in input."));
            }
            RenderRegion renderRegion = new RenderRegion(mapRectangle, new DirtyEvent());

            return(new BoundsPresent(renderRegion));
        }
Esempio n. 3
0
        public Present Evaluate(Present[] paramList)
        {
            Present result;

            try
            {
                TileAddress ta         = (TileAddress)paramList[0];
                string      renderPath = namingScheme.GetRenderPath(ta);
                if (File.Exists(renderPath))
                {
                    GDIBigLockedImage gDIBigLockedImage = GDIBigLockedImage.FromFile(renderPath);
                    gDIBigLockedImage.CopyPixels();
                    result = new ImageRef(new ImageRefCounted(gDIBigLockedImage));
                }
                else
                {
                    result = new BeyondImageBounds();
                }
            }
            catch (Exception ex)
            {
                result = new PresentFailureCode(ex);
            }

            return(result);
        }
Esempio n. 4
0
		public Present Evaluate(Present[] paramList)
		{
			StringParameter stringParameter = (StringParameter)paramList[0];
			IntParameter intParameter = (IntParameter)paramList[1];
			D.Assert(paramList.Length == 2);
			Present result;
			try
			{
				result = new WPFOpenDocument(stringParameter.value, intParameter.value);
			}
			catch (DllNotFoundException ex)
			{
				MessageBox.Show("It appears that .Net 3.0 is not installed on this machine. Please install .Net 3.0 and restart the application.", "Missing Dependency");
				result = new PresentFailureCode(ex);
			}
			catch (FileNotFoundException ex2)
			{
				if (ex2.Source == "PresentationCore")
				{
					MessageBox.Show("It appears that .Net 3.0 is not installed on this machine. Please install .Net 3.0 and restart the application.", "Missing Dependency");
				}
				result = new PresentFailureCode(ex2);
			}
			catch (Exception ex3)
			{
				result = new PresentFailureCode(ex3);
			}
			return result;
		}
Esempio n. 5
0
        public Present Evaluate(Present[] paramList)
        {
            StringParameter stringParameter = (StringParameter)paramList[0];
            IntParameter    intParameter    = (IntParameter)paramList[1];

            D.Assert(paramList.Length == 2);
            Present result;

            try
            {
                result = new WPFOpenDocument(stringParameter.value, intParameter.value);
            }
            catch (DllNotFoundException ex)
            {
                MessageBox.Show("It appears that .Net 3.0 is not installed on this machine. Please install .Net 3.0 and restart the application.", "Missing Dependency");
                result = new PresentFailureCode(ex);
            }
            catch (FileNotFoundException ex2)
            {
                if (ex2.Source == "PresentationCore")
                {
                    MessageBox.Show("It appears that .Net 3.0 is not installed on this machine. Please install .Net 3.0 and restart the application.", "Missing Dependency");
                }
                result = new PresentFailureCode(ex2);
            }
            catch (Exception ex3)
            {
                result = new PresentFailureCode(ex3);
            }
            return(result);
        }
Esempio n. 6
0
        public Present Evaluate(Present[] paramList)
        {
            Size value = ((SizeParameter)paramList[0]).value;
            GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(value, "CompositeImageVerb");
            Present           result;

            try
            {
                GDIBigLockedImage obj;
                Monitor.Enter(obj = gDIBigLockedImage);
                try
                {
                    Graphics graphics = gDIBigLockedImage.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheGraphics();
                    using (graphics)
                    {
                        for (int i = 1; i < paramList.Length; i++)
                        {
                            Present present = paramList[i];
                            if (present is PresentFailureCode)
                            {
                                result = new PresentFailureCode((PresentFailureCode)present, "CompositeImageVerb");
                                return(result);
                            }
                            if (!(present is ImageRef))
                            {
                                result = new PresentFailureCode(new Exception("Unexpected result of child computation in CompositeImageVerb"));
                                return(result);
                            }
                            ImageRef          imageRef = (ImageRef)present;
                            GDIBigLockedImage image;
                            Monitor.Enter(image = imageRef.image);
                            try
                            {
                                graphics.DrawImage(imageRef.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage(), new Rectangle(0, 0, value.Width, value.Height));
                            }
                            finally
                            {
                                Monitor.Exit(image);
                            }
                        }
                    }
                }
                finally
                {
                    Monitor.Exit(obj);
                }
                ImageRef imageRef2 = new ImageRef(new ImageRefCounted(gDIBigLockedImage));
                gDIBigLockedImage = null;
                result            = imageRef2;
            }
            finally
            {
                if (gDIBigLockedImage != null)
                {
                    gDIBigLockedImage.Dispose();
                }
            }
            return(result);
        }
Esempio n. 7
0
        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 Present Evaluate(Present[] paramList)
		{
			Size value = ((SizeParameter)paramList[0]).value;
			GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(value, "CompositeImageVerb");
			Present result;
			try
			{
				GDIBigLockedImage obj;
				Monitor.Enter(obj = gDIBigLockedImage);
				try
				{
					Graphics graphics = gDIBigLockedImage.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheGraphics();
					using (graphics)
					{
						for (int i = 1; i < paramList.Length; i++)
						{
							Present present = paramList[i];
							if (present is PresentFailureCode)
							{
								result = new PresentFailureCode((PresentFailureCode)present, "CompositeImageVerb");
								return result;
							}
							if (!(present is ImageRef))
							{
								result = new PresentFailureCode(new Exception("Unexpected result of child computation in CompositeImageVerb"));
								return result;
							}
							ImageRef imageRef = (ImageRef)present;
							GDIBigLockedImage image;
							Monitor.Enter(image = imageRef.image);
							try
							{
								graphics.DrawImage(imageRef.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage(), new Rectangle(0, 0, value.Width, value.Height));
							}
							finally
							{
								Monitor.Exit(image);
							}
						}
					}
				}
				finally
				{
					Monitor.Exit(obj);
				}
				ImageRef imageRef2 = new ImageRef(new ImageRefCounted(gDIBigLockedImage));
				gDIBigLockedImage = null;
				result = imageRef2;
			}
			finally
			{
				if (gDIBigLockedImage != null)
				{
					gDIBigLockedImage.Dispose();
				}
			}
			return result;
		}
Esempio n. 9
0
        public Present Evaluate(Present[] paramList)
        {
            Present result;

            try
            {
                TileAddress ta = (TileAddress)paramList[0];
                if (BuildConfig.theConfig.injectTemporaryTileFailures && new Random().Next() % 2 == 0)
                {
                    result = new InjectedTileFailure();
                }
                else
                {
                    HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(GetTileURL(ta));
                    httpWebRequest.Timeout = 9000;
                    HttpWebResponse httpWebResponse;
                    try
                    {
                        httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    }
                    catch (WebException ex)
                    {
                        if (ex.Response is HttpWebResponse)
                        {
                            HttpWebResponse httpWebResponse2 = (HttpWebResponse)ex.Response;
                            if (httpWebResponse2.StatusCode == HttpStatusCode.BadRequest ||
                                httpWebResponse2.StatusCode == HttpStatusCode.NotFound)
                            {
                                result = new UnretryableFailure(ex);
                                return(result);
                            }
                        }

                        result = new RetryableFailure(ex, "Timeout waiting for tile in WebTileFetch");
                        return(result);
                    }

                    if (httpWebResponse.StatusCode != HttpStatusCode.OK)
                    {
                        throw new Exception(string.Format("HTTP {0} from web source",
                                                          httpWebResponse.StatusCode.ToString()));
                    }

                    Stream            responseStream = httpWebResponse.GetResponseStream();
                    GDIBigLockedImage image          = GDIBigLockedImage.FromStream(responseStream);
                    httpWebResponse.Close();
                    result = new ImageRef(new ImageRefCounted(image));
                }
            }
            catch (Exception ex2)
            {
                result = new PresentFailureCode(ex2);
            }

            return(result);
        }
Esempio n. 10
0
 public Present Evaluate(Present[] paramList)
 {
     if (paramList[0] is PresentFailureCode)
     {
         return(new PresentFailureCode((PresentFailureCode)paramList[0], "ApplyVerbPresent"));
     }
     if (!(paramList[0] is VerbPresent))
     {
         return(PresentFailureCode.FailedCast(paramList[0], "ApplyVerbPresent"));
     }
     Present[] array = new Present[paramList.Length - 1];
     Array.Copy(paramList, 1, array, 0, paramList.Length - 1);
     return(((VerbPresent)paramList[0]).Evaluate(array));
 }
Esempio n. 11
0
		public Present Evaluate(Present[] paramList)
		{
			Present result;
			try
			{
				TileAddress ta = (TileAddress)paramList[0];
				if (BuildConfig.theConfig.injectTemporaryTileFailures && new Random().Next() % 2 == 0)
				{
					result = new InjectedTileFailure();
				}
				else
				{
					HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(this.GetTileURL(ta));
					httpWebRequest.Timeout = 9000;
					HttpWebResponse httpWebResponse;
					try
					{
						httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
					}
					catch (WebException ex)
					{
						if (ex.Response is HttpWebResponse)
						{
							HttpWebResponse httpWebResponse2 = (HttpWebResponse)ex.Response;
							if (httpWebResponse2.StatusCode == HttpStatusCode.BadRequest || httpWebResponse2.StatusCode == HttpStatusCode.NotFound)
							{
								result = new UnretryableFailure(ex);
								return result;
							}
						}
						result = new RetryableFailure(ex, "Timeout waiting for tile in WebTileFetch");
						return result;
					}
					if (httpWebResponse.StatusCode != HttpStatusCode.OK)
					{
						throw new Exception(string.Format("HTTP {0} from web source", httpWebResponse.StatusCode.ToString()));
					}
					Stream responseStream = httpWebResponse.GetResponseStream();
					GDIBigLockedImage image = GDIBigLockedImage.FromStream(responseStream);
					httpWebResponse.Close();
					result = new ImageRef(new ImageRefCounted(image));
				}
			}
			catch (Exception ex2)
			{
				result = new PresentFailureCode(ex2);
			}
			return result;
		}
Esempio n. 12
0
        internal void DoWork()
        {
            D.Assert(this._present == null);
            Present presentValue;

            try
            {
                presentValue = this._future.Realize("AsyncRecord.DoWork");
            }
            catch (Exception ex)
            {
                presentValue = new PresentFailureCode(ex);
            }
            this.Notify(presentValue);
        }
Esempio n. 13
0
		public Present Evaluate(Present[] paramList)
		{
			StringParameter stringParameter = (StringParameter)paramList[0];
			IntParameter intParameter = (IntParameter)paramList[1];
			D.Assert(paramList.Length == 2);
			Present result;
			try
			{
				result = new FoxitOpenDocument(stringParameter.value, intParameter.value);
			}
			catch (Exception ex)
			{
				result = new PresentFailureCode(ex);
			}
			return result;
		}
Esempio n. 14
0
        public Present Evaluate(Present[] paramList)
        {
            StringParameter stringParameter = (StringParameter)paramList[0];
            IntParameter    intParameter    = (IntParameter)paramList[1];

            D.Assert(paramList.Length == 2);
            Present result;

            try
            {
                result = new FoxitOpenDocument(stringParameter.value, intParameter.value);
            }
            catch (Exception ex)
            {
                result = new PresentFailureCode(ex);
            }
            return(result);
        }
Esempio n. 15
0
        public Present Evaluate(Present[] paramList)
        {
            if (!(paramList[0] is IntParameter))
            {
                return(PresentFailureCode.FailedCast(paramList[0], "FoxitOpenDocument.Evaluate"));
            }

            switch (((IntParameter)paramList[0]).value)
            {
            case 0:
            {
                D.Assert(paramList.Length == 5);
                MapRectangleParameter mapRectangleParameter = (MapRectangleParameter)paramList[1];
                SizeParameter         sizeParameter         = (SizeParameter)paramList[2];
                BoolParameter         boolParameter         = (BoolParameter)paramList[3];
                BoolParameter         boolParameter2        = (BoolParameter)paramList[4];
                return(Render(mapRectangleParameter.value,
                              sizeParameter.value,
                              boolParameter.value,
                              boolParameter2.value));
            }

            case 1:
                D.Assert(paramList.Length == 1);
                return(FetchBounds());

            case 2:
                D.Assert(paramList.Length == 2);
                return(new IntParameter(5));

            case 3:
                D.Assert(paramList.Length == 1);
                if (BuildConfig.theConfig.suppressFoxitMessages)
                {
                    return(new StringParameter(null));
                }

                return(new StringParameter("MapCruncher PDF rendering powered by Foxit Software Company"));

            default:
                return(new PresentFailureCode("Invalid AccessVerb"));
            }
        }
Esempio n. 16
0
        public Present Evaluate(Present[] paramList)
        {
            if (!(paramList[0] is IntParameter))
            {
                return(PresentFailureCode.FailedCast(paramList[0], "FoxitOpenDocument.Evaluate"));
            }

            switch (((IntParameter)paramList[0]).value)
            {
            case 0:
            {
                D.Assert(paramList.Length == 5);
                MapRectangleParameter mapRectangleParameter = (MapRectangleParameter)paramList[1];
                SizeParameter         sizeParameter         = (SizeParameter)paramList[2];
                BoolParameter         boolParameter         = (BoolParameter)paramList[3];
                BoolParameter         boolParameter2        = (BoolParameter)paramList[4];
                return(Render(mapRectangleParameter.value,
                              sizeParameter.value,
                              boolParameter.value,
                              boolParameter2.value));
            }

            case 1:
                D.Assert(paramList.Length == 1);
                return(FetchBounds());

            case 2:
            {
                D.Assert(paramList.Length == 2);
                SizeParameter sizeParameter2 = (SizeParameter)paramList[1];
                return(ImageDetail(sizeParameter2.value));
            }

            case 3:
                D.Assert(paramList.Length == 1);
                return(new StringParameter(null));

            default:
                return(new PresentFailureCode("Invalid AccessVerb"));
            }
        }
Esempio n. 17
0
		public Present Evaluate(Present[] paramList)
		{
			Present result;
			try
			{
				TileAddress ta = (TileAddress)paramList[0];
				string renderPath = this.namingScheme.GetRenderPath(ta);
				if (File.Exists(renderPath))
				{
					GDIBigLockedImage gDIBigLockedImage = GDIBigLockedImage.FromFile(renderPath);
					gDIBigLockedImage.CopyPixels();
					result = new ImageRef(new ImageRefCounted(gDIBigLockedImage));
				}
				else
				{
					result = new BeyondImageBounds();
				}
			}
			catch (Exception ex)
			{
				result = new PresentFailureCode(ex);
			}
			return result;
		}
Esempio n. 18
0
 public PresentFailureCode(PresentFailureCode innerFailure, string provenance)
 {
     this.provenance = provenance + innerFailure.provenance;
     exception       = innerFailure.exception;
 }
Esempio n. 19
0
		internal void DoWork()
		{
			D.Assert(this._present == null);
			Present presentValue;
			try
			{
				presentValue = this._future.Realize("AsyncRecord.DoWork");
			}
			catch (Exception ex)
			{
				presentValue = new PresentFailureCode(ex);
			}
			this.Notify(presentValue);
		}
		public AlwaysReturnFailureFuture(PresentFailureCode pfc)
		{
			this.pfc = pfc;
		}
Esempio n. 21
0
 public PresentFailureCode(PresentFailureCode innerFailure, string provenance)
 {
     this.provenance = provenance + innerFailure.provenance;
     this._ex        = innerFailure._ex;
 }
Esempio n. 22
0
		public PresentFailureCode(PresentFailureCode innerFailure, string provenance)
		{
			this.provenance = provenance + innerFailure.provenance;
			this._ex = innerFailure._ex;
		}
 public AlwaysReturnFailureFuture(PresentFailureCode pfc)
 {
     this.pfc = pfc;
 }