// Background Worker - end operations private void EventLoadBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { if (e.Result == null) return; _siebelTreeView = (SiebelTreeView)e.Result; LoadSiebelTreeView(); } catch (Exception ex) { MessageBox.Show(ex.Message, @"Write Events TreeView", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FormNotepad() { InitializeComponent(); // initialization _defaultPath = Directory.GetCurrentDirectory(); _openConfigFile = _defaultPath + @"\cfg\default_cfg.xml"; _openLogFile = null; // start focus on tree so that open //IMPEMENT FOCUS IN TREE SO THAT FIRST BUTTON DONT LOOK GAY // Loads ToolTips InitializeTooltip(); // Event Load Background Worker Initialization InitializeEventsLoadBackGroundWorker(); // Initialize TextBox InitializeFastColoredTextBox(); // Initialize TextBox SintaxHighLight InitializeSintraxHighlight(); // store form header text _originalFormHeaderText = base.Text; // initialize find InitializeFindVariables(); // set the default line = to a line that does not exists _selectedNode = null; // initialize bookmark color _bookmarkColor = Color.DarkRed; // set the object that contains tree nodes to null _siebelTreeView = null; }
// Background Worker - run operations private void EventLoadBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { try { bool auxCancel = false; BackgroundWorker bw = (BackgroundWorker)sender; // input arguments Dictionary<string, object> argsBkWorkerEvents = (Dictionary<string, object>)e.Argument; string openLogFile = (string)argsBkWorkerEvents["OpenLogFile"]; string openConfigFile = (string)argsBkWorkerEvents["OpenConfigFile"]; string defaultPath = (string)argsBkWorkerEvents["DefaultPath"]; SiebelTreeView stv = new SiebelTreeView(openLogFile, openConfigFile, defaultPath); // start events processing stv.LoadEvents(); // wait to event load ends while (stv.AreEventsLoading()) { Thread.Sleep(100); // if is to stop dont talk to load events class anymore if (auxCancel) continue; if (bw.CancellationPending) { // send signal to load events thread end stv.StopEventsLoading(); auxCancel = true; } bw.ReportProgress(stv.LoadEventsPercentageDone()); } // if shit appends then set percentage to 0 and set the results to null if (bw.CancellationPending) { bw.ReportProgress(0); e.Result = null; return; } // if not canceled returns 100% and set the results to the class that represents the event nodes bw.ReportProgress(100); e.Result = stv; } catch (Exception ex) { MessageBox.Show(ex.Message, @"Load Events to TreeView", MessageBoxButtons.OK, MessageBoxIcon.Error); e.Result = null; } }