B2021-018: Incoming transitions not always enabling Convert to Text

This commit is contained in:
Kathy Ruffing 2021-04-22 14:30:35 +00:00
parent 6d9a3f5f4e
commit 8d05b057aa
2 changed files with 8 additions and 33 deletions

View File

@ -1336,7 +1336,6 @@ namespace Volian.Controls.Library
this.lbSrchResultsIncTrans.SelectedIndexChanged += new System.EventHandler(this.lbSrchResults_SelectedValueChanged); this.lbSrchResultsIncTrans.SelectedIndexChanged += new System.EventHandler(this.lbSrchResults_SelectedValueChanged);
this.lbSrchResultsIncTrans.ItemClick += new System.EventHandler(this.lbSrchResultsIncTrans_ItemClicked); this.lbSrchResultsIncTrans.ItemClick += new System.EventHandler(this.lbSrchResultsIncTrans_ItemClicked);
this.lbSrchResultsIncTrans.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lbSrchResults_MouseMove); this.lbSrchResultsIncTrans.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lbSrchResults_MouseMove);
this.lbSrchResultsIncTrans.ItemCheck += this.lbSrchResultsIncTrans_ItemChecked;
// //
// panSearchButtons // panSearchButtons
// //

View File

@ -1172,32 +1172,15 @@ namespace Volian.Controls.Library
LastResultsMouseOverIndex = ResultsMouseOverIndex; LastResultsMouseOverIndex = ResultsMouseOverIndex;
} }
} }
// B2021-003: random crash on lbSrchResultsIncTrans selection. Originally, only ItemClicked was used // B2021-018: Removed code that was tracking the number of items checked in the incoming transition
// to track how many items in the list were checked. However, this gets called for both // listbox. Found that could just look at the CheckedItems.Count value. (Previous fixes
// the clicked & checked events, so the count of checked items was not accurate (this count, // that were removed are B2021-003 & part of C2020-033 (part was for permissions, which was not removed)
// IncTransSelectedCount was incremented/decremented when event occurred). The reason that the clicked
// event needs to be used is that the sender contains the bound item (proms item) but the checked
// event does not, so both are needed. The tracking of checked items is done to enable/disable
// the 'Convert Selected to Text' button. The fix was to flag from the ItemChecked event that the
// item was checked not just selected, so that the code in Clicked only runs for a check event.
private bool didcheck = false;
private void lbSrchResultsIncTrans_ItemChecked(object sender, EventArgs e)
{
didcheck = true;
}
// C2020-033: lbSrchResultsIncTrans_ItemClicked is used to check permissions of a selection before allowing an // C2020-033: lbSrchResultsIncTrans_ItemClicked is used to check permissions of a selection before allowing an
// item to be clicked and to turn on/off the btnTranCvtSelToTxt button for converting selected to test. // item to be clicked and to turn on/off the btnTranCvtSelToTxt button for converting selected to test.
// Two variables are used to keep track if items are checked in the list box:
// JustDidSelection - selecting an item event goes into both SelectedValueChanged & ItemClicked
// but need to keep track of itemclicked which is event for checking/unchecking of Incoming Transition
// items in lbSrchResultsIncTrans
// IncTransSelectedCount is used to keep track if any items are checked
private int IncTransSelectedCount = 0;
bool JustDidSelection = false;
private void lbSrchResultsIncTrans_ItemClicked(object sender, EventArgs e) private void lbSrchResultsIncTrans_ItemClicked(object sender, EventArgs e)
{ {
ListBoxItem lbi = sender as ListBoxItem; ListBoxItem lbi = sender as ListBoxItem;
if (didcheck && lbi != null) if (lbi != null)
{ {
ItemBindingData ibd = lbi.Tag as ItemBindingData; ItemBindingData ibd = lbi.Tag as ItemBindingData;
ItemInfo ii = ibd.DataItem as ItemInfo; ItemInfo ii = ibd.DataItem as ItemInfo;
@ -1210,15 +1193,11 @@ namespace Volian.Controls.Library
"Convert Transition to Text", MessageBoxButtons.OK, MessageBoxIcon.Information); "Convert Transition to Text", MessageBoxButtons.OK, MessageBoxIcon.Information);
lbi.CheckState = CheckState.Unchecked; lbi.CheckState = CheckState.Unchecked;
} }
else
if (!JustDidSelection) IncTransSelectedCount++;
} }
else // B2021-018: use the CheckedItems.Count on the list box for the search results for
if (!JustDidSelection && IncTransSelectedCount > 0) IncTransSelectedCount--; // user unchecked an item // incoming transitions to determine whether to enable the convert selected to text:
if (!JustDidSelection) btnTranCvtSelToTxt.Enabled = IncTransSelectedCount > 0; btnTranCvtSelToTxt.Enabled = (lbSrchResultsIncTrans.CheckedItems.Count > 0);
} }
didcheck = false;
JustDidSelection = false;
} }
private void GrpPanSearchResults_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) private void GrpPanSearchResults_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{ {
@ -1240,7 +1219,6 @@ namespace Volian.Controls.Library
lbSrchResultsIncTrans.Enabled = false; lbSrchResultsIncTrans.Enabled = false;
lbSrchResultsIncTrans.UseWaitCursor = true; lbSrchResultsIncTrans.UseWaitCursor = true;
} }
JustDidSelection = true;
ListBox mylb = sender as ListBox; ListBox mylb = sender as ListBox;
// If the list is being refreshed, then set the selection index to -1 (no selection) // If the list is being refreshed, then set the selection index to -1 (no selection)
@ -1476,7 +1454,6 @@ namespace Volian.Controls.Library
private void btnSearch_Click(object sender, EventArgs e) private void btnSearch_Click(object sender, EventArgs e)
{ {
IncTransSelectedCount = 0;
_fromLoad = false; _fromLoad = false;
DateTime start = DateTime.Now; DateTime start = DateTime.Now;
Cursor savcursor = Cursor; Cursor savcursor = Cursor;
@ -2312,7 +2289,6 @@ namespace Volian.Controls.Library
private bool _fromLoad = false; private bool _fromLoad = false;
private void btnLoadSearchResults_Click(object sender, System.EventArgs e) private void btnLoadSearchResults_Click(object sender, System.EventArgs e)
{ {
IncTransSelectedCount = 0;
_fromLoad = true; _fromLoad = true;
_LoadingList = true; _LoadingList = true;
ofdSearchResults.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS"; ofdSearchResults.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS";
@ -2713,7 +2689,7 @@ namespace Volian.Controls.Library
// C2020-033: Update the search panel for Incoming transitions. This gets called from the tree view & the ribbon // C2020-033: Update the search panel for Incoming transitions. This gets called from the tree view & the ribbon
public void UpdateSearchIncTransResults() public void UpdateSearchIncTransResults()
{ {
IncTransSelectedCount = 0; //IncTransSelectedCount = 0;
tabSearchTypes.SelectedTab = tabSearchTypes.Tabs[4]; tabSearchTypes.SelectedTab = tabSearchTypes.Tabs[4];
lbSrchResultsIncTrans.DataSource = null; lbSrchResultsIncTrans.DataSource = null;