Exemple #1
0
 public void RefreshByTimeRange(DateTime start, DateTime end)
 {
     if (fileDescriptor != null && end >= start)
     {
         try
         {
             if (fileDescriptor.FileBlockCount == 0)
             {
                 lblLoadSize.Text       = SR.GetString("FileBlockInfo_LoadingSize") + SR.GetString("FileBlockInfo_EmptyFile");
                 lblLoadPercentage.Text = string.Empty;
                 graphics.FillRectangle(selectedItemBrush, new Rectangle(new Point(0, 0), DrawPanel.Size));
             }
             else
             {
                 long num  = 0L;
                 long num2 = 0L;
                 long num3 = 0L;
                 if (end > start)
                 {
                     foreach (FileBlockInfo fileBlock in fileDescriptor.FileBlocks)
                     {
                         long num4 = fileBlock.EndFileOffset - fileBlock.StartFileOffset;
                         if (num4 > 0)
                         {
                             if ((fileBlock.StartDate >= start && fileBlock.EndDate <= end) || (fileBlock.StartDate <= start && fileBlock.EndDate >= start) || (fileBlock.StartDate <= end && fileBlock.EndDate >= end))
                             {
                                 num2 += num4;
                             }
                             else if (fileBlock.EndDate < start)
                             {
                                 num += num4;
                             }
                             else if (fileBlock.StartDate > end)
                             {
                                 num3 += num4;
                             }
                         }
                         else if (fileBlock.StartDate == fileBlock.EndDate)
                         {
                             if (fileBlock.StartDate >= start && fileBlock.StartDate <= end)
                             {
                                 num2 += ((fileDescriptor.FileSize <= 5000000) ? fileDescriptor.FileSize : 5000000);
                             }
                             else if (fileBlock.StartDate < start)
                             {
                                 num += ((fileDescriptor.FileSize <= 5000000) ? fileDescriptor.FileSize : 5000000);
                             }
                             else if (fileBlock.StartDate > end)
                             {
                                 num3 += ((fileDescriptor.FileSize <= 5000000) ? fileDescriptor.FileSize : 5000000);
                             }
                         }
                         else
                         {
                             num2 += ((fileDescriptor.FileSize <= 5000000) ? fileDescriptor.FileSize : 5000000);
                         }
                     }
                 }
                 else
                 {
                     num  = fileDescriptor.FileSize;
                     num3 = 0L;
                     num2 = 0L;
                 }
                 graphics.FillRectangle(unselectedItemBrush, new Rectangle(new Point(0, 0), DrawPanel.Size));
                 if (num2 != 0L)
                 {
                     int num5 = (int)((double)num / (double)fileDescriptor.FileSize * (double)DrawPanel.Size.Width);
                     int num6 = (int)((double)num3 / (double)fileDescriptor.FileSize * (double)DrawPanel.Size.Width);
                     graphics.FillRectangle(selectedItemBrush, new Rectangle(num5, 0, DrawPanel.Size.Width - num5 - num6, DrawPanel.Size.Height));
                 }
                 lblLoadSize.Text = SR.GetString("FileBlockInfo_LoadingSize") + Utilities.GetFileSizeString(num2);
                 double num7 = 0.0;
                 num7 = ((num2 + num + num3 == 0L) ? 0.0 : ((double)num2 / (double)(num2 + num + num3) * 100.0));
                 lblLoadPercentage.Text = SR.GetString("FileBlockInfo_LoadingPre") + num7.ToString("###.##", CultureInfo.CurrentCulture);
                 startDateTime          = start;
                 endDateTime            = end;
             }
         }
         catch (Exception e)
         {
             ExceptionManager.GeneralExceptionFilter(e);
         }
     }
 }
 public override void GetTraces()
 {
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         if (!isTraceOpen)
         {
             try
             {
                 OpenLogFile();
             }
             catch (Win32Exception)
             {
                 throw new TraceViewerException(SR.GetString("MsgInvalidInputFile"));
             }
         }
         else if (handle == 0L)
         {
             throw new TraceViewerException(SR.GetString("MsgNullHandle"));
         }
         if (startTimeFilter != DateTime.MinValue || endTimeFilter != DateTime.MaxValue)
         {
             filterTimeRange = true;
         }
         else
         {
             filterTimeRange = false;
         }
         ulong[] handles = new ulong[1]
         {
             handle
         };
         uint num;
         if (filterTimeRange)
         {
             NativeMethods.FileTime start = new NativeMethods.FileTime(startTimeFilter.ToFileTime());
             NativeMethods.FileTime end   = new NativeMethods.FileTime(endTimeFilter.ToFileTime());
             num = NativeMethods.ProcessTrace(handles, 1u, ref start, ref end);
             if (num != 0)
             {
                 throw new Win32Exception(Marshal.GetLastWin32Error());
             }
         }
         else
         {
             num = NativeMethods.ProcessTrace(handles, 1u, IntPtr.Zero, IntPtr.Zero);
             if (num != 0)
             {
                 throw new Win32Exception(Marshal.GetLastWin32Error());
             }
         }
         if (num != 0 && num != 1223)
         {
             throw new TraceViewerException(SR.GetString("MsgProcessTraceFailed"));
         }
     }
     catch (Exception e)
     {
         ExceptionManager.GeneralExceptionFilter(e);
         throw new TraceViewerException(SR.GetString("MsgUnhandledExceptionInEtwGetTraces"));
     }
 }