Ejemplo n.º 1
0
 /// <summary>
 /// Dump the events arguments to log file PrintEventsLog.txt.
 /// This method will only dump EventArguments of ViewPrint, two event arguments will be handled:
 /// ViewPrintingEventArgs and ViewPrintedEventArgs.
 /// Typical properties of EventArgs of them will be dumped to log file.
 /// </summary>
 /// <param name="eventArgs">Event argument to be dumped. </param>
 private static void DumpEventArguments(RevitAPIEventArgs eventArgs)
 {
     // Dump parameters now:
     // white space is for align purpose.
     if (eventArgs.GetType().Equals(typeof(ViewPrintingEventArgs)))
     {
         Trace.WriteLine("ViewPrintingEventArgs Parameters ------>");
         ViewPrintingEventArgs args = eventArgs as ViewPrintingEventArgs;
         Trace.WriteLine("    TotalViews          : " + args.TotalViews);
         Trace.WriteLine("    View Index          : " + args.Index);
         Trace.WriteLine("    View Information    :");
         DumpViewInfo(args.View, "      ");
     }
     else if (eventArgs.GetType().Equals(typeof(ViewPrintedEventArgs)))
     {
         Trace.WriteLine("ViewPrintedEventArgs Parameters ------>");
         ViewPrintedEventArgs args = eventArgs as ViewPrintedEventArgs;
         Trace.WriteLine("    Event Status        : " + args.Status);
         Trace.WriteLine("    TotalViews          : " + args.TotalViews);
         Trace.WriteLine("    View Index          : " + args.Index);
         Trace.WriteLine("    View Information    :");
         DumpViewInfo(args.View, "      ");
     }
     else
     {
         // no handling for other arguments
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Dump the events arguments to log files: PrintLog.txt and PrintEventsLog.txt.
 /// This method will only dump EventArguments of ViewPrint and DocumentPrint,
 /// that's, 4 event arguments will be handled here:
 /// . DocumentPrintingEventArgs
 /// . DocumentPrintedEventArgs
 /// . ViewPrintingEventArgs
 /// . ViewPrintedEventArgs
 /// </summary>
 /// <param name="eventArgs">Event argument to be dumped. </param>
 private static void DumpEventArguments(RevitAPIEventArgs eventArgs)
 {
     // Dump parameters now:
     // white space is for align purpose.
     if (eventArgs.GetType().Equals(typeof(DocumentPrintingEventArgs)))
     {
         Trace.WriteLine("DocumentPrintingEventArgs Parameters ------>");
         DocumentPrintingEventArgs args = eventArgs as DocumentPrintingEventArgs;
         Trace.WriteLine("    Event Cancellable   : " + args.Cancellable); // cancellable
         Trace.WriteLine("    Views to be printed : ");                    // Views
         DumpViewsInfo(args.Document, args.GetViewElementIds(), "    ");
     }
     else if (eventArgs.GetType().Equals(typeof(DocumentPrintedEventArgs)))
     {
         Trace.WriteLine("DocumentPrintedEventArgs Parameters ------>");
         DocumentPrintedEventArgs args = eventArgs as DocumentPrintedEventArgs;
         Trace.WriteLine("    Event Status      : " + args.Status.ToString()); // Status
         Trace.WriteLine("    Event Cancellable : " + args.Cancellable);       // Cancellable
         //
         // PrintedViews
         IList <ElementId> ids = args.GetPrintedViewElementIds();
         if (null == ids || 0 == ids.Count)
         {
             Trace.WriteLine("    Views been printed: <null>");
         }
         else
         {
             Trace.WriteLine("    Views been printed: ");
             DumpViewsInfo(args.Document, ids, "      ");
         }
         //
         // FailedViews
         ids = args.GetFailedViewElementIds();
         if (null == ids || 0 == ids.Count)
         {
             Trace.WriteLine("    Views failed: <null>");
         }
         else
         {
             Trace.WriteLine("    Views Failed : ");
             DumpViewsInfo(args.Document, ids, "      ");
         }
     }
     else if (eventArgs.GetType().Equals(typeof(ViewPrintingEventArgs)))
     {
         Trace.WriteLine("ViewPrintingEventArgs Parameters ------>");
         ViewPrintingEventArgs args = eventArgs as ViewPrintingEventArgs;
         Trace.WriteLine("    Event Cancellable   : " + args.Cancellable); // Cancellable
         Trace.WriteLine("    TotalViews          : " + args.TotalViews);  // TotalViews
         Trace.WriteLine("    View Index          : " + args.Index);       // Index
         Trace.WriteLine("    View Information    :");                     // View
         DumpViewInfo(args.View, "      ");
     }
     else if (eventArgs.GetType().Equals(typeof(ViewPrintedEventArgs)))
     {
         Trace.WriteLine("ViewPrintedEventArgs Parameters ------>");
         ViewPrintedEventArgs args = eventArgs as ViewPrintedEventArgs;
         Trace.WriteLine("    Event Status        : " + args.Status);     // Cancellable
         Trace.WriteLine("    TotalViews          : " + args.TotalViews); // TotalViews
         Trace.WriteLine("    View Index          : " + args.Index);      // Index
         Trace.WriteLine("    View Information    :");                    // View
         DumpViewInfo(args.View, "      ");
     }
     else
     {
         // no handling for other argument
     }
 }
Ejemplo n.º 3
0
 private void doc_ViewPrinting(object sender, ViewPrintingEventArgs e)
 {
     DisplayEvent("View printing");
 }