private void MasterCategoryListDlg_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
switch (DialogResult)
{
default:
m_selPOS = null;
break;
case DialogResult.OK:
{
// Closing with normal selection(s).
foreach (TreeNode tn in m_nodes)
{
MasterCategory mc = tn.Tag as MasterCategory;
Debug.Assert(mc != null);
if ((tn.Checked || (tn == m_tvMasterList.SelectedNode))
&& !mc.InDatabase)
{
// if this.m_subItemOwner != null, it indicates where to put the newly chosed POS
mc.AddToDatabase(m_cache,
m_posList,
(tn.Parent == null) ? null : tn.Parent.Tag as MasterCategory,
m_subItemOwner);
}
}
MasterCategory mc2 = m_tvMasterList.SelectedNode.Tag as MasterCategory;
Debug.Assert(mc2 != null);
m_selPOS = mc2.POS;
Debug.Assert(m_selPOS != null);
break;
}
case DialogResult.Yes:
{
// Closing via the hotlink.
// Do nothing special, except avoid setting m_selPOS to null, as in the default case.
break;
}
}
if (m_mediator != null)
{
m_mediator.PropertyTable.SetProperty("masterCatListDlgLocation", Location);
m_mediator.PropertyTable.SetProperty("masterCatListDlgSize", Size);
}
}