private void InsertItemsListbox(int dummyPosition, int dummyPositionAndId, PresenterMainSplContPanelUpTabs.LineChangeType dummyNotRelevant, int dummyNotRelevant2, IEnumerable <string> lines, bool changedContentEdited = false, string changeableContent = "", int dummy = -1) { if (Tags.TokenSource.Token.IsCancellationRequested) { return; } _view.ListRightResult.UiThread (delegate { //try //{ _view.ListRightResult.Items.Clear(); if (lines == null) { return; } // ReSharper disable once CoVariantArrayConversion _view.ListRightResult.Items.AddRange(lines.ToArray()); //} //catch (Exception ex) //{ // MessageBox.Show(Resources.PresenterUserSettingsRightAutoShownTabs_InsertItemsListbox_An_error_occured_in_the_user_setting_when_setting_a_new_item_to_listbox__ + ex, Resources.PresenterUserSettingsRightAutoShownTabs_InsertItemsListbox_Clipboard_Helper_error, MessageBoxButtons.OK); //} } ); }
private void SetLinesAsync ( int navigationPosition, int id, PresenterMainSplContPanelUpTabs.LineChangeType lineChangeType, int tabIndex, Dictionary <int, string> linesSlow, List <TagType> tags, Action <int, int, PresenterMainSplContPanelUpTabs.LineChangeType, int, IList <string>, bool, string, int> action, CancellationToken cancelToken, string clipboard = "", bool isChangedContentEdited = false ) { foreach (var line in linesSlow) { if (cancelToken.IsCancellationRequested) { return; } if (StringContainsTags(line.Value, new List <TagType> { TagType.WebGetJason })) { LinesOut[line.Key] = TransformLine(line.Value, UsedIn.MainDisplay, tags, clipboard); switch (lineChangeType) { case PresenterMainSplContPanelUpTabs.LineChangeType.AutoMulti: case PresenterMainSplContPanelUpTabs.LineChangeType.AutoSingle: action( navigationPosition, id, PresenterMainSplContPanelUpTabs.LineChangeType.AutoSingle, tabIndex, new List <string> { LinesOut[line.Key] }, isChangedContentEdited, _changeableContent, line.Key); break; case PresenterMainSplContPanelUpTabs.LineChangeType.ManualMulti: case PresenterMainSplContPanelUpTabs.LineChangeType.ManualSingle: action( navigationPosition, id, PresenterMainSplContPanelUpTabs.LineChangeType.ManualSingle, tabIndex, new List <string> { LinesOut[line.Key] }, isChangedContentEdited, _changeableContent, line.Key); break; } } else { LinesOut[line.Key] = TransformLine(line.Value, UsedIn.MainDisplay, tags, clipboard); action(navigationPosition, id, lineChangeType, tabIndex, LinesOut, isChangedContentEdited, _changeableContent, -1); } } action(navigationPosition, id, lineChangeType, tabIndex, LinesOut, isChangedContentEdited, _changeableContent, -1); }
/// <summary> /// Transforms tags for presentation for the user. There are five places where presentation occurs: In the settings, /// in the program main form, when pasting to another program, when clicking on a item (opens url in web browser) or /// in tags inside tags (nested tags). /// </summary> public async void TransformLines( int navigationPosition, int id, PresenterMainSplContPanelUpTabs.LineChangeType lineChangeType, int tabIndex, List <string> lines, List <TagType> tags, Action <int, int, PresenterMainSplContPanelUpTabs.LineChangeType, int, IList <string>, bool, string, int> action, string clipboard = "", bool changedContentEdited = false, string changedContent = "") { Cancel(); Action = action; Lines = lines; TokenSource = new CancellationTokenSource(); _cancellationToken = TokenSource.Token; _changedContent = changedContent; _changedContentEdited = changedContentEdited; if (Lines == null) { return; } var linesWithIndex = CreateLinesWithIndex(Lines); var linesFast = GetFastLines(linesWithIndex); LinesOut = new List <string>(lines); foreach (var line in linesFast) { LinesOut[line.Key] = TransformLine(line.Value, UsedIn.MainDisplay, tags, clipboard); } //Set fast lines if (Action == null) { return; } { Action(navigationPosition, id, lineChangeType, tabIndex, LinesOut, changedContentEdited, _changeableContent, -1); var linesSlow = GetSlowLines(linesWithIndex); var stripped = StripOutEverythingExceptLineNumberingAndInfoTag(linesSlow); foreach (var line in stripped) { LinesOut[line.Key] = TransformLine(line.Value, UsedIn.MainDisplay, tags, clipboard); } //Set slow lines Action(navigationPosition, id, lineChangeType, tabIndex, LinesOut, changedContentEdited, _changeableContent, -1); //Set slow lines async if (linesSlow.Count != 0) { await Task.Run(() => SetLinesAsync(navigationPosition, id, lineChangeType, tabIndex, linesSlow, tags, Action, _cancellationToken, clipboard, changedContentEdited), _cancellationToken).ConfigureAwait(true); //parse delayed Tags } } }