示例#1
0
        /// <summary>
        /// Used to display search messages (like exclusions, errors) to the user.
        /// </summary>
        /// <param name="displayType">The type of message to display</param>
        /// <history>
        /// [Curtis_Beard]	   09/27/2012	ADD: 1741735, better error handling display
        /// [Curtis_Beard]	   12/06/2012	CHG: 1741735, rework to use common LogItems
        /// [Curtis_Beard]	   11/11/2014	CHG: use new log items viewer form
        /// [Curtis_Beard]	   03/03/2015	CHG: 93, used saved window position if enabled, add bounds check
        /// </history>
        private void DisplaySearchMessages(LogItem.LogItemTypes? displayType)
        {
            if (this.InvokeRequired)
             {
            DisplaySearchMessagesCallBack del = new DisplaySearchMessagesCallBack(DisplaySearchMessages);
            this.Invoke(del, new object[1] { displayType });
            return;
             }

             if ((!displayType.HasValue && AnyLogItems()) || (displayType.HasValue && GetLogItemsCountByType(displayType.Value) > 0))
             {
            using (var frm = new frmLogDisplay())
            {
               frm.LogItems = LogItems;

               frm.DefaultFilterType = displayType;
               frm.StartPosition = FormStartPosition.Manual;

               Rectangle defaultBounds = new Rectangle(this.Left + 20, this.Bottom - frm.Height - stbStatus.Height - 20, this.Width - 40, frm.Height);

               int width = Core.GeneralSettings.LogDisplaySavePosition && Core.GeneralSettings.LogDisplayWidth != -1 ? Core.GeneralSettings.LogDisplayWidth : defaultBounds.Width;
               int height = Core.GeneralSettings.LogDisplaySavePosition && Core.GeneralSettings.LogDisplayHeight != -1 ? Core.GeneralSettings.LogDisplayHeight : defaultBounds.Height;
               int left = Core.GeneralSettings.LogDisplaySavePosition && Core.GeneralSettings.LogDisplayLeft != -1 ? Core.GeneralSettings.LogDisplayLeft : defaultBounds.X;
               int top = Core.GeneralSettings.LogDisplaySavePosition && Core.GeneralSettings.LogDisplayTop != -1 ? Core.GeneralSettings.LogDisplayTop : defaultBounds.Y;

               frm.Bounds = new Rectangle(left, top, width, height);

               // form can't find a screen to fit on, so reset to default on primary screen
               if (!Screen.AllScreens.Any(s => s.WorkingArea.IntersectsWith(frm.Bounds)))
               {
                  frm.Bounds = defaultBounds;
               }

               frm.ShowDialog(this);
            }
             }
        }
示例#2
0
        /// <summary>
        /// Removes the specified LogItemType from the display.
        /// </summary>
        /// <param name="type">LogItemType to remove</param>
        /// <history>
        /// [Curtis_Beard]	   12/06/2012	ADD: 1741735, initial dialog for filterable log items viewer.
        /// [Curtis_Beard]	   03/02/2015	CHG: set sort to null before remove
        /// </history>
        private void RemoveLogItemType(LogItem.LogItemTypes type)
        {
            lstLog.BeginUpdate();
             lstLog.ListViewItemSorter = null;

             foreach (ListViewItem lstItem in lstLog.Items)
             {
            LogItem item = lstItem.Tag as LogItem;
            if (item.ItemType == type)
            {
               lstLog.Items.Remove(lstItem);
            }
             }

             lstLog.ListViewItemSorter = new LogItemComparer();
             lstLog.Sort();

             lstLog.EndUpdate();
        }
