Ejemplo n.º 1
0
        public void CommitTest()
        {
            var destination = new RemoteDestination()
            {
                AutoCommit = false,
                Level      = (int)EventSeverity.Verbose,
                ServiceUrl = "http://md.xsolon.net/logs/slog.ashx"
            };

            using (var logger = new LoggerClass("TraceDestinationTests"))
            {
                logger.NotifyEvent += (e) =>
                {
                    e.Props["DomainKey"] = "STSv2";
                };

                logger.Destinations.Add(destination);

                logger.NotifyInformation("Information");

                logger.Notify((int)EventSeverity.Verbose - 1, () => { return("Not be logged"); });

                int count = destination.LogList.Count;

                Assert.AreEqual(1, count);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            using (Library lib = new Library())
            {
                String sFileSpec = "../../Resources/Sample_Input/ducky.pdf";
                String sOutput   = "../RemoteGoToActions-out.pdf";

                if (args.Length > 0)
                {
                    sFileSpec = args[0];
                }

                if (args.Length > 1)
                {
                    sOutput = args[1];
                }

                Console.WriteLine("Writing to output " + sOutput + ". Using " + sFileSpec + " as file specification");

                Document doc = new Document();

                // Standard letter size page (8.5" x 11")
                Rect pageRect = new Rect(0, 0, 612, 792);
                Page docpage  = doc.CreatePage(Document.BeforeFirstPage, pageRect);
                Console.WriteLine("Created page.");

                LinkAnnotation newLink = new LinkAnnotation(docpage, new Rect(153, 198, 306, 396));
                Console.WriteLine("Created new Link Annotation");

                // RemoteGoToActions need a FileSpecification and a RemoteDestination.
                //
                // The FileSpecification specifies which file should be opened when the LinkAnnotation is "clicked"
                //
                // The RemoteDestination specifies a particular view (page number, Fit type, rectangle, and zoom level)
                // to display when the file in the FileSpecification is opened. Remember page numbers start at 0.
                //
                // FileSpecification objects, RemoteDestination objects, and RemoteGoToActions
                // must be associated with a Document. The association happens at object creation time and cannot be changed.
                //
                // FileSpecifications and RemoteDestinations are associated with the Document that is passed in the constructor.
                // RemoteGoToActions are associated with the same Document as the RemoteDestination used to create it.
                //
                // When creating a RemoteGoToAction, make sure that the FileSpecification and RemoteDestination are both
                // associated with the same Document, or an exception will be thrown.

                // FileSpecifications can take either a relative or an absolute path. It is best to specify
                // a relative path if the document is intended to work across multiple platforms (Windows, Linux, Mac)
                FileSpecification fileSpec = new FileSpecification(doc, sFileSpec);
                Console.WriteLine("Path to remote document : " + fileSpec.Path);

                RemoteDestination remoteDest = new RemoteDestination(doc, 0, "XYZ", new Rect(0, 0, 4 * 72, 4 * 72), 1.5);
                Console.WriteLine("When the Link is clicked the remote document will open to : ");
                Console.WriteLine("Page Number : " + remoteDest.PageNumber);
                Console.WriteLine("zoom level : " + remoteDest.Zoom);
                Console.WriteLine("fit type : " + remoteDest.FitType);
                Console.WriteLine("rectangle : " + remoteDest.DestRect.ToString());

                // Now create the RemoteGoToAction from the fileSpec and the RemoteDestination
                RemoteGoToAction remoteAction = new RemoteGoToAction(fileSpec, remoteDest);

                // assign the RemoteGoToAction to the LinkAnnotation
                newLink.Action = remoteAction;

                doc.Save(SaveFlags.Full, sOutput);
            }
        }