Remove `SharedComponents` references and legacy `LiveLogCache` logic: - Eliminate unused `SharedComponents` references across the solution to streamline dependencies. - Comment out `LiveLogCache` interactions in multiple modules, transitioning to alternative or undefined logging mechanisms. - Add optional `regReadersOptional` parameters to `ShowCycleBeginFormOp` methods for improved flexibility. - Introduce `ITestMethodSmart` interface to support smart reader functionality. - Add new `LogCacheAppender` configuration to `log4netConfig.xml` for diagnostic use. - Update project files to remove outdated references and include newly introduced files.
92 lines
3.5 KiB
C#
92 lines
3.5 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AppDiagnostic
|
|
{
|
|
public class LogFilter
|
|
{
|
|
private ListView _listView;
|
|
private string _filterText = string.Empty; // Pre uloženie aktuálneho filtrovaného reťazca
|
|
|
|
// Konstruktor
|
|
public LogFilter(ListView listView)
|
|
{
|
|
_listView = listView;
|
|
}
|
|
|
|
// Metóda na aplikovanie filtra na ListView
|
|
public void ApplyFilter(string filterText)
|
|
{
|
|
_filterText = filterText.ToLower(); // Ukladáme text filtra bez ohľadu na veľkosť písmen
|
|
|
|
// Po aplikovaní filtra obnovíme zobrazenie
|
|
RefreshListView();
|
|
}
|
|
|
|
public void RefreshListView()
|
|
{
|
|
try
|
|
{
|
|
// Skontrolujeme, či sme na hlavnom vlákne a v prípade potreby použijeme Invoke
|
|
if (_listView.InvokeRequired)
|
|
{
|
|
// Použijeme Invoke, ak nie sme na hlavnom vlákne
|
|
_listView.Invoke(new Action(RefreshListView));
|
|
}
|
|
else
|
|
{
|
|
// Vymazanie existujúcich položiek
|
|
_listView.Items.Clear();
|
|
|
|
// Načítame všetky logy (ideálne z cache alebo databázy)
|
|
//var logs = LiveLogCache.Instance.GetLogs(0, LiveLogCache.Instance.Logs.Count);
|
|
|
|
// Pridáme len tie logy, ktoré spĺňajú filter
|
|
// foreach (var log in logs)
|
|
// {
|
|
// if (log.ToLower().Contains(_filterText)) // Kontrola, či log obsahuje filter text
|
|
// {
|
|
// var listViewItem = new ListViewItem(log);
|
|
//
|
|
// // Striedanie farieb riadkov
|
|
// if (_listView.Items.Count % 2 == 0) // Párny index => biela
|
|
// {
|
|
// listViewItem.BackColor = Color.White;
|
|
// }
|
|
// else // Nepárny index => svetlá sivá
|
|
// {
|
|
// listViewItem.BackColor = Color.FromArgb(240, 240, 240); // Veľmi svetlá sivá
|
|
// }
|
|
//
|
|
// // Pridanie efektu pre novú položku
|
|
// ApplyNewItemEffect(listViewItem);
|
|
//
|
|
// // Pridanie položky do ListView
|
|
// _listView.Items.Add(listViewItem);
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// Zachytíme výnimku, ak sa niečo pokazí, a zobrazíme ju užívateľovi
|
|
MessageBox.Show($"An error occurred while refreshing the log view: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
// Môžete pridať ďalšie metódy na zobrazenie alebo efekt pre nové položky, ak je to potrebné
|
|
private void ApplyNewItemEffect(ListViewItem item)
|
|
{
|
|
// Prípadný efekt pre nový pridaný log
|
|
// Môžete pridať animáciu alebo zmenu farby atď.
|
|
item.ForeColor = Color.Green; // Napríklad zmeníme farbu písma na zelenú
|
|
}
|
|
}
|
|
}
|