- >(json) ?? new();
_filteredData = _allData.ToList();
}
private void DisplayRecord()
{
if (_filteredData.Count == 0)
{
webView.NavigateToString("
Tuesday, November 11, 2025
questions for improvement
using ExamTopics;
using Newtonsoft.Json;
using Microsoft.Web.WebView2.WinForms;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using iTextSharp.tool.xml.css;
public partial class DiscussionViewerForm : Form
{
private List _allData = new();
private List _filteredData = new();
private int _currentIndex = 0;
private string _jsonPath = "ExamTopicsData.json";
string searchStoreFile = Path.Combine(Application.StartupPath, "last_search.txt");
private string simpleStoreFile = Path.Combine(Application.StartupPath, "simple_list.txt");
private HashSet simpleMarked = new HashSet();
public DiscussionViewerForm()
{
InitializeComponent();
this.Load += DiscussionViewerForm_Load; // Add Form Load event
}
private async void DiscussionViewerForm_Load(object sender, EventArgs e)
{
await webView.EnsureCoreWebView2Async(null);
// Listen when a page finishes loading
webView.CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted;
LoadData();
if (File.Exists(simpleStoreFile))
{
simpleMarked = new HashSet(File.ReadAllLines(simpleStoreFile));
}
if (File.Exists(searchStoreFile))
{
try
{
string lastSearch = File.ReadAllText(searchStoreFile);
txtSearch.Text = lastSearch;
// ✅ Auto trigger search if exists
if (!string.IsNullOrWhiteSpace(lastSearch))
btnSearch.PerformClick();
}
catch { }
}
}
private void btnSimple_Click(object sender, EventArgs e)
{
if (_filteredData.Count == 0) return;
var current = _filteredData[_currentIndex];
string key = current.Id?.ToString() ?? current.Url; // choose any unique field
if (!string.IsNullOrWhiteSpace(key))
{
simpleMarked.Add(key);
File.WriteAllLines(simpleStoreFile, simpleMarked);
btnNext.PerformClick(); // auto move to next
}
}
private async void CoreWebView2_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
{
string css = @"
.show { display: none !important; }
.full-width-header { display: none !important; }
.action-row-container { display: none !important; }
.contrib__ulimited.contrib__block { display: none !important; }
.question-discussion-header { display: none !important; }
";
string script = $@"
let style = document.createElement('style');
style.innerHTML = `{css}`;
document.head.appendChild(style);
";
try
{
await webView.ExecuteScriptAsync(script);
}
catch (Exception ex)
{
MessageBox.Show("CSS Injection Error: " + ex.Message);
}
}
private void LoadData()
{
if (!File.Exists(_jsonPath))
{
MessageBox.Show("JSON file not found!");
return;
}
var json = File.ReadAllText(_jsonPath);
_allData = JsonConvert.DeserializeObject
Subscribe to:
Comments (Atom)
Featured Post
questions for improvement
using ExamTopics; using Newtonsoft.Json; using Microsoft.Web.WebView2.WinForms; using System; using System.Collections.Generic; using System...
-
GST Questions and Answers Q51) How do you handle ITC on goods sent for job work? ...
-
Plugin Interview Questions: 1. Explain in details about the event execution pipeline. 2. When do we register a plugin in a...
-
GAC (Global Assembly Cache):- Plugin stored in GAC does not support Dynamics 365 Online. Plugin does not backed up with d...