コード例 #1
0
 public static int GetImageIndex(Activity activity)
 {
     if (activity.ActivityType == ActivityType.RootActivity)
     {
         return(TraceViewerForm.GetImageIndexFromImageList(Images.RootActivity));
     }
     if (activity.ActivityType == ActivityType.ServiceHostActivity)
     {
         return(TraceViewerForm.GetImageIndexFromImageList(Images.HostActivityIcon));
     }
     if (activity.ActivityType == ActivityType.ListenActivity)
     {
         return(TraceViewerForm.GetImageIndexFromImageList(Images.ListenActivity));
     }
     if (activity.ActivityType == ActivityType.MessageActivity)
     {
         return(TraceViewerForm.GetImageIndexFromImageList(Images.MessageActivityIcon));
     }
     if (activity.ActivityType == ActivityType.ConnectionActivity)
     {
         return(TraceViewerForm.GetImageIndexFromImageList(Images.ConnectionActivityIcon));
     }
     if (activity.ActivityType == ActivityType.UserCodeExecutionActivity)
     {
         return(TraceViewerForm.GetImageIndexFromImageList(Images.ExecutionActivityIcon));
     }
     return(TraceViewerForm.GetImageIndexFromImageList(Images.DefaultActivityIcon));
 }
コード例 #2
0
        private ListViewItem ComposeTraceListItem(TraceRecord tr)
        {
            InternalMessageInfo internalMessageInfo = ExtraceMessageLog(tr);
            int num = -1;

            if (tr.MessageProperties == MessageProperty.MessageIn)
            {
                num = TraceViewerForm.GetImageIndexFromImageList(Images.MessageReceiveTrace);
            }
            else if (tr.MessageProperties == MessageProperty.MessageOut)
            {
                num = TraceViewerForm.GetImageIndexFromImageList(Images.MessageSentTrace);
            }
            ListViewItem listViewItem = null;

            listViewItem = ((num == -1) ? new ListViewItem(new string[5]
            {
                (internalMessageInfo != null && !string.IsNullOrEmpty(internalMessageInfo.Action)) ? internalMessageInfo.Action : string.Empty,
                Utilities.GetShortTimeStringFromDateTime(tr.Time),
                string.IsNullOrEmpty(tr.Execution.ComputerName) ? tr.Execution.ProcessName : (tr.Execution.ComputerName + SR.GetString("SL_ExecutionSep") + tr.Execution.ProcessName),
                TraceViewerForm.GetActivityDisplayName(tr.ActivityID),
                (internalMessageInfo != null && !string.IsNullOrEmpty(internalMessageInfo.To)) ? internalMessageInfo.To : string.Empty
            }) : new ListViewItem(new string[5]
            {
                (internalMessageInfo != null && !string.IsNullOrEmpty(internalMessageInfo.Action)) ? internalMessageInfo.Action : string.Empty,
                Utilities.GetShortTimeStringFromDateTime(tr.Time),
                string.IsNullOrEmpty(tr.Execution.ComputerName) ? tr.Execution.ProcessName : (tr.Execution.ComputerName + SR.GetString("SL_ExecutionSep") + tr.Execution.ProcessName),
                TraceViewerForm.GetActivityDisplayName(tr.ActivityID),
                (internalMessageInfo != null && !string.IsNullOrEmpty(internalMessageInfo.To)) ? internalMessageInfo.To : string.Empty
            }, num));
            listViewItem.Tag = tr;
            if (currentDataSource != null && currentDataSource.Activities.ContainsKey(tr.ActivityID))
            {
                if (currentDataSource.Activities[tr.ActivityID].HasError)
                {
                    listViewItem.ForeColor = Color.Red;
                    ListViewItem listViewItem2 = listViewItem;
                    listViewItem2.Font = new Font(listViewItem2.Font, listViewItem.Font.Style | FontStyle.Bold);
                }
                else if (currentDataSource.Activities[tr.ActivityID].HasWarning)
                {
                    listViewItem.BackColor = Color.Yellow;
                }
            }
            return(listViewItem);
        }