示例#3
0
        /// <summary>
        /// Gets the number of items in the LogItems list for a given type.
        /// </summary>
        /// <param name="type">LogItemType to determine count</param>
        /// <returns>0 if LogItems is null, count for type otherwise</returns>
        /// <history>
        /// [Curtis_Beard]	   12/06/2012	CHG: 1741735, rework to use common LogItems
        /// </history>
        private int GetLogItemsCountByType(LogItem.LogItemTypes type)
        {
            if (LogItems == null || LogItems.Count == 0)
            return 0;

             return LogItems.FindAll(
             delegate(LogItem item)
             {
                return item.ItemType == type;
             }
             ).Count;
        }
示例#4
0
        /// <summary>
        /// Adds the specified LogItemType to the display.
        /// </summary>
        /// <param name="type">LogItemType to add</param>
        /// <history>
        /// [Curtis_Beard]	   12/06/2012	ADD: 1741735, initial dialog for filterable log items viewer.
        /// [Curtis_Beard]	   11/11/2014	CHG: format details display for exclusions
        /// [Curtis_Beard]	   03/02/2015	CHG: set sort to null before add
        /// </history>
        private void AddLogItemType(LogItem.LogItemTypes type)
        {
            lstLog.BeginUpdate();
             lstLog.ListViewItemSorter = null;

             foreach (LogItem item in LogItems)
             {
            if (item.ItemType == type)
            {
               string typeText = Language.GetGenericText(string.Format("LogDisplay.{0}", type), type.ToString());
               string valueText = item.Value;
               string detailsText = item.Details;
               if (item.ItemType == LogItem.LogItemTypes.Exclusion)
               {
                  // convert details from format FilterItem~~FilterValue
                  string[] values = Utils.SplitByString(detailsText, "~~");
                  var filterItem = FilterItem.FromString(values[0]);
                  detailsText = string.Format("{0} -> {1}{2}{3}{4}",
                     Language.GetGenericText(string.Format("Exclusions.{0}", filterItem.FilterType.Category), filterItem.FilterType.Category.ToString()),
                     Language.GetGenericText(string.Format("Exclusions.{0}", filterItem.FilterType.SubCategory), filterItem.FilterType.SubCategory.ToString()),
                     !string.IsNullOrEmpty(filterItem.Value) && filterItem.FilterType.SubCategory != FilterType.SubCategories.Extension ? ", " + values[1] : string.Empty,
                     filterItem.ValueOption != FilterType.ValueOptions.None ? " " + Language.GetGenericText(string.Format("Exclusions.{0}", filterItem.ValueOption), filterItem.ValueOption.ToString()) : string.Empty,
                     !string.IsNullOrEmpty(filterItem.Value) && filterItem.FilterType.SubCategory != FilterType.SubCategories.Extension ? " " + filterItem.Value : string.Empty
                     );
               }
               else if (item.ItemType == LogItem.LogItemTypes.Status)
               {
                  // Value = Language lookup text (e.g. SearchFinished,SearchCancelled)
                  // Details = 0||1 replacement arguments where 0 is file name or error message, 1 is details
                  string[] values = Utils.SplitByString(detailsText, "||");
                  valueText = string.Format(Language.GetGenericText(valueText), values);
                  detailsText = string.Empty;
                  if (values.Length > 1)
                  {
                     detailsText = values[1];
                  }
               }
               else if (item.ItemType == LogItem.LogItemTypes.Error)
               {
                  // Value = Language lookup text (e.g. SearchGenericError, SearchFileError)
                  // Details = 0||1 replacement arguments where 0 = file or empty string, 1 = details (error text)
                  string[] values = Utils.SplitByString(detailsText, "||");
                  valueText = string.Format(Language.GetGenericText(valueText), values[0]);
                  detailsText = values[1];
               }

               ListViewItem lstItem = new ListViewItem(new string[4] { item.Date.ToShortDateString() + " " + item.Date.ToString("hh:mm:ss.ff tt"), typeText, valueText, detailsText });
               lstItem.Tag = item;
               lstLog.Items.Add(lstItem);
            }
             }

             lstLog.ListViewItemSorter = new LogItemComparer();
             lstLog.Sort();

             lstLog.EndUpdate();
        